From f764f25747607ced59403a8da7ef9029d5bbf9a4 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 19 Jul 2010 21:39:57 +0200 Subject: [PATCH] Implement activate-item(-alt) for bookmarkbar mouse buttons --- midori/midori-browser.c | 50 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 16f25e24..a9359d00 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2651,6 +2651,30 @@ midori_browser_menu_item_deselect_cb (GtkWidget* menuitem, _midori_browser_set_statusbar_text (browser, NULL); } +static void +midori_bookmarkbar_activate_item (GtkAction* action, + KatzeItem* item, + MidoriBrowser* browser) +{ + midori_browser_set_current_uri (browser, katze_item_get_uri (item)); +} + +static gboolean +midori_bookmarkbar_activate_item_alt (GtkAction* action, + KatzeItem* item, + guint button, + MidoriBrowser* browser) +{ + if (button == 2) + { + gint n = midori_browser_add_uri (browser, katze_item_get_uri (item)); + midori_browser_set_current_page_smartly (browser, n); + return TRUE; + } + + return FALSE; +} + static void _action_trash_populate_popup (GtkAction* action, GtkMenu* menu, @@ -2697,15 +2721,10 @@ _action_trash_activate_item_alt (GtkAction* action, { if (button == 2) { - gint n; - - n = midori_browser_add_uri (browser, katze_item_get_uri (item)); - + gint n = midori_browser_add_uri (browser, katze_item_get_uri (item)); midori_browser_set_current_page_smartly (browser, n); - katze_array_remove_item (browser->trash, item); _midori_browser_update_actions (browser); - return TRUE; } @@ -5668,6 +5687,10 @@ midori_browser_init (MidoriBrowser* browser) g_object_connect (action, "signal::populate-popup", _action_tools_populate_popup, browser, + "signal::activate-item", + midori_bookmarkbar_activate_item, browser, + "signal::activate-item-alt", + midori_bookmarkbar_activate_item_alt, browser, NULL); gtk_action_group_add_action (browser->action_group, action); g_object_unref (action); @@ -6284,17 +6307,12 @@ midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem, item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem"); if (event->button == 2) { - if (katze_item_get_uri (item)) + if (KATZE_ITEM_IS_BOOKMARK (item)) { n = midori_browser_add_uri (browser, katze_item_get_uri (item)); midori_browser_set_current_page_smartly (browser, n); - return TRUE; } - else - { - /* FIXME: This is a folder and we need to popup a menu */ - } } else if (event->button == 3) { @@ -6308,12 +6326,10 @@ static void midori_bookmarkbar_insert_item (GtkWidget* toolbar, KatzeItem* item) { - GtkToolItem* toolitem; - MidoriBrowser* browser = midori_browser_get_for_widget (toolbar); - - toolitem = katze_array_action_create_tool_item_for ( - KATZE_ARRAY_ACTION (_action_by_name (browser, "Tools")), item); + GtkAction* action = _action_by_name (browser, "Tools"); + GtkToolItem* toolitem = katze_array_action_create_tool_item_for ( + KATZE_ARRAY_ACTION (action), item); g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item); if (KATZE_IS_ITEM (item)) -- 2.39.5