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.
This commit is contained in:
Michael Natterer 2012-10-31 23:15:42 +01:00
parent 620e79d3a1
commit 819ad3b4d9
2 changed files with 9 additions and 38 deletions

View File

@ -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);
@ -787,17 +781,6 @@ toolbox_area_notify (GimpGuiConfig *config,
g_object_set (area, "visible", visible, NULL);
}
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,

View File

@ -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,
@ -332,15 +329,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);