Commit 59207896 authored by Søren Sandmann's avatar Søren Sandmann Committed by Søren Sandmann Pedersen

Call gtk_tool_item_rebuild_menu().

Tue Sep 14 23:20:56 2004  Søren Sandmann  <sandmann@redhat.com>

	* gtk/gtkaction.c (connect_proxy): Call
	gtk_tool_item_rebuild_menu().

	* gtk/gtktoolitem.c (gtk_tool_item_class_init): Update
	documentation for GtkToolItem::create_menu_proxy.

	* gtk/gtktoolitem.c (gtk_tool_item_rebuild_menu): New
	API to make the toolbar update itself when the proxy menu item
	for a tool item changes.

	* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Call
	gtk_tool_item_rebuild_menu here()

	* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents):
	Remove redundant check for need_label.
parent f67c09c9
Tue Sep 14 23:20:56 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkaction.c (connect_proxy): Call
gtk_tool_item_rebuild_menu().
* gtk/gtktoolitem.c (gtk_tool_item_class_init): Update
documentation for GtkToolItem::create_menu_proxy.
* gtk/gtktoolitem.c (gtk_tool_item_rebuild_menu): New
API to make the toolbar update itself when the proxy menu item
for a tool item changes.
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Call
gtk_tool_item_rebuild_menu here()
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents):
Remove redundant check for need_label.
2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused
......
Tue Sep 14 23:20:56 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkaction.c (connect_proxy): Call
gtk_tool_item_rebuild_menu().
* gtk/gtktoolitem.c (gtk_tool_item_class_init): Update
documentation for GtkToolItem::create_menu_proxy.
* gtk/gtktoolitem.c (gtk_tool_item_rebuild_menu): New
API to make the toolbar update itself when the proxy menu item
for a tool item changes.
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Call
gtk_tool_item_rebuild_menu here()
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents):
Remove redundant check for need_label.
2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused
......
Tue Sep 14 23:20:56 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkaction.c (connect_proxy): Call
gtk_tool_item_rebuild_menu().
* gtk/gtktoolitem.c (gtk_tool_item_class_init): Update
documentation for GtkToolItem::create_menu_proxy.
* gtk/gtktoolitem.c (gtk_tool_item_rebuild_menu): New
API to make the toolbar update itself when the proxy menu item
for a tool item changes.
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Call
gtk_tool_item_rebuild_menu here()
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents):
Remove redundant check for need_label.
2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused
......
Tue Sep 14 23:20:56 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtkaction.c (connect_proxy): Call
gtk_tool_item_rebuild_menu().
* gtk/gtktoolitem.c (gtk_tool_item_class_init): Update
documentation for GtkToolItem::create_menu_proxy.
* gtk/gtktoolitem.c (gtk_tool_item_rebuild_menu): New
API to make the toolbar update itself when the proxy menu item
for a tool item changes.
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents): Call
gtk_tool_item_rebuild_menu here()
* gtk/gtktoolbutton.c (gtk_tool_button_construct_contents):
Remove redundant check for need_label.
2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused
......
......@@ -869,9 +869,9 @@ connect_proxy (GtkAction *action,
}
if (gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)) == NULL)
g_signal_connect_object (proxy, "activate",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
g_signal_connect_object (proxy, "activate",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
else if (GTK_IS_TOOL_ITEM (proxy))
......@@ -903,6 +903,8 @@ connect_proxy (GtkAction *action,
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))
{
......@@ -920,10 +922,10 @@ connect_proxy (GtkAction *action,
g_signal_connect_object (action, "notify::stock-id",
G_CALLBACK (gtk_action_sync_property),
proxy, 0);
g_signal_connect_object (proxy, "clicked",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
g_signal_connect_object (proxy, "clicked",
G_CALLBACK (gtk_action_activate), action,
G_CONNECT_SWAPPED);
}
}
else if (GTK_IS_BUTTON (proxy))
{
......
......@@ -1234,7 +1234,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
}
/* This resize will run before the first idle handler. This
* will make sure that items get the right goal allocatiuon
* will make sure that items get the right goal allocation
* so that the idle handler will not immediately return
* FALSE
*/
......@@ -3734,6 +3734,12 @@ internal_insert_element (GtkToolbar *toolbar,
/*
* ToolbarContent methods
*/
typedef enum {
UNKNOWN,
YES,
NO,
} TriState;
struct _ToolbarContent
{
ContentType type;
......@@ -3748,6 +3754,7 @@ struct _ToolbarContent
GtkAllocation goal_allocation;
guint is_placeholder : 1;
guint disappearing : 1;
TriState has_menu : 2;
} tool_item;
struct
......@@ -4238,8 +4245,11 @@ toolbar_content_set_child_visible (ToolbarContent *content,
}
else
{
content->u.compatibility.space_visible = visible;
gtk_widget_queue_draw (GTK_WIDGET (toolbar));
if (content->u.compatibility.space_visible != visible)
{
content->u.compatibility.space_visible = visible;
gtk_widget_queue_draw (GTK_WIDGET (toolbar));
}
}
break;
}
......@@ -4470,13 +4480,34 @@ toolbar_content_retrieve_menu_item (ToolbarContent *content)
static gboolean
toolbar_content_has_proxy_menu_item (ToolbarContent *content)
{
GtkWidget *menu_item;
if (content->type == TOOL_ITEM)
{
GtkWidget *menu_item;
menu_item = toolbar_content_retrieve_menu_item (content);
if (content->u.tool_item.has_menu == YES)
return TRUE;
else if (content->u.tool_item.has_menu == NO)
return FALSE;
return menu_item != NULL;
menu_item = toolbar_content_retrieve_menu_item (content);
content->u.tool_item.has_menu = menu_item? YES : NO;
return menu_item != NULL;
}
else
{
return FALSE;
}
}
static void
toolbar_content_set_unknown_menu_status (ToolbarContent *content)
{
if (content->type == TOOL_ITEM)
content->u.tool_item.has_menu = UNKNOWN;
}
static gboolean
toolbar_content_is_separator (ToolbarContent *content)
{
......@@ -4723,3 +4754,21 @@ _gtk_toolbar_elide_underscores (const gchar *original)
return result;
}
void
_gtk_toolbar_rebuild_menu (GtkToolbar *toolbar)
{
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
GList *list;
priv->need_rebuild = TRUE;
for (list = priv->content; list != NULL; list = list->next)
{
ToolbarContent *content = list->data;
toolbar_content_set_unknown_menu_status (content);
}
gtk_widget_queue_resize (GTK_WIDGET (toolbar));
}
......@@ -173,7 +173,6 @@ void _gtk_toolbar_paint_space_line (GtkWidget *widget,
gint _gtk_toolbar_get_default_space_size (void);
/* deprecated */
#ifndef GTK_DISABLE_DEPRECATED
void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
......
......@@ -262,14 +262,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
GtkIconSize icon_size;
GtkWidget *box = NULL;
if (gtk_tool_item_get_proxy_menu_item (tool_item, MENU_ID))
{
/* Remove item, so it will be recreated on the next
* create_proxy_menu_item()
*/
gtk_tool_item_set_proxy_menu_item (tool_item, MENU_ID, NULL);
}
if (button->priv->icon_widget && button->priv->icon_widget->parent)
{
gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
......@@ -304,12 +296,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
need_label = TRUE;
}
if (style != GTK_TOOLBAR_ICONS &&
((style != GTK_TOOLBAR_BOTH_HORIZ ||
gtk_tool_item_get_is_important (GTK_TOOL_ITEM (button)))))
need_label = TRUE;
if (need_label)
{
if (button->priv->label_widget)
......@@ -407,6 +394,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_button_set_relief (GTK_BUTTON (button->priv->button),
gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button)));
gtk_tool_item_rebuild_menu (tool_item);
gtk_widget_queue_resize (GTK_WIDGET (button));
}
......
......@@ -179,8 +179,9 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
* GtkToolItem::create-menu-proxy:
* @toolitem: the object the signal was emitted on
*
* This signal is emitted when the toolbar is displaying an overflow menu.
* In response the tool item should either
* This signal is emitted when the toolbar needs information from @tool_item
* about whether the item should appear in the toolbar overflow menu. In
* response the tool item should either
* <itemizedlist>
* <listitem> call gtk_tool_item_set_proxy_menu_item() with a %NULL
* pointer and return %TRUE to indicate that the item should not appear
......@@ -195,7 +196,12 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
* installs a menu item.
* </listitem>
* </itemizedlist>
*
*
* The toolbar may cache the result of this signal. When the tool item changes
* how it will respond to this signal it must call gtk_tool_item_rebuild_menu()
* to invalidate the cache and ensure that the toolbar rebuilds its overflow
* menu.
*
* Return value: %TRUE if the signal was handled, %FALSE if not
**/
toolitem_signals[CREATE_MENU_PROXY] =
......@@ -1004,7 +1010,8 @@ gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0, &retval);
g_signal_emit (tool_item, toolitem_signals[CREATE_MENU_PROXY], 0,
&retval);
return tool_item->priv->menu_item;
}
......@@ -1040,6 +1047,34 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
return NULL;
}
/**
* gtk_tool_item_rebuild_menu()
* @tool_item: a #GtkToolItem
*
* Calling this function signals to the toolbar that the
* overflow menu item for @tool_item has changed. If the
* overflow menu is visible when this function it called,
* the menu will be rebuilt.
*
* The function must be called when the tool item
* changes what it will do in response to the "create_menu_proxy"
* signal.
*
* Since: 2.6
**/
void
gtk_tool_item_rebuild_menu (GtkToolItem *tool_item)
{
GtkWidget *widget;
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
widget = GTK_WIDGET (tool_item);
if (widget->parent && GTK_IS_TOOLBAR (widget->parent))
_gtk_toolbar_rebuild_menu (GTK_TOOLBAR (widget->parent));
}
/**
* gtk_tool_item_set_proxy_menu_item:
* @tool_item: a #GtkToolItem:
......
......@@ -110,6 +110,7 @@ GtkWidget * gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
void gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
const gchar *menu_item_id,
GtkWidget *menu_item);
void gtk_tool_item_rebuild_menu (GtkToolItem *tool_item);
/* internal function */
void _gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment