[gnome-news] application: Migrate to Primary Menu
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-news] application: Migrate to Primary Menu
- Date: Mon, 21 Jan 2019 15:37:57 +0000 (UTC)
commit e173472eb5aa043b0a9b5736799cfcf93950bf0f
Author: Christopher Davis <brainblasted disroot org>
Date: Mon Jan 21 10:36:36 2019 -0500
application: Migrate to Primary Menu
As per Initiatives#4,
we are retiring the Shell App Menu in favor of an in-window
Primary Menu.
This re-implements 56a97929 because Glade moved everything around and broke things.
data/gtk/menus.ui | 9 ++-------
data/ui/headerbar.ui | 24 ++++++++++++++++++++++++
gnomenews/application.py | 2 ++
gnomenews/toolbar.py | 7 +++++++
4 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index 659d969..e796e70 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -1,16 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gnome-news">
- <menu id="app-menu">
+ <menu id="primary-menu">
<section>
<item>
- <attribute name="label" translatable="yes">About</attribute>
+ <attribute name="label" translatable="yes">About News</attribute>
<attribute name="action">app.about</attribute>
</item>
- <item>
- <attribute name="label" translatable="yes">Quit</attribute>
- <attribute name="action">app.quit</attribute>
- <attribute name="accel"><Primary>q</attribute>
- </item>
</section>
</menu>
</interface>
diff --git a/data/ui/headerbar.ui b/data/ui/headerbar.ui
index 63f26ba..2d0c4e8 100644
--- a/data/ui/headerbar.ui
+++ b/data/ui/headerbar.ui
@@ -145,6 +145,30 @@
<property name="visible">True</property>
<property name="vexpand">False</property>
<property name="show_close_button">True</property>
+ <child>
+ <object class="GtkMenuButton" id="primary-menu-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">center</property>
+ <property name="sensitive">True</property>
+ <property name="use_popover">True</property>
+ <property name="tooltip_text" translatable="yes">Menu</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
<child>
<object class="GtkButton" id="starred-button">
<property name="can_focus">False</property>
diff --git a/gnomenews/application.py b/gnomenews/application.py
index 91bb63d..273ad5d 100644
--- a/gnomenews/application.py
+++ b/gnomenews/application.py
@@ -68,6 +68,8 @@ class Application(Gtk.Application):
action.connect("activate", getattr(self, action_name))
self.add_action(action)
+ self.set_accels_for_action("app.quit", ["<Primary>q"])
+
Gtk.Application.do_startup(self)
@log
diff --git a/gnomenews/toolbar.py b/gnomenews/toolbar.py
index cd4a8a9..c271df5 100644
--- a/gnomenews/toolbar.py
+++ b/gnomenews/toolbar.py
@@ -77,6 +77,12 @@ class Toolbar(GObject.GObject):
self._starred_button.connect('clicked', self._toggle_starred)
self.starred = False
+ # Primary menu
+ self._ui.add_from_resource('/org/gnome/News/gtk/menus.ui')
+ self._primary_menu = self._ui.get_object('primary-menu')
+ self._primary_menu_button = self._ui.get_object('primary-menu-button')
+ self._primary_menu_button.set_menu_model(self._primary_menu)
+
self.set_state(ToolbarState.MAIN)
self._stack_switcher.show()
@@ -144,6 +150,7 @@ class Toolbar(GObject.GObject):
self._back_button.set_visible(self._state == ToolbarState.CHILD_VIEW)
self._search_button.set_visible(self._state != ToolbarState.CHILD_VIEW)
self._starred_button.set_visible(self._state == ToolbarState.CHILD_VIEW)
+ self._primary_menu_button.set_visible(self._state != ToolbarState.CHILD_VIEW)
self.add_toggle_button.set_visible(self._state != ToolbarState.CHILD_VIEW)
@log
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]