diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-26 19:10:10 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-26 19:10:10 (EDT) |
commit | 23788c2144cd8d78a95771ce0c7122d264263e79 (patch) | |
tree | f16e8b5bd7be77cc9dc470f77b035daf3974daf6 /src | |
parent | b1387b34d0fb3baaa10e3e6e5d9d193b35749828 (diff) | |
download | marquee-23788c2144cd8d78a95771ce0c7122d264263e79.zip marquee-23788c2144cd8d78a95771ce0c7122d264263e79.tar.gz marquee-23788c2144cd8d78a95771ce0c7122d264263e79.tar.bz2 |
MqTabBody: Preserve document navigation menu items
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-body.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/tab-body.c b/src/tab-body.c index 72fa871..5010c5d 100644 --- a/src/tab-body.c +++ b/src/tab-body.c @@ -129,14 +129,16 @@ context_menu_image_cb(WebKitContextMenu *context_menu, MqTabBody *body) } static void -context_menu_document_cb(WebKitContextMenu *context_menu, MqTabBody *body) +context_menu_document_cb(WebKitContextMenu *context_menu, GList *nav_items, + MqTabBody *body) { ITEM_DECLS_NO_CUSTOM - NEW_STOCK_ITEM(GO_BACK); /* Back */ - NEW_STOCK_ITEM(GO_FORWARD); /* Forward */ - NEW_STOCK_ITEM(STOP); /* Stop */ - NEW_STOCK_ITEM(RELOAD); /* Reload */ + /* Back, Forward, Stop, Reload */ + for (; nav_items; nav_items = nav_items->next) { + webkit_context_menu_append(context_menu, nav_items->data); + g_object_unref(nav_items->data); + } NEW_SEPARATOR_ITEM(); /* --- */ NEW_STOCK_ITEM(SELECT_ALL); /* Select All */ NEW_SEPARATOR_ITEM(); /* --- */ @@ -150,6 +152,7 @@ context_menu_cb(WebKitWebView __attribute__((unused)) *web_view, WebKitHitTestResult *hit_test_result, MqTabBody *body) { GList *items; + GList *nav_items; GList *input_items; GList *spell_items; gboolean is_selection; @@ -163,6 +166,7 @@ context_menu_cb(WebKitWebView __attribute__((unused)) *web_view, * that aren't easy to reproduce (e.g. the Unicode menu and spelling * guesses). */ items = webkit_context_menu_get_items(context_menu); + nav_items = NULL; input_items = NULL; spell_items = NULL; is_selection = FALSE; @@ -173,6 +177,14 @@ context_menu_cb(WebKitWebView __attribute__((unused)) *web_view, #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch" switch (stock_action) { + case WKCMA(GO_BACK): + case WKCMA(GO_FORWARD): + case WKCMA(STOP): + case WKCMA(RELOAD): + g_object_ref(items->data); + nav_items = g_list_prepend(nav_items, + items->data); + break; case WKCMA(COPY): is_selection = TRUE; break; @@ -205,6 +217,9 @@ context_menu_cb(WebKitWebView __attribute__((unused)) *web_view, } #pragma GCC diagnostic pop } + nav_items = g_list_reverse(nav_items); + input_items = g_list_reverse(input_items); + spell_items = g_list_reverse(spell_items); webkit_context_menu_remove_all(context_menu); @@ -274,7 +289,7 @@ context_menu_cb(WebKitWebView __attribute__((unused)) *web_view, if (is_selection) { g_print(" selection"); } else { - context_menu_document_cb(context_menu, body); + context_menu_document_cb(context_menu, nav_items, body); } } g_print("\n"); |