[gnome-terminal/wip/fmuellner/headerbar: 4/6] window: Move app menu into headerbar
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/wip/fmuellner/headerbar: 4/6] window: Move app menu into headerbar
- Date: Fri, 2 Nov 2018 02:15:02 +0000 (UTC)
commit c7e120c48d10eb2614f44f085006538aa881519b
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 2 00:33:49 2018 +0100
window: Move app menu into headerbar
GNOME is retiring the app menu[0], so stop exporting it. The new headerbar
gives us a place to expose the menu instead.
[0] https://gitlab.gnome.org/GNOME/Initiatives/wikis/App-Menu-Retirement
https://bugzilla.gnome.org/show_bug.cgi?id=756798
src/terminal-app.c | 17 ++++++-----------
src/{terminal-appmenu.ui => terminal-primarymenu.ui} | 10 ++--------
src/terminal-window.c | 8 ++++++++
src/terminal-window.ui | 19 +++++++++++++++++++
src/terminal.gresource.xml | 2 +-
5 files changed, 36 insertions(+), 20 deletions(-)
---
diff --git a/src/terminal-app.c b/src/terminal-app.c
index f8e290d5..06fa3bc3 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -638,17 +638,16 @@ terminal_app_startup (GApplication *application)
app_load_css (application);
- /* Figure out whether the shell shows appmenu/menubar */
- gboolean shell_shows_appmenu, shell_shows_menubar;
+ /* Figure out whether the shell shows menubar */
+ gboolean shell_shows_menubar;
g_object_get (gtk_settings_get_default (),
- "gtk-shell-shows-app-menu", &shell_shows_appmenu,
"gtk-shell-shows-menubar", &shell_shows_menubar,
NULL);
- /* App menu */
- GMenu *appmenu_new_terminal_section = gtk_application_get_menu_by_id (gtk_application,
+ /* Primary menu */
+ GMenu *winmenu_new_terminal_section = gtk_application_get_menu_by_id (gtk_application,
"new-terminal-section");
- fill_new_terminal_section (app, appmenu_new_terminal_section, NULL, 0); /* no submenu */
+ fill_new_terminal_section (app, winmenu_new_terminal_section, NULL, 0); /* no submenu */
/* Menubar */
/* If the menubar is shown by the shell, omit mnemonics for the submenus. This is because Alt+F etc.
@@ -676,11 +675,7 @@ terminal_app_startup (GApplication *application)
/* Install the encodings submenu */
terminal_encodings_append_menu (app->menubar_set_encoding_submenu);
- /* Show/hide the appmenu/menubar as appropriate:
- * If the shell wants to show the menubar, make it available.
- * If the shell wants to show both the appmenu and the menubar, there's no need for the appmenu. */
- if (shell_shows_appmenu && shell_shows_menubar)
- gtk_application_set_app_menu (GTK_APPLICATION (app), NULL);
+ /* If the shell wants to show the menubar, make it available. */
if (shell_shows_menubar)
gtk_application_set_menubar (GTK_APPLICATION (app), app->menubar);
diff --git a/src/terminal-appmenu.ui b/src/terminal-primarymenu.ui
similarity index 81%
rename from src/terminal-appmenu.ui
rename to src/terminal-primarymenu.ui
index 8ea3159f..8d8c0638 100644
--- a/src/terminal-appmenu.ui
+++ b/src/terminal-primarymenu.ui
@@ -16,27 +16,21 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<interface>
- <menu id="app-menu">
+ <menu id="primary-menu">
<section id="new-terminal-section" />
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
- </section>
- <section>
<item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="label" translatable="yes">_About Terminal</attribute>
<attribute name="action">app.about</attribute>
</item>
- <item>
- <attribute name="label" translatable="yes">_Quit</attribute>
- <attribute name="action">app.quit</attribute>
- </item>
</section>
</menu>
</interface>
diff --git a/src/terminal-window.c b/src/terminal-window.c
index b222ce5f..6f82b3eb 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -53,6 +53,7 @@ struct _TerminalWindowPrivate
TerminalScreenPopupInfo *popup_info;
+ GtkWidget *primary_menubutton;
GtkWidget *menubar;
TerminalMdiContainer *mdi_container;
GtkWidget *main_vbox;
@@ -2083,6 +2084,7 @@ terminal_window_init (TerminalWindow *window)
TerminalApp *app;
GSettings *gtk_debug_settings;
GtkWindowGroup *window_group;
+ GMenu *primary_menu;
// GtkAccelGroup *accel_group;
uuid_t u;
char uuidstr[37], role[64];
@@ -2095,6 +2097,10 @@ terminal_window_init (TerminalWindow *window)
gtk_widget_init_template (GTK_WIDGET (window));
+ primary_menu = gtk_application_get_menu_by_id (GTK_APPLICATION (app), "primary-menu");
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->primary_menubutton),
+ G_MENU_MODEL (primary_menu));
+
uuid_generate (u);
uuid_unparse (u, uuidstr);
priv->uuid = g_strdup (uuidstr);
@@ -2260,6 +2266,8 @@ terminal_window_class_init (TerminalWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/terminal/ui/window.ui");
+ gtk_widget_class_bind_template_child_private (widget_class, TerminalWindow, primary_menubutton);
+
#if GTK_CHECK_VERSION(3, 19, 5)
gtk_widget_class_set_css_name(widget_class, TERMINAL_WINDOW_CSS_NAME);
#else
diff --git a/src/terminal-window.ui b/src/terminal-window.ui
index 1940919b..375bc2d7 100644
--- a/src/terminal-window.ui
+++ b/src/terminal-window.ui
@@ -7,6 +7,25 @@
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="show_close_button">True</property>
+ <child>
+ <object class="GtkMenuButton" id="primary_menubutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon_name">open-menu-symbolic</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index 7b84a5f7..4341fcc1 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -18,7 +18,7 @@
<gresources>
<gresource prefix="/org/gnome/terminal">
<file alias="css/terminal.css" compressed="true">terminal.common.css</file>
- <file alias="gtk/menus.ui" compressed="true" preprocess="xml-stripblanks">terminal-appmenu.ui</file>
+ <file alias="gtk/menus.ui" compressed="true" preprocess="xml-stripblanks">terminal-primarymenu.ui</file>
<file alias="ui/menubar-with-mnemonics.ui" compressed="true"
preprocess="xml-stripblanks">terminal-menubar-with-mnemonics.ui</file>
<file alias="ui/menubar-without-mnemonics.ui" compressed="true"
preprocess="xml-stripblanks">terminal-menubar-without-mnemonics.ui</file>
<file alias="ui/notebook-menu.ui" compressed="true"
preprocess="xml-stripblanks">terminal-notebook-menu.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]