diff options
author | Søren Sandmann <sandmann@redhat.com> | 2004-09-14 21:40:41 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2004-09-14 21:40:41 +0000 |
commit | 59207896851a3bc0cb46761d1baab0f478a65edb (patch) | |
tree | 270857b34ce9e7757ca1506b5353afb6e4a5eb6a | |
parent | f67c09c994f3e4a75618fd357afeeb6a3a8b40a5 (diff) | |
download | gtk+-59207896851a3bc0cb46761d1baab0f478a65edb.tar.gz |
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.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 18 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 18 | ||||
-rw-r--r-- | gtk/gtkaction.c | 16 | ||||
-rw-r--r-- | gtk/gtktoolbar.c | 63 | ||||
-rw-r--r-- | gtk/gtktoolbar.h | 1 | ||||
-rw-r--r-- | gtk/gtktoolbutton.c | 17 | ||||
-rw-r--r-- | gtk/gtktoolitem.c | 43 | ||||
-rw-r--r-- | gtk/gtktoolitem.h | 1 |
10 files changed, 180 insertions, 33 deletions
@@ -1,3 +1,21 @@ +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 diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index a423f76592..ad5e2484f6 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +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 diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index a423f76592..ad5e2484f6 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +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 diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index a423f76592..ad5e2484f6 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +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 diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index c946f79b21..d154b9582d 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -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)) { diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index a53a24ffb1..d00dac3d62 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -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)); +} diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h index 3b005bb930..fd616ddbee 100644 --- a/gtk/gtktoolbar.h +++ b/gtk/gtktoolbar.h @@ -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, diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c index b96a3a009d..5b5eb1cc6d 100644 --- a/gtk/gtktoolbutton.c +++ b/gtk/gtktoolbutton.c @@ -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)); } diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c index 97461f36cb..b33677a990 100644 --- a/gtk/gtktoolitem.c +++ b/gtk/gtktoolitem.c @@ -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; } @@ -1041,6 +1048,34 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item, } /** + * 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: * @menu_item_id: a string used to identify @menu_item diff --git a/gtk/gtktoolitem.h b/gtk/gtktoolitem.h index f6d7950d12..1293585f6d 100644 --- a/gtk/gtktoolitem.h +++ b/gtk/gtktoolitem.h @@ -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); |