[atomix] Migrate from appmenu to in-app menu (#14)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atomix] Migrate from appmenu to in-app menu (#14)
- Date: Sun, 7 Oct 2018 03:02:31 +0000 (UTC)
commit 44c4093dbfb6409dbb77991cec0564bae4e133fc
Author: Robert Roth <robert roth off gmail com>
Date: Sun Oct 7 06:02:19 2018 +0300
Migrate from appmenu to in-app menu (#14)
data/ui/interface.ui | 44 +++++++++++++++++++++++++++++---------------
data/ui/menu.ui | 2 +-
src/main.c | 10 ++++------
3 files changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/data/ui/interface.ui b/data/ui/interface.ui
index 5d27520..124b676 100644
--- a/data/ui/interface.ui
+++ b/data/ui/interface.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface>
- <requires lib="gtk+" version="3.10"/>
+ <requires lib="gtk+" version="3.12"/>
<object class="GtkApplicationWindow" id="mainwin">
<property name="width_request">678</property>
<property name="height_request">520</property>
@@ -9,6 +9,33 @@
<property name="border_width">0</property>
<property name="icon_name">atomix</property>
<property name="show_menubar">False</property>
+ <child type="titlebar">
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="name">headerbar</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="title">Atomix</property>
+ <property name="show_close_button">True</property>
+ <property name="decoration_layout">menu:close</property>
+ <child>
+ <object class="GtkMenuButton" id="primary-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-image">
+ <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">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox" id="content_hbox">
<property name="visible">True</property>
@@ -234,18 +261,5 @@
</child>
</object>
</child>
- <child type="titlebar">
- <object class="GtkHeaderBar" id="headerbar">
- <property name="name">headerbar</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title">Atomix</property>
- <property name="show_close_button">True</property>
- <property name="decoration_layout">menu:close</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
</object>
</interface>
diff --git a/data/ui/menu.ui b/data/ui/menu.ui
index cf4d36c..0b04c0c 100644
--- a/data/ui/menu.ui
+++ b/data/ui/menu.ui
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <menu id="app-menu">
+ <menu id="primary-menu">
<section>
<item>
<attribute name="label" translatable="yes">New Game</attribute>
diff --git a/src/main.c b/src/main.c
index 9ecd57a..72a9d8b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -596,6 +596,7 @@ static AtomixApp *create_gui (GApplication *app_instance)
GtkWidget *stats_grid;
GtkWidget *time_label;
GtkWidget *headerbar;
+ GtkWidget *primary_menu_button;
app = g_new0 (AtomixApp, 1);
app->level = NULL;
@@ -646,13 +647,10 @@ static AtomixApp *create_gui (GApplication *app_instance)
headerbar = GTK_WIDGET (gtk_builder_get_object(builder, "headerbar"));
gtk_application_add_window (GTK_APPLICATION (app->app_instance), GTK_WINDOW (app->mainwin));
gtk_window_set_titlebar (GTK_WINDOW (app->mainwin), headerbar);
- GMenu * menu = G_MENU (gtk_builder_get_object (builder, "app-menu"));
- gtk_application_set_app_menu (GTK_APPLICATION (app->app_instance), G_MENU_MODEL (menu));
-
- g_object_set (gtk_widget_get_settings (headerbar),
- "gtk-shell-shows-app-menu", FALSE,
- NULL);
+ GMenu * menu = G_MENU (gtk_builder_get_object (builder, "primary-menu"));
+ primary_menu_button = GTK_WIDGET (gtk_builder_get_object (builder, "primary-menu-button"));
+ gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (primary_menu_button), G_MENU_MODEL (menu));
g_object_unref (builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]