[glade3] 2010-03-28 Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>



commit 69012ceacae43466b54cfba6e9c113e51977ea35
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Mar 28 19:29:23 2010 -0400

    2010-03-28  Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
    
    	* gladeui/glade-base-editor.c: Avoid GtkEntry feedback loop with g_signal_handlers_block_by_func(),
    	fixes bug 609612.

 ChangeLog                   |    5 +++++
 gladeui/glade-base-editor.c |   29 ++++++++++++++++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8a101b1..7a53dfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-28  Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
+
+	* gladeui/glade-base-editor.c: Avoid GtkEntry feedback loop with g_signal_handlers_block_by_func(),
+	fixes bug 609612.
+
 2010-03-28  Tristan Van Berkom <tvb gnome org>
 
 	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in:
diff --git a/gladeui/glade-base-editor.c b/gladeui/glade-base-editor.c
index 40a2b90..37924fe 100644
--- a/gladeui/glade-base-editor.c
+++ b/gladeui/glade-base-editor.c
@@ -316,22 +316,28 @@ glade_base_editor_get_child_selected (GladeBaseEditor *e, GtkTreeIter *iter)
 	return gtk_tree_selection_get_selected (sel, NULL, iter);
 }
 
+/* Forward declaration for glade_base_editor_project_widget_name_changed */
+static void
+glade_base_editor_project_widget_name_changed (GladeProject *project,
+					       GladeWidget  *widget,
+					       GladeBaseEditor *editor);
+
 static void
 glade_base_editor_name_activate (GtkEntry *entry, GladeWidget *gchild)
 {
 	const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
-	
+	GladeBaseEditor *editor = g_object_get_data (G_OBJECT (entry), "editor");
+
 	if (strcmp (glade_widget_get_name (gchild), text))
+	{
+		g_signal_handlers_block_by_func (gchild->project,
+						 glade_base_editor_project_widget_name_changed,
+						 editor);
 		glade_command_set_name (gchild, text);
-}
-
-static gboolean
-glade_base_editor_name_focus_out (GtkWidget *entry,
-				  GdkEventFocus *event,
-				  GladeWidget *gchild)
-{
-	glade_base_editor_name_activate (GTK_ENTRY (entry), gchild);
-	return FALSE;
+		g_signal_handlers_unblock_by_func (gchild->project,
+						   glade_base_editor_project_widget_name_changed,
+						   editor);
+	}
 }
 
 static void
@@ -1976,8 +1982,9 @@ glade_base_editor_add_default_properties (GladeBaseEditor *editor,
 	
 	entry = gtk_entry_new ();
 	gtk_entry_set_text (GTK_ENTRY (entry), glade_widget_get_name (gchild));
+	g_object_set_data (G_OBJECT (entry), "editor", editor);
 	g_signal_connect (entry, "activate", G_CALLBACK (glade_base_editor_name_activate), gchild);
-	g_signal_connect (entry, "focus-out-event", G_CALLBACK (glade_base_editor_name_focus_out), gchild);
+	g_signal_connect (entry, "changed", G_CALLBACK (glade_base_editor_name_activate), gchild);
 	glade_base_editor_table_attach (editor, label, entry);
 
 	if (child_class && gtk_tree_model_iter_n_children (child_class, NULL) > 1)



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