]> spindle.queued.net Git - midori/commitdiff
Open new tabs by double or middle clicking on the tabbar
authorNick Schermer <nick@xfce.org>
Tue, 13 Jan 2009 19:50:17 +0000 (20:50 +0100)
committerChristian Dywan <christian@twotoasts.de>
Tue, 13 Jan 2009 19:50:17 +0000 (20:50 +0100)
midori/midori-browser.c

index 8d9bbf15c2662aee1f46c1ec1f34533995f49631..37f7413b9a47dd5b40af67748cf0ac829a52d1aa 100644 (file)
@@ -2998,6 +2998,24 @@ gtk_notebook_switch_page_cb (GtkWidget*       notebook,
     _midori_browser_update_progress (browser, MIDORI_VIEW (view));
 }
 
+static gboolean
+gtk_notebook_button_press_event_cb (GtkNotebook*    notebook,
+                                    GdkEventButton* event,
+                                    MidoriBrowser*  browser)
+{
+    /* Open a new tab on double click or middle mouse click */
+    if (event->window == notebook->event_window
+        && ((event->type == GDK_2BUTTON_PRESS && event->button == 1)
+        || (event->type == GDK_BUTTON_PRESS && event->button == 2)))
+    {
+       gtk_action_activate (_action_by_name (browser, "TabNew"));
+
+       return TRUE;
+    }
+
+    return FALSE;
+}
+
 static void
 _action_history_delete_activate (GtkAction*     action,
                                  MidoriBrowser* browser)
@@ -4020,6 +4038,9 @@ midori_browser_init (MidoriBrowser* browser)
     g_signal_connect_after (browser->notebook, "switch-page",
                             G_CALLBACK (gtk_notebook_switch_page_cb),
                             browser);
+    g_signal_connect (browser->notebook, "button-press-event",
+                      G_CALLBACK (gtk_notebook_button_press_event_cb),
+                      browser);
     gtk_widget_show (browser->notebook);
 
     /* Inspector container */