From e794fe798af5cc3eaf32bcc61446cb0257210946 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Thu, 8 Jul 2010 23:08:18 +0200 Subject: [PATCH] Implement minimize, duplicate and close other as actions This allows keyboard shortcuts to be assigned to these operations. --- midori/midori-browser.c | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index cdbe57d4..e421c540 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -4403,6 +4403,46 @@ _action_tab_current_activate (GtkAction* action, gtk_widget_grab_focus (view); } +static void +_action_tab_minimize_activate (GtkAction* action, + MidoriBrowser* browser) +{ + GtkWidget* view = midori_browser_get_current_tab (browser); + g_object_set (view, "minimized", + !katze_object_get_boolean (view, "minimized"), NULL); +} + +static void +_action_tab_duplicate_activate (GtkAction* action, + MidoriBrowser* browser) +{ + GtkWidget* view = midori_browser_get_current_tab (browser); + MidoriNewView where = MIDORI_NEW_VIEW_TAB; + GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW, + "settings", browser->settings, NULL); + midori_view_set_uri (MIDORI_VIEW (new_view), + midori_view_get_display_uri (MIDORI_VIEW (view))); + gtk_widget_show (new_view); + g_signal_emit_by_name (view, "new-view", new_view, where); +} + +static void +midori_browser_close_other_tabs_cb (GtkWidget* view, + gpointer data) +{ + GtkWidget* remaining_view = data; + if (view != remaining_view) + gtk_widget_destroy (view); +} + +static void +_action_tab_close_other_activate (GtkAction* action, + MidoriBrowser* browser) +{ + GtkWidget* view = midori_browser_get_current_tab (browser); + midori_browser_foreach (browser, midori_browser_close_other_tabs_cb, view); +} + static const gchar* credits_authors[] = { "Christian Dywan ", NULL }; static const gchar* credits_documenters[] = @@ -4960,6 +5000,15 @@ static const GtkActionEntry entries[] = { "TabCurrent", NULL, N_("Focus _Current Tab"), "Home", N_("Focus the current tab"), G_CALLBACK (_action_tab_current_activate) }, + { "TabMinimize", NULL, + N_("Minimize _Current Tab"), "", + N_("Minimize the current tab"), G_CALLBACK (_action_tab_minimize_activate) }, + { "TabDuplicate", NULL, + N_("_Duplicate Current Tab"), "", + N_("Duplicate the current tab"), G_CALLBACK (_action_tab_duplicate_activate) }, + { "TabCloseOther", NULL, + N_("Close Ot_her Tabs"), "", + N_("Close all tabs except the current tab"), G_CALLBACK (_action_tab_close_other_activate) }, { "LastSession", NULL, N_("Open last _session"), NULL, N_("Open the tabs saved in the last session"), NULL }, @@ -5238,6 +5287,9 @@ static const gchar* ui_markup = "" "" "" + "" + "" + "" "" "" "" -- 2.39.5