+2007-01-27 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtktoolbar.c:
+ * gtk/gtktoolitem.c:
+ * gtk/gtktoolbutton.c: Rearrange things so that setting
+ multiple properties causes not more than a single
+ reconstruction of the contents.
+
+ * gtk/gtkaction.c (connect_proxy): Set all tool button
+ properties in one go.
+
2007-01-27 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstatusicon.c:
}
else if (GTK_IS_TOOL_ITEM (proxy))
{
- /* toolbar item specific synchronisers ... */
-
- g_object_set (proxy,
- "visible-horizontal", action->private_data->visible_horizontal,
- "visible-vertical", action->private_data->visible_vertical,
- "is-important", action->private_data->is_important,
- NULL);
-
- gtk_action_sync_tooltip (action, proxy);
-
- g_signal_connect_object (proxy, "create_menu_proxy",
- G_CALLBACK (gtk_action_create_menu_proxy),
- action, 0);
-
- gtk_tool_item_rebuild_menu (GTK_TOOL_ITEM (proxy));
-
/* toolbar button specific synchronisers ... */
if (GTK_IS_TOOL_BUTTON (proxy))
{
g_object_set (proxy,
+ "visible-horizontal", action->private_data->visible_horizontal,
+ "visible-vertical", action->private_data->visible_vertical,
+ "is-important", action->private_data->is_important,
"label", action->private_data->short_label,
"use-underline", TRUE,
"stock-id", action->private_data->stock_id,
g_signal_connect_object (proxy, "clicked",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
- }
+ }
+ else
+ {
+ g_object_set (proxy,
+ "visible-horizontal", action->private_data->visible_horizontal,
+ "visible-vertical", action->private_data->visible_vertical,
+ "is-important", action->private_data->is_important,
+ NULL);
+ }
+
+ gtk_action_sync_tooltip (action, proxy);
+
+ g_signal_connect_object (proxy, "create_menu_proxy",
+ G_CALLBACK (gtk_action_create_menu_proxy),
+ action, 0);
+
+ gtk_tool_item_rebuild_menu (GTK_TOOL_ITEM (proxy));
}
else if (GTK_IS_BUTTON (proxy))
{
gboolean overflowing;
gboolean size_changed;
GtkAllocation item_area;
+ GtkShadowType shadow_type;
size_changed = FALSE;
if (widget->allocation.x != allocation->x ||
gtk_widget_get_child_requisition (GTK_WIDGET (priv->arrow_button),
&arrow_requisition);
+ shadow_type = get_shadow_type (toolbar);
+
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
available_size = size = allocation->width - 2 * border_width;
short_size = allocation->height - 2 * border_width;
arrow_size = arrow_requisition.width;
- if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+ if (shadow_type != GTK_SHADOW_NONE)
{
available_size -= 2 * widget->style->xthickness;
short_size -= 2 * widget->style->ythickness;
short_size = allocation->width - 2 * border_width;
arrow_size = arrow_requisition.height;
- if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+ if (shadow_type != GTK_SHADOW_NONE)
{
available_size -= 2 * widget->style->ythickness;
short_size -= 2 * widget->style->xthickness;
allocations[i].x += allocation->x;
allocations[i].y += allocation->y;
- if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+ if (shadow_type != GTK_SHADOW_NONE)
{
allocations[i].x += widget->style->xthickness;
allocations[i].y += widget->style->ythickness;
arrow_allocation.x += allocation->x;
arrow_allocation.y += allocation->y;
- if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+ if (shadow_type != GTK_SHADOW_NONE)
{
arrow_allocation.x += widget->style->xthickness;
arrow_allocation.y += widget->style->ythickness;
item_area.x += allocation->x;
item_area.y += allocation->y;
- if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
+ if (shadow_type != GTK_SHADOW_NONE)
{
item_area.x += widget->style->xthickness;
item_area.y += widget->style->ythickness;
gtk_toolbar_update_button_relief (GtkToolbar *toolbar)
{
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+ GtkReliefStyle relief;
+
+ relief = get_button_relief (toolbar);
+
+ if (relief != gtk_button_get_relief (GTK_BUTTON (priv->arrow_button)))
+ {
+ gtk_toolbar_reconfigured (toolbar);
- gtk_toolbar_reconfigured (toolbar);
-
- gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), get_button_relief (toolbar));
+ gtk_button_set_relief (GTK_BUTTON (priv->arrow_button), relief);
+ }
}
static void
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (widget);
priv->max_homogeneous_pixels = -1;
-
+
if (GTK_WIDGET_REALIZED (widget))
gtk_style_set_background (widget->style, widget->window, widget->state);
toolbar);
priv->settings = g_object_ref (settings);
+
+ style_change_notify (toolbar);
+ icon_size_change_notify (toolbar);
+ animation_change_notify (toolbar);
}
else
priv->settings = NULL;
-
- style_change_notify (toolbar);
- icon_size_change_notify (toolbar);
- animation_change_notify (toolbar);
}
static int
if (child->type == GTK_TOOLBAR_CHILD_SPACE)
{
- if (get_space_style (toolbar) == GTK_TOOLBAR_SPACE_LINE &&
- content->u.compatibility.space_visible)
- {
- _gtk_toolbar_paint_space_line (GTK_WIDGET (toolbar), toolbar,
- &expose->area,
- &content->u.compatibility.space_allocation);
- }
+ if (content->u.compatibility.space_visible &&
+ get_space_style (toolbar) == GTK_TOOLBAR_SPACE_LINE)
+ _gtk_toolbar_paint_space_line (GTK_WIDGET (toolbar), toolbar,
+ &expose->area,
+ &content->u.compatibility.space_allocation);
return;
}
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL &&
gtk_tool_item_get_visible_horizontal (item))
- {
- return TRUE;
- }
+ return TRUE;
if ((toolbar->orientation == GTK_ORIENTATION_VERTICAL &&
gtk_tool_item_get_visible_vertical (item)))
- {
- return TRUE;
- }
+ return TRUE;
return FALSE;
break;
GtkWidget *icon_widget;
guint use_underline : 1;
+ guint contents_invalid : 1;
};
GType
button->priv = GTK_TOOL_BUTTON_GET_PRIVATE (button);
+ button->priv->contents_invalid = TRUE;
+
gtk_tool_item_set_homogeneous (toolitem, TRUE);
/* create button */
GtkWidget *box = NULL;
guint icon_spacing;
+ button->priv->contents_invalid = FALSE;
+
gtk_widget_style_get (GTK_WIDGET (tool_item),
"icon-spacing", &icon_spacing,
NULL);
gtk_tool_button_property_notify (GObject *object,
GParamSpec *pspec)
{
- if (strcmp (pspec->name, "is-important") == 0)
+ GtkToolButton *button = GTK_TOOL_BUTTON (object);
+
+ if (button->priv->contents_invalid)
gtk_tool_button_construct_contents (GTK_TOOL_ITEM (object));
if (parent_class->notify)
GtkToolButton *button;
button = g_object_new (GTK_TYPE_TOOL_BUTTON,
+ "label", label,
+ "icon-widget", icon_widget,
NULL);
-
- if (label)
- gtk_tool_button_set_label (button, label);
-
- if (icon_widget)
- gtk_tool_button_set_icon_widget (button, icon_widget);
return GTK_TOOL_ITEM (button);
}
old_label = button->priv->label_text;
button->priv->label_text = g_strdup (label);
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "label");
+ button->priv->contents_invalid = TRUE;
- if (old_label)
- g_free (old_label);
+ g_free (old_label);
+
+ g_object_notify (G_OBJECT (button), "label");
}
/**
if (use_underline != button->priv->use_underline)
{
button->priv->use_underline = use_underline;
-
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
+ button->priv->contents_invalid = TRUE;
g_object_notify (G_OBJECT (button), "use-underline");
}
old_stock_id = button->priv->stock_id;
button->priv->stock_id = g_strdup (stock_id);
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "stock-id");
+ button->priv->contents_invalid = TRUE;
g_free (old_stock_id);
+
+ g_object_notify (G_OBJECT (button), "stock-id");
}
/**
old_icon_name = button->priv->icon_name;
button->priv->icon_name = g_strdup (icon_name);
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
-
- g_object_notify (G_OBJECT (button), "icon-name");
+ button->priv->contents_invalid = TRUE;
g_free (old_icon_name);
+
+ g_object_notify (G_OBJECT (button), "icon-name");
}
/**
if (button->priv->icon_widget)
{
if (button->priv->icon_widget->parent)
- {
- gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
+ gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
button->priv->icon_widget);
- }
g_object_unref (button->priv->icon_widget);
}
if (icon_widget)
- {
- g_object_ref_sink (icon_widget);
- }
+ g_object_ref_sink (icon_widget);
button->priv->icon_widget = icon_widget;
-
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
+ button->priv->contents_invalid = TRUE;
g_object_notify (G_OBJECT (button), "icon-widget");
}
if (button->priv->label_widget)
{
if (button->priv->label_widget->parent)
- {
- gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
- button->priv->label_widget);
- }
+ gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
+ button->priv->label_widget);
g_object_unref (button->priv->label_widget);
}
if (label_widget)
- {
- g_object_ref_sink (label_widget);
- }
+ g_object_ref_sink (label_widget);
button->priv->label_widget = label_widget;
-
- gtk_tool_button_construct_contents (GTK_TOOL_ITEM (button));
+ button->priv->contents_invalid = TRUE;
g_object_notify (G_OBJECT (button), "label-widget");
}
}
static void
-gtk_tool_item_parent_set (GtkWidget *toolitem,
- GtkWidget *prev_parent)
+gtk_tool_item_parent_set (GtkWidget *toolitem,
+ GtkWidget *prev_parent)
{
- _gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
+ if (GTK_WIDGET (toolitem)->parent != NULL)
+ _gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
}
static void