[glade] Move GladeWidgetAdaptor code for GtkToolPalette 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 GtkToolPalette into it's own C file
- Date: Sat, 4 May 2013 07:24:57 +0000 (UTC)
commit bd3ffc965c1f62270fb49c7066f0360a044d608c
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat May 4 14:49:45 2013 +0900
Move GladeWidgetAdaptor code for GtkToolPalette into it's own C file
plugins/gtk+/Makefile.am | 1 +
plugins/gtk+/glade-gtk-tool-palette.c | 224 +++++++++++++++++++++++++++++++++
plugins/gtk+/glade-gtk.c | 196 ----------------------------
po/POTFILES.in | 1 +
4 files changed, 226 insertions(+), 196 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 2ee4b6f..9439a46 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-palette.c \
glade-gtk-toolbar.c \
glade-gtk-widget.c \
glade-gtk-window.c \
diff --git a/plugins/gtk+/glade-gtk-tool-palette.c b/plugins/gtk+/glade-gtk-tool-palette.c
new file mode 100644
index 0000000..746dc40
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-tool-palette.c
@@ -0,0 +1,224 @@
+/*
+ * glade-gtk-tool-palette.c - GladeWidgetAdaptor for GtkToolPalette
+ *
+ * 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-menu-shell.h"
+#include "glade-gtk.h"
+
+void
+glade_gtk_tool_palette_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_TOOL_PALETTE (container));
+ if (GTK_IS_TOOL_ITEM_GROUP (child) == FALSE)
+ return;
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ g_value_set_int (value,
+ gtk_tool_palette_get_group_position (GTK_TOOL_PALETTE (container),
+ GTK_TOOL_ITEM_GROUP (child)));
+ }
+ else
+ { /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
+ }
+}
+
+void
+glade_gtk_tool_palette_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ GValue * value)
+{
+ g_return_if_fail (GTK_IS_TOOL_PALETTE (container));
+ g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child));
+
+ g_return_if_fail (property_name != NULL || value != NULL);
+
+ if (strcmp (property_name, "position") == 0)
+ {
+ GtkToolPalette *palette = GTK_TOOL_PALETTE (container);
+ GList *children;
+ gint position, size;
+
+ children = glade_util_container_get_all_children (GTK_CONTAINER (palette));
+ size = g_list_length (children);
+ g_list_free (children);
+
+ position = g_value_get_int (value);
+
+ if (position >= size)
+ position = size - 1;
+
+ gtk_tool_palette_set_group_position (palette, GTK_TOOL_ITEM_GROUP (child), position);
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+gboolean
+glade_gtk_tool_palette_add_verify (GladeWidgetAdaptor *adaptor,
+ GtkWidget *container,
+ GtkWidget *child,
+ gboolean user_feedback)
+{
+ if (!GTK_IS_TOOL_ITEM_GROUP (child))
+ {
+ if (user_feedback)
+ {
+ GladeWidgetAdaptor *tool_item_group_adaptor =
+ glade_widget_adaptor_get_by_type (GTK_TYPE_TOOL_ITEM_GROUP);
+
+ glade_util_ui_message (glade_app_get_window (),
+ GLADE_UI_INFO, NULL,
+ ONLY_THIS_GOES_IN_THAT_MSG,
+ glade_widget_adaptor_get_title (tool_item_group_adaptor),
+ glade_widget_adaptor_get_title (adaptor));
+ }
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+glade_gtk_tool_palette_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkToolPalette *palette;
+ GtkToolItemGroup *group;
+
+ g_return_if_fail (GTK_IS_TOOL_PALETTE (object));
+ g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child));
+
+ palette = GTK_TOOL_PALETTE (object);
+ group = GTK_TOOL_ITEM_GROUP (child);
+
+ gtk_container_add (GTK_CONTAINER (palette), GTK_WIDGET (group));
+
+ if (glade_util_object_is_loading (object))
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+
+ /* Packing props arent around when parenting during a glade_widget_dup() */
+ if (gchild && glade_widget_get_packing_properties (gchild))
+ glade_widget_pack_property_set (gchild, "position",
+ gtk_tool_palette_get_group_position (palette, group));
+ }
+}
+
+void
+glade_gtk_tool_palette_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+}
+
+static void
+glade_gtk_tool_palette_launch_editor (GladeWidgetAdaptor * adaptor,
+ GObject * palette)
+{
+ GladeBaseEditor *editor;
+ GtkWidget *window;
+
+ /* Editor */
+ editor = glade_base_editor_new (palette, NULL,
+ _("Group"), GTK_TYPE_TOOL_ITEM_GROUP,
+ NULL);
+
+ glade_base_editor_append_types (editor, GTK_TYPE_TOOL_ITEM_GROUP,
+ _("Button"), GTK_TYPE_TOOL_BUTTON,
+ _("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON,
+ _("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON,
+ _("Menu"), GTK_TYPE_MENU_TOOL_BUTTON,
+ _("Custom"), GTK_TYPE_TOOL_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_TOOL_ITEM,
+ NULL);
+
+ glade_base_editor_append_types (editor, GTK_TYPE_MENU_TOOL_BUTTON,
+ _("Normal"), GTK_TYPE_MENU_ITEM,
+ _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
+ _("Recent Menu"), GTK_TYPE_RECENT_CHOOSER_MENU,
+ NULL);
+
+ glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
+ _("Normal"), GTK_TYPE_MENU_ITEM,
+ _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
+ _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
+ _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
+ _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
+ _("Recent Menu"), GTK_TYPE_RECENT_CHOOSER_MENU,
+ NULL);
+
+ g_signal_connect (editor, "get-display-name",
+ G_CALLBACK (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
+ g_signal_connect (editor, "child-selected",
+ G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected),
+ NULL);
+ g_signal_connect (editor, "change-type",
+ G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
+ g_signal_connect (editor, "build-child",
+ G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
+ g_signal_connect (editor, "delete-child",
+ G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
+ g_signal_connect (editor, "move-child",
+ G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
+
+ gtk_widget_show (GTK_WIDGET (editor));
+
+ window =
+ glade_base_editor_pack_new_window (editor, _("Tool Palette Editor"), NULL);
+ gtk_widget_show (window);
+}
+
+void
+glade_gtk_tool_palette_action_activate (GladeWidgetAdaptor * adaptor,
+ GObject * object, const gchar * action_path)
+{
+ if (strcmp (action_path, "launch_editor") == 0)
+ {
+ glade_gtk_tool_palette_launch_editor (adaptor, object);
+ }
+ else
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
+ object, action_path);
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index a217b67..69d8b04 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -83,202 +83,6 @@ glade_gtk_init (const gchar * name)
-/* ----------------------------- GtkToolPalette ------------------------------ */
-void
-glade_gtk_tool_palette_get_child_property (GladeWidgetAdaptor * adaptor,
- GObject * container,
- GObject * child,
- const gchar * property_name,
- GValue * value)
-{
- g_return_if_fail (GTK_IS_TOOL_PALETTE (container));
- if (GTK_IS_TOOL_ITEM_GROUP (child) == FALSE)
- return;
-
- if (strcmp (property_name, "position") == 0)
- {
- g_value_set_int (value,
- gtk_tool_palette_get_group_position (GTK_TOOL_PALETTE (container),
- GTK_TOOL_ITEM_GROUP (child)));
- }
- else
- { /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
- }
-}
-
-void
-glade_gtk_tool_palette_set_child_property (GladeWidgetAdaptor * adaptor,
- GObject * container,
- GObject * child,
- const gchar * property_name,
- GValue * value)
-{
- g_return_if_fail (GTK_IS_TOOL_PALETTE (container));
- g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child));
-
- g_return_if_fail (property_name != NULL || value != NULL);
-
- if (strcmp (property_name, "position") == 0)
- {
- GtkToolPalette *palette = GTK_TOOL_PALETTE (container);
- GList *children;
- gint position, size;
-
- children = glade_util_container_get_all_children (GTK_CONTAINER (palette));
- size = g_list_length (children);
- g_list_free (children);
-
- position = g_value_get_int (value);
-
- if (position >= size)
- position = size - 1;
-
- gtk_tool_palette_set_group_position (palette, GTK_TOOL_ITEM_GROUP (child), position);
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-}
-
-gboolean
-glade_gtk_tool_palette_add_verify (GladeWidgetAdaptor *adaptor,
- GtkWidget *container,
- GtkWidget *child,
- gboolean user_feedback)
-{
- if (!GTK_IS_TOOL_ITEM_GROUP (child))
- {
- if (user_feedback)
- {
- GladeWidgetAdaptor *tool_item_group_adaptor =
- glade_widget_adaptor_get_by_type (GTK_TYPE_TOOL_ITEM_GROUP);
-
- glade_util_ui_message (glade_app_get_window (),
- GLADE_UI_INFO, NULL,
- ONLY_THIS_GOES_IN_THAT_MSG,
- glade_widget_adaptor_get_title (tool_item_group_adaptor),
- glade_widget_adaptor_get_title (adaptor));
- }
-
- return FALSE;
- }
-
- return TRUE;
-}
-
-void
-glade_gtk_tool_palette_add_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- GtkToolPalette *palette;
- GtkToolItemGroup *group;
-
- g_return_if_fail (GTK_IS_TOOL_PALETTE (object));
- g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child));
-
- palette = GTK_TOOL_PALETTE (object);
- group = GTK_TOOL_ITEM_GROUP (child);
-
- gtk_container_add (GTK_CONTAINER (palette), GTK_WIDGET (group));
-
- if (glade_util_object_is_loading (object))
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
-
- /* Packing props arent around when parenting during a glade_widget_dup() */
- if (gchild && glade_widget_get_packing_properties (gchild))
- glade_widget_pack_property_set (gchild, "position",
- gtk_tool_palette_get_group_position (palette, group));
- }
-}
-
-void
-glade_gtk_tool_palette_remove_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-}
-
-static void
-glade_gtk_tool_palette_launch_editor (GladeWidgetAdaptor * adaptor,
- GObject * palette)
-{
- GladeBaseEditor *editor;
- GtkWidget *window;
-
- /* Editor */
- editor = glade_base_editor_new (palette, NULL,
- _("Group"), GTK_TYPE_TOOL_ITEM_GROUP,
- NULL);
-
- glade_base_editor_append_types (editor, GTK_TYPE_TOOL_ITEM_GROUP,
- _("Button"), GTK_TYPE_TOOL_BUTTON,
- _("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON,
- _("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON,
- _("Menu"), GTK_TYPE_MENU_TOOL_BUTTON,
- _("Custom"), GTK_TYPE_TOOL_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_TOOL_ITEM,
- NULL);
-
- glade_base_editor_append_types (editor, GTK_TYPE_MENU_TOOL_BUTTON,
- _("Normal"), GTK_TYPE_MENU_ITEM,
- _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- _("Recent Menu"), GTK_TYPE_RECENT_CHOOSER_MENU,
- NULL);
-
- glade_base_editor_append_types (editor, GTK_TYPE_MENU_ITEM,
- _("Normal"), GTK_TYPE_MENU_ITEM,
- _("Image"), GTK_TYPE_IMAGE_MENU_ITEM,
- _("Check"), GTK_TYPE_CHECK_MENU_ITEM,
- _("Radio"), GTK_TYPE_RADIO_MENU_ITEM,
- _("Separator"), GTK_TYPE_SEPARATOR_MENU_ITEM,
- _("Recent Menu"), GTK_TYPE_RECENT_CHOOSER_MENU,
- NULL);
-
- g_signal_connect (editor, "get-display-name",
- G_CALLBACK (glade_gtk_menu_shell_tool_item_get_display_name), NULL);
- g_signal_connect (editor, "child-selected",
- G_CALLBACK (glade_gtk_menu_shell_tool_item_child_selected),
- NULL);
- g_signal_connect (editor, "change-type",
- G_CALLBACK (glade_gtk_menu_shell_change_type), NULL);
- g_signal_connect (editor, "build-child",
- G_CALLBACK (glade_gtk_menu_shell_build_child), NULL);
- g_signal_connect (editor, "delete-child",
- G_CALLBACK (glade_gtk_menu_shell_delete_child), NULL);
- g_signal_connect (editor, "move-child",
- G_CALLBACK (glade_gtk_menu_shell_move_child), NULL);
-
- gtk_widget_show (GTK_WIDGET (editor));
-
- window =
- glade_base_editor_pack_new_window (editor, _("Tool Palette Editor"), NULL);
- gtk_widget_show (window);
-}
-
-void
-glade_gtk_tool_palette_action_activate (GladeWidgetAdaptor * adaptor,
- GObject * object, const gchar * action_path)
-{
- if (strcmp (action_path, "launch_editor") == 0)
- {
- glade_gtk_tool_palette_launch_editor (adaptor, object);
- }
- else
- GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor,
- object, action_path);
-}
-
/* ----------------------------- GtkToolItemGroup ------------------------------ */
gboolean
glade_gtk_tool_item_group_add_verify (GladeWidgetAdaptor *adaptor,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a9923ef..fefdcc7 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-palette.c
plugins/gtk+/glade-gtk-toolbar.c
plugins/gtk+/glade-gtk-widget.c
plugins/gtk+/glade-gtk-window.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]