[five-or-more/gsoc-vala-port: 7/29] Add menu and button callbacks
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/gsoc-vala-port: 7/29] Add menu and button callbacks
- Date: Mon, 13 Aug 2018 05:49:47 +0000 (UTC)
commit 4301cfe6c3ee1ca01819625684aac3280f4390ec
Author: Ruxandra Simion <ruxandra simion93 gmail com>
Date: Thu May 31 01:36:02 2018 +0300
Add menu and button callbacks
data/five-or-more-menu.ui | 32 +++++++++++++
data/org.gnome.five-or-more.gresource.xml | 3 ++
src-vala/main.vala | 75 +++++++++++++++++++++++++++++++
3 files changed, 110 insertions(+)
---
diff --git a/data/five-or-more-menu.ui b/data/five-or-more-menu.ui
new file mode 100644
index 0000000..5c81bfa
--- /dev/null
+++ b/data/five-or-more-menu.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <menu id="app-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Scores</attribute>
+ <attribute name="action">app.scores</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Preferences</attribute>
+ <attribute name="action">app.preferences</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Help</attribute>
+ <attribute name="action">app.help</attribute>
+ <attribute name="accel">F1</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">About</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/org.gnome.five-or-more.gresource.xml b/data/org.gnome.five-or-more.gresource.xml
index 330568f..1ace8b8 100644
--- a/data/org.gnome.five-or-more.gresource.xml
+++ b/data/org.gnome.five-or-more.gresource.xml
@@ -3,4 +3,7 @@
<gresource prefix="/org/gnome/five-or-more/ui">
<file>five-or-more-vala.ui</file>
</gresource>
+ <gresource prefix="/org/gnome/five-or-more/gtk">
+ <file preprocess="xml-stripblanks" alias="menus.ui">five-or-more-menu.ui</file>
+ </gresource>
</gresources>
diff --git a/src-vala/main.vala b/src-vala/main.vala
index a730e1a..53c9c2d 100644
--- a/src-vala/main.vala
+++ b/src-vala/main.vala
@@ -1,6 +1,16 @@
public class FiveOrMoreApp: Gtk.Application {
private Gtk.Window window;
+ private const GLib.ActionEntry action_entries[] =
+ {
+ {"new-game", new_game_cb },
+ {"scores", scores_cb },
+ {"preferences", preferences_cb },
+ {"help", help_cb },
+ {"about", about_cb },
+ {"quit", quit }
+ };
+
public FiveOrMoreApp () {
Object (application_id: "org.gnome.five-or-more", flags: ApplicationFlags.FLAGS_NONE);
}
@@ -10,6 +20,13 @@ public class FiveOrMoreApp: Gtk.Application {
window.present ();
}
+ protected override void startup ()
+ {
+ base.startup ();
+
+ add_action_entries (action_entries, this);
+ }
+
public static int main (string[] args) {
Environment.set_application_name (_("Five or More"));
Gtk.Window.set_default_icon_name ("five-or-more");
@@ -17,4 +34,62 @@ public class FiveOrMoreApp: Gtk.Application {
var app = new FiveOrMoreApp ();
return app.run (args);
}
+
+ private void new_game_cb ()
+ {
+
+ }
+
+ private void scores_cb ()
+ {
+
+ }
+
+ private void preferences_cb ()
+ {
+
+ }
+
+ private void help_cb ()
+ {
+ try
+ {
+ Gtk.show_uri (window.get_screen (), "help:five-or-more", Gtk.get_current_event_time ());
+ }
+ catch (GLib.Error e)
+ {
+ GLib.warning ("Unable to open help: %s", e.message);
+ }
+ }
+
+ private void about_cb ()
+ {
+ /* Appears on the About dialog. */
+ const string authors[] = { "Robert Szokovacs <szo appaloosacorp hu>",
+ "Szabolcs B\xc3\xa1n <shooby gnome hu>",
+ null
+ };
+
+ const string artists[] = { null
+ };
+
+ const string documenters[] = { "Tiffany Antopolski",
+ "Lanka Rathnayaka",
+ null
+ };
+
+ Gtk.show_about_dialog (window,
+ "program-name", _("Five or More"),
+ "logo-icon-name", "five-or-more",
+ "version", VERSION,
+ "comments", _("GNOME port of the once-popular Color Lines game"),
+ "copyright", "Copyright © 1997–2008 Free Software Foundation, Inc.\n
Copyright © 2013–2014 Michael Catanzaro",
+ "license-type", Gtk.License.GPL_2_0,
+ "authors", authors,
+ "artists", artists,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "website", "https://wiki.gnome.org/Apps/Five%20or%20more"
+ );
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]