Reverse Open tabs in the background with Ctrl

This commit is contained in:
Christian Dywan 2008-07-16 18:08:47 +02:00
parent 7f0da8ac84
commit 05426deadb
2 changed files with 67 additions and 53 deletions

View file

@ -335,10 +335,8 @@ static void
_midori_browser_set_current_page_smartly (MidoriBrowser* browser, _midori_browser_set_current_page_smartly (MidoriBrowser* browser,
gint n) gint n)
{ {
gboolean open_tabs_in_the_background; if (!sokoke_object_get_boolean (browser->settings,
g_object_get (browser->settings, "open-tabs-in-the-background", "open-tabs-in-the-background"))
&open_tabs_in_the_background, NULL);
if (!open_tabs_in_the_background)
midori_browser_set_current_page (browser, n); midori_browser_set_current_page (browser, n);
} }
@ -483,6 +481,69 @@ midori_web_view_console_message_cb (GtkWidget* web_view,
return TRUE; return TRUE;
} }
static gboolean
midori_web_view_button_press_event_cb (MidoriWebView* web_view,
GdkEventButton* event,
MidoriBrowser* browser)
{
GdkModifierType state = (GdkModifierType)0;
gint x, y;
const gchar* link_uri;
guint n;
gboolean background;
gdk_window_get_pointer (NULL, &x, &y, &state);
link_uri = midori_web_view_get_link_uri (web_view);
switch (event->button)
{
case 1:
if (!link_uri)
return FALSE;
if (state & GDK_SHIFT_MASK)
{
/* Open link in new window */
g_signal_emit (browser, signals[NEW_WINDOW], 0, link_uri);
return TRUE;
}
else if (state & GDK_MOD1_MASK)
{
/* Open link in new tab */
n = midori_browser_add_uri (browser, link_uri);
background = sokoke_object_get_boolean (browser->settings,
"open-tabs-in-the-background");
if (state & GDK_CONTROL_MASK)
background = !background;
if (!background)
midori_browser_set_current_page (browser, n);
return TRUE;
}
break;
case 2:
if (link_uri)
{
/* Open link in new tab */
n = midori_browser_add_uri (browser, link_uri);
background = sokoke_object_get_boolean (browser->settings,
"open-tabs-in-the-background");
if (state & GDK_CONTROL_MASK)
background = !background;
if (!background)
midori_browser_set_current_page (browser, n);
return TRUE;
}
else if (state & GDK_CONTROL_MASK)
{
webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (web_view), 1.0);
return FALSE; /* Allow Ctrl + Middle click */
}
break;
case 3:
return FALSE;
}
return FALSE;
}
static void static void
midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser, midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
KatzeXbelItem* bookmark) KatzeXbelItem* bookmark)
@ -869,6 +930,8 @@ _midori_browser_add_tab (MidoriBrowser* browser,
midori_web_view_new_tab_cb, browser, midori_web_view_new_tab_cb, browser,
"signal::new-window", "signal::new-window",
midori_web_view_new_window_cb, browser, midori_web_view_new_window_cb, browser,
"signal::button-press-event",
midori_web_view_button_press_event_cb, browser,
"signal::populate-popup", "signal::populate-popup",
midori_web_view_populate_popup_cb, browser, midori_web_view_populate_popup_cb, browser,
NULL); NULL);

View file

@ -327,52 +327,6 @@ webkit_web_view_hovering_over_link (MidoriWebView* web_view,
g_signal_emit (web_view, signals[ELEMENT_MOTION], 0, link_uri); g_signal_emit (web_view, signals[ELEMENT_MOTION], 0, link_uri);
} }
static gboolean
gtk_widget_button_press_event (MidoriWebView* web_view,
GdkEventButton* event)
{
GdkModifierType state = (GdkModifierType)0;
gint x, y;
gdk_window_get_pointer (NULL, &x, &y, &state);
switch (event->button)
{
case 1:
if (!web_view->link_uri)
return FALSE;
if (state & GDK_SHIFT_MASK)
{
/* Open link in new window */
g_signal_emit (web_view, signals[NEW_WINDOW], 0, web_view->link_uri);
return TRUE;
}
else if(state & GDK_MOD1_MASK)
{
/* Open link in new tab */
g_signal_emit (web_view, signals[NEW_TAB], 0, web_view->link_uri);
return TRUE;
}
break;
case 2:
if (state & GDK_CONTROL_MASK)
{
webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (web_view), 1.0);
return FALSE; /* Allow Ctrl + Middle click */
}
else
{
if (!web_view->link_uri)
return FALSE;
/* Open link in new tab */
g_signal_emit (web_view, signals[NEW_TAB], 0, web_view->link_uri);
return TRUE;
}
break;
case 3:
return FALSE;
}
return FALSE;
}
static gboolean static gboolean
gtk_widget_button_press_event_after (MidoriWebView* web_view, gtk_widget_button_press_event_after (MidoriWebView* web_view,
GdkEventButton* event) GdkEventButton* event)
@ -392,7 +346,6 @@ gtk_widget_button_press_event_after (MidoriWebView* web_view,
uri = gtk_clipboard_wait_for_text (clipboard); uri = gtk_clipboard_wait_for_text (clipboard);
if (uri && strchr (uri, '.') && !strchr (uri, ' ')) if (uri && strchr (uri, '.') && !strchr (uri, ' '))
{ {
g_print ("gtk_widget_button_press_event_after, sokoke_magic_uri\n");
new_uri = sokoke_magic_uri (uri, NULL); new_uri = sokoke_magic_uri (uri, NULL);
if (state & GDK_CONTROL_MASK) if (state & GDK_CONTROL_MASK)
g_signal_emit (web_view, signals[NEW_TAB], 0, new_uri); g_signal_emit (web_view, signals[NEW_TAB], 0, new_uri);
@ -552,8 +505,6 @@ midori_web_view_init (MidoriWebView* web_view)
"signal::hovering-over-link", "signal::hovering-over-link",
webkit_web_view_hovering_over_link, NULL, webkit_web_view_hovering_over_link, NULL,
"signal::button-press-event", "signal::button-press-event",
gtk_widget_button_press_event, NULL,
"signal_after::button-press-event",
gtk_widget_button_press_event_after, NULL, gtk_widget_button_press_event_after, NULL,
"signal::button-release-event", "signal::button-release-event",
gtk_widget_button_release_event, NULL, gtk_widget_button_release_event, NULL,