all: Port to GMenu

Port from GtkAction and GtkMenuManager to GAction and GMenu.

(Initial patch by Lars Uebernickel <lars.uebernickel@canonical.com>)

https://bugzilla.gnome.org/show_bug.cgi?id=745329
parent 42fbb7e0
......@@ -13,6 +13,8 @@ AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.9 foreign no-dist-gzip dist-bzip2])
AC_USE_SYSTEM_EXTENSIONS
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
GETTEXT_PACKAGE=gnome-terminal
......@@ -26,7 +28,7 @@ AM_MAINTAINER_MODE([enable])
PKG_PROG_PKG_CONFIG
AC_PROG_MKDIR_P
AC_PROG_CC
AC_PROG_CC_C99
AC_ISC_POSIX
AC_HEADER_STDC
AM_PROG_LIBTOOL
......@@ -294,7 +296,6 @@ CC_CHECK_FLAGS_APPEND([WARN_CFLAGS],[CFLAGS],[ \
-Wall \
-Wcast-align \
-Wendif-labels \
-Werror=declaration-after-statement \
"-Werror=format=2 -Werror=format-nonliteral -Werror=format-security" \
-Werror=implicit-function-declaration \
-Werror=init-self \
......
......@@ -61,6 +61,8 @@ gnome_terminal_server_SOURCES = \
terminal-libgsystem.h \
terminal-mdi-container.c \
terminal-mdi-container.h \
terminal-menu-button.h \
terminal-menu-button.c \
terminal-notebook.c \
terminal-notebook.h \
terminal-pcre2.h \
......@@ -80,8 +82,6 @@ gnome_terminal_server_SOURCES = \
terminal-search-popover.h \
terminal-tab-label.c \
terminal-tab-label.h \
terminal-tabs-menu.c \
terminal-tabs-menu.h \
terminal-util.c \
terminal-util.h \
terminal-version.h \
......@@ -94,7 +94,6 @@ nodist_gnome_terminal_server_SOURCES = $(gnome_terminal_server_built)
gnome_terminal_server_CPPFLAGS = \
-DTERMINAL_COMPILATION \
-DTERM_LOCALEDIR="\"$(datadir)/locale\"" \
-DTERM_HELPDIR="\"$(HELP_DIR)\"" \
-DTERM_LIBEXECDIR="\"$(libexecdir)\"" \
$(AM_CPPFLAGS)
......@@ -416,7 +415,6 @@ CLEANFILES = \
EXTRA_DIST = \
terminal.about \
terminal.xml \
terminal-menus.ui \
terminal-window.ui \
terminal.gresource.xml \
......
......@@ -205,6 +205,7 @@ migrate_string (GConfClient *client,
gconf_value_free (value);
}
#if 0
static void
migrate_string_list (GConfClient *client,
const char *gconf_path,
......@@ -235,6 +236,7 @@ migrate_string_list (GConfClient *client,
if (value)
gconf_value_free (value);
}
#endif
static void
migrate_enum (GConfClient *client,
......@@ -328,8 +330,6 @@ migrate_global_prefs (GSettings *settings,
migrate_bool (client, GCONF_GLOBAL_PREFIX, "use_menu_accelerator",
settings, TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY,
FALSE);
migrate_string_list (client, GCONF_GLOBAL_PREFIX, "active_encodings",
settings, TERMINAL_SETTING_ENCODINGS_KEY);
g_object_unref (client);
......
......@@ -310,7 +310,11 @@
<choice value="ISO-8859-14" />
<choice value="ISO-8859-15" />
<choice value="ISO-8859-16" />
<!-- <choice value="UTF-7" /> -->
<choice value="UTF-8" />
<!-- <choice value="UTF-16" /> -->
<!-- <choice value="UTF-32" /> -->
<!-- <choice value="UCS-4" /> -->
<choice value="ARMSCII-8" />
<choice value="BIG5" />
<choice value="BIG5-HKSCS" />
......@@ -331,6 +335,7 @@
<choice value="ISO-2022-JP" />
<choice value="ISO-2022-KR" />
<choice value="ISO-IR-111" />
<!-- <choice value="JOHAB" /> -->
<choice value="KOI8-R" />
<choice value="KOI8-U" />
<choice value="MAC_ARABIC" />
......@@ -391,6 +396,14 @@
<default>'disabled'</default>
<summary>Keyboard shortcut to save the current tab contents to file</summary>
</key>
<key name="export" type="s">
<default>'disabled'</default>
<summary>Keyboard shortcut to export the current tab contents to file in various formats</summary>
</key>
<key name="print" type="s">
<default>'disabled'</default>
<summary>Keyboard shortcut to print the current tab contents to printer or file</summary>
</key>
<key name="close-tab" type="s">
<default>'&lt;Ctrl&gt;&lt;Shift&gt;w'</default>
<summary>Keyboard shortcut to close a tab</summary>
......@@ -619,6 +632,10 @@
<default>'disabled'</default>
<summary>Keyboard shortcut to switch to the numbered tab</summary>
</key>
<key name="switch-to-tab-last" type="s">
<default>'disabled'</default>
<summary>Keyboard shortcut to switch to the last tab</summary>
</key>
<key name="help" type="s">
<default>'F1'</default>
<summary>Keyboard shortcut to launch help</summary>
......@@ -677,21 +694,9 @@
<summary>Whether the shell integration is enabled</summary>
</key>
<!-- This one is deprecated and unused -->
<key name="encodings" type="as">
<!-- Translators: Please note that this has to be a list of
valid encodings (which are to be taken from the list in src/encoding.c).
It has to include UTF-8 the list entries themselves are not to be
translated. This is provided for customization of the default encoding
menu; see bug 144810 for an use case. In most cases, this should be
left alone.
-->
<default>["UTF-8"]</default>
<summary>List of available encodings</summary>
<description>
A subset of possible encodings are presented in
the Encoding submenu. This is a list of encodings
to appear there.
</description>
</key>
<key name="confirm-close" type="b">
......
......@@ -143,7 +143,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label480">
<object class="GtkLabel" id="new-terminal-mode-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
......@@ -429,75 +429,6 @@
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="encodings">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="encodings-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">E_ncodings shown in menu:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">encodings-treeview</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTreeView" id="encodings-treeview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscroll_policy">natural</property>
<property name="vscroll_policy">natural</property>
<property name="headers_visible">False</property>
<property name="headers_clickable">False</property>
<property name="rules_hint">True</property>
<property name="enable_search">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<accessibility>
<relation type="labelled-by" target="encodings-label"/>
</accessibility>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Encodings</property>
</object>
<packing>
<property name="position">3</property>
<property name="tab_fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
......
......@@ -2,7 +2,7 @@
/*
* Copyright © 2002 Havoc Pennington
* Copyright © 2002 Mathias Hasselmann
* Copyright © 2008, 2011 Christian Persch
* Copyright © 2008, 2011, 2017 Christian Persch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include "terminal-app.h"
#include "terminal-encoding.h"
#include "terminal-enums.h"
#include "profile-editor.h"
#include "terminal-schemas.h"
......@@ -486,55 +487,36 @@ init_color_scheme_menu (GtkWidget *widget)
}
enum {
ENCODINGS_COLUMN_ID,
ENCODINGS_COLUMN_MARKUP
ENCODINGS_COLUMN_ID = 0,
ENCODINGS_COLUMN_TEXT = 1
};
static void
init_encodings_combo (GtkWidget *widget)
{
GtkCellRenderer *renderer;
GHashTableIter ht_iter;
gpointer key, value;
gs_unref_object GtkListStore *store;
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
g_hash_table_iter_init (&ht_iter, terminal_app_get_encodings (terminal_app_get ()));
while (g_hash_table_iter_next (&ht_iter, &key, &value)) {
TerminalEncoding *encoding = value;
GtkTreeIter iter;
gs_free char *name;
name = g_markup_printf_escaped ("%s <span size=\"small\">%s</span>",
terminal_encoding_get_charset (encoding),
encoding->name);
gtk_list_store_insert_with_values (store, &iter, -1,
ENCODINGS_COLUMN_MARKUP, name,
ENCODINGS_COLUMN_ID, terminal_encoding_get_charset (encoding),
-1);
}
gs_unref_object GtkListStore *store = terminal_encodings_list_store_new (ENCODINGS_COLUMN_ID,
ENCODINGS_COLUMN_TEXT);
/* Now turn on sorting */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
ENCODINGS_COLUMN_MARKUP,
ENCODINGS_COLUMN_TEXT,
GTK_SORT_ASCENDING);
gtk_combo_box_set_id_column (GTK_COMBO_BOX (widget), ENCODINGS_COLUMN_ID);
gtk_combo_box_set_model (GTK_COMBO_BOX (widget), GTK_TREE_MODEL (store));
/* Cell renderer */
renderer = gtk_cell_renderer_text_new ();
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer,
"markup", ENCODINGS_COLUMN_MARKUP, NULL);
"text", ENCODINGS_COLUMN_TEXT, NULL);
}
static void
editor_help_button_clicked_cb (GtkWidget *button,
GtkWidget *editor)
{
terminal_util_show_help ("profile", GTK_WINDOW (editor));
terminal_util_show_help ("profile");
}
static void
......@@ -799,7 +781,6 @@ fixup_color_chooser_button (void)
/**
* terminal_profile_edit:
* @profile: a #GSettings
* @transient_parent: a #GtkWindow, or %NULL
* @widget_name: a widget name in the profile editor's UI, or %NULL
*
* Shows the profile editor with @profile, anchored to @transient_parent.
......@@ -808,7 +789,6 @@ fixup_color_chooser_button (void)
*/
void
terminal_profile_edit (GSettings *profile,
GtkWindow *transient_parent,
const char *widget_name)
{
TerminalSettingsList *profiles_list;
......@@ -823,8 +803,6 @@ terminal_profile_edit (GSettings *profile,
{
terminal_util_dialog_focus_widget (editor, widget_name);
gtk_window_set_transient_for (GTK_WINDOW (editor),
GTK_WINDOW (transient_parent));
gtk_window_present (GTK_WINDOW (editor));
return;
}
......@@ -1220,7 +1198,5 @@ terminal_profile_edit (GSettings *profile,
terminal_util_dialog_focus_widget (editor, widget_name);
gtk_window_set_transient_for (GTK_WINDOW (editor),
GTK_WINDOW (transient_parent));
gtk_window_present (GTK_WINDOW (editor));
}
......@@ -24,7 +24,6 @@
G_BEGIN_DECLS
void terminal_profile_edit (GSettings *profile,
GtkWindow *transient_parent,
const char *widget_name);
G_END_DECLS
......
......@@ -100,13 +100,11 @@ increase_rlimit_nofile (void)
return TRUE;
}
int
main (int argc, char **argv)
static int
init_server (int argc,
char *argv[],
GApplication **application)
{
gs_unref_object GApplication *app = NULL;
const char *home_dir, *charset;
GError *error = NULL;
if (G_UNLIKELY ((getuid () != geteuid () ||
getgid () != getegid ()) &&
geteuid () == 0 &&
......@@ -121,7 +119,7 @@ main (int argc, char **argv)
}
terminal_i18n_init (TRUE);
const char *charset;
if (!g_get_charset (&charset)) {
g_printerr ("Non UTF-8 locale (%s) is not supported!\n", charset);
return _EXIT_FAILURE_NO_UTF8;
......@@ -134,36 +132,38 @@ main (int argc, char **argv)
if (g_getenv ("G_ENABLE_DIAGNOSTIC") == NULL)
g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE);
#ifndef ENABLE_DISTRO_PACKAGING
#ifdef HAVE_UBUNTU
#ifndef ENABLE_DISTRO_PACKAGING
/* Set some env vars to disable the ubuntu modules. Their package will be
* built using --enable-distro-packaging, but anyone running from git will
* get the right behaviour.
*/
g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE);
#endif
g_setenv ("UBUNTU_MENUPROXY", "0", TRUE);
g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE);
#endif
#endif
_terminal_debug_init ();
// FIXMEchpe: just use / here but make sure #565328 doesn't regress
/* Change directory to $HOME so we don't prevent unmounting, e.g. if the
* factory is started by nautilus-open-terminal. See bug #565328.
* On failure back to /.
*/
home_dir = g_get_home_dir ();
const char *home_dir = g_get_home_dir ();
if (home_dir == NULL || chdir (home_dir) < 0)
(void) chdir ("/");
g_set_prgname ("gnome-terminal-server");
g_set_application_name (_("Terminal"));
GError *error = NULL;
if (!gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error)) {
g_printerr ("Failed to parse arguments: %s\n", error->message);
g_error_free (error);
exit (_EXIT_FAILURE_GTK_INIT);
if (error != NULL) {
g_printerr ("Failed to parse arguments: %s\n", error->message);
g_error_free (error);
}
return _EXIT_FAILURE_GTK_INIT;
}
if (!increase_rlimit_nofile ()) {
......@@ -171,11 +171,25 @@ main (int argc, char **argv)
}
/* Now we can create the app */
app = terminal_app_new (app_id);
GApplication *app = terminal_app_new (app_id);
g_free (app_id);
app_id = NULL;
/* We stay around a bit after the last window closed */
g_application_set_inactivity_timeout (app, INACTIVITY_TIMEOUT);
*application = app;
return 0;
}
int
main (int argc,
char *argv[])
{
gs_unref_object GApplication *app = NULL;
int r = init_server (argc, argv, &app);
if (r != 0)
return r;
return g_application_run (app, 0, NULL);
}
......@@ -54,6 +54,7 @@
#define KEY_COPY "copy"
#define KEY_COPY_HTML "copy-html"
#define KEY_DETACH_TAB "detach-tab"
#define KEY_EXPORT "export"
#define KEY_FIND "find"
#define KEY_FIND_CLEAR "find-clear"
#define KEY_FIND_PREV "find-previous"
......@@ -69,6 +70,7 @@
#define KEY_PASTE "paste"
#define KEY_PREFERENCES "preferences"
#define KEY_PREV_TAB "prev-tab"
#define KEY_PRINT "print"
#define KEY_PROFILE_PREFERENCES "profile-preferences"
#define KEY_READ_ONLY "read-only"
#define KEY_RESET_AND_CLEAR "reset-and-clear"
......@@ -81,40 +83,6 @@
#define KEY_ZOOM_OUT "zoom-out"
#define KEY_SWITCH_TAB_PREFIX "switch-to-tab-"
/* Accel paths for the gtkuimanager based menus */
#define ACCEL_PATH_ROOT "<Actions>/Main/"
#define ACCEL_PATH_KEY_CLOSE_TAB ACCEL_PATH_ROOT "FileCloseTab"
#define ACCEL_PATH_KEY_CLOSE_WINDOW ACCEL_PATH_ROOT "FileCloseWindow"
#define ACCEL_PATH_KEY_COPY ACCEL_PATH_ROOT "EditCopy"
#define ACCEL_PATH_KEY_COPY_HTML ACCEL_PATH_ROOT "EditCopyHtml"
#define ACCEL_PATH_KEY_DETACH_TAB ACCEL_PATH_ROOT "TabsDetach"
#define ACCEL_PATH_KEY_FIND ACCEL_PATH_ROOT "SearchFind"
#define ACCEL_PATH_KEY_FIND_CLEAR ACCEL_PATH_ROOT "SearchClearHighlight"
#define ACCEL_PATH_KEY_FIND_PREV ACCEL_PATH_ROOT "SearchFindPrevious"
#define ACCEL_PATH_KEY_FIND_NEXT ACCEL_PATH_ROOT "SearchFindNext"
#define ACCEL_PATH_KEY_FULL_SCREEN ACCEL_PATH_ROOT "ViewFullscreen"
#define ACCEL_PATH_KEY_HELP ACCEL_PATH_ROOT "HelpContents"
#define ACCEL_PATH_KEY_MOVE_TAB_LEFT ACCEL_PATH_ROOT "TabsMoveLeft"
#define ACCEL_PATH_KEY_MOVE_TAB_RIGHT ACCEL_PATH_ROOT "TabsMoveRight"
#define ACCEL_PATH_KEY_NEW_PROFILE ACCEL_PATH_ROOT "FileNewProfile"
#define ACCEL_PATH_KEY_NEW_TAB ACCEL_PATH_ROOT "FileNewTab"
#define ACCEL_PATH_KEY_NEW_WINDOW ACCEL_PATH_ROOT "FileNewWindow"
#define ACCEL_PATH_KEY_NEXT_TAB ACCEL_PATH_ROOT "TabsNext"
#define ACCEL_PATH_KEY_PASTE ACCEL_PATH_ROOT "EditPaste"
#define ACCEL_PATH_KEY_PREFERENCES ACCEL_PATH_ROOT "EditPreferences"
#define ACCEL_PATH_KEY_PREV_TAB ACCEL_PATH_ROOT "TabsPrevious"
#define ACCEL_PATH_KEY_PROFILE_PREFERENCES ACCEL_PATH_ROOT "EditCurrentProfile"
#define ACCEL_PATH_KEY_READ_ONLY ACCEL_PATH_ROOT "TerminalReadOnly"
#define ACCEL_PATH_KEY_RESET ACCEL_PATH_ROOT "TerminalReset"
#define ACCEL_PATH_KEY_RESET_AND_CLEAR ACCEL_PATH_ROOT "TerminalResetClear"
#define ACCEL_PATH_KEY_SAVE_CONTENTS ACCEL_PATH_ROOT "FileSaveContents"
#define ACCEL_PATH_KEY_SELECT_ALL ACCEL_PATH_ROOT "EditSelectAll"
#define ACCEL_PATH_KEY_TOGGLE_MENUBAR ACCEL_PATH_ROOT "ViewMenubar"
#define ACCEL_PATH_KEY_ZOOM_IN ACCEL_PATH_ROOT "ViewZoomIn"
#define ACCEL_PATH_KEY_ZOOM_NORMAL ACCEL_PATH_ROOT "ViewZoom100"
#define ACCEL_PATH_KEY_ZOOM_OUT ACCEL_PATH_ROOT "ViewZoomOut"
#define ACCEL_PATH_KEY_SWITCH_TAB_PREFIX ACCEL_PATH_ROOT "TabsSwitch"
#if 1
/*
* We don't want to enable content saving until vte supports it async.
......@@ -137,11 +105,7 @@ typedef struct
const GVariantType *action_parameter_type;
const char *action_parameter;
GVariant *parameter;
gboolean installed;
#if 1
/* Legacy gtkuimanager menu accelerator */
const char *legacy_accel_path;
#endif
const char *shadow_action_name;
} KeyEntry;
typedef struct
......@@ -151,42 +115,52 @@ typedef struct
const char *user_visible_name;
} KeyEntryList;
#define ENTRY_FULL(name, key, action, type, parameter, shadow_name) \
{ name, key, "win." action, (const GVariantType *) type, parameter, NULL, shadow_name }
#define ENTRY(name, key, action, type, parameter) \
{ name, key, "win." action, (const GVariantType *) type, parameter, NULL, FALSE, ACCEL_PATH_##key }
ENTRY_FULL (name, key, action, type, parameter, "win.shadow")
#define ENTRY_MDI(name, key, action, type, parameter) \
ENTRY_FULL (name, key, action, type, parameter, "win.shadow-mdi")
static KeyEntry file_entries[] = {
ENTRY (N_("New Terminal in New Tab"), KEY_NEW_TAB, "new-terminal", "(ss)", "('tab','current')" ),
ENTRY (N_("New Terminal in New Window"), KEY_NEW_WINDOW, "new-terminal", "(ss)", "('window','current')"),
ENTRY (N_("New Profile"), KEY_NEW_PROFILE, "new-profile", NULL, NULL ),
ENTRY (N_("New Tab"), KEY_NEW_TAB, "new-terminal", "(ss)", "('tab','current')" ),
ENTRY (N_("New Window"), KEY_NEW_WINDOW, "new-terminal", "(ss)", "('window','current')"),
ENTRY (N_("New Profile"), KEY_NEW_PROFILE, "new-profile", NULL, NULL ),
#ifdef ENABLE_SAVE
ENTRY (N_("Save Contents"), KEY_SAVE_CONTENTS, "save-contents", NULL, NULL ),
ENTRY (N_("Save Contents"), KEY_SAVE_CONTENTS, "save-contents", NULL, NULL ),
#endif
#ifdef ENABLE_EXPORT
ENTRY (N_("Export"), KEY_EXPORT, "export", NULL, NULL ),
#endif
ENTRY (N_("Close Terminal"), KEY_CLOSE_TAB, "close", "s", "'tab'" ),
ENTRY (N_("Close All Terminals"), KEY_CLOSE_WINDOW, "close", "s", "'window'" ),
#ifdef ENABLE_PRINT
ENTRY (N_("Print"), KEY_PRINT, "print", NULL, NULL ),
#endif
ENTRY (N_("Close Tab"), KEY_CLOSE_TAB, "close", "s", "'tab'" ),
ENTRY (N_("Close Window"), KEY_CLOSE_WINDOW, "close", "s", "'window'" ),
};
static KeyEntry edit_entries[] = {
ENTRY (N_("Copy"), KEY_COPY, "copy", "s", "'text'" ),
ENTRY (N_("Copy as HTML"), KEY_COPY_HTML, "copy", "s", "'html'" ),
ENTRY (N_("Paste"), KEY_PASTE, "paste", "s", "'normal'"),
ENTRY (N_("Paste"), KEY_PASTE, "paste-text", NULL, NULL ),
ENTRY (N_("Select All"), KEY_SELECT_ALL, "select-all", NULL, NULL ),
ENTRY (N_("Preferences"), KEY_PREFERENCES, "preferences", NULL, NULL ),
ENTRY (N_("Preferences"), KEY_PREFERENCES, "edit-preferences", NULL, NULL ),
ENTRY (N_("Profile Preferences"), KEY_PROFILE_PREFERENCES, "edit-profile", NULL, NULL ),
};
static KeyEntry find_entries[] = {
ENTRY (N_("Find"), KEY_FIND, "find", "s", "'find'" ),
ENTRY (N_("Find Next"), KEY_FIND_NEXT, "find", "s", "'next'" ),
ENTRY (N_("Find Previous"), KEY_FIND_PREV, "find", "s", "'previous'"),
ENTRY (N_("Clear Find Highlight"), KEY_FIND_CLEAR, "find", "s", "'clear'" )
ENTRY (N_("Find"), KEY_FIND, "find", NULL, NULL),
ENTRY (N_("Find Next"), KEY_FIND_NEXT, "find-forward", NULL, NULL),
ENTRY (N_("Find Previous"), KEY_FIND_PREV, "find-backward", NULL, NULL),
ENTRY (N_("Clear Highlight"), KEY_FIND_CLEAR, "find-clear", NULL, NULL)
};
static KeyEntry view_entries[] = {
ENTRY (N_("Hide and Show toolbar"), KEY_TOGGLE_MENUBAR, "show-menubar", NULL, NULL),
ENTRY (N_("Hide and Show Menubar"), KEY_TOGGLE_MENUBAR, "show-menubar", NULL, NULL),
ENTRY (N_("Full Screen"), KEY_FULL_SCREEN, "fullscreen", NULL, NULL),
ENTRY (N_("Zoom In"), KEY_ZOOM_IN, "zoom", "i", "1" ),
ENTRY (N_("Zoom Out"), KEY_ZOOM_OUT, "zoom", "i", "-1"),
ENTRY (N_("Normal Size"), KEY_ZOOM_NORMAL, "zoom", "i", "0" )
ENTRY (N_("Zoom In"), KEY_ZOOM_IN, "zoom-in", NULL, NULL),
ENTRY (N_("Zoom Out"), KEY_ZOOM_OUT, "zoom-out", NULL, NULL),
ENTRY (N_("Normal Size"), KEY_ZOOM_NORMAL, "zoom-normal", NULL, NULL)
};
static KeyEntry terminal_entries[] = {
......@@ -196,37 +170,56 @@ static KeyEntry terminal_entries[] = {
};
static KeyEntry tabs_entries[] = {
ENTRY (N_("Switch to Previous Terminal"), KEY_PREV_TAB, "switch-tab", "i", "-2"),
ENTRY (N_("Switch to Next Terminal"), KEY_NEXT_TAB, "switch-tab", "i", "-1"),
ENTRY (N_("Move Terminal to the Left"), KEY_MOVE_TAB_LEFT, "move-tab", "i", "-1"),
ENTRY (N_("Move Terminal to the Right"), KEY_MOVE_TAB_RIGHT, "move-tab", "i", "1" ),
ENTRY (N_("Detach Terminal"), KEY_DETACH_TAB, "detach-tab", NULL, NULL),
#define SWITCH_TAB_ENTRY(num) \
ENTRY (NULL, \
KEY_SWITCH_TAB_PREFIX # num, \
"switch-tab", \
"i", \
# num)
SWITCH_TAB_ENTRY (1), SWITCH_TAB_ENTRY (2), SWITCH_TAB_ENTRY (3), SWITCH_TAB_ENTRY (4),
SWITCH_TAB_ENTRY (5), SWITCH_TAB_ENTRY (6), SWITCH_TAB_ENTRY (7), SWITCH_TAB_ENTRY (8),
SWITCH_TAB_ENTRY (9), SWITCH_TAB_ENTRY (10), SWITCH_TAB_ENTRY (11), SWITCH_TAB_ENTRY (12),
SWITCH_TAB_ENTRY (13), SWITCH_TAB_ENTRY (14), SWITCH_TAB_ENTRY (15), SWITCH_TAB_ENTRY (16),
SWITCH_TAB_ENTRY (17), SWITCH_TAB_ENTRY (18), SWITCH_TAB_ENTRY (19), SWITCH_TAB_ENTRY (20),
SWITCH_TAB_ENTRY (21), SWITCH_TAB_ENTRY (22), SWITCH_TAB_ENTRY (23), SWITCH_TAB_ENTRY (24),
SWITCH_TAB_ENTRY (25), SWITCH_TAB_ENTRY (26), SWITCH_TAB_ENTRY (27), SWITCH_TAB_ENTRY (28),
SWITCH_TAB_ENTRY (29), SWITCH_TAB_ENTRY (30), SWITCH_TAB_ENTRY (31), SWITCH_TAB_ENTRY (32),
SWITCH_TAB_ENTRY (33), SWITCH_TAB_ENTRY (34), SWITCH_TAB_ENTRY (35)
#undef SWITCH_TAB_ENTRY
ENTRY_MDI (N_("Switch to Previous Tab"), KEY_PREV_TAB, "tab-switch-left", NULL, NULL),
ENTRY_MDI (N_("Switch to Next Tab"), KEY_NEXT_TAB, "tab-switch-right", NULL, NULL),
ENTRY_MDI (N_("Move Tab to the Left"), KEY_MOVE_TAB_LEFT, "tab-move-left", NULL, NULL),
ENTRY_MDI (N_("Move Tab to the Right"), KEY_MOVE_TAB_RIGHT, "tab-move-right", NULL, NULL),
ENTRY_MDI (N_("Detach Tab"), KEY_DETACH_TAB, "tab-detach", NULL, NULL),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "1", "active-tab", "i", "0"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "2", "active-tab", "i", "1"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "3", "active-tab", "i", "2"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "4", "active-tab", "i", "3"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "5", "active-tab", "i", "4"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "6", "active-tab", "i", "5"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "7", "active-tab", "i", "6"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "8", "active-tab", "i", "7"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "9", "active-tab", "i", "8"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "10", "active-tab", "i", "9"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "11", "active-tab", "i", "10"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "12", "active-tab", "i", "11"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "13", "active-tab", "i", "12"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "14", "active-tab", "i", "13"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "15", "active-tab", "i", "14"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "16", "active-tab", "i", "15"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "17", "active-tab", "i", "16"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "18", "active-tab", "i", "17"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "19", "active-tab", "i", "18"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "20", "active-tab", "i", "19"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "21", "active-tab", "i", "20"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "22", "active-tab", "i", "21"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "23", "active-tab", "i", "22"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "24", "active-tab", "i", "23"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "25", "active-tab", "i", "24"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "26", "active-tab", "i", "25"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "27", "active-tab", "i", "26"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "28", "active-tab", "i", "27"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "29", "active-tab", "i", "28"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "30", "active-tab", "i", "29"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "31", "active-tab", "i", "30"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "32", "active-tab", "i", "31"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "33", "active-tab", "i", "32"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "34", "active-tab", "i", "33"),
ENTRY_MDI (NULL, KEY_SWITCH_TAB_PREFIX "35", "active-tab", "i", "34"),
ENTRY_MDI (N_("Switch to Last Tab"), KEY_SWITCH_TAB_PREFIX "last", "active-tab", "i", "-1"),
};
static KeyEntry help_entries[] = {
ENTRY (N_("Contents"), KEY_HELP, "help", NULL, NULL)
};
#undef ENTRY_FULL
#undef ENTRY
#undef ENTRY_MDI
static KeyEntryList all_entries[] =
{
......@@ -268,14 +261,12 @@ key_changed_cb (GSettings *settings,
gpointer user_data)
{
GtkApplication *application = user_data;
KeyEntry *key_entry;
gs_free char *value = NULL;
_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
"key %s changed\n",
settings_key);
key_entry = g_hash_table_lookup (settings_key_to_entry, settings_key);
KeyEntry *key_entry = g_hash_table_lookup (settings_key_to_entry, settings_key);
if (!key_entry)
{
/* shouldn't really happen, but let's be safe */
......@@ -284,34 +275,38 @@ key_changed_cb (GSettings *settings,
return;
}
value = g_settings_get_string (settings, settings_key);
gs_free char *value = g_settings_get_string (settings, settings_key);
gs_free char *detailed = g_action_print_detailed_name (key_entry->action_name,
key_entry->parameter);
gs_unref_variant GVariant *shadow_parameter = g_variant_new_string (detailed);
/* We want to always consume the action's accelerators, even if the corresponding
* action is insensitive, so the corresponding shortcut key escape code isn't sent
* to the terminal. See bug #453193, bug #138609, and bug #559728.
* Since GtkApplication's accelerators don't use GtkAccelGroup, we have no way
* to intercept/chain on its activation. The only way to do this that I found
* was to install an extra action with the same accelerator that shadows
* the real action and gets activated when the shadowed action is disabled.
*/
if (g_str_equal (value, "disabled")) {
if (key_entry->installed)
gtk_application_remove_accelerator (application,
key_entry->action_name,
key_entry->parameter);
key_entry->installed = FALSE;
gtk_application_remove_accelerator (application,
key_entry->action_name,
key_entry->parameter);
gtk_application_remove_accelerator (application,
key_entry->shadow_action_name,
shadow_parameter);
} else {
gtk_application_add_accelerator (application,
value,
key_entry->action_name,
key_entry->parameter);
key_entry->installed = TRUE;