[lightsoff/appmenu-retirement] Migrate from appmenu to in-app menu (#8)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lightsoff/appmenu-retirement] Migrate from appmenu to in-app menu (#8)
- Date: Mon, 8 Oct 2018 20:40:25 +0000 (UTC)
commit aa6f364a0e87c70ace9821cd6ecf7960eef155ef
Author: Robert Roth <robert roth off gmail com>
Date: Sun Oct 7 06:46:03 2018 +0300
Migrate from appmenu to in-app menu (#8)
data/lightsoff-menus.ui | 10 +++----
data/lightsoff.ui | 66 +++++++++++++++++++++++++++++++++++------------
src/lightsoff-window.vala | 4 +++
3 files changed, 56 insertions(+), 24 deletions(-)
---
diff --git a/data/lightsoff-menus.ui b/data/lightsoff-menus.ui
index 502ad18..b28dbc6 100644
--- a/data/lightsoff-menus.ui
+++ b/data/lightsoff-menus.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.12"/>
- <menu id="app-menu">
+ <menu id="primary-menu">
<section>
<item>
<attribute name="label" translatable="yes">_Start Over</attribute>
@@ -16,14 +16,10 @@
<attribute name="accel">F1</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="label" translatable="yes">_About Lights Off</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/lightsoff.ui b/data/lightsoff.ui
index 877776b..3a17517 100644
--- a/data/lightsoff.ui
+++ b/data/lightsoff.ui
@@ -1,49 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<template class="LightsoffWindow" parent="GtkApplicationWindow">
+ <property name="can_focus">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
- <property name="show-close-button">True</property>
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Level X</property>
+ <property name="subtitle" translatable="yes">y moves</property>
+ <property name="show_close_button">True</property>
+ <property name="decoration_layout">:close</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
- <property name="valign">center</property><!-- ??? -->
- <property name="focus-on-click">False</property>
- <property name="tooltip-text" translatable="yes">Return to the previous level</property>
- <property name="action-name">win.previous-level</property>
- <style><class name="image-button"/></style>
+ <property name="can_focus">False</property>
+ <property name="focus_on_click">False</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Return to the previous level</property>
+ <property name="valign">center</property>
+ <property name="action_name">win.previous-level</property>
<child>
<object class="GtkImage">
- <property name="icon-name">go-previous-symbolic</property>
<property name="visible">True</property>
- <property name="icon-size">1</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-previous-symbolic</property>
+ <property name="icon_size">1</property>
+ </object>
+ </child>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="menu_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="primary-menu-button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
</object>
</child>
</object>
<packing>
- <property name="pack-type">start</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property>
- <property name="valign">center</property><!-- ??? -->
- <property name="focus-on-click">False</property>
- <property name="tooltip-text" translatable="yes">Proceed to the next level</property>
- <property name="action-name">win.next-level</property>
- <style><class name="image-button"/></style>
+ <property name="can_focus">False</property>
+ <property name="focus_on_click">False</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Proceed to the next level</property>
+ <property name="valign">center</property>
+ <property name="action_name">win.next-level</property>
<child>
<object class="GtkImage">
- <property name="icon-name">go-next-symbolic</property>
<property name="visible">True</property>
- <property name="icon-size">1</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">go-next-symbolic</property>
+ <property name="icon_size">1</property>
</object>
</child>
+ <style>
+ <class name="image-button"/>
+ </style>
</object>
<packing>
- <property name="pack-type">end</property>
+ <property name="pack_type">end</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/src/lightsoff-window.vala b/src/lightsoff-window.vala
index a96b4dd..ac4aeb7 100644
--- a/src/lightsoff-window.vala
+++ b/src/lightsoff-window.vala
@@ -16,6 +16,7 @@ using Gtk;
public class LightsoffWindow : ApplicationWindow
{
[GtkChild] private HeaderBar headerbar;
+ [GtkChild] private MenuButton menu_button;
private GLib.Settings settings;
private GameView game_view;
@@ -69,6 +70,9 @@ public class LightsoffWindow : ApplicationWindow
{
settings = new GLib.Settings ("org.gnome.lightsoff");
+ var menu_builder = new Gtk.Builder.from_resource ("/org/gnome/lightsoff/gtk/menus.ui");
+ menu_button.set_menu_model ((GLib.Menu) menu_builder.get_object ("primary-menu"));
+
add_action_entries (window_actions, this);
previous_level = (SimpleAction) this.lookup_action ("previous-level");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]