[Xfce4-commits] <terminal:master> Disconnect bindings before closing the dialog.

Nick Schermer noreply at xfce.org
Sun Mar 21 23:10:02 CET 2010


Updating branch refs/heads/master
         to 028dc2efd846defe796c7fa097ed84818bb43431 (commit)
       from 9356d3b37bcbe80dd1a4757715b01dccc2965978 (commit)

commit 028dc2efd846defe796c7fa097ed84818bb43431
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Mar 21 23:05:31 2010 +0100

    Disconnect bindings before closing the dialog.
    
    This avoids possible problems when Gtk+ emits property
    changes before the widgets are destroyed. This is currently
    the case for text entries in some Gtk 2.18 releases.

 terminal/terminal-preferences-dialog.c |   39 ++++++++++++++++++++-----------
 terminal/terminal-preferences-dialog.h |    1 +
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index 587bd92..8f33628 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -64,24 +64,28 @@ terminal_preferences_dialog_class_init (TerminalPreferencesDialogClass *klass)
 
 
 #define BIND_PROPERTIES(name, property) \
-  { object = gtk_builder_get_object (GTK_BUILDER (dialog), name); \
+  G_STMT_START { \
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), name); \
   terminal_return_if_fail (G_IS_OBJECT (object)); \
-  exo_mutual_binding_new (G_OBJECT (dialog->preferences), name, \
-                          G_OBJECT (object), property); }
+  binding = exo_mutual_binding_new (G_OBJECT (dialog->preferences), name, \
+                                    G_OBJECT (object), property); \
+  dialog->bindings = g_slist_prepend (dialog->bindings, binding); \
+  } G_STMT_END
 
 
 
 static void
 terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
 {
-  GError        *error = NULL;
-  guint          i;
-  GObject       *object, *object2;
-  GtkWidget     *editor;
-  gchar          palette_name[16];
-  GtkFileFilter *filter;
-  gchar         *file;
-  const gchar   *props_active[] = { "title-mode", "command-login-shell",
+  GError           *error = NULL;
+  guint             i;
+  GObject          *object, *object2;
+  GtkWidget        *editor;
+  gchar             palette_name[16];
+  GtkFileFilter    *filter;
+  gchar            *file;
+  ExoMutualBinding *binding;
+  const gchar      *props_active[] = { "title-mode", "command-login-shell",
                                     "command-update-records", "scrolling-single-line",
                                     "scrolling-on-output", "scrolling-on-keystroke",
                                     "scrolling-bar", "font-allow-bold",
@@ -94,9 +98,9 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
                                     , "font-anti-alias"
 #endif
                                     };
-  const gchar   *props_color[] =  { "color-foreground", "color-cursor",
-                                    "color-background", "tab-activity-color",
-                                    "color-selection" };
+  const gchar      *props_color[] =  { "color-foreground", "color-cursor",
+                                       "color-background", "tab-activity-color",
+                                       "color-selection" };
 
   dialog->preferences = terminal_preferences_get ();
 
@@ -248,6 +252,8 @@ terminal_preferences_dialog_response (GtkWidget                 *widget,
                                       gint                       response,
                                       TerminalPreferencesDialog *dialog)
 {
+  GSList *li;
+
   /* check if we should open the user manual */
   if (G_UNLIKELY (response == 1))
     {
@@ -256,6 +262,11 @@ terminal_preferences_dialog_response (GtkWidget                 *widget,
     }
   else
     {
+      /* disconnect all the bindings */
+      for (li = dialog->bindings; li != NULL; li = li->next)
+        exo_mutual_binding_unbind (li->data);
+      g_slist_free (dialog->bindings);
+
       /* close the preferences dialog */
       gtk_widget_destroy (widget);
     }
diff --git a/terminal/terminal-preferences-dialog.h b/terminal/terminal-preferences-dialog.h
index b2db4f5..268d70a 100644
--- a/terminal/terminal-preferences-dialog.h
+++ b/terminal/terminal-preferences-dialog.h
@@ -48,6 +48,7 @@ struct _TerminalPreferencesDialog
 
   TerminalPreferences *preferences;
   guint                signal_id;
+  GSList              *bindings;
 };
 
 GType      terminal_preferences_dialog_get_type (void) G_GNUC_CONST;



More information about the Xfce4-commits mailing list