[glade] Move GladeWidgetAdaptor code for GtkPaned 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 GtkPaned into it's own C file
- Date: Fri, 3 May 2013 17:06:37 +0000 (UTC)
commit 3cd9be03e8f16c375bda1b9a6d265a54cd189c40
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri May 3 22:23:14 2013 +0900
Move GladeWidgetAdaptor code for GtkPaned into it's own C file
plugins/gtk+/Makefile.am | 1 +
plugins/gtk+/glade-gtk-paned.c | 162 ++++++++++++++++++++++++++++++++++++++++
plugins/gtk+/glade-gtk.c | 138 ----------------------------------
po/POTFILES.in | 1 +
4 files changed, 164 insertions(+), 138 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 7e017f8..9dafa38 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -40,6 +40,7 @@ libgladegtk_la_SOURCES = \
glade-gtk-grid.c \
glade-gtk-info-bar.c \
glade-gtk-notebook.c \
+ glade-gtk-paned.c \
glade-gtk-switch.c \
glade-gtk-table.c \
glade-gtk-widget.c \
diff --git a/plugins/gtk+/glade-gtk-paned.c b/plugins/gtk+/glade-gtk-paned.c
new file mode 100644
index 0000000..09bc711
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-paned.c
@@ -0,0 +1,162 @@
+/*
+ * glade-gtk-paned.c - GladeWidgetAdaptor for GtkPaned
+ *
+ * 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>
+
+void
+glade_gtk_paned_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * paned, GladeCreateReason reason)
+{
+ g_return_if_fail (GTK_IS_PANED (paned));
+
+ if (reason == GLADE_CREATE_USER &&
+ gtk_paned_get_child1 (GTK_PANED (paned)) == NULL)
+ gtk_paned_add1 (GTK_PANED (paned), glade_placeholder_new ());
+
+ if (reason == GLADE_CREATE_USER &&
+ gtk_paned_get_child2 (GTK_PANED (paned)) == NULL)
+ gtk_paned_add2 (GTK_PANED (paned), glade_placeholder_new ());
+}
+
+void
+glade_gtk_paned_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ GtkPaned *paned;
+ GtkWidget *child1, *child2;
+ gboolean loading;
+
+ g_return_if_fail (GTK_IS_PANED (object));
+
+ paned = GTK_PANED (object);
+ loading = glade_util_object_is_loading (object);
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
+ if (loading == FALSE)
+ {
+ /* Remove a placeholder */
+ if (child1 && GLADE_IS_PLACEHOLDER (child1))
+ {
+ gtk_container_remove (GTK_CONTAINER (object), child1);
+ child1 = NULL;
+ }
+ else if (child2 && GLADE_IS_PLACEHOLDER (child2))
+ {
+ gtk_container_remove (GTK_CONTAINER (object), child2);
+ child2 = NULL;
+ }
+ }
+
+ /* Add the child */
+ if (child1 == NULL)
+ gtk_paned_add1 (paned, GTK_WIDGET (child));
+ else if (child2 == NULL)
+ gtk_paned_add2 (paned, GTK_WIDGET (child));
+
+ if (GLADE_IS_PLACEHOLDER (child) == FALSE && loading)
+ {
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+
+ if (gchild && glade_widget_get_packing_properties (gchild))
+ {
+ if (child1 == NULL)
+ glade_widget_pack_property_set (gchild, "first", TRUE);
+ else if (child2 == NULL)
+ glade_widget_pack_property_set (gchild, "first", FALSE);
+ }
+ }
+}
+
+void
+glade_gtk_paned_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+
+ glade_gtk_paned_post_create (adaptor, object, GLADE_CREATE_USER);
+}
+
+void
+glade_gtk_paned_set_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name,
+ const GValue * value)
+{
+ if (strcmp (property_name, "first") == 0)
+ {
+ GtkPaned *paned = GTK_PANED (container);
+ gboolean first = g_value_get_boolean (value);
+ GtkWidget *place, *wchild = GTK_WIDGET (child);
+
+ place = (first) ? gtk_paned_get_child1 (paned) :
+ gtk_paned_get_child2 (paned);
+
+ if (place && GLADE_IS_PLACEHOLDER (place))
+ gtk_container_remove (GTK_CONTAINER (container), place);
+
+ g_object_ref (child);
+ gtk_container_remove (GTK_CONTAINER (container), wchild);
+ if (first)
+ gtk_paned_add1 (paned, wchild);
+ else
+ gtk_paned_add2 (paned, wchild);
+ g_object_unref (child);
+
+ /* Ensure placeholders */
+ if (glade_util_object_is_loading (child) == FALSE)
+ {
+ if ((place = gtk_paned_get_child1 (paned)) == NULL)
+ gtk_paned_add1 (paned, glade_placeholder_new ());
+
+ if ((place = gtk_paned_get_child2 (paned)) == NULL)
+ gtk_paned_add2 (paned, glade_placeholder_new ());
+ }
+ }
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
+ container, child,
+ property_name, value);
+}
+
+void
+glade_gtk_paned_get_child_property (GladeWidgetAdaptor * adaptor,
+ GObject * container,
+ GObject * child,
+ const gchar * property_name, GValue * value)
+{
+ if (strcmp (property_name, "first") == 0)
+ g_value_set_boolean (value, GTK_WIDGET (child) ==
+ gtk_paned_get_child1 (GTK_PANED (container)));
+ else
+ /* Chain Up */
+ GWA_GET_CLASS
+ (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
+ container, child,
+ property_name, value);
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index f9b0bd0..309e031 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -85,144 +85,6 @@ glade_gtk_init (const gchar * name)
{
}
-/* ----------------------------- GtkPaned ------------------------------ */
-void
-glade_gtk_paned_post_create (GladeWidgetAdaptor * adaptor,
- GObject * paned, GladeCreateReason reason)
-{
- g_return_if_fail (GTK_IS_PANED (paned));
-
- if (reason == GLADE_CREATE_USER &&
- gtk_paned_get_child1 (GTK_PANED (paned)) == NULL)
- gtk_paned_add1 (GTK_PANED (paned), glade_placeholder_new ());
-
- if (reason == GLADE_CREATE_USER &&
- gtk_paned_get_child2 (GTK_PANED (paned)) == NULL)
- gtk_paned_add2 (GTK_PANED (paned), glade_placeholder_new ());
-}
-
-void
-glade_gtk_paned_add_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- GtkPaned *paned;
- GtkWidget *child1, *child2;
- gboolean loading;
-
- g_return_if_fail (GTK_IS_PANED (object));
-
- paned = GTK_PANED (object);
- loading = glade_util_object_is_loading (object);
-
- child1 = gtk_paned_get_child1 (paned);
- child2 = gtk_paned_get_child2 (paned);
-
- if (loading == FALSE)
- {
- /* Remove a placeholder */
- if (child1 && GLADE_IS_PLACEHOLDER (child1))
- {
- gtk_container_remove (GTK_CONTAINER (object), child1);
- child1 = NULL;
- }
- else if (child2 && GLADE_IS_PLACEHOLDER (child2))
- {
- gtk_container_remove (GTK_CONTAINER (object), child2);
- child2 = NULL;
- }
- }
-
- /* Add the child */
- if (child1 == NULL)
- gtk_paned_add1 (paned, GTK_WIDGET (child));
- else if (child2 == NULL)
- gtk_paned_add2 (paned, GTK_WIDGET (child));
-
- if (GLADE_IS_PLACEHOLDER (child) == FALSE && loading)
- {
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
-
- if (gchild && glade_widget_get_packing_properties (gchild))
- {
- if (child1 == NULL)
- glade_widget_pack_property_set (gchild, "first", TRUE);
- else if (child2 == NULL)
- glade_widget_pack_property_set (gchild, "first", FALSE);
- }
- }
-}
-
-void
-glade_gtk_paned_remove_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-
- glade_gtk_paned_post_create (adaptor, object, GLADE_CREATE_USER);
-}
-
-void
-glade_gtk_paned_set_child_property (GladeWidgetAdaptor * adaptor,
- GObject * container,
- GObject * child,
- const gchar * property_name,
- const GValue * value)
-{
- if (strcmp (property_name, "first") == 0)
- {
- GtkPaned *paned = GTK_PANED (container);
- gboolean first = g_value_get_boolean (value);
- GtkWidget *place, *wchild = GTK_WIDGET (child);
-
- place = (first) ? gtk_paned_get_child1 (paned) :
- gtk_paned_get_child2 (paned);
-
- if (place && GLADE_IS_PLACEHOLDER (place))
- gtk_container_remove (GTK_CONTAINER (container), place);
-
- g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (container), wchild);
- if (first)
- gtk_paned_add1 (paned, wchild);
- else
- gtk_paned_add2 (paned, wchild);
- g_object_unref (child);
-
- /* Ensure placeholders */
- if (glade_util_object_is_loading (child) == FALSE)
- {
- if ((place = gtk_paned_get_child1 (paned)) == NULL)
- gtk_paned_add1 (paned, glade_placeholder_new ());
-
- if ((place = gtk_paned_get_child2 (paned)) == NULL)
- gtk_paned_add2 (paned, glade_placeholder_new ());
- }
- }
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_set_property (adaptor,
- container, child,
- property_name, value);
-}
-
-void
-glade_gtk_paned_get_child_property (GladeWidgetAdaptor * adaptor,
- GObject * container,
- GObject * child,
- const gchar * property_name, GValue * value)
-{
- if (strcmp (property_name, "first") == 0)
- g_value_set_boolean (value, GTK_WIDGET (child) ==
- gtk_paned_get_child1 (GTK_PANED (container)));
- else
- /* Chain Up */
- GWA_GET_CLASS
- (GTK_TYPE_CONTAINER)->child_get_property (adaptor,
- container, child,
- property_name, value);
-}
-
/* ----------------------------- GtkExpander ------------------------------ */
void
glade_gtk_expander_post_create (GladeWidgetAdaptor * adaptor,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f2381b4..eeac9ce 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -67,6 +67,7 @@ plugins/gtk+/glade-gtk-container.c
plugins/gtk+/glade-gtk-frame.c
plugins/gtk+/glade-gtk-grid.c
plugins/gtk+/glade-gtk-notebook.c
+plugins/gtk+/glade-gtk-paned.c
plugins/gtk+/glade-gtk-table.c
plugins/gtk+/glade-gtk-widget.c
plugins/gtk+/glade-icon-factory-editor.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]