diff options
author | Javier <dev.git@javispedro.com> | 2015-02-14 19:21:43 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2015-02-14 19:21:43 +0100 |
commit | 6946d04adcc2861908485dd669e6b6375b4e5982 (patch) | |
tree | 7f74b4fc6341a271c62dee261436b04e0ebf804c | |
parent | 1779190286a37b0e414ecc4a17ecb69994ee6005 (diff) | |
download | topmenu-gtk-6946d04adcc2861908485dd669e6b6375b4e5982.tar.gz topmenu-gtk-6946d04adcc2861908485dd669e6b6375b4e5982.zip |
properly handle MenuShell's insert signal with position = -1
-rw-r--r-- | module/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
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 |