Revise and unitfy behavior modulating modifier handling
We define modfifier macros that indicate whether a modifier indicates a new window, new tab, background tab or scrolling. Modifier checks in the address entry, the search entry and view now use the same consistent modifiers.
This commit is contained in:
parent
dc25035e29
commit
82cb12b605
4 changed files with 39 additions and 40 deletions
|
@ -327,7 +327,7 @@ midori_location_action_treeview_button_press_cb (GtkWidget* treeview,
|
||||||
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
|
gtk_tree_model_get (action->completion_model, &iter, URI_COL, &uri, -1);
|
||||||
gtk_entry_set_text (GTK_ENTRY (action->entry), uri);
|
gtk_entry_set_text (GTK_ENTRY (action->entry), uri);
|
||||||
g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
|
g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
|
||||||
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
|
MIDORI_MOD_NEW_TAB (event->state));
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -932,7 +932,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
|
|
||||||
if (is_enter)
|
if (is_enter)
|
||||||
g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
|
g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
|
||||||
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
|
MIDORI_MOD_NEW_TAB (event->state));
|
||||||
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -942,7 +942,7 @@ midori_location_action_key_press_event_cb (GtkEntry* entry,
|
||||||
if (is_enter)
|
if (is_enter)
|
||||||
if ((text = gtk_entry_get_text (entry)) && *text)
|
if ((text = gtk_entry_get_text (entry)) && *text)
|
||||||
g_signal_emit (action, signals[SUBMIT_URI], 0, text,
|
g_signal_emit (action, signals[SUBMIT_URI], 0, text,
|
||||||
(event->state & GDK_CONTROL_MASK) ? TRUE : FALSE);
|
MIDORI_MOD_NEW_TAB (event->state));
|
||||||
break;
|
break;
|
||||||
case GDK_Escape:
|
case GDK_Escape:
|
||||||
{
|
{
|
||||||
|
|
|
@ -357,15 +357,15 @@ midori_search_action_key_press_event_cb (GtkWidget* entry,
|
||||||
case GDK_Return:
|
case GDK_Return:
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
g_signal_emit (search_action, signals[SUBMIT], 0, text,
|
g_signal_emit (search_action, signals[SUBMIT], 0, text,
|
||||||
(event->state & GDK_MOD1_MASK) ? TRUE : FALSE);
|
MIDORI_MOD_NEW_TAB (event->state));
|
||||||
search_action->last_proxy = entry;
|
search_action->last_proxy = entry;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case GDK_Up:
|
case GDK_Up:
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (MIDORI_MOD_SCROLL (event->state))
|
||||||
_midori_search_action_move_index (search_action, - 1);
|
_midori_search_action_move_index (search_action, - 1);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case GDK_Down:
|
case GDK_Down:
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (MIDORI_MOD_SCROLL (event->state))
|
||||||
_midori_search_action_move_index (search_action, + 1);
|
_midori_search_action_move_index (search_action, + 1);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1237,47 +1237,33 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
|
||||||
case 1:
|
case 1:
|
||||||
if (!link_uri)
|
if (!link_uri)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#if HAVE_OSX
|
if (MIDORI_MOD_NEW_TAB (event->state))
|
||||||
/* FIXME: Test for Command key */
|
|
||||||
if (0)
|
|
||||||
#else
|
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Open link in new tab */
|
/* Open link in new tab */
|
||||||
background = view->open_tabs_in_the_background;
|
background = view->open_tabs_in_the_background;
|
||||||
if (event->state & GDK_SHIFT_MASK)
|
if (MIDORI_MOD_BACKGROUND (event->state))
|
||||||
background = !background;
|
background = !background;
|
||||||
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
|
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (event->state & GDK_SHIFT_MASK)
|
else if (MIDORI_MOD_NEW_WINDOW (event->state))
|
||||||
{
|
{
|
||||||
/* Open link in new window */
|
/* Open link in new window */
|
||||||
g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);
|
g_signal_emit (view, signals[NEW_WINDOW], 0, link_uri);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (event->state & GDK_MOD1_MASK)
|
|
||||||
{
|
|
||||||
/* Open link in new tab */
|
|
||||||
background = view->open_tabs_in_the_background;
|
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
|
||||||
background = !background;
|
|
||||||
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (link_uri)
|
if (link_uri)
|
||||||
{
|
{
|
||||||
/* Open link in new tab */
|
/* Open link in new tab */
|
||||||
background = view->open_tabs_in_the_background;
|
background = view->open_tabs_in_the_background;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (MIDORI_MOD_BACKGROUND (event->state))
|
||||||
background = !background;
|
background = !background;
|
||||||
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
|
g_signal_emit (view, signals[NEW_TAB], 0, link_uri, background);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (event->state & GDK_CONTROL_MASK)
|
else if (MIDORI_MOD_SCROLL (event->state))
|
||||||
{
|
{
|
||||||
midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0);
|
midori_view_set_zoom_level (MIDORI_VIEW (view), 1.0);
|
||||||
return FALSE; /* Allow Ctrl + Middle click */
|
return FALSE; /* Allow Ctrl + Middle click */
|
||||||
|
@ -1304,36 +1290,43 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view,
|
||||||
GDK_SELECTION_PRIMARY);
|
GDK_SELECTION_PRIMARY);
|
||||||
if ((uri = gtk_clipboard_wait_for_text (clipboard)))
|
if ((uri = gtk_clipboard_wait_for_text (clipboard)))
|
||||||
{
|
{
|
||||||
KatzeArray* empty_array = katze_array_new (KATZE_TYPE_ITEM);
|
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
while (uri[i++] != '\0')
|
while (uri[i++] != '\0')
|
||||||
if (uri[i] == '\n' || uri[i] == '\r')
|
if (uri[i] == '\n' || uri[i] == '\r')
|
||||||
uri[i] = ' ';
|
uri[i] = ' ';
|
||||||
new_uri = sokoke_magic_uri (g_strstrip (uri), empty_array, NULL);
|
g_strstrip (uri);
|
||||||
g_object_unref (empty_array);
|
|
||||||
if (!new_uri)
|
/* Hold Alt to search for the selected word */
|
||||||
|
if (event->state & GDK_MOD1_MASK)
|
||||||
{
|
{
|
||||||
gchar* search;
|
KatzeArray* empty_array = katze_array_new (KATZE_TYPE_ITEM);
|
||||||
g_object_get (view->settings, "location-entry-search",
|
new_uri = sokoke_magic_uri (uri, empty_array, NULL);
|
||||||
&search, NULL);
|
g_object_unref (empty_array);
|
||||||
new_uri = sokoke_search_uri (search, uri);
|
if (!new_uri)
|
||||||
|
{
|
||||||
|
gchar* search;
|
||||||
|
g_object_get (view->settings, "location-entry-search",
|
||||||
|
&search, NULL);
|
||||||
|
new_uri = sokoke_search_uri (search, uri);
|
||||||
|
}
|
||||||
|
katze_assign (uri, new_uri);
|
||||||
}
|
}
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
|
||||||
|
if (MIDORI_MOD_NEW_TAB (event->state))
|
||||||
{
|
{
|
||||||
background = view->open_tabs_in_the_background;
|
background = view->open_tabs_in_the_background;
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (MIDORI_MOD_BACKGROUND (event->state))
|
||||||
background = !background;
|
background = !background;
|
||||||
g_signal_emit (view, signals[NEW_TAB], 0, new_uri, background);
|
g_signal_emit (view, signals[NEW_TAB], 0, uri, background);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
midori_view_set_uri (MIDORI_VIEW (view), new_uri);
|
midori_view_set_uri (MIDORI_VIEW (view), uri);
|
||||||
gtk_widget_grab_focus (GTK_WIDGET (view));
|
gtk_widget_grab_focus (GTK_WIDGET (view));
|
||||||
}
|
}
|
||||||
g_free (new_uri);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if WEBKIT_CHECK_VERSION (1, 1, 15)
|
#if WEBKIT_CHECK_VERSION (1, 1, 15)
|
||||||
|
@ -1409,7 +1402,7 @@ gtk_widget_scroll_event_cb (WebKitWebView* web_view,
|
||||||
{
|
{
|
||||||
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
|
event->state = event->state & MIDORI_KEYS_MODIFIER_MASK;
|
||||||
|
|
||||||
if (event->state & GDK_CONTROL_MASK)
|
if (MIDORI_MOD_SCROLL (event->state))
|
||||||
{
|
{
|
||||||
if (event->direction == GDK_SCROLL_DOWN)
|
if (event->direction == GDK_SCROLL_DOWN)
|
||||||
midori_view_set_zoom_level (view,
|
midori_view_set_zoom_level (view,
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
#ifndef __SOKOKE_H__
|
#ifndef __SOKOKE_H__
|
||||||
#define __SOKOKE_H__ 1
|
#define __SOKOKE_H__ 1
|
||||||
|
|
||||||
|
/* Common behavior modifiers */
|
||||||
|
#define MIDORI_MOD_NEW_WINDOW(state) (state & GDK_SHIFT_MASK)
|
||||||
|
#define MIDORI_MOD_NEW_TAB(state) (state & GDK_CONTROL_MASK)
|
||||||
|
#define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK)
|
||||||
|
#define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK)
|
||||||
|
|
||||||
#include <katze/katze.h>
|
#include <katze/katze.h>
|
||||||
|
|
||||||
#include <webkit/webkit.h>
|
#include <webkit/webkit.h>
|
||||||
|
|
Loading…
Reference in a new issue