From 6946d04adcc2861908485dd669e6b6375b4e5982 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 14 Feb 2015 19:21:43 +0100 Subject: properly handle MenuShell's insert signal with position = -1 --- module/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/module/main.c b/module/main.c index 2df60b2..e85ac3e 100644 --- a/module/main.c +++ b/module/main.c @@ -244,7 +244,15 @@ handle_shell_insert (GtkMenuShell *menu_shell, GtkWidget *child, gint position, gint offset = compute_shell_position_in_appmenu (window_data, menu_shell); g_return_if_fail (offset >= 0); - add_menu_item_to_appmenu (window_data, item, offset + position); + if (position < 0) { + // Gtk internally handles position=-1 as "append". + // So we add this item after all the other items from this shell + gint n_items = count_container_items (GTK_CONTAINER (menu_shell)) - 1; + // -1 because count_container_items will count the item we're just adding + add_menu_item_to_appmenu (window_data, item, offset + n_items); + } else { + add_menu_item_to_appmenu (window_data, item, offset + position); + } } static void -- cgit v1.2.3