[glade3] 2010-03-30 Tristan Van Berkom <tvb gnome org>



commit 7d9925eab354abf167382d512bc75b3fd4b5a263
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Mar 30 10:51:26 2010 -0400

    2010-03-30  Tristan Van Berkom <tvb gnome org>
    
    	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Block the glade_gtk_text_buffer_changed()
    	  handler when updating the buffer text (this feedback loop was causing segfaults when undoing
    	  modifications to a text buffer's text).

 ChangeLog                |    6 ++++++
 plugins/gtk+/glade-gtk.c |   28 +++++++++++++++++++++++++++-
 plugins/gtk+/gtk+.xml.in |    1 +
 3 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4d942a1..1f1f4c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-30  Tristan Van Berkom <tvb gnome org>
+
+	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Block the glade_gtk_text_buffer_changed()
+	  handler when updating the buffer text (this feedback loop was causing segfaults when undoing
+	  modifications to a text buffer's text).
+
 2010-03-29  Tristan Van Berkom <tvb gnome org>
 
 	* gladeui/glade-editor-property.[ch]: 
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 1560239..189b350 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -8591,7 +8591,7 @@ glade_gtk_text_buffer_changed (GtkTextBuffer *buffer, GladeWidget *gbuffy)
 	{
 		glade_property_get (prop, &text_prop);
 
-		if (text_prop == NULL || text == NULL || strcmp (text, text_prop))
+		if (g_strcmp0 (text, text_prop))
 			glade_command_set_property (prop, text);
 	}
 	g_free (text);
@@ -8611,6 +8611,32 @@ glade_gtk_text_buffer_post_create (GladeWidgetAdaptor *adaptor,
 			  gbuffy);
 }
 
+
+void
+glade_gtk_text_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_text_buffer_changed, gwidget);
+
+		if (g_value_get_string (value))
+			gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), g_value_get_string (value), -1);
+		else
+			gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), "", -1);
+
+		g_signal_handlers_unblock_by_func (object, glade_gtk_text_buffer_changed, gwidget);
+
+       	}
+	else if (GPC_VERSION_CHECK (property->klass, gtk_major_version, gtk_minor_version + 1))
+		GWA_GET_CLASS (G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+}
+
 /* ----------------------------- GtkTextView ------------------------------ */
 static void
 glade_gtk_text_view_changed (GtkTextBuffer *buffer, GladeWidget *gtext)
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index db92135..8792ea9 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -3345,6 +3345,7 @@ embedded in another object</_tooltip>
     <glade-widget-class name="GtkTextBuffer" generic-name="textbuffer" _title="Text Buffer" 
 			libglade-unsupported="True" toplevel="True">
       <post-create-function>glade_gtk_text_buffer_post_create</post-create-function>
+      <set-property-function>glade_gtk_text_buffer_set_property</set-property-function>
       <signals>
 	<signal id="paste-done" since="2.16"/>
       </signals>



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