diff options
Diffstat (limited to 'libowl/owlwindowmenu.c')
-rw-r--r-- | libowl/owlwindowmenu.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libowl/owlwindowmenu.c b/libowl/owlwindowmenu.c index 4f6b2d7..a00e09e 100644 --- a/libowl/owlwindowmenu.c +++ b/libowl/owlwindowmenu.c @@ -71,6 +71,15 @@ position_func (GtkMenu *menu, */ gdk_window_get_origin (window->window, x, y); + + /* Maemo does this which I believe is a theme extension + gtk_widget_style_get (GTK_WIDGET (menu), + "horizontal-offset", x, + "vertical-offset", y, + NULL); + *x += window_x; + *y += window_y; + */ } /* @@ -167,3 +176,38 @@ owl_set_window_menu (GtkWindow *window, GtkMenu *menu) /* Add a filter so that we can catch the CUSTOM event and display the menu. */ gdk_window_add_filter (w, filter_func, window); } + +/** + * owl_set_window_menu_item: + * @window: a top-level #GtkWindow + * @menuitem: a #GtkMenuItem + * + * Make the submenu in @menuitem pop up when the CUSTOM protocol is sent to + * @window. This means that when the user clicks on the title bar with a + * suitable window manager, the menu appears. + * + * This is a convenience function for applications which use GtkUIManager to + * construct their menus. + */ +void +owl_set_window_menu_item (GtkWindow *window, GtkMenuItem *menuitem) +{ + GtkWidget *menu; + + g_return_if_fail (GTK_IS_WINDOW (window)); + /* TODO: allow NULL menu to unset? */ + g_return_if_fail (GTK_IS_MENU_ITEM (menuitem)); + + menu = gtk_menu_item_get_submenu (menuitem); + if (!menu) { + g_warning ("%s: GtkMenuItem doesn't have a submenu", G_STRFUNC); + return; + } + + g_object_ref (menu); + + gtk_menu_item_remove_submenu (menuitem); + owl_set_window_menu (window, GTK_MENU (menu)); + + g_object_unref (menu); +} |