From f0647ee95ae464b66800ced4bcaf870d254eb14e Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 26 Apr 2011 22:57:13 +0200 Subject: [PATCH] Cycle between location and paned widgets with F6 --- midori/midori-browser.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index b3264051..6aa3b3df 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2987,6 +2987,10 @@ _action_window_populate_popup (GtkAction* action, _action_by_name (browser, "TabCurrent")); gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); + menuitem = gtk_action_create_menu_item ( + _action_by_name (browser, "NextView")); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); + gtk_widget_show (menuitem); menuitem = gtk_action_create_menu_item ( _action_by_name (browser, "TabNext")); gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem); @@ -4540,6 +4544,13 @@ _action_tab_current_activate (GtkAction* action, gtk_widget_grab_focus (view); } +static void +_action_next_view_activate (GtkAction* action, + MidoriBrowser* browser) +{ + gtk_widget_grab_focus (midori_browser_get_current_tab (browser)); +} + static void _action_tab_minimize_activate (GtkAction* action, MidoriBrowser* browser) @@ -4729,6 +4740,26 @@ midori_panel_notify_position_cb (GObject* hpaned, (GSourceFunc)midori_browser_panel_timeout, hpaned, NULL); } +static gboolean +midori_panel_cycle_child_focus_cb (GtkWidget* hpaned, + gboolean reversed, + MidoriBrowser* browser) +{ + /* Default cycle goes between all GtkPaned widgets. + If focus is in the panel, focus the location as if it's a paned. + If nothing is focussed, simply go to the location. + Be sure to suppress the default because the signal can recurse. */ + GtkWidget* focus = gtk_window_get_focus (GTK_WINDOW (browser)); + if (gtk_widget_get_ancestor (focus, MIDORI_TYPE_PANEL) + || !gtk_widget_get_ancestor (focus, GTK_TYPE_PANED)) + { + g_signal_stop_emission_by_name (hpaned, "cycle-child-focus"); + gtk_action_activate (_action_by_name (browser, "Location")); + return TRUE; + } + return FALSE; +} + static void midori_panel_notify_page_cb (MidoriPanel* panel, GParamSpec* pspec, @@ -5172,6 +5203,9 @@ static const GtkActionEntry entries[] = { "TabCurrent", NULL, N_("Focus _Current Tab"), "Home", N_("Focus the current tab"), G_CALLBACK (_action_tab_current_activate) }, + { "NextView", NULL, + N_("Focus _Next view"), "F6", + N_("Cycle focus between views"), G_CALLBACK (_action_next_view_activate) }, { "TabMinimize", NULL, N_("Only show the Icon of the _Current Tab"), "", N_("Only show the icon of the current tab"), G_CALLBACK (_action_tab_minimize_activate) }, @@ -5471,6 +5505,7 @@ static const gchar* ui_markup = "" "" "" + "" "" "" "" @@ -6036,6 +6071,9 @@ midori_browser_init (MidoriBrowser* browser) g_signal_connect (hpaned, "notify::position", G_CALLBACK (midori_panel_notify_position_cb), browser); + g_signal_connect (hpaned, "cycle-child-focus", + G_CALLBACK (midori_panel_cycle_child_focus_cb), + browser); gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0); gtk_widget_show (hpaned); browser->panel = g_object_new (MIDORI_TYPE_PANEL, -- 2.39.5