[gimp] app: use g_object_bind_property() to set sensitivity here too



commit 3184c0f3391f6f34949e3d4cd5bfd7b7a7a47d2e
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 11 11:43:19 2011 +0200

    app: use g_object_bind_property() to set sensitivity here too

 app/dialogs/convert-dialog.c           |    5 ++-
 app/dialogs/preferences-dialog.c       |   10 +++++---
 app/dialogs/stroke-dialog.c            |   34 +++++++++++--------------------
 app/tools/gimpcoloroptions.c           |    6 ++--
 app/tools/gimprectangleselectoptions.c |   13 ++++++-----
 app/widgets/gimpwidgets-utils.c        |   10 ++------
 6 files changed, 34 insertions(+), 44 deletions(-)
---
diff --git a/app/dialogs/convert-dialog.c b/app/dialogs/convert-dialog.c
index 58fcde9..8b0a8fb 100644
--- a/app/dialogs/convert-dialog.c
+++ b/app/dialogs/convert-dialog.c
@@ -225,8 +225,9 @@ convert_dialog_new (GimpImage    *image,
                     G_CALLBACK (gimp_toggle_button_update),
                     &dialog->remove_dups);
 
-  g_object_set_data (G_OBJECT (button), "inverse_sensitive", toggle);
-  gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (button));
+  g_object_bind_property (button, "active",
+                          toggle, "sensitive",
+                          G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
 
   /*  dithering  */
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 3148efb..5c27ad9 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -445,8 +445,6 @@ prefs_resolution_source_callback (GtkWidget *widget,
   gdouble  yres;
   gboolean from_gdk;
 
-  gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (widget));
-
   from_gdk = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
   if (from_gdk)
@@ -2359,7 +2357,6 @@ prefs_dialog_new (Gimp       *gimp,
   gtk_widget_show (button);
 
   g_object_set_data (G_OBJECT (button), "monitor_resolution_sizeentry", entry);
-  g_object_set_data (G_OBJECT (button), "inverse_sensitive", entry);
 
   g_signal_connect (button, "toggled",
                     G_CALLBACK (prefs_resolution_source_callback),
@@ -2388,7 +2385,12 @@ prefs_dialog_new (Gimp       *gimp,
   gtk_widget_set_sensitive (calibrate_button,
                             ! display_config->monitor_res_from_gdk);
 
-  g_object_set_data (G_OBJECT (entry), "inverse_sensitive", calibrate_button);
+  g_object_bind_property (button, "active",
+                          entry,  "sensitive",
+                          G_BINDING_SYNC_CREATE);
+  g_object_bind_property (button,           "active",
+                          calibrate_button, "sensitive",
+                          G_BINDING_SYNC_CREATE);
 
   g_signal_connect (calibrate_button, "clicked",
                     G_CALLBACK (prefs_resolution_calibrate_callback),
diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c
index b7a3a7f..24c9ef9 100644
--- a/app/dialogs/stroke-dialog.c
+++ b/app/dialogs/stroke-dialog.c
@@ -70,7 +70,7 @@ stroke_dialog_new (GimpItem    *item,
   GtkWidget         *dialog;
   GtkWidget         *main_vbox;
   GtkWidget         *radio_box;
-  GtkWidget         *libart_radio;
+  GtkWidget         *cairo_radio;
   GtkWidget         *paint_radio;
   GSList            *group;
   GtkWidget         *frame;
@@ -133,8 +133,8 @@ stroke_dialog_new (GimpItem    *item,
   group = gtk_radio_button_get_group (g_object_get_data (G_OBJECT (radio_box),
                                                          "radio-button"));
 
-  libart_radio = g_object_ref (group->next->data);
-  gtk_container_remove (GTK_CONTAINER (radio_box), libart_radio);
+  cairo_radio = g_object_ref (group->next->data);
+  gtk_container_remove (GTK_CONTAINER (radio_box), cairo_radio);
 
   paint_radio = g_object_ref (group->data);
   gtk_container_remove (GTK_CONTAINER (radio_box), paint_radio);
@@ -148,7 +148,7 @@ stroke_dialog_new (GimpItem    *item,
     font_desc = pango_font_description_new ();
     pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
 
-    gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (libart_radio)),
+    gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (cairo_radio)),
                             font_desc);
     gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (paint_radio)),
                             font_desc);
@@ -163,12 +163,8 @@ stroke_dialog_new (GimpItem    *item,
   gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
   gtk_widget_show (frame);
 
-  gtk_frame_set_label_widget (GTK_FRAME (frame), libart_radio);
-  g_object_unref (libart_radio);
-
-  g_signal_connect (libart_radio, "toggled",
-                    G_CALLBACK (gimp_toggle_button_sensitive_update),
-                    NULL);
+  gtk_frame_set_label_widget (GTK_FRAME (frame), cairo_radio);
+  g_object_unref (cairo_radio);
 
   {
     GtkWidget *stroke_editor;
@@ -181,10 +177,9 @@ stroke_dialog_new (GimpItem    *item,
     gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
     gtk_widget_show (stroke_editor);
 
-    gtk_widget_set_sensitive (stroke_editor,
-                              gimp_stroke_options_get_method (options) ==
-                              GIMP_STROKE_METHOD_LIBART);
-    g_object_set_data (G_OBJECT (libart_radio), "set_sensitive", stroke_editor);
+    g_object_bind_property (cairo_radio,   "active",
+                            stroke_editor, "sensitive",
+                            G_BINDING_SYNC_CREATE);
   }
 
 
@@ -197,10 +192,6 @@ stroke_dialog_new (GimpItem    *item,
   gtk_frame_set_label_widget (GTK_FRAME (frame), paint_radio);
   g_object_unref (paint_radio);
 
-  g_signal_connect (paint_radio, "toggled",
-                    G_CALLBACK (gimp_toggle_button_sensitive_update),
-                    NULL);
-
   {
     GtkWidget *vbox;
     GtkWidget *hbox;
@@ -212,10 +203,9 @@ stroke_dialog_new (GimpItem    *item,
     gtk_container_add (GTK_CONTAINER (frame), vbox);
     gtk_widget_show (vbox);
 
-    gtk_widget_set_sensitive (vbox,
-                              gimp_stroke_options_get_method (options) ==
-                              GIMP_STROKE_METHOD_PAINT_CORE);
-    g_object_set_data (G_OBJECT (paint_radio), "set_sensitive", vbox);
+    g_object_bind_property (paint_radio, "active",
+                            vbox,        "sensitive",
+                            G_BINDING_SYNC_CREATE);
 
     hbox = gtk_hbox_new (FALSE, 6);
     gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
diff --git a/app/tools/gimpcoloroptions.c b/app/tools/gimpcoloroptions.c
index 4264041..2ff2c8c 100644
--- a/app/tools/gimpcoloroptions.c
+++ b/app/tools/gimpcoloroptions.c
@@ -164,9 +164,9 @@ gimp_color_options_gui (GimpToolOptions *tool_options)
   gtk_frame_set_label_widget (GTK_FRAME (frame), button);
   gtk_widget_show (button);
 
-  gtk_widget_set_sensitive (scale,
-                            GIMP_COLOR_OPTIONS (config)->sample_average);
-  g_object_set_data (G_OBJECT (button), "set_sensitive", scale);
+  g_object_bind_property (config, "sample-average",
+                          scale,  "sensitive",
+                          G_BINDING_SYNC_CREATE);
 
   return vbox;
 }
diff --git a/app/tools/gimprectangleselectoptions.c b/app/tools/gimprectangleselectoptions.c
index 38f61d2..45a7d22 100644
--- a/app/tools/gimprectangleselectoptions.c
+++ b/app/tools/gimprectangleselectoptions.c
@@ -156,8 +156,8 @@ gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
   if (tool_options->tool_info->tool_type == GIMP_TYPE_RECTANGLE_SELECT_TOOL)
     {
       GtkWidget *frame;
-      GtkWidget *button;
       GtkWidget *scale;
+      GtkWidget *toggle;
 
       scale = gimp_prop_spin_scale_new (config, "corner-radius",
                                         _("Radius"),
@@ -165,14 +165,15 @@ gimp_rectangle_select_options_gui (GimpToolOptions *tool_options)
 
       frame = gimp_prop_expanding_frame_new (config, "round-corners",
                                              _("Rounded corners"),
-                                             scale, &button);
+                                             scale, NULL);
       gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
       gtk_widget_show (frame);
 
-      g_object_set_data (G_OBJECT (button), "set_sensitive",
-                         GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle);
-      gtk_widget_set_sensitive (GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle,
-                                GIMP_RECTANGLE_SELECT_OPTIONS (tool_options)->round_corners);
+      toggle = GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle;
+
+      g_object_bind_property (config, "round-corners",
+                              toggle, "sensitive",
+                              G_BINDING_SYNC_CREATE);
     }
 
   /*  the rectangle options  */
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index efdf0ef..6bf2e22 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -329,13 +329,9 @@ gimp_enum_radio_box_add (GtkBox    *box,
           gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
           gtk_widget_show (widget);
 
-          g_object_set_data (G_OBJECT (radio), "set_sensitive", widget);
-          g_signal_connect (radio, "toggled",
-                            G_CALLBACK (gimp_toggle_button_sensitive_update),
-                            NULL);
-
-          gtk_widget_set_sensitive (widget,
-                                    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (list->data)));
+          g_object_bind_property (radio,  "active",
+                                  widget, "sensitive",
+                                  G_BINDING_SYNC_CREATE);
 
           gtk_widget_show (hbox);
 



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