Implement 'Open all in Tabs' for bookmark folders and history

This commit is contained in:
Christian Dywan 2009-02-27 21:52:51 +01:00
parent da2e4755e6
commit 0ddf1bd1b2
3 changed files with 129 additions and 47 deletions

View file

@ -2434,7 +2434,7 @@ midori_browser_bookmark_popup_item (GtkWidget* menu,
if (!strcmp (stock_id, GTK_STOCK_EDIT)) if (!strcmp (stock_id, GTK_STOCK_EDIT))
gtk_widget_set_sensitive (menuitem, gtk_widget_set_sensitive (menuitem,
KATZE_IS_ARRAY (item) || uri != NULL); 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); gtk_widget_set_sensitive (menuitem, uri != NULL);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), browser); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), browser);
@ -2465,13 +2465,29 @@ midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem,
guint n; guint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); 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
{
if ((uri = katze_item_get_uri (item)) && *uri)
{ {
n = midori_browser_add_item (browser, item); n = midori_browser_add_item (browser, item);
_midori_browser_set_current_page_smartly (browser, n); _midori_browser_set_current_page_smartly (browser, n);
} }
}
} }
static void static void
@ -2532,12 +2548,21 @@ midori_browser_bookmark_popup (GtkWidget* widget,
GtkWidget* menuitem; GtkWidget* menuitem;
menu = gtk_menu_new (); menu = gtk_menu_new ();
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, midori_browser_bookmark_popup_item (menu, GTK_STOCK_OPEN, NULL,
item, midori_browser_bookmark_open_activate_cb, browser); item, midori_browser_bookmark_open_activate_cb, browser);
midori_browser_bookmark_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), midori_browser_bookmark_popup_item (menu,
STOCK_TAB_NEW, _("Open in New _Tab"),
item, midori_browser_bookmark_open_in_tab_activate_cb, browser); item, midori_browser_bookmark_open_in_tab_activate_cb, browser);
midori_browser_bookmark_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), midori_browser_bookmark_popup_item (menu,
STOCK_WINDOW_NEW, _("Open in New _Window"),
item, midori_browser_bookmark_open_in_window_activate_cb, browser); item, midori_browser_bookmark_open_in_window_activate_cb, browser);
}
menuitem = gtk_separator_menu_item_new (); menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem); gtk_widget_show (menuitem);

View file

@ -640,7 +640,7 @@ midori_bookmarks_popup_item (GtkWidget* menu,
if (!strcmp (stock_id, GTK_STOCK_EDIT)) if (!strcmp (stock_id, GTK_STOCK_EDIT))
gtk_widget_set_sensitive (menuitem, gtk_widget_set_sensitive (menuitem,
KATZE_IS_ARRAY (item) || uri != NULL); 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); gtk_widget_set_sensitive (menuitem, uri != NULL);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), bookmarks); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), bookmarks);
@ -674,9 +674,30 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem,
guint n; guint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); 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
{
if ((uri = katze_item_get_uri (item)) && *uri)
{ {
GtkWidget* browser; GtkWidget* browser;
MidoriWebSettings* settings; MidoriWebSettings* settings;
@ -687,6 +708,7 @@ midori_bookmarks_open_in_tab_activate_cb (GtkWidget* menuitem,
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (MIDORI_BROWSER (browser), n); midori_browser_set_current_page (MIDORI_BROWSER (browser), n);
} }
}
} }
static void static void
@ -749,12 +771,19 @@ midori_bookmarks_popup (GtkWidget* widget,
GtkWidget* menuitem; GtkWidget* menuitem;
menu = gtk_menu_new (); menu = gtk_menu_new ();
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, midori_bookmarks_popup_item (menu, GTK_STOCK_OPEN, NULL,
item, midori_bookmarks_open_activate_cb, bookmarks); item, midori_bookmarks_open_activate_cb, bookmarks);
midori_bookmarks_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), midori_bookmarks_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"),
item, midori_bookmarks_open_in_tab_activate_cb, bookmarks); item, midori_bookmarks_open_in_tab_activate_cb, bookmarks);
midori_bookmarks_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), midori_bookmarks_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
item, midori_bookmarks_open_in_window_activate_cb, bookmarks); item, midori_bookmarks_open_in_window_activate_cb, bookmarks);
}
menuitem = gtk_separator_menu_item_new (); menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem); gtk_widget_show (menuitem);

View file

@ -674,7 +674,7 @@ midori_history_popup_item (GtkWidget* menu,
if (!strcmp (stock_id, GTK_STOCK_EDIT)) if (!strcmp (stock_id, GTK_STOCK_EDIT))
gtk_widget_set_sensitive (menuitem, gtk_widget_set_sensitive (menuitem,
KATZE_IS_ARRAY (item) || uri != NULL); 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); gtk_widget_set_sensitive (menuitem, uri != NULL);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item); g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
g_signal_connect (menuitem, "activate", G_CALLBACK (callback), history); g_signal_connect (menuitem, "activate", G_CALLBACK (callback), history);
@ -708,9 +708,30 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
guint n; guint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (menuitem), "KatzeItem"); 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
{
if ((uri = katze_item_get_uri (item)) && *uri)
{ {
GtkWidget* browser; GtkWidget* browser;
MidoriWebSettings* settings; MidoriWebSettings* settings;
@ -721,6 +742,7 @@ midori_history_open_in_tab_activate_cb (GtkWidget* menuitem,
if (!katze_object_get_boolean (settings, "open-tabs-in-the-background")) if (!katze_object_get_boolean (settings, "open-tabs-in-the-background"))
midori_browser_set_current_page (MIDORI_BROWSER (browser), n); midori_browser_set_current_page (MIDORI_BROWSER (browser), n);
} }
}
} }
static void static void
@ -783,15 +805,21 @@ midori_history_popup (GtkWidget* widget,
GtkWidget* menuitem; GtkWidget* menuitem;
menu = gtk_menu_new (); menu = gtk_menu_new ();
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, midori_history_popup_item (menu, GTK_STOCK_OPEN, NULL,
item, midori_history_open_activate_cb, history); item, midori_history_open_activate_cb, history);
midori_history_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"), midori_history_popup_item (menu, STOCK_TAB_NEW, _("Open in New _Tab"),
item, midori_history_open_in_tab_activate_cb, history); item, midori_history_open_in_tab_activate_cb, history);
midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"), midori_history_popup_item (menu, STOCK_WINDOW_NEW, _("Open in New _Window"),
item, midori_history_open_in_window_activate_cb, history); item, midori_history_open_in_window_activate_cb, history);
if (!KATZE_IS_ARRAY (item))
midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL, midori_history_popup_item (menu, STOCK_BOOKMARK_ADD, NULL,
item, midori_history_bookmark_activate_cb, history); item, midori_history_bookmark_activate_cb, history);
}
menuitem = gtk_separator_menu_item_new (); menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem); gtk_widget_show (menuitem);