[gtk+] colorchooser: Do less in ::response



commit ad8bf6491c4baf1782e504d925c45c286030ab27
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 7 21:42:28 2012 -0500

    colorchooser: Do less in ::response
    
    Some people destroy their widgets in ::response, so trying
    to access dialog internals from the class handler that is
    running afterwards has the potential to cause problems.
    Instead, we can reset the ::show-editor property every
    time we map the dialog.

 gtk/gtkcolorchooserdialog.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c
index 7877225..177224e 100644
--- a/gtk/gtkcolorchooserdialog.c
+++ b/gtk/gtkcolorchooserdialog.c
@@ -147,9 +147,18 @@ gtk_color_chooser_dialog_response (GtkDialog *dialog,
       gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
       gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
     }
+}
 
-  g_object_set (GTK_COLOR_CHOOSER_DIALOG (dialog)->priv->chooser,
+static void
+gtk_color_chooser_dialog_map (GtkWidget *widget)
+{
+  /* We never want the dialog to come up with the editor,
+   * even if it was showing the editor the last time it was used.
+   */
+  g_object_set (GTK_COLOR_CHOOSER_DIALOG (widget)->priv->chooser,
                 "show-editor", FALSE, NULL);
+
+  GTK_WIDGET_CLASS (gtk_color_chooser_dialog_parent_class)->map (widget);
 }
 
 static void
@@ -219,11 +228,14 @@ static void
 gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
   GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (class);
 
   object_class->get_property = gtk_color_chooser_dialog_get_property;
   object_class->set_property = gtk_color_chooser_dialog_set_property;
 
+  widget_class->map = gtk_color_chooser_dialog_map;
+
   dialog_class->response = gtk_color_chooser_dialog_response;
 
   g_object_class_override_property (object_class, PROP_RGBA, "rgba");



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