summaryrefslogtreecommitdiff
path: root/gtk/gtktoolbar.c
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2004-09-14 21:40:41 +0000
committerSøren Sandmann Pedersen <ssp@src.gnome.org>2004-09-14 21:40:41 +0000
commit59207896851a3bc0cb46761d1baab0f478a65edb (patch)
tree270857b34ce9e7757ca1506b5353afb6e4a5eb6a /gtk/gtktoolbar.c
parentf67c09c994f3e4a75618fd357afeeb6a3a8b40a5 (diff)
downloadgtk+-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.
Diffstat (limited to 'gtk/gtktoolbar.c')
-rw-r--r--gtk/gtktoolbar.c63
1 files changed, 56 insertions, 7 deletions
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));
+}