diff options
author | Morten Welinder <terra@gnome.org> | 2004-02-06 21:18:50 +0000 |
---|---|---|
committer | Morten Welinder <mortenw@src.gnome.org> | 2004-02-06 21:18:50 +0000 |
commit | 95ba48b38f92075f74d59f4e0ace33bd0d7ec8cf (patch) | |
tree | 902b4aaba3356b2b9212a0753e8bcb3005cf8549 /gtk/gtktoolbar.c | |
parent | d8b6a89a12a82191a6a22bdf426d2b68065d2111 (diff) | |
download | gdk-pixbuf-95ba48b38f92075f74d59f4e0ace33bd0d7ec8cf.tar.gz |
Cleanup using gtk_menu_attach_to_widget. Also fixes leak, see #133411.
2004-02-06 Morten Welinder <terra@gnome.org>
* gtk/gtktoolbar.c (show_menu): Cleanup using
gtk_menu_attach_to_widget. Also fixes leak, see #133411.
Diffstat (limited to 'gtk/gtktoolbar.c')
-rw-r--r-- | gtk/gtktoolbar.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 9a4a337c9..efc15367e 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -2422,11 +2422,18 @@ menu_deactivated (GtkWidget *menu, GtkToolbar *toolbar) { GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->arrow_button), FALSE); } static void +menu_detached (GtkWidget *toolbar, + GtkMenu *menu) +{ + GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar); + priv->menu = NULL; +} + +static void remove_item (GtkWidget *menu_item, gpointer data) { @@ -2445,10 +2452,13 @@ show_menu (GtkToolbar *toolbar, gtk_container_foreach (GTK_CONTAINER (priv->menu), remove_item, NULL); gtk_widget_destroy (GTK_WIDGET (priv->menu)); } - + priv->menu = GTK_MENU (gtk_menu_new ()); + gtk_menu_attach_to_widget (priv->menu, + GTK_WIDGET (toolbar), + menu_detached); g_signal_connect (priv->menu, "deactivate", G_CALLBACK (menu_deactivated), toolbar); - + for (list = priv->content; list != NULL; list = list->next) { ToolbarContent *content = list->data; @@ -2466,8 +2476,6 @@ show_menu (GtkToolbar *toolbar, } } - gtk_window_set_screen (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (priv->menu))), - gtk_widget_get_screen (GTK_WIDGET (toolbar))); gtk_widget_show_all (GTK_WIDGET (priv->menu)); gtk_menu_popup (priv->menu, NULL, NULL, |