[gnome-terminal] window: Unify new tab and new window
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] window: Unify new tab and new window
- Date: Fri, 21 Jun 2013 13:21:58 +0000 (UTC)
commit 99fc0136a5be6323b81b8b339482bc699b53e1f9
Author: Christian Persch <chpe gnome org>
Date: Mon Feb 18 15:40:07 2013 +0100
window: Unify new tab and new window
Instead of having two sets of "New terminal" items, unify them into one
"New Terminal" type of items that will open a terminal in a tab or window
depending on a pref, and that can be inverted by using control key.
https://bugzilla.gnome.org/show_bug.cgi?id=543996
Conflicts:
src/org.gnome.Terminal.gschema.xml.in
src/terminal-window.c
src/terminal.xml
src/org.gnome.Terminal.gschema.xml.in | 10 +++
src/preferences.ui | 58 +++++++++++++++++++
src/terminal-enums.h | 5 ++
src/terminal-prefs.c | 9 +++-
src/terminal-schemas.h | 1 +
src/terminal-window.c | 102 ++++++++++++++-------------------
src/terminal.xml | 7 +--
7 files changed, 127 insertions(+), 65 deletions(-)
---
diff --git a/src/org.gnome.Terminal.gschema.xml.in b/src/org.gnome.Terminal.gschema.xml.in
index 35a4d67..8905b5a 100644
--- a/src/org.gnome.Terminal.gschema.xml.in
+++ b/src/org.gnome.Terminal.gschema.xml.in
@@ -31,6 +31,11 @@
<value nick='ignore' value='3'/>
</enum>
+ <enum id='org.gnome.Terminal.NewTerminalMode'>
+ <value nick='window' value='0'/>
+ <value nick='tab' value='1'/>
+ </enum>
+
<enum id='org.gnome.Terminal.ScrollbarPolicy'>
<value nick='always' value='0'/>
<value nick='automatic' value='1'/>
@@ -622,6 +627,11 @@
<_summary>Whether to use a dark theme variant</_summary>
</key>
+ <key name="new-terminal-mode" enum="org.gnome.Terminal.NewTerminalMode">
+ <default>'window'</default>
+ <_summary>Whether to open new terminals as windows or tabs</_summary>
+ </key>
+
<!-- <child name="profiles" schema="org.gnome.Terminal.ProfilesList" /> -->
<child name="keybindings" schema="org.gnome.Terminal.Legacy.Keybindings" />
diff --git a/src/preferences.ui b/src/preferences.ui
index c1067a3..1adc54f 100644
--- a/src/preferences.ui
+++ b/src/preferences.ui
@@ -1,6 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkListStore" id="new-terminal-mode-liststore">
+ <columns>
+ <!-- column-name gchararray -->
+ <column type="gchararray"/>
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes" comments="Open new terminal in new window">Window</col>
+ <col id="1" translatable="no">window</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" comments="Open new terminal in new tab">Tab</col>
+ <col id="1" translatable="no">tab</col>
+ </row>
+ </data>
+ </object>
<object class="GtkDialog" id="preferences-dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -137,6 +154,47 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="hbox140">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <property name="orientation">horizontal</property>
+ <child>
+ <object class="GtkLabel" id="label480">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Open _new terminals in:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">new-terminal-mode-combobox</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="new-terminal-mode-combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">new-terminal-mode-liststore</property>
+ <property name="id-column">1</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
</object>
</child>
<child type="tab">
diff --git a/src/terminal-enums.h b/src/terminal-enums.h
index d0a7635..6c5b60a 100644
--- a/src/terminal-enums.h
+++ b/src/terminal-enums.h
@@ -24,6 +24,11 @@
G_BEGIN_DECLS
+typedef enum {
+ TERMINAL_NEW_TERMINAL_MODE_WINDOW,
+ TERMINAL_NEW_TERMINAL_MODE_TAB
+} TerminalNewTerminalMode;
+
typedef enum
{
TERMINAL_TITLE_REPLACE,
diff --git a/src/terminal-prefs.c b/src/terminal-prefs.c
index 692a941..92cf765 100644
--- a/src/terminal-prefs.c
+++ b/src/terminal-prefs.c
@@ -591,7 +591,7 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
GtkWidget *dialog, *tree_view;
GtkWidget *show_menubar_button, *disable_mnemonics_button, *disable_menu_accel_button;
GtkWidget *tree_view_container, *new_button, *edit_button, *clone_button, *remove_button;
- GtkWidget *dark_theme_button;
+ GtkWidget *dark_theme_button, *new_terminal_mode_combo;
GtkWidget *default_hbox, *default_label;
GtkTreeSelection *selection;
GSettings *settings;
@@ -613,6 +613,7 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
"preferences-dialog", &dialog,
"default-show-menubar-checkbutton", &show_menubar_button,
"dark-theme-checkbutton", &dark_theme_button,
+ "new-terminal-mode-combobox", &new_terminal_mode_combo,
"disable-mnemonics-checkbutton", &disable_mnemonics_button,
"disable-menu-accel-checkbutton", &disable_menu_accel_button,
"accelerators-treeview", &tree_view,
@@ -646,6 +647,12 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+ g_settings_bind (settings,
+ TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY,
+ new_terminal_mode_combo,
+ "active-id",
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+
/* Keybindings tab */
g_settings_bind (settings,
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index 86f66bd..e8a83d7 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -71,6 +71,7 @@ G_BEGIN_DECLS
#define TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY "menu-accelerator-enabled"
#define TERMINAL_SETTING_ENABLE_MNEMONICS_KEY "mnemonics-enabled"
#define TERMINAL_SETTING_ENCODINGS_KEY "encodings"
+#define TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY "new-terminal-mode"
#define TERMINAL_SETTING_SCHEMA_VERSION "schema-version"
#define TERMINAL_SETTINGS_LIST_LIST_KEY "list"
diff --git a/src/terminal-window.c b/src/terminal-window.c
index a9501b4..c1ecd9f 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -90,8 +90,7 @@ struct _TerminalWindowPrivate
#define PROFILE_DATA_KEY "GT::Profile"
-#define FILE_NEW_TERMINAL_TAB_UI_PATH "/menubar/File/FileNewTabProfiles"
-#define FILE_NEW_TERMINAL_WINDOW_UI_PATH "/menubar/File/FileNewWindowProfiles"
+#define FILE_NEW_TERMINAL_UI_PATH "/menubar/File/FileNewTerminalProfiles"
#define SET_ENCODING_UI_PATH "/menubar/Terminal/TerminalSetEncoding/EncodingsPH"
#define SET_ENCODING_ACTION_NAME_PREFIX "TerminalSetEncoding"
@@ -149,9 +148,7 @@ static void screen_close_request_cb (TerminalMdiContainer *container,
TerminalWindow *window);
/* Menu action callbacks */
-static void file_new_window_callback (GtkAction *action,
- TerminalWindow *window);
-static void file_new_tab_callback (GtkAction *action,
+static void file_new_terminal_callback (GtkAction *action,
TerminalWindow *window);
static void file_new_profile_callback (GtkAction *action,
TerminalWindow *window);
@@ -657,6 +654,8 @@ terminal_window_update_new_terminal_menus (TerminalWindow *window)
gtk_action_set_visible (action, have_single_profile);
action = gtk_action_group_get_action (priv->action_group, "FileNewWindow");
gtk_action_set_visible (action, have_single_profile);
+ action = gtk_action_group_get_action (priv->action_group, "FileNewTerminal");
+ gtk_action_set_visible (action, have_single_profile);
if (have_single_profile)
{
@@ -678,27 +677,15 @@ terminal_window_update_new_terminal_menus (TerminalWindow *window)
GSettings *profile = (GSettings *) p->data;
char name[32];
- g_snprintf (name, sizeof (name), "FileNewTab.%u", n);
- terminal_window_create_new_terminal_action (window,
- profile,
- name,
- n,
- G_CALLBACK (file_new_tab_callback));
-
- gtk_ui_manager_add_ui (priv->ui_manager, priv->new_terminal_ui_id,
- FILE_NEW_TERMINAL_TAB_UI_PATH,
- name, name,
- GTK_UI_MANAGER_MENUITEM, FALSE);
-
- g_snprintf (name, sizeof (name), "FileNewWindow.%u", n);
+ g_snprintf (name, sizeof (name), "FileNewTerminal.%u", n);
terminal_window_create_new_terminal_action (window,
profile,
name,
n,
- G_CALLBACK (file_new_window_callback));
+ G_CALLBACK (file_new_terminal_callback));
gtk_ui_manager_add_ui (priv->ui_manager, priv->new_terminal_ui_id,
- FILE_NEW_TERMINAL_WINDOW_UI_PATH,
+ FILE_NEW_TERMINAL_UI_PATH,
name, name,
GTK_UI_MANAGER_MENUITEM, FALSE);
@@ -1568,8 +1555,7 @@ terminal_window_init (TerminalWindow *window)
{
/* Toplevel */
{ "File", NULL, N_("_File") },
- { "FileNewWindowProfiles", STOCK_NEW_WINDOW, N_("Open _Terminal")},
- { "FileNewTabProfiles", STOCK_NEW_TAB, N_("Open Ta_b") },
+ { "FileNewTerminalProfiles", STOCK_NEW_WINDOW, N_("Open _Terminal")},
{ "Edit", NULL, N_("_Edit") },
{ "View", NULL, N_("_View") },
{ "Search", NULL, N_("_Search") },
@@ -1582,10 +1568,13 @@ terminal_window_init (TerminalWindow *window)
/* File menu */
{ "FileNewWindow", STOCK_NEW_WINDOW, N_("Open _Terminal"), "<shift><control>N",
NULL,
- G_CALLBACK (file_new_window_callback) },
+ G_CALLBACK (file_new_terminal_callback) },
{ "FileNewTab", STOCK_NEW_TAB, N_("Open Ta_b"), "<shift><control>T",
NULL,
- G_CALLBACK (file_new_tab_callback) },
+ G_CALLBACK (file_new_terminal_callback) },
+ { "FileNewTerminal", STOCK_NEW_TAB, N_("Open _Terminal"), NULL,
+ NULL,
+ G_CALLBACK (file_new_terminal_callback) },
{ "FileNewProfile", GTK_STOCK_OPEN, N_("New _Profile"), "",
NULL,
G_CALLBACK (file_new_profile_callback) },
@@ -1726,10 +1715,7 @@ terminal_window_init (TerminalWindow *window)
G_CALLBACK (edit_paste_callback) },
{ "PopupNewTerminal", NULL, N_("Open _Terminal"), NULL,
NULL,
- G_CALLBACK (file_new_window_callback) },
- { "PopupNewTab", NULL, N_("Open Ta_b"), NULL,
- NULL,
- G_CALLBACK (file_new_tab_callback) },
+ G_CALLBACK (file_new_terminal_callback) },
{ "PopupLeaveFullscreen", NULL, N_("L_eave Full Screen"), NULL,
NULL,
G_CALLBACK (popup_leave_fullscreen_callback) },
@@ -2704,51 +2690,46 @@ terminal_window_update_geometry (TerminalWindow *window)
}
static void
-file_new_window_callback (GtkAction *action,
- TerminalWindow *window)
+file_new_terminal_callback (GtkAction *action,
+ TerminalWindow *window)
{
TerminalWindowPrivate *priv = window->priv;
TerminalApp *app;
- TerminalWindow *new_window;
GSettings *profile;
char *new_working_directory;
+ const char *name;
+ TerminalNewTerminalMode mode;
+ GdkModifierType modifiers;
- app = terminal_app_get ();
+ g_assert (TERMINAL_IS_WINDOW (window));
+ app = terminal_app_get ();
profile = g_object_get_data (G_OBJECT (action), PROFILE_DATA_KEY);
if (!profile)
profile = terminal_screen_get_profile (priv->active_screen);
if (!profile)
return;
- new_window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)));
-
- new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
- terminal_app_new_terminal (app, new_window, profile,
- NULL, NULL,
- new_working_directory,
- terminal_screen_get_initial_environment (priv->active_screen),
- 1.0);
- g_free (new_working_directory);
-
- gtk_window_present (GTK_WINDOW (new_window));
-}
-
-static void
-file_new_tab_callback (GtkAction *action,
- TerminalWindow *window)
-{
- TerminalWindowPrivate *priv = window->priv;
- TerminalApp *app;
- GSettings *profile;
- char *new_working_directory;
+ name = gtk_action_get_name (action);
+ if (g_str_has_prefix (name, "FileNewTab"))
+ mode = TERMINAL_NEW_TERMINAL_MODE_TAB;
+ else if (g_str_has_prefix (name, "FileNewWindow"))
+ mode = TERMINAL_NEW_TERMINAL_MODE_WINDOW;
+ else {
+ mode = g_settings_get_enum (terminal_app_get_global_settings (app),
+ TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY);
+ if (gtk_get_current_event_state (&modifiers) &&
+ (modifiers & gtk_accelerator_get_default_mod_mask () & GDK_CONTROL_MASK)) {
+ /* Invert */
+ if (mode == TERMINAL_NEW_TERMINAL_MODE_WINDOW)
+ mode = TERMINAL_NEW_TERMINAL_MODE_TAB;
+ else
+ mode = TERMINAL_NEW_TERMINAL_MODE_WINDOW;
+ }
+ }
- app = terminal_app_get ();
- profile = g_object_get_data (G_OBJECT (action), PROFILE_DATA_KEY);
- if (!profile)
- profile = terminal_screen_get_profile (priv->active_screen);
- if (!profile)
- return;
+ if (mode == TERMINAL_NEW_TERMINAL_MODE_WINDOW)
+ window = terminal_app_new_window (app, gtk_widget_get_screen (GTK_WIDGET (window)));
new_working_directory = terminal_screen_get_current_dir (priv->active_screen);
terminal_app_new_terminal (app, window, profile,
@@ -2757,6 +2738,9 @@ file_new_tab_callback (GtkAction *action,
terminal_screen_get_initial_environment (priv->active_screen),
1.0);
g_free (new_working_directory);
+
+ if (mode == TERMINAL_NEW_TERMINAL_MODE_WINDOW)
+ gtk_window_present (GTK_WINDOW (window));
}
static void
diff --git a/src/terminal.xml b/src/terminal.xml
index cf28f07..6743393 100644
--- a/src/terminal.xml
+++ b/src/terminal.xml
@@ -1,10 +1,8 @@
<ui>
<menubar>
<menu action="File">
- <menuitem action="FileNewWindow" />
- <menu action="FileNewWindowProfiles" />
- <menuitem action="FileNewTab" />
- <menu action="FileNewTabProfiles" />
+ <menuitem action="FileNewTerminal" />
+ <menu action="FileNewTerminalProfiles" />
<separator />
<menuitem action="FileNewProfile" />
<menuitem action="FileSaveContents" />
@@ -85,7 +83,6 @@
<menuitem action="PopupCopyLinkAddress" />
<separator />
<menuitem action="PopupNewTerminal" />
- <menuitem action="PopupNewTab" />
<separator />
<menuitem action="PopupCopy" />
<menuitem action="PopupPaste" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]