From 0ddf1bd1b2a190c627a5ceea342375293d952284 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 27 Feb 2009 21:52:51 +0100 Subject: [PATCH] Implement 'Open all in Tabs' for bookmark folders and history --- midori/midori-browser.c | 47 +++++++++++++++++++++------- panels/midori-bookmarks.c | 63 +++++++++++++++++++++++++++----------- panels/midori-history.c | 64 ++++++++++++++++++++++++++++----------- 3 files changed, 128 insertions(+), 46 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 2f68ef07..d078db7f 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2434,7 +2434,7 @@ midori_browser_bookmark_popup_item (GtkWidget* menu, if (!strcmp (stock_id, GTK_STOCK_EDIT)) gtk_widget_set_sensitive (menuitem, KATZE_IS_ARRAY (item) || uri != NULL); - else if (strcmp (stock_id, GTK_STOCK_DELETE)) + else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE)) gtk_widget_set_sensitive (menuitem, uri != NULL); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), browser); @@ -2465,12 +2465,28 @@ midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem, guint n; item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); - uri = katze_item_get_uri (item); + if (KATZE_IS_ARRAY (item)) + { + KatzeItem* child; + guint i = 0; - if (uri && *uri) + while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i))) + { + if ((uri = katze_item_get_uri (child)) && *uri) + { + n = midori_browser_add_item (browser, child); + _midori_browser_set_current_page_smartly (browser, n); + } + i++; + } + } + else { - n = midori_browser_add_item (browser, item); - _midori_browser_set_current_page_smartly (browser, n); + if ((uri = katze_item_get_uri (item)) && *uri) + { + n = midori_browser_add_item (browser, item); + _midori_browser_set_current_page_smartly (browser, n); + } } } @@ -2532,12 +2548,21 @@ midori_browser_bookmark_popup (GtkWidget* widget, GtkWidget* menuitem; menu = gtk_menu_new (); - midori_browser_bookmark_popup_item (menu, GTK_STOCK_OPEN, NULL, - item, midori_browser_bookmark_open_activate_cb, browser); - midori_browser_bookmark_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), - item, midori_browser_bookmark_open_in_tab_activate_cb, browser); - midori_browser_bookmark_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), - item, midori_browser_bookmark_open_in_window_activate_cb, browser); + if (KATZE_IS_ARRAY (item)) + midori_browser_bookmark_popup_item (menu, + STOCK_TAB_NEW, _("Open all in _Tabs"), + item, midori_browser_bookmark_open_in_tab_activate_cb, browser); + else + { + midori_browser_bookmark_popup_item (menu, GTK_STOCK_OPEN, NULL, + item, midori_browser_bookmark_open_activate_cb, browser); + midori_browser_bookmark_popup_item (menu, + STOCK_TAB_NEW, _("Open in New _Tab"), + item, midori_browser_bookmark_open_in_tab_activate_cb, browser); + midori_browser_bookmark_popup_item (menu, + STOCK_WINDOW_NEW, _("Open in New _Window"), + item, midori_browser_bookmark_open_in_window_activate_cb, browser); + } menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); diff --git a/panels/midori-bookmarks.c b/panels/midori-bookmarks.c index 9526a2d3..d4150077 100644 --- a/panels/midori-bookmarks.c +++ b/panels/midori-bookmarks.c @@ -640,7 +640,7 @@ midori_bookmarks_popup_item (GtkWidget* menu, if (!strcmp (stock_id, GTK_STOCK_EDIT)) gtk_widget_set_sensitive (menuitem, KATZE_IS_ARRAY (item) || uri != NULL); - else if (strcmp (stock_id, GTK_STOCK_DELETE)) + else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE)) gtk_widget_set_sensitive (menuitem, uri != NULL); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), bookmarks); @@ -674,18 +674,40 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem, guint n; item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); - uri = katze_item_get_uri (item); + if (KATZE_IS_ARRAY (item)) + { + KatzeItem* child; + guint i = 0; - if (uri && *uri) + while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i))) + { + if ((uri = katze_item_get_uri (child)) && *uri) + { + GtkWidget* browser; + MidoriWebSettings* settings; + + browser = gtk_widget_get_toplevel (GTK_WIDGET (bookmarks)); + n = midori_browser_add_item (MIDORI_BROWSER (browser), child); + settings = katze_object_get_object (browser, "settings"); + if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) + midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + } + i++; + } + } + else { - GtkWidget* browser; - MidoriWebSettings* settings; - - browser = gtk_widget_get_toplevel (GTK_WIDGET (bookmarks)); - n = midori_browser_add_item (MIDORI_BROWSER (browser), item); - settings = katze_object_get_object (browser, "settings"); - if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) - midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + if ((uri = katze_item_get_uri (item)) && *uri) + { + GtkWidget* browser; + MidoriWebSettings* settings; + + browser = gtk_widget_get_toplevel (GTK_WIDGET (bookmarks)); + n = midori_browser_add_item (MIDORI_BROWSER (browser), item); + settings = katze_object_get_object (browser, "settings"); + if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) + midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + } } } @@ -749,12 +771,19 @@ midori_bookmarks_popup (GtkWidget* widget, GtkWidget* menuitem; menu = gtk_menu_new (); - midori_bookmarks_popup_item (menu, GTK_STOCK_OPEN, NULL, - item, midori_bookmarks_open_activate_cb, bookmarks); - midori_bookmarks_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), - item, midori_bookmarks_open_in_tab_activate_cb, bookmarks); - midori_bookmarks_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), - item, midori_bookmarks_open_in_window_activate_cb, bookmarks); + if (KATZE_IS_ARRAY (item)) + midori_bookmarks_popup_item (menu, + STOCK_TAB_NEW, _("Open all in _Tabs"), + item, midori_bookmarks_open_in_tab_activate_cb, bookmarks); + else + { + midori_bookmarks_popup_item (menu, GTK_STOCK_OPEN, NULL, + item, midori_bookmarks_open_activate_cb, bookmarks); + midori_bookmarks_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), + item, midori_bookmarks_open_in_tab_activate_cb, bookmarks); + midori_bookmarks_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), + item, midori_bookmarks_open_in_window_activate_cb, bookmarks); + } menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); diff --git a/panels/midori-history.c b/panels/midori-history.c index ca52924e..3ef50bba 100644 --- a/panels/midori-history.c +++ b/panels/midori-history.c @@ -674,7 +674,7 @@ midori_history_popup_item (GtkWidget* menu, if (!strcmp (stock_id, GTK_STOCK_EDIT)) gtk_widget_set_sensitive (menuitem, KATZE_IS_ARRAY (item) || uri != NULL); - else if (strcmp (stock_id, GTK_STOCK_DELETE)) + else if (!KATZE_IS_ARRAY (item) && strcmp (stock_id, GTK_STOCK_DELETE)) gtk_widget_set_sensitive (menuitem, uri != NULL); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), history); @@ -708,18 +708,40 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem, guint n; item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); - uri = katze_item_get_uri (item); + if (KATZE_IS_ARRAY (item)) + { + KatzeItem* child; + guint i = 0; - if (uri && *uri) + while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i))) + { + if ((uri = katze_item_get_uri (child)) && *uri) + { + GtkWidget* browser; + MidoriWebSettings* settings; + + browser = gtk_widget_get_toplevel (GTK_WIDGET (history)); + n = midori_browser_add_item (MIDORI_BROWSER (browser), child); + settings = katze_object_get_object (browser, "settings"); + if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) + midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + } + i++; + } + } + else { - GtkWidget* browser; - MidoriWebSettings* settings; - - browser = gtk_widget_get_toplevel (GTK_WIDGET (history)); - n = midori_browser_add_item (MIDORI_BROWSER (browser), item); - settings = katze_object_get_object (browser, "settings"); - if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) - midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + if ((uri = katze_item_get_uri (item)) && *uri) + { + GtkWidget* browser; + MidoriWebSettings* settings; + + browser = gtk_widget_get_toplevel (GTK_WIDGET (history)); + n = midori_browser_add_item (MIDORI_BROWSER (browser), item); + settings = katze_object_get_object (browser, "settings"); + if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) + midori_browser_set_current_page (MIDORI_BROWSER (browser), n); + } } } @@ -783,15 +805,21 @@ midori_history_popup (GtkWidget* widget, GtkWidget* menuitem; menu = gtk_menu_new (); - midori_history_popup_item (menu, GTK_STOCK_OPEN, NULL, - item, midori_history_open_activate_cb, history); - midori_history_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), - item, midori_history_open_in_tab_activate_cb, history); - midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), - item, midori_history_open_in_window_activate_cb, history); - if (!KATZE_IS_ARRAY (item)) + if (KATZE_IS_ARRAY (item)) + midori_history_popup_item (menu, + STOCK_TAB_NEW, _("Open all in _Tabs"), + item, midori_history_open_in_tab_activate_cb, history); + else + { + midori_history_popup_item (menu, GTK_STOCK_OPEN, NULL, + item, midori_history_open_activate_cb, history); + midori_history_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), + item, midori_history_open_in_tab_activate_cb, history); + midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), + item, midori_history_open_in_window_activate_cb, history); midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL, item, midori_history_bookmark_activate_cb, history); + } menuitem = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); -- 2.39.5