[glade] Move GladeWidgetAdaptor code for GtkEntryBuffer into it's own C file



commit c29aaa1cdd8091277fcd0468cdcea1c7766b7446
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat May 4 15:07:20 2013 +0900

    Move GladeWidgetAdaptor code for GtkEntryBuffer into it's own C file

 plugins/gtk+/Makefile.am              |    1 +
 plugins/gtk+/glade-gtk-entry-buffer.c |   89 +++++++++++++++++++++++++++++++++
 plugins/gtk+/glade-gtk.c              |   65 ------------------------
 po/POTFILES.in                        |    1 +
 4 files changed, 91 insertions(+), 65 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 35336e5..9ce20c4 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -40,6 +40,7 @@ libgladegtk_la_SOURCES =              \
        glade-gtk-container.c           \
        glade-gtk-dialog.c              \
        glade-gtk-entry.c               \
+       glade-gtk-entry-buffer.c        \
        glade-gtk-expander.c            \
        glade-gtk-file-chooser-widget.c \
        glade-gtk-fixed-layout.c        \
diff --git a/plugins/gtk+/glade-gtk-entry-buffer.c b/plugins/gtk+/glade-gtk-entry-buffer.c
new file mode 100644
index 0000000..d700115
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-entry-buffer.c
@@ -0,0 +1,89 @@
+/*
+ * glade-gtk-entry-buffer.c - GladeWidgetAdaptor for GtkEntryBuffer
+ *
+ * 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>
+
+static void
+glade_gtk_entry_buffer_changed (GtkTextBuffer * buffer,
+                                GParamSpec * pspec, GladeWidget * gbuffy)
+{
+  const gchar *text_prop = NULL;
+  GladeProperty *prop;
+  gchar *text = NULL;
+
+  if (glade_widget_superuser ())
+    return;
+
+  g_object_get (buffer, "text", &text, NULL);
+
+  if ((prop = glade_widget_get_property (gbuffy, "text")))
+    {
+      glade_property_get (prop, &text_prop);
+
+      if (text_prop == NULL || g_strcmp0 (text, text_prop))
+        glade_command_set_property (prop, text);
+    }
+  g_free (text);
+}
+
+void
+glade_gtk_entry_buffer_post_create (GladeWidgetAdaptor * adaptor,
+                                    GObject * object, GladeCreateReason reason)
+{
+  GladeWidget *gbuffy;
+
+  gbuffy = glade_widget_get_from_gobject (object);
+
+  g_signal_connect (object, "notify::text",
+                    G_CALLBACK (glade_gtk_entry_buffer_changed), gbuffy);
+}
+
+void
+glade_gtk_entry_buffer_set_property (GladeWidgetAdaptor * adaptor,
+                                     GObject * object,
+                                     const gchar * id, const GValue * value)
+{
+  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+  GladeProperty *property = glade_widget_get_property (gwidget, id);
+
+  if (!strcmp (id, "text"))
+    {
+      g_signal_handlers_block_by_func (object, glade_gtk_entry_buffer_changed,
+                                       gwidget);
+
+      if (g_value_get_string (value))
+        gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object),
+                                   g_value_get_string (value), -1);
+      else
+        gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object), "", -1);
+
+      g_signal_handlers_unblock_by_func (object, glade_gtk_entry_buffer_changed,
+                                         gwidget);
+
+    }
+  else if (GPC_VERSION_CHECK
+           (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
+    GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 824d3cc..f2b69d2 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -80,71 +80,6 @@ glade_gtk_init (const gchar * name)
 
 
 
-/* ----------------------------- GtkTextBuffer ------------------------------ */
-static void
-glade_gtk_entry_buffer_changed (GtkTextBuffer * buffer,
-                                GParamSpec * pspec, GladeWidget * gbuffy)
-{
-  const gchar *text_prop = NULL;
-  GladeProperty *prop;
-  gchar *text = NULL;
-
-  if (glade_widget_superuser ())
-    return;
-
-  g_object_get (buffer, "text", &text, NULL);
-
-  if ((prop = glade_widget_get_property (gbuffy, "text")))
-    {
-      glade_property_get (prop, &text_prop);
-
-      if (text_prop == NULL || g_strcmp0 (text, text_prop))
-        glade_command_set_property (prop, text);
-    }
-  g_free (text);
-}
-
-void
-glade_gtk_entry_buffer_post_create (GladeWidgetAdaptor * adaptor,
-                                    GObject * object, GladeCreateReason reason)
-{
-  GladeWidget *gbuffy;
-
-  gbuffy = glade_widget_get_from_gobject (object);
-
-  g_signal_connect (object, "notify::text",
-                    G_CALLBACK (glade_gtk_entry_buffer_changed), gbuffy);
-}
-
-
-void
-glade_gtk_entry_buffer_set_property (GladeWidgetAdaptor * adaptor,
-                                     GObject * object,
-                                     const gchar * id, const GValue * value)
-{
-  GladeWidget *gwidget = glade_widget_get_from_gobject (object);
-  GladeProperty *property = glade_widget_get_property (gwidget, id);
-
-  if (!strcmp (id, "text"))
-    {
-      g_signal_handlers_block_by_func (object, glade_gtk_entry_buffer_changed,
-                                       gwidget);
-
-      if (g_value_get_string (value))
-        gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object),
-                                   g_value_get_string (value), -1);
-      else
-        gtk_entry_buffer_set_text (GTK_ENTRY_BUFFER (object), "", -1);
-
-      g_signal_handlers_unblock_by_func (object, glade_gtk_entry_buffer_changed,
-                                         gwidget);
-
-    }
-  else if (GPC_VERSION_CHECK
-           (glade_property_get_class (property), gtk_major_version, gtk_minor_version + 1))
-    GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
-}
-
 
 
 /* ----------------------------- GtkTextBuffer ------------------------------ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index beb9af0..060cf65 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -68,6 +68,7 @@ plugins/gtk+/glade-gtk-button.c
 plugins/gtk+/glade-gtk-container.c
 plugins/gtk+/glade-gtk-dialog.c
 plugins/gtk+/glade-gtk-entry.c
+plugins/gtk+/glade-gtk-entry-buffer.c
 plugins/gtk+/glade-gtk-expander.c
 plugins/gtk+/glade-gtk-file-chooser-widget.c
 plugins/gtk+/glade-gtk-fixed-layout.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]