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> 2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused * 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> 2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused * 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> 2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused * 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> 2004-09-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmain.c (do_post_parse_initialization): Remove an unused * gtk/gtkmain.c (do_post_parse_initialization): Remove an unused
......
...@@ -903,6 +903,8 @@ connect_proxy (GtkAction *action, ...@@ -903,6 +903,8 @@ connect_proxy (GtkAction *action,
G_CALLBACK (gtk_action_create_menu_proxy), G_CALLBACK (gtk_action_create_menu_proxy),
action, 0); action, 0);
gtk_tool_item_rebuild_menu (GTK_TOOL_ITEM (proxy));
/* toolbar button specific synchronisers ... */ /* toolbar button specific synchronisers ... */
if (GTK_IS_TOOL_BUTTON (proxy)) if (GTK_IS_TOOL_BUTTON (proxy))
{ {
......
...@@ -1234,7 +1234,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar) ...@@ -1234,7 +1234,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
} }
/* This resize will run before the first idle handler. This /* 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 * so that the idle handler will not immediately return
* FALSE * FALSE
*/ */
...@@ -3734,6 +3734,12 @@ internal_insert_element (GtkToolbar *toolbar, ...@@ -3734,6 +3734,12 @@ internal_insert_element (GtkToolbar *toolbar,
/* /*
* ToolbarContent methods * ToolbarContent methods
*/ */
typedef enum {
UNKNOWN,
YES,
NO,
} TriState;
struct _ToolbarContent struct _ToolbarContent
{ {
ContentType type; ContentType type;
...@@ -3748,6 +3754,7 @@ struct _ToolbarContent ...@@ -3748,6 +3754,7 @@ struct _ToolbarContent
GtkAllocation goal_allocation; GtkAllocation goal_allocation;
guint is_placeholder : 1; guint is_placeholder : 1;
guint disappearing : 1; guint disappearing : 1;
TriState has_menu : 2;
} tool_item; } tool_item;
struct struct
...@@ -4237,10 +4244,13 @@ toolbar_content_set_child_visible (ToolbarContent *content, ...@@ -4237,10 +4244,13 @@ toolbar_content_set_child_visible (ToolbarContent *content,
gtk_widget_set_child_visible (child->widget, visible); gtk_widget_set_child_visible (child->widget, visible);
} }
else else
{
if (content->u.compatibility.space_visible != visible)
{ {
content->u.compatibility.space_visible = visible; content->u.compatibility.space_visible = visible;
gtk_widget_queue_draw (GTK_WIDGET (toolbar)); gtk_widget_queue_draw (GTK_WIDGET (toolbar));
} }
}
break; break;
} }
} }
...@@ -4470,11 +4480,32 @@ toolbar_content_retrieve_menu_item (ToolbarContent *content) ...@@ -4470,11 +4480,32 @@ toolbar_content_retrieve_menu_item (ToolbarContent *content)
static gboolean static gboolean
toolbar_content_has_proxy_menu_item (ToolbarContent *content) toolbar_content_has_proxy_menu_item (ToolbarContent *content)
{ {
if (content->type == TOOL_ITEM)
{
GtkWidget *menu_item; GtkWidget *menu_item;
if (content->u.tool_item.has_menu == YES)
return TRUE;
else if (content->u.tool_item.has_menu == NO)
return FALSE;
menu_item = toolbar_content_retrieve_menu_item (content); menu_item = toolbar_content_retrieve_menu_item (content);
content->u.tool_item.has_menu = menu_item? YES : NO;
return menu_item != NULL; 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 static gboolean
...@@ -4723,3 +4754,21 @@ _gtk_toolbar_elide_underscores (const gchar *original) ...@@ -4723,3 +4754,21 @@ _gtk_toolbar_elide_underscores (const gchar *original)
return result; 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, ...@@ -173,7 +173,6 @@ void _gtk_toolbar_paint_space_line (GtkWidget *widget,
gint _gtk_toolbar_get_default_space_size (void); gint _gtk_toolbar_get_default_space_size (void);
/* deprecated */ /* deprecated */
#ifndef GTK_DISABLE_DEPRECATED #ifndef GTK_DISABLE_DEPRECATED
void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, void gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
......
...@@ -262,14 +262,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) ...@@ -262,14 +262,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
GtkIconSize icon_size; GtkIconSize icon_size;
GtkWidget *box = NULL; 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) if (button->priv->icon_widget && 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),
...@@ -305,11 +297,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) ...@@ -305,11 +297,6 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
need_label = TRUE; 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 (need_label)
{ {
if (button->priv->label_widget) if (button->priv->label_widget)
...@@ -407,6 +394,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item) ...@@ -407,6 +394,8 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
gtk_button_set_relief (GTK_BUTTON (button->priv->button), gtk_button_set_relief (GTK_BUTTON (button->priv->button),
gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (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)); gtk_widget_queue_resize (GTK_WIDGET (button));
} }
......
...@@ -179,8 +179,9 @@ gtk_tool_item_class_init (GtkToolItemClass *klass) ...@@ -179,8 +179,9 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
* GtkToolItem::create-menu-proxy: * GtkToolItem::create-menu-proxy:
* @toolitem: the object the signal was emitted on * @toolitem: the object the signal was emitted on
* *
* This signal is emitted when the toolbar is displaying an overflow menu. * This signal is emitted when the toolbar needs information from @tool_item
* In response the tool item should either * about whether the item should appear in the toolbar overflow menu. In
* response the tool item should either
* <itemizedlist> * <itemizedlist>
* <listitem> call gtk_tool_item_set_proxy_menu_item() with a %NULL * <listitem> call gtk_tool_item_set_proxy_menu_item() with a %NULL
* pointer and return %TRUE to indicate that the item should not appear * pointer and return %TRUE to indicate that the item should not appear
...@@ -196,6 +197,11 @@ gtk_tool_item_class_init (GtkToolItemClass *klass) ...@@ -196,6 +197,11 @@ gtk_tool_item_class_init (GtkToolItemClass *klass)
* </listitem> * </listitem>
* </itemizedlist> * </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 * Return value: %TRUE if the signal was handled, %FALSE if not
**/ **/
toolitem_signals[CREATE_MENU_PROXY] = toolitem_signals[CREATE_MENU_PROXY] =
...@@ -1004,7 +1010,8 @@ gtk_tool_item_retrieve_proxy_menu_item (GtkToolItem *tool_item) ...@@ -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_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; return tool_item->priv->menu_item;
} }
...@@ -1040,6 +1047,34 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item, ...@@ -1040,6 +1047,34 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
return NULL; 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: * gtk_tool_item_set_proxy_menu_item:
* @tool_item: a #GtkToolItem: * @tool_item: a #GtkToolItem:
......
...@@ -110,6 +110,7 @@ GtkWidget * gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item, ...@@ -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, void gtk_tool_item_set_proxy_menu_item (GtkToolItem *tool_item,
const gchar *menu_item_id, const gchar *menu_item_id,
GtkWidget *menu_item); GtkWidget *menu_item);
void gtk_tool_item_rebuild_menu (GtkToolItem *tool_item);
/* internal function */ /* internal function */
void _gtk_tool_item_toolbar_reconfigured (GtkToolItem *tool_item); 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