From aafe750b089b7dd1c891c084c5a9b48e26862ac3 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce.cowan@strath.ac.uk> Date: Wed, 1 Jan 2020 20:59:36 +0000 Subject: [PATCH] Add primary menu --- data/interface.ui | 51 +++++++++++++++++++++++++++++++++------- data/menu.ui | 24 ------------------- data/rugby.gresource.xml | 1 - src/find_year.sh | 4 ++-- src/main.c | 16 +------------ src/meson.build | 2 +- 6 files changed, 46 insertions(+), 52 deletions(-) delete mode 100644 data/menu.ui diff --git a/data/interface.ui b/data/interface.ui index 7546571..69af7b6 100644 --- a/data/interface.ui +++ b/data/interface.ui @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.0 --> <!-- - SPDX-FileCopyrightText: 2012-2019 Bruce Cowan <bruce@bcowan.me.uk> + SPDX-FileCopyrightText: 2012-2020 Bruce Cowan <bruce@bcowan.me.uk> SPDX-License-Identifier: LGPL-3.0-or-later --> -<!-- Generated with glade 3.22.1 --> <interface> <requires lib="gtk+" version="3.16"/> <object class="GtkAdjustment" id="adjustment1"> @@ -12,8 +12,30 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> + <object class="GtkPopoverMenu" id="popovermenu1"> + <property name="can_focus">False</property> + <child> + <object class="GtkModelButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="action_name">app.about</property> + <property name="text" translatable="yes">About Rugby</property> + </object> + <packing> + <property name="submenu">main</property> + </packing> + </child> + </object> <template class="RugbyAppWindow" parent="GtkApplicationWindow"> <property name="can_focus">False</property> + <child> + <object class="GtkListBox" id="listbox"> + <property name="height_request">400</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + </object> + </child> <child type="titlebar"> <object class="GtkHeaderBar"> <property name="visible">True</property> @@ -52,13 +74,24 @@ </child> </object> </child> - </object> - </child> - <child> - <object class="GtkListBox" id="listbox"> - <property name="height_request">400</property> - <property name="visible">True</property> - <property name="can_focus">False</property> + <child> + <object class="GtkMenuButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="popover">popovermenu1</property> + <child> + <object class="GtkImage"> + <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> </template> diff --git a/data/menu.ui b/data/menu.ui deleted file mode 100644 index 7608018..0000000 --- a/data/menu.ui +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<!-- - SPDX-FileCopyrightText: 2017 Bruce Cowan <bruce@bcowan.me.uk> - - SPDX-License-Identifier: LGPL-3.0-or-later ---> -<interface> - <menu id="appmenu"> - <section> - <item> - <attribute name="label" translatable="yes">_About</attribute> - <attribute name="action">app.about</attribute> - <attribute name="accel"><Primary>a</attribute> - </item> - </section> - <section> - <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/rugby.gresource.xml b/data/rugby.gresource.xml index 7dd2d80..65409f7 100644 --- a/data/rugby.gresource.xml +++ b/data/rugby.gresource.xml @@ -7,7 +7,6 @@ <gresources> <gresource prefix="/uk/me/bcowan/rugby"> <file preprocess="xml-stripblanks">interface.ui</file> - <file preprocess="xml-stripblanks">menu.ui</file> <file compressed="true">rugby.css</file> </gresource> </gresources> diff --git a/src/find_year.sh b/src/find_year.sh index 9eaa2f5..cbab476 100755 --- a/src/find_year.sh +++ b/src/find_year.sh @@ -1,6 +1,6 @@ #!/bin/sh -# SPDX-FileCopyrightText: 2018, 2019 Bruce Cowan <bruce@bcowan.me.uk> +# SPDX-FileCopyrightText: 2018-2020 Bruce Cowan <bruce@bcowan.me.uk> # # SPDX-License-Identifier: CC0-1.0 -git log -1 --format=%cd --date-format:%Y +git log -1 --format=%cd --date=format:%Y diff --git a/src/main.c b/src/main.c index 6702108..a97ae83 100644 --- a/src/main.c +++ b/src/main.c @@ -36,15 +36,6 @@ about_activated (GSimpleAction *simple, "authors", authors, "comments", "Rugby scores possiblities program", NULL); - -} - -static void -quit_activated (GSimpleAction *simple, - GVariant *parameter, - gpointer user_data) -{ - g_application_quit (G_APPLICATION (user_data)); } static void @@ -53,8 +44,7 @@ on_startup (GApplication *app, { const GActionEntry app_entries[] = { - { "about", about_activated }, - { "quit", quit_activated } + { .name = "about", .activate = about_activated }, }; g_action_map_add_action_entries (G_ACTION_MAP (app), @@ -62,10 +52,6 @@ on_startup (GApplication *app, G_N_ELEMENTS (app_entries), app); - g_autoptr (GtkBuilder) builder = gtk_builder_new_from_resource ("/uk/me/bcowan/rugby/menu.ui"); - GMenuModel *app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")); - gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu); - // CSS styling g_autoptr (GtkCssProvider) provider = gtk_css_provider_new (); gtk_css_provider_load_from_resource (provider, "/uk/me/bcowan/rugby/rugby.css"); diff --git a/src/meson.build b/src/meson.build index 27d3c6e..6f16b3f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,7 +9,7 @@ conf.set('TRY_POINTS', get_option('try_points')) conf.set('UTRY_POINTS', get_option('utry_points')) conf.set('KICK_POINTS', get_option('kick_points')) -year = run_command('find_year.sh').stdout() +year = run_command('find_year.sh').stdout().strip() conf.set_quoted('COPYRIGHT_YEAR', year) config_h = configure_file(configuration: conf, output: 'config.h') -- GitLab