[gnome-clocks] Remove appmenu
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Remove appmenu
- Date: Fri, 2 Nov 2018 22:30:59 +0000 (UTC)
commit 206e0d837d9c533363bc74642dfe83695cb68793
Author: Paolo Borelli <pborelli gnome org>
Date: Fri Nov 2 23:28:12 2018 +0100
Remove appmenu
Initiatives#4
data/gtk/menus.ui | 24 ------------------------
data/ui/window.ui | 30 ++++++++++++++++++++++++++++++
src/application.vala | 8 ++++++--
src/window.vala | 11 ++++++++++-
4 files changed, 46 insertions(+), 27 deletions(-)
---
diff --git a/data/gtk/menus.ui b/data/gtk/menus.ui
index d143ac4..111c772 100644
--- a/data/gtk/menus.ui
+++ b/data/gtk/menus.ui
@@ -1,35 +1,11 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <menu id="app-menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
- <attribute name="action">win.show-help-overlay</attribute>
- <attribute name="accel"><Primary>F1</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Help</attribute>
- <attribute name="action">win.help</attribute>
- <attribute name="accel">F1</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_About</attribute>
- <attribute name="action">win.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>
<menu id="selection-menu">
<section>
<item>
<attribute name="action">win.select-all</attribute>
<attribute name="label" translatable="yes">Select All</attribute>
- <attribute name="accel"><Primary>a</attribute>
</item>
<item>
<attribute name="action">win.select-none</attribute>
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 007858b..0ad4700 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -3,6 +3,22 @@
<!-- interface-requires gtk+ 3.8 -->
<template class="ClocksWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Clocks</property>
+ <menu id="primary-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+ <attribute name="action">win.show-help-overlay</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">win.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">win.about</attribute>
+ </item>
+ </section>
+ </menu>
<child type="titlebar">
<object class="ClocksHeaderBar" id="header_bar">
<property name="visible">True</property>
@@ -16,6 +32,20 @@
<property name="visible">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="valign">center</property>
+ <property name="menu_model">primary-menu</property>
+ <property name="action_name">win.show-primary-menu</property>
+ <property name="direction">none</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
</object>
</child>
<child>
diff --git a/src/application.vala b/src/application.vala
index 32c3e74..e44df9f 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -111,8 +111,12 @@ public class Application : Gtk.Application {
});
update_theme (settings);
- add_accelerator ("<Primary>n", "win.new", null);
- add_accelerator ("<Primary>a", "win.select-all", null);
+ set_accels_for_action ("win.new", { "<Primary>n" });
+ set_accels_for_action ("win.select-all", { "<Primary>a" });
+ set_accels_for_action ("win.show-primary-menu", { "F10" });
+ set_accels_for_action ("win.show-help-overlay", { "<Primary>F10" });
+ set_accels_for_action ("win.help", { "F1" });
+ set_accels_for_action ("app.quit", { "<Primary>q" });
}
protected override int handle_local_options (GLib.VariantDict options) {
diff --git a/src/window.vala b/src/window.vala
index 0cf2f7c..0d62cfd 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -21,7 +21,8 @@ namespace Clocks {
[GtkTemplate (ui = "/org/gnome/clocks/ui/window.ui")]
public class Window : Gtk.ApplicationWindow {
private const GLib.ActionEntry[] action_entries = {
- // app menu
+ // primary menu
+ { "show-primary-menu", on_show_primary_menu_activate, null, "false", null },
{ "new", on_new_activate },
{ "help", on_help_activate },
{ "about", on_about_activate },
@@ -37,6 +38,8 @@ public class Window : Gtk.ApplicationWindow {
private Gtk.Stack stack;
[GtkChild]
private Gtk.StackSwitcher stack_switcher;
+ [GtkChild]
+ private Gtk.MenuButton menu_button;
private GLib.Settings settings;
private Gtk.Widget[] panels;
@@ -153,6 +156,11 @@ public class Window : Gtk.ApplicationWindow {
}
}
+ private void on_show_primary_menu_activate (SimpleAction action) {
+ var state = action.get_state ().get_boolean ();
+ action.set_state (new Variant.boolean (!state));
+ }
+
private void on_new_activate () {
((Clock) stack.visible_child).activate_new ();
}
@@ -272,6 +280,7 @@ public class Window : Gtk.ApplicationWindow {
if (header_bar.mode == HeaderBar.Mode.NORMAL) {
header_bar.custom_title = stack_switcher;
+ menu_button.show ();
}
header_bar.set_show_close_button (header_bar.mode != HeaderBar.Mode.SELECTION);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]