From e27caf137470363f5d229d00b360aeab58ddd4f6 Mon Sep 17 00:00:00 2001 From: Jerome Marty Date: Tue, 25 Jan 2011 21:48:09 +0100 Subject: [PATCH 2/2] Add support to move tabs with menu entries and keyboard shortcuts --- terminal/terminal-preferences.c | 24 +++++++++++++++++++++++ terminal/terminal-window.c | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 0 deletions(-) diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c index 466bb08..d6fc5da 100644 --- a/terminal/terminal-preferences.c +++ b/terminal/terminal-preferences.c @@ -60,6 +60,8 @@ enum PROP_ACCEL_RESET_AND_CLEAR, PROP_ACCEL_PREV_TAB, PROP_ACCEL_NEXT_TAB, + PROP_ACCEL_TAB_MOVE_LEFT, + PROP_ACCEL_TAB_MOVE_RIGHT, PROP_ACCEL_SWITCH_TO_TAB1, PROP_ACCEL_SWITCH_TO_TAB2, PROP_ACCEL_SWITCH_TO_TAB3, @@ -514,6 +516,28 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass) EXO_PARAM_READWRITE)); /** + * TerminalPreferences:accel-tab-move-left: + **/ + g_object_class_install_property (gobject_class, + PROP_ACCEL_TAB_MOVE_LEFT, + g_param_spec_string ("accel-tab-move-left", + _("Move Tab Left"), + "AccelTabMoveLeft", + "Page_Up", + EXO_PARAM_READWRITE)); + + /** + * TerminalPreferences:accel-tab-move-right: + **/ + g_object_class_install_property (gobject_class, + PROP_ACCEL_TAB_MOVE_RIGHT, + g_param_spec_string ("accel-tab-move-right", + _("Move Tab Right"), + "AccelTabMoveRight", + "Page_Down", + EXO_PARAM_READWRITE)); + + /** * TerminalPreferences:accel-switch-to-tab1: **/ g_object_class_install_property (gobject_class, diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c index 7a95f43..381256a 100644 --- a/terminal/terminal-window.c +++ b/terminal/terminal-window.c @@ -170,6 +170,10 @@ static void terminal_window_action_prev_tab (GtkAction TerminalWindow *window); static void terminal_window_action_next_tab (GtkAction *action, TerminalWindow *window); +static void terminal_window_tab_move_left (GtkAction *action, + TerminalWindow *window); +static void terminal_window_tab_move_right (GtkAction *action, + TerminalWindow *window); static void terminal_window_action_goto_tab (GtkRadioAction *action, GtkNotebook *notebook); static void terminal_window_action_set_title (GtkAction *action, @@ -241,6 +245,8 @@ static const GtkActionEntry action_entries[] = { "go-menu", NULL, N_ ("_Go"), NULL, NULL, NULL, }, { "prev-tab", GTK_STOCK_GO_BACK, N_ ("_Previous Tab"), NULL, N_ ("Switch to previous tab"), G_CALLBACK (terminal_window_action_prev_tab), }, { "next-tab", GTK_STOCK_GO_FORWARD, N_ ("_Next Tab"), NULL, N_ ("Switch to next tab"), G_CALLBACK (terminal_window_action_next_tab), }, + { "tab-move-left", NULL, N_ ("Move Tab _Left"), NULL, N_ ("Move Tab Left"), G_CALLBACK (terminal_window_tab_move_left), }, + { "tab-move-right", NULL, N_ ("Move Tab _Right"), NULL, N_ ("Move Tab Right"), G_CALLBACK (terminal_window_tab_move_right), }, { "help-menu", NULL, N_ ("_Help"), NULL, NULL, NULL, }, { "contents", GTK_STOCK_HELP, N_ ("_Contents"), NULL, N_ ("Display help contents"), G_CALLBACK (terminal_window_action_contents), }, { "report-bug", TERMINAL_STOCK_REPORTBUG, N_ ("_Report a bug"), NULL, N_ ("Report a bug in Terminal"), G_CALLBACK (terminal_window_action_report_bug), }, @@ -1507,6 +1513,40 @@ terminal_window_action_next_tab (GtkAction *action, static void +terminal_window_tab_move_left (GtkAction *action, + TerminalWindow *window) +{ + GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook); + gint page_num,last_page; + GtkWidget *page; + + page_num = gtk_notebook_get_current_page (notebook); + last_page = gtk_notebook_get_n_pages (notebook) - 1; + page = gtk_notebook_get_nth_page (notebook, page_num); + + gtk_notebook_reorder_child (notebook, page, page_num == 0 ? last_page : page_num - 1); +} + + + +static void +terminal_window_tab_move_right (GtkAction *action, + TerminalWindow *window) +{ + GtkNotebook *notebook = GTK_NOTEBOOK (window->notebook); + gint page_num,last_page; + GtkWidget *page; + + page_num = gtk_notebook_get_current_page (notebook); + last_page = gtk_notebook_get_n_pages (notebook) - 1; + page = gtk_notebook_get_nth_page (notebook, page_num); + + gtk_notebook_reorder_child (notebook, page, page_num == last_page ? 0 : page_num + 1); +} + + + +static void terminal_window_action_goto_tab (GtkRadioAction *action, GtkNotebook *notebook) { -- 1.7.1