[glade] Move GladeWidgetAdaptor code for GtkToolButton into it's own C file
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Move GladeWidgetAdaptor code for GtkToolButton into it's own C file
- Date: Sat, 4 May 2013 07:25:12 +0000 (UTC)
commit 9c925c2b9b6ec27f56eb5800296a3753b6c51153
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat May 4 14:56:18 2013 +0900
Move GladeWidgetAdaptor code for GtkToolButton into it's own C file
plugins/gtk+/Makefile.am | 1 +
plugins/gtk+/glade-gtk-tool-button.c | 209 ++++++++++++++++++++++++++++++++++
plugins/gtk+/glade-gtk.c | 184 ------------------------------
po/POTFILES.in | 1 +
4 files changed, 211 insertions(+), 184 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 92040ba..87f18ac 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -59,6 +59,7 @@ libgladegtk_la_SOURCES = \
glade-gtk-recent-chooser-menu.c \
glade-gtk-switch.c \
glade-gtk-table.c \
+ glade-gtk-tool-button.c \
glade-gtk-tool-item.c \
glade-gtk-tool-item-group.c \
glade-gtk-tool-palette.c \
diff --git a/plugins/gtk+/glade-gtk-tool-button.c b/plugins/gtk+/glade-gtk-tool-button.c
new file mode 100644
index 0000000..8bee483
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-tool-button.c
@@ -0,0 +1,209 @@
+/*
+ * glade-gtk-tool-button.c - GladeWidgetAdaptor for GtkToolButton
+ *
+ * Copyright (C) 2013 Tristan Van Berkom
+ *
+ * Authors:
+ * Tristan Van Berkom <tristan van berkom gmail com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+#include "glade-gtk.h"
+#include "glade-tool-button-editor.h"
+
+GladeEditable *
+glade_gtk_tool_button_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
+{
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *) glade_tool_button_editor_new ();
+ else
+ return GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->create_editable (adaptor, type);
+}
+
+static void
+glade_gtk_tool_button_set_image_mode (GObject * object, const GValue * value)
+{
+ GladeWidget *gbutton;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+ gbutton = glade_widget_get_from_gobject (object);
+
+ glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE, NOT_SELECTED_MSG);
+
+ switch (g_value_get_int (value))
+ {
+ case GLADE_TB_MODE_STOCK:
+ glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
+ break;
+ case GLADE_TB_MODE_ICON:
+ glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
+ break;
+ case GLADE_TB_MODE_CUSTOM:
+ glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE, NULL);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+glade_gtk_tool_button_set_custom_label (GObject * object, const GValue * value)
+{
+ GladeWidget *gbutton;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+ gbutton = glade_widget_get_from_gobject (object);
+
+ glade_widget_property_set_sensitive (gbutton, "label", FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "label-widget", FALSE, NOT_SELECTED_MSG);
+ glade_widget_property_set_sensitive (gbutton, "use-underline", FALSE,
+ _("This property only applies when configuring the label with text"));
+
+ if (g_value_get_boolean (value))
+ glade_widget_property_set_sensitive (gbutton, "label-widget", TRUE, NULL);
+ else
+ {
+ glade_widget_property_set_sensitive (gbutton, "label", TRUE, NULL);
+ glade_widget_property_set_sensitive (gbutton, "use-underline", TRUE, NULL);
+ }
+}
+
+static void
+glade_gtk_tool_button_set_label (GObject * object, const GValue * value)
+{
+ const gchar *label;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+
+ label = g_value_get_string (value);
+
+ if (label && strlen (label) == 0)
+ label = NULL;
+
+ gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
+}
+
+static void
+glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value)
+{
+ const gchar *stock_id;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+
+ stock_id = g_value_get_string (value);
+
+ if (stock_id && strlen (stock_id) == 0)
+ stock_id = NULL;
+
+ gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
+}
+
+static void
+glade_gtk_tool_button_set_icon_name (GObject * object, const GValue * value)
+{
+ const gchar *name;
+
+ g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
+
+ name = g_value_get_string (value);
+
+ if (name && strlen (name) == 0)
+ name = NULL;
+
+ gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (object), name);
+}
+
+void
+glade_gtk_tool_button_set_property (GladeWidgetAdaptor * adaptor,
+ GObject * object,
+ const gchar * id, const GValue * value)
+{
+ if (!strcmp (id, "image-mode"))
+ glade_gtk_tool_button_set_image_mode (object, value);
+ else if (!strcmp (id, "icon-name"))
+ glade_gtk_tool_button_set_icon_name (object, value);
+ else if (!strcmp (id, "stock-id"))
+ glade_gtk_tool_button_set_stock_id (object, value);
+ else if (!strcmp (id, "label"))
+ glade_gtk_tool_button_set_label (object, value);
+ else if (!strcmp (id, "custom-label"))
+ glade_gtk_tool_button_set_custom_label (object, value);
+ else
+ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->set_property (adaptor,
+ object, id, value);
+}
+
+static void
+glade_gtk_tool_button_parse_finished (GladeProject * project,
+ GladeWidget * widget)
+{
+ gchar *stock_str = NULL, *icon_name = NULL;
+ gint stock_id = 0;
+ GtkWidget *label_widget = NULL, *image_widget = NULL;
+
+ glade_widget_property_get (widget, "stock-id", &stock_str);
+ glade_widget_property_get (widget, "icon-name", &icon_name);
+ glade_widget_property_get (widget, "icon-widget", &image_widget);
+ glade_widget_property_get (widget, "label-widget", &label_widget);
+
+ if (label_widget)
+ glade_widget_property_set (widget, "custom-label", TRUE);
+ else
+ glade_widget_property_set (widget, "custom-label", FALSE);
+
+ if (image_widget)
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_CUSTOM);
+ else if (icon_name)
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_ICON);
+ else if (stock_str)
+ {
+ /* Update the stock property */
+ stock_id =
+ glade_utils_enum_value_from_string (GLADE_TYPE_STOCK_IMAGE,
+ stock_str);
+ if (stock_id < 0)
+ stock_id = 0;
+ glade_widget_property_set (widget, "glade-stock", stock_id);
+
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
+ }
+ else
+ glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
+}
+
+void
+glade_gtk_tool_button_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
+ glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
+ return;
+
+ /* First chain up and read in all the normal properties.. */
+ GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
+
+ /* Run this after the load so that icon-widget is resolved. */
+ g_signal_connect (glade_widget_get_project (widget),
+ "parse-finished",
+ G_CALLBACK (glade_gtk_tool_button_parse_finished), widget);
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index e512839..0954098 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -82,190 +82,6 @@ glade_gtk_init (const gchar * name)
}
-/* ----------------------------- GtkToolItem ------------------------------ */
-
-/* ----------------------------- GtkToolButton ------------------------------ */
-GladeEditable *
-glade_gtk_tool_button_create_editable (GladeWidgetAdaptor * adaptor,
- GladeEditorPageType type)
-{
- if (type == GLADE_PAGE_GENERAL)
- return (GladeEditable *) glade_tool_button_editor_new ();
- else
- return GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->create_editable (adaptor, type);
-}
-
-static void
-glade_gtk_tool_button_set_image_mode (GObject * object, const GValue * value)
-{
- GladeWidget *gbutton;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
- gbutton = glade_widget_get_from_gobject (object);
-
- glade_widget_property_set_sensitive (gbutton, "stock-id", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "icon-name", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "icon-widget", FALSE, NOT_SELECTED_MSG);
-
- switch (g_value_get_int (value))
- {
- case GLADE_TB_MODE_STOCK:
- glade_widget_property_set_sensitive (gbutton, "stock-id", TRUE, NULL);
- break;
- case GLADE_TB_MODE_ICON:
- glade_widget_property_set_sensitive (gbutton, "icon-name", TRUE, NULL);
- break;
- case GLADE_TB_MODE_CUSTOM:
- glade_widget_property_set_sensitive (gbutton, "icon-widget", TRUE, NULL);
- break;
- default:
- break;
- }
-}
-
-
-static void
-glade_gtk_tool_button_set_custom_label (GObject * object, const GValue * value)
-{
- GladeWidget *gbutton;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
- gbutton = glade_widget_get_from_gobject (object);
-
- glade_widget_property_set_sensitive (gbutton, "label", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "label-widget", FALSE, NOT_SELECTED_MSG);
- glade_widget_property_set_sensitive (gbutton, "use-underline", FALSE,
- _("This property only applies when configuring the label with text"));
-
- if (g_value_get_boolean (value))
- glade_widget_property_set_sensitive (gbutton, "label-widget", TRUE, NULL);
- else
- {
- glade_widget_property_set_sensitive (gbutton, "label", TRUE, NULL);
- glade_widget_property_set_sensitive (gbutton, "use-underline", TRUE, NULL);
- }
-}
-
-static void
-glade_gtk_tool_button_set_label (GObject * object, const GValue * value)
-{
- const gchar *label;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
-
- label = g_value_get_string (value);
-
- if (label && strlen (label) == 0)
- label = NULL;
-
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (object), label);
-}
-
-static void
-glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value)
-{
- const gchar *stock_id;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
-
- stock_id = g_value_get_string (value);
-
- if (stock_id && strlen (stock_id) == 0)
- stock_id = NULL;
-
- gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id);
-}
-
-static void
-glade_gtk_tool_button_set_icon_name (GObject * object, const GValue * value)
-{
- const gchar *name;
-
- g_return_if_fail (GTK_IS_TOOL_BUTTON (object));
-
- name = g_value_get_string (value);
-
- if (name && strlen (name) == 0)
- name = NULL;
-
- gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (object), name);
-}
-
-void
-glade_gtk_tool_button_set_property (GladeWidgetAdaptor * adaptor,
- GObject * object,
- const gchar * id, const GValue * value)
-{
- if (!strcmp (id, "image-mode"))
- glade_gtk_tool_button_set_image_mode (object, value);
- else if (!strcmp (id, "icon-name"))
- glade_gtk_tool_button_set_icon_name (object, value);
- else if (!strcmp (id, "stock-id"))
- glade_gtk_tool_button_set_stock_id (object, value);
- else if (!strcmp (id, "label"))
- glade_gtk_tool_button_set_label (object, value);
- else if (!strcmp (id, "custom-label"))
- glade_gtk_tool_button_set_custom_label (object, value);
- else
- GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->set_property (adaptor,
- object, id, value);
-}
-
-static void
-glade_gtk_tool_button_parse_finished (GladeProject * project,
- GladeWidget * widget)
-{
- gchar *stock_str = NULL, *icon_name = NULL;
- gint stock_id = 0;
- GtkWidget *label_widget = NULL, *image_widget = NULL;
-
- glade_widget_property_get (widget, "stock-id", &stock_str);
- glade_widget_property_get (widget, "icon-name", &icon_name);
- glade_widget_property_get (widget, "icon-widget", &image_widget);
- glade_widget_property_get (widget, "label-widget", &label_widget);
-
- if (label_widget)
- glade_widget_property_set (widget, "custom-label", TRUE);
- else
- glade_widget_property_set (widget, "custom-label", FALSE);
-
- if (image_widget)
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_CUSTOM);
- else if (icon_name)
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_ICON);
- else if (stock_str)
- {
- /* Update the stock property */
- stock_id =
- glade_utils_enum_value_from_string (GLADE_TYPE_STOCK_IMAGE,
- stock_str);
- if (stock_id < 0)
- stock_id = 0;
- glade_widget_property_set (widget, "glade-stock", stock_id);
-
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
- }
- else
- glade_widget_property_set (widget, "image-mode", GLADE_TB_MODE_STOCK);
-}
-
-void
-glade_gtk_tool_button_read_widget (GladeWidgetAdaptor * adaptor,
- GladeWidget * widget, GladeXmlNode * node)
-{
- if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||
- glade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))
- return;
-
- /* First chain up and read in all the normal properties.. */
- GWA_GET_CLASS (GTK_TYPE_TOOL_ITEM)->read_widget (adaptor, widget, node);
-
- /* Run this after the load so that icon-widget is resolved. */
- g_signal_connect (glade_widget_get_project (widget),
- "parse-finished",
- G_CALLBACK (glade_gtk_tool_button_parse_finished), widget);
-}
-
/* ----------------------------- GtkMenuToolButton ------------------------------ */
GList *
glade_gtk_menu_tool_button_get_children (GladeWidgetAdaptor * adaptor,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 261792c..a3d55e5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -87,6 +87,7 @@ plugins/gtk+/glade-gtk-radio-menu-item.c
plugins/gtk+/glade-gtk-recent-chooser-menu.c
plugins/gtk+/glade-gtk-switch.c
plugins/gtk+/glade-gtk-table.c
+plugins/gtk+/glade-gtk-tool-button.c
plugins/gtk+/glade-gtk-tool-item.c
plugins/gtk+/glade-gtk-tool-item-group.c
plugins/gtk+/glade-gtk-tool-palette.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]