Alt + Enter in the location should issue a new tab

This commit is contained in:
Dale Whittaker 2008-08-31 03:21:29 +02:00 committed by Christian Dywan
parent d60190aaee
commit 8025d129a1
2 changed files with 51 additions and 5 deletions

View file

@ -2030,10 +2030,12 @@ _action_location_reset_uri (GtkAction* action,
static void static void
_action_location_submit_uri (GtkAction* action, _action_location_submit_uri (GtkAction* action,
const gchar* uri, const gchar* uri,
gboolean new_tab,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
gchar* location_entry_search; gchar* location_entry_search;
gchar* new_uri; gchar* new_uri;
gint n;
g_object_get (browser->settings, "location-entry-search", g_object_get (browser->settings, "location-entry-search",
&location_entry_search, NULL); &location_entry_search, NULL);
@ -2043,7 +2045,13 @@ _action_location_submit_uri (GtkAction* action,
else if (!new_uri) else if (!new_uri)
new_uri = g_strdup (location_entry_search); new_uri = g_strdup (location_entry_search);
g_free (location_entry_search); g_free (location_entry_search);
_midori_browser_open_uri (browser, new_uri); if (new_tab)
{
n = midori_browser_add_uri (browser, new_uri);
midori_browser_set_current_page (browser, n);
}
else
_midori_browser_open_uri (browser, new_uri);
g_free (new_uri); g_free (new_uri);
gtk_widget_grab_focus (midori_browser_get_current_tab (browser)); gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
} }

View file

@ -76,6 +76,42 @@ static void
midori_location_action_disconnect_proxy (GtkAction* action, midori_location_action_disconnect_proxy (GtkAction* action,
GtkWidget* proxy); GtkWidget* proxy);
static void
midori_cclosure_marshal_VOID__STRING_BOOLEAN (GClosure* closure,
GValue* return_value,
guint n_param_values,
const GValue* param_values,
gpointer invocation_hint,
gpointer marshal_data)
{
typedef void(*GMarshalFunc_VOID__STRING_BOOLEAN) (gpointer data1,
const gchar* arg_1,
gboolean arg_2,
gpointer data2);
register GMarshalFunc_VOID__STRING_BOOLEAN callback;
register GCClosure* cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3);
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__STRING_BOOLEAN) (marshal_data
? marshal_data : cc->callback);
callback (data1,
g_value_get_string (param_values + 1),
g_value_get_boolean (param_values + 2),
data2);
}
static void static void
midori_location_action_class_init (MidoriLocationActionClass* class) midori_location_action_class_init (MidoriLocationActionClass* class)
{ {
@ -126,9 +162,10 @@ midori_location_action_class_init (MidoriLocationActionClass* class)
0, 0,
0, 0,
NULL, NULL,
g_cclosure_marshal_VOID__STRING, midori_cclosure_marshal_VOID__STRING_BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_NONE, 2,
G_TYPE_STRING); G_TYPE_STRING,
G_TYPE_BOOLEAN);
gobject_class = G_OBJECT_CLASS (class); gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = midori_location_action_finalize; gobject_class->finalize = midori_location_action_finalize;
@ -285,7 +322,8 @@ midori_location_action_key_press_event_cb (GtkWidget* widget,
{ {
if ((uri = gtk_entry_get_text (GTK_ENTRY (widget)))) if ((uri = gtk_entry_get_text (GTK_ENTRY (widget))))
{ {
g_signal_emit (action, signals[SUBMIT_URI], 0, uri); g_signal_emit (action, signals[SUBMIT_URI], 0, uri,
(event->state & GDK_MOD1_MASK) ? TRUE : FALSE);
return TRUE; return TRUE;
} }
} }