[gnome-terminal/wip/fmuellner/headerbar: 7/8] window: Improve menu-bar-accel handling with headerbar
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/wip/fmuellner/headerbar: 7/8] window: Improve menu-bar-accel handling with headerbar
- Date: Sun, 4 Nov 2018 00:01:39 +0000 (UTC)
commit f1fc52962fe706e07e4650bfbc7e5d46e842f4a4
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Nov 3 18:56:54 2018 +0100
window: Improve menu-bar-accel handling with headerbar
GTK's handling of the menu-bar accel simply focuses the first
focusable titlebar child when custom decorations are used. It
makes more sense for us to repurpose it to toggle the primary
menu in that case, so do that.
https://bugzilla.gnome.org/show_bug.cgi?id=756798
src/terminal-window.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 79326086..e6b225a8 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -1070,6 +1070,16 @@ action_leave_fullscreen_cb (GSimpleAction *action,
g_variant_new_boolean (FALSE));
}
+static void
+action_menu_bar_accel_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ TerminalWindow *window = user_data;
+
+ g_action_group_activate_action (G_ACTION_GROUP (window), "header-menu", NULL);
+}
+
static void
action_inspector_cb (GSimpleAction *action,
GVariant *parameter,
@@ -1364,6 +1374,8 @@ enable_menubar_accel_changed_cb (GSettings *settings,
const char *key,
GtkSettings *gtk_settings)
{
+ TerminalApp *app = terminal_app_get ();
+
#if GTK_CHECK_VERSION (3, 20, 0)
if (g_settings_get_boolean (settings, key))
gtk_settings_reset_property (gtk_settings, "gtk-menu-bar-accel");
@@ -1380,6 +1392,19 @@ enable_menubar_accel_changed_cb (GSettings *settings,
else
g_object_set (gtk_settings, "gtk-menu-bar-accel", NULL, NULL);
#endif
+
+ /* When a headerbar is used, GTK uses the menu-bar accel to move focus
+ into the titlebar. We want it to toggle the primary header menu instead */
+ if (terminal_app_get_use_headerbar (app))
+ {
+ char *menu_accels[2] = { NULL, NULL };
+
+ g_object_get (gtk_settings, "gtk-menu-bar-accel", &menu_accels[0], NULL);
+ gtk_application_set_accels_for_action (GTK_APPLICATION (app),
+ "win.menu-bar-accel",
+ (const char * const *)menu_accels);
+ g_free (*menu_accels);
+ }
}
/* The menubar is shown by the app, and the use of mnemonics (e.g. Alt+F for File) is toggled.
@@ -2065,6 +2090,7 @@ terminal_window_init (TerminalWindow *window)
{ "help", action_help_cb, NULL, NULL, NULL },
{ "inspector", action_inspector_cb, NULL, NULL, NULL },
{ "leave-fullscreen", action_leave_fullscreen_cb, NULL, NULL, NULL },
+ { "menu-bar-accel", action_menu_bar_accel_cb, NULL, NULL, NULL },
{ "new-terminal", action_new_terminal_cb, "(ss)", NULL, NULL },
{ "open-match", action_open_match_cb, NULL, NULL, NULL },
{ "open-hyperlink", action_open_hyperlink_cb, NULL, NULL, NULL },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]