GNOME Bugzilla – Bug 106286
[PATCH] Add "Move Tab Left", "Move Tab Right" menu and keybindings
Last modified: 2006-01-06 12:58:37 UTC
add tab moving capcability "Move Tab Left" "Move Tab Right" here path: diff -urN gnome-terminal.orig/src/gnome-terminal.schemas gnome-terminal/src/gnome-terminal.schemas --- gnome-terminal.orig/src/gnome-terminal.schemas 2002-12-03 09:49:37.000000000 +0600 +++ gnome-terminal/src/gnome-terminal.schemas 2003-02-04 09:35:02.000000000 +0600 @@ -847,6 +847,40 @@ </schema> <schema> + <key>/schemas/apps/gnome-terminal/keybindings/move_tab_left</key> + <applyto>/apps/gnome-terminal/keybindings/move_tab_left</applyto> + <owner>gnome-terminal</owner> + <type>string</type> + <default><Ctrl><Shift>Page_Up</default> + <locale name="C"> + <short>Accelerator to move current tab left.</short> + <long> + Accelerator key to move current tab left. Expressed as a string + in the same format used for GTK+ resource files. + If you set the option to the special string "disabled", then there + will be no keybinding for this action. + </long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/gnome-terminal/keybindings/move_tab_right</key> + <applyto>/apps/gnome-terminal/keybindings/move_tab_right</applyto> + <owner>gnome-terminal</owner> + <type>string</type> + <default><Ctrl><Shift>Page_Down</default> + <locale name="C"> + <short>Accelerator to move current tab right.</short> + <long> + Accelerator key to move current tab right. Expressed as a string + in the same format used for GTK+ resource files. + If you set the option to the special string "disabled", then there + will be no keybinding for this action. + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/gnome-terminal/keybindings/switch_to_tab_1</key> <applyto>/apps/gnome-terminal/keybindings/switch_to_tab_1</applyto> <owner>gnome-terminal</owner> diff -urN gnome-terminal.orig/src/terminal-accels.c gnome-terminal/src/terminal-accels.c --- gnome-terminal.orig/src/terminal-accels.c 2003-01-05 14:31:50.000000000 +0600 +++ gnome-terminal/src/terminal-accels.c 2003-02-04 06:48:50.000000000 +0600 @@ -43,6 +43,8 @@ #define KEY_RESET_AND_CLEAR CONF_KEYS_PREFIX"/reset_and_clear" #define KEY_PREV_TAB CONF_KEYS_PREFIX"/prev_tab" #define KEY_NEXT_TAB CONF_KEYS_PREFIX"/next_tab" +#define KEY_MOVE_TAB_LEFT CONF_KEYS_PREFIX"/move_tab_left" +#define KEY_MOVE_TAB_RIGHT CONF_KEYS_PREFIX"/move_tab_right" #define KEY_SET_TERMINAL_TITLE CONF_KEYS_PREFIX"/set_window_title" #define PREFIX_KEY_SWITCH_TO_TAB CONF_KEYS_PREFIX"/switch_to_tab_" #define KEY_HELP CONF_KEYS_PREFIX"/help" @@ -122,6 +124,10 @@ KEY_PREV_TAB, ACCEL_PATH_PREV_TAB, 0, 0, NULL, FALSE }, { N_("Switch to Next Tab"), KEY_NEXT_TAB, ACCEL_PATH_NEXT_TAB, 0, 0, NULL, FALSE }, + { N_("Move Tab Left"), + KEY_MOVE_TAB_LEFT, ACCEL_PATH_MOVE_TAB_LEFT, 0, 0, NULL, FALSE }, + { N_("Move Tab Right"), + KEY_MOVE_TAB_RIGHT, ACCEL_PATH_MOVE_TAB_RIGHT, 0, 0, NULL, FALSE }, { N_("Switch to Tab 1"), PREFIX_KEY_SWITCH_TO_TAB"1", PREFIX_ACCEL_PATH_SWITCH_TO_TAB"1", 0, 0, NULL, FALSE }, diff -urN gnome-terminal.orig/src/terminal-accels.h gnome-terminal/src/terminal-accels.h --- gnome-terminal.orig/src/terminal-accels.h 2002-10-05 05:55:41.000000000 +0700 +++ gnome-terminal/src/terminal-accels.h 2003-02-04 06:15:58.000000000 +0600 @@ -47,6 +47,8 @@ #define ACCEL_PATH_ZOOM_IN ACCEL_PATH_ROOT"/zoom_in" #define ACCEL_PATH_ZOOM_OUT ACCEL_PATH_ROOT"/zoom_out" #define ACCEL_PATH_ZOOM_NORMAL ACCEL_PATH_ROOT"/zoom_normal" +#define ACCEL_PATH_MOVE_TAB_LEFT ACCEL_PATH_ROOT"/move_tab_left" +#define ACCEL_PATH_MOVE_TAB_RIGHT ACCEL_PATH_ROOT"/move_tab_right" #define FORMAT_ACCEL_PATH_SWITCH_TO_TAB ACCEL_PATH_ROOT"/switch_to_tab_%d" #define PREFIX_ACCEL_PATH_SWITCH_TO_TAB ACCEL_PATH_ROOT"/switch_to_tab_" diff -urN gnome-terminal.orig/src/terminal-window.c gnome-terminal/src/terminal-window.c --- gnome-terminal.orig/src/terminal-window.c 2003-01-05 11:32:29.000000000 +0600 +++ gnome-terminal/src/terminal-window.c 2003-02-17 12:43:40.000000000 +0600 @@ -62,6 +62,8 @@ GtkWidget *choose_config_menuitem; GtkWidget *next_tab_menuitem; GtkWidget *previous_tab_menuitem; + GtkWidget *moveleft_tab_menuitem; + GtkWidget *moveright_tab_menuitem; GtkWidget *go_menu; GtkWidget *encoding_menuitem; GList *tab_menuitems; @@ -171,6 +173,10 @@ TerminalWindow *window); static void previous_tab_callback (GtkWidget *menuitem, TerminalWindow *window); +static void moveleft_tab_callback (GtkWidget *menuitem, + TerminalWindow *window); +static void moveright_tab_callback (GtkWidget *menuitem, + TerminalWindow *window); static void change_tab_callback (GtkWidget *menuitem, TerminalWindow *window); static void help_callback (GtkWidget *menuitem, @@ -842,6 +848,14 @@ G_CALLBACK (next_tab_callback), window); window->priv->next_tab_menuitem = mi; + mi = append_menuitem (menu, _("Move Tab _Left"), ACCEL_PATH_MOVE_TAB_LEFT, + G_CALLBACK (moveleft_tab_callback), window); + window->priv->moveleft_tab_menuitem = mi; + + mi = append_menuitem (menu, _("Move Tab _Right"), ACCEL_PATH_MOVE_TAB_RIGHT, + G_CALLBACK (moveright_tab_callback), window); + window->priv->moveright_tab_menuitem = mi; + mi = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); @@ -1128,7 +1142,7 @@ notebook = window->priv->notebook; page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); - gtk_widget_set_sensitive (window->priv->previous_tab_menuitem, + gtk_widget_set_sensitive (window->priv->moveleft_tab_menuitem, page_num > 0); @@ -1144,7 +1158,7 @@ else gtk_widget_set_sensitive (window->priv->close_tab_menuitem, TRUE); - gtk_widget_set_sensitive (window->priv->next_tab_menuitem, + gtk_widget_set_sensitive (window->priv->moveright_tab_menuitem, !on_last_page); } @@ -2474,6 +2488,40 @@ } static void +moveleft_tab_callback(GtkWidget *menuitem, + TerminalWindow *window) +{ + gint page_num; + GtkWidget *page; + + page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (window->priv->notebook)); + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (window->priv->notebook), page_num); + + gtk_notebook_reorder_child(GTK_NOTEBOOK (window->priv->notebook), + page, + page_num-1); + update_tab_sensitivity (window); + reset_tab_menuitems (window); +} + +static void +moveright_tab_callback(GtkWidget *menuitem, + TerminalWindow *window) +{ + gint page_num; + GtkWidget *page; + + page_num = gtk_notebook_get_current_page(GTK_NOTEBOOK (window->priv->notebook)); + page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (window->priv->notebook), page_num); + + gtk_notebook_reorder_child(GTK_NOTEBOOK (window->priv->notebook), + page, + page_num+1); + update_tab_sensitivity (window); + reset_tab_menuitems (window); +} + +static void change_tab_callback (GtkWidget *menuitem, TerminalWindow *window) {
Thanks. Should this line be deleted? - gtk_widget_set_sensitive (window->priv->next_tab_menuitem, + gtk_widget_set_sensitive (window->priv->moveright_tab_menuitem, We probably need a Tabs menu, matching Epiphany (and presumably the HIG) instead of current Go menu.
1) I use it because of aditional "bug" 106289 2) i think Tabs menu is right
Has patch: prio->High, keyword +PATCH, changing summary
If we do this, we should also be able to move tabs by dragging, we should have tab context menus and close buttons on the tabs. Perhaps we can just steal the code for this from Epiphany. Perhaps I can do it. Well, strike the latter. I can't. :)
Created attachment 27242 [details] [review] The patch in attachment form
*** Bug 113428 has been marked as a duplicate of this bug. ***
So, gedit has this cool thing that's somewhat connected with this feature. It basically allows you to couple and de-couple tabs from the window into their own window. ie. open up 2 docs in gedit, click and drag [creates 4-arrowed pointer] out of the window - it moves your doc from the tab into its own window. Neato, it would be absolutely awesome if gnome-terminal could do this.
isn't this related to bug #86938 ?
It seems this patch was applied and nobody closed the bug. This feature is present in HEAD and probably a lot of older versions, resolving. Thanks!