[gimp] app: use g_object_bind_property() to set widget visibility



commit 819ad3b4d95d097c690da9617f54ef2dd60bc141
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 31 23:15:42 2012 +0100

    app: use g_object_bind_property() to set widget visibility
    
    instead of connecting to "notify::boolean-property" of something just
    to set "widget::visible" in the callback.

 app/widgets/gimptoolbox.c     |   23 +++--------------------
 app/widgets/gimptoolpalette.c |   24 ++++++------------------
 2 files changed, 9 insertions(+), 38 deletions(-)
---
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 772ca3f..71e75fb 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -141,9 +141,6 @@ static GtkWidget * toolbox_create_image_area            (GimpToolbox    *toolbox
 static void        toolbox_area_notify                  (GimpGuiConfig  *config,
                                                          GParamSpec     *pspec,
                                                          GtkWidget      *area);
-static void        toolbox_wilber_notify                (GimpGuiConfig  *config,
-                                                         GParamSpec     *pspec,
-                                                         GtkWidget      *wilber);
 static void        toolbox_paste_received               (GtkClipboard   *clipboard,
                                                          const gchar    *text,
                                                          gpointer        data);
@@ -243,8 +240,9 @@ gimp_toolbox_constructed (GObject *object)
   gtk_box_pack_start (GTK_BOX (toolbox->p->vbox), toolbox->p->header,
                       FALSE, FALSE, 0);
 
-  if (config->toolbox_wilber)
-    gtk_widget_show (toolbox->p->header);
+  g_object_bind_property (config,             "toolbox-wilber",
+                          toolbox->p->header, "visible",
+                          G_BINDING_SYNC_CREATE);
 
   g_signal_connect (toolbox->p->header, "size-request",
                     G_CALLBACK (gimp_toolbox_size_request_wilber),
@@ -256,10 +254,6 @@ gimp_toolbox_constructed (GObject *object)
   gimp_help_set_help_data (toolbox->p->header,
                            _("Drop image files here to open them"), NULL);
 
-  g_signal_connect_object (config, "notify::toolbox-wilber",
-                           G_CALLBACK (toolbox_wilber_notify),
-                           toolbox->p->header, 0);
-
   toolbox->p->tool_palette = gimp_tool_palette_new ();
   gimp_tool_palette_set_toolbox (GIMP_TOOL_PALETTE (toolbox->p->tool_palette),
                                  toolbox);
@@ -788,17 +782,6 @@ toolbox_area_notify (GimpGuiConfig *config,
 }
 
 static void
-toolbox_wilber_notify (GimpGuiConfig *config,
-                       GParamSpec    *pspec,
-                       GtkWidget     *wilber)
-{
-  gboolean   visible;
-
-  g_object_get (config, pspec->name, &visible, NULL);
-  g_object_set (wilber, "visible", visible, NULL);
-}
-
-static void
 toolbox_paste_received (GtkClipboard *clipboard,
                         const gchar  *text,
                         gpointer      data)
diff --git a/app/widgets/gimptoolpalette.c b/app/widgets/gimptoolpalette.c
index 1608cf3..f773d3c 100644
--- a/app/widgets/gimptoolpalette.c
+++ b/app/widgets/gimptoolpalette.c
@@ -75,9 +75,6 @@ static void     gimp_tool_palette_tool_reorder        (GimpContainer   *containe
                                                        GimpToolInfo    *tool_info,
                                                        gint             index,
                                                        GimpToolPalette *palette);
-static void     gimp_tool_palette_tool_visible_notify (GimpToolInfo    *tool_info,
-                                                       GParamSpec      *pspec,
-                                                       GtkToolItem     *item);
 static void     gimp_tool_palette_tool_button_toggled (GtkWidget       *widget,
                                                        GimpToolPalette *palette);
 static gboolean gimp_tool_palette_tool_button_press   (GtkWidget       *widget,
@@ -333,15 +330,6 @@ gimp_tool_palette_tool_reorder (GimpContainer   *container,
 }
 
 static void
-gimp_tool_palette_tool_visible_notify (GimpToolInfo *tool_info,
-                                       GParamSpec   *pspec,
-                                       GtkToolItem  *item)
-{
-  gtk_tool_item_set_visible_horizontal (item, tool_info->visible);
-  gtk_tool_item_set_visible_vertical   (item, tool_info->visible);
-}
-
-static void
 gimp_tool_palette_tool_button_toggled (GtkWidget       *widget,
                                        GimpToolPalette *palette)
 {
@@ -410,12 +398,12 @@ gimp_tool_palette_initialize_tools (GimpToolPalette *palette)
       gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);
       gtk_widget_show (GTK_WIDGET (item));
 
-      gtk_tool_item_set_visible_horizontal (item, tool_info->visible);
-      gtk_tool_item_set_visible_vertical   (item, tool_info->visible);
-
-      g_signal_connect_object (tool_info, "notify::visible",
-                               G_CALLBACK (gimp_tool_palette_tool_visible_notify),
-                               item, 0);
+      g_object_bind_property (tool_info, "visible",
+                              item,      "visible-horizontal",
+                              G_BINDING_SYNC_CREATE);
+      g_object_bind_property (tool_info, "visible",
+                              item,      "visible-vertical",
+                              G_BINDING_SYNC_CREATE);
 
       g_object_set_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY, item);
       g_object_set_data (G_OBJECT (item)  ,    TOOL_INFO_DATA_KEY,   tool_info);



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