Commit 206e0d83 authored by Paolo Borelli's avatar Paolo Borelli

Remove appmenu

Initiatives#4
parent 354d1494
<?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">&lt;Primary&gt;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">&lt;Primary&gt;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">&lt;Primary&gt;a</attribute>
</item>
<item>
<attribute name="action">win.select-none</attribute>
......
......@@ -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>
......
......@@ -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) {
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment