[swell-foop] Added first-run hint screen (bgo #728620)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [swell-foop] Added first-run hint screen (bgo #728620)
- Date: Thu, 16 Oct 2014 20:43:16 +0000 (UTC)
commit 560c86b7650c4e4b70bf4de22273e752e9b4e3b1
Author: Robert Roth <robert roth off gmail com>
Date: Thu Oct 16 23:42:25 2014 +0300
Added first-run hint screen (bgo #728620)
data/Makefile.am | 3 +-
data/org.gnome.swell-foop.gschema.xml | 5 +++
data/swell-foop.css | 15 ++++++++
src/swell-foop.vala | 62 ++++++++++++++++++++++++++++++++-
4 files changed, 83 insertions(+), 2 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 40aa326..b547fe8 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -5,7 +5,8 @@ gsettings_SCHEMAS = org.gnome.swell-foop.gschema.xml
swelldir=$(datadir)/swell-foop
swell_DATA = \
- preferences.ui
+ preferences.ui \
+ swell-foop.css
desktop_in_files = swell-foop.desktop.in
desktopdir = $(datadir)/applications
diff --git a/data/org.gnome.swell-foop.gschema.xml b/data/org.gnome.swell-foop.gschema.xml
index a4438f0..da10576 100644
--- a/data/org.gnome.swell-foop.gschema.xml
+++ b/data/org.gnome.swell-foop.gschema.xml
@@ -20,6 +20,11 @@
<summary>Board color count</summary>
<description>The number of colors of tiles to use in the game.</description>
</key>
+ <key name="first-run" type="b">
+ <default>true</default>
+ <summary>Is this the first run</summary>
+ <description>Setting to decide whether to show first-run hint dialog or not.</description>
+ </key>
<key name="zealous" type="b">
<default>true</default>
<summary>Zealous animation</summary>
diff --git a/data/swell-foop.css b/data/swell-foop.css
new file mode 100644
index 0000000..e7db802
--- /dev/null
+++ b/data/swell-foop.css
@@ -0,0 +1,15 @@
+.welcome {
+ font-size:1.5em;
+}
+
+.tip {
+ font-size: 1em;
+}
+
+.play {
+ font-size: 1em;
+ padding-right:12px;
+ padding-left:12px;
+ padding-top:6px;
+ padding-bottom:6px;
+}
diff --git a/src/swell-foop.vala b/src/swell-foop.vala
index 795c133..063232a 100644
--- a/src/swell-foop.vala
+++ b/src/swell-foop.vala
@@ -53,6 +53,55 @@ public class SwellFoop : Gtk.Application
Object (application_id: "org.gnome.swell-foop", flags: ApplicationFlags.FLAGS_NONE);
}
+ private void load_css ()
+ {
+ var css_provider = new Gtk.CssProvider ();
+ var css_path = Path.build_filename (DATADIR, "swell-foop.css");
+ try
+ {
+ css_provider.load_from_path (css_path);
+ }
+ catch (GLib.Error e)
+ {
+ warning ("Error loading css styles from %s: %s", css_path, e.message);
+ }
+ Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+
+ private Gtk.Stack build_first_run_stack ()
+ {
+ var stack = new Gtk.Stack ();
+ var first_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 12);
+ load_css ();
+ var logo = new Gtk.Image.from_icon_name ("swell-foop", Gtk.IconSize.DIALOG );
+ logo.set_pixel_size (96);
+ first_vbox.pack_start (logo, false);
+ var label = new Gtk.Label (_("Welcome to Swell Foop"));
+ label.get_style_context ().add_class ("welcome");
+ first_vbox.pack_start (label, false);
+ label = new Gtk.Label (_("Clear as many blocks as you can.\nFewer clicks means more points."));
+ label.get_style_context ().add_class ("tip");
+ first_vbox.pack_start (label, false);
+ var play_button = new Gtk.Button.with_mnemonic (_("Let's _Play"));
+ play_button.get_style_context ().add_class ("play");
+ play_button.get_style_context ().add_class ("suggested-action");
+ play_button.valign = Gtk.Align.CENTER;
+ play_button.halign = Gtk.Align.CENTER;
+ play_button.clicked.connect (() => {
+ stack.set_transition_type (Gtk.StackTransitionType.SLIDE_UP);
+ stack.set_transition_duration (500);
+ stack.set_visible_child_name ("game");
+ settings.set_boolean ("first-run", false);
+ });
+ first_vbox.pack_start (play_button, false);
+ first_vbox.halign = Gtk.Align.CENTER;
+ first_vbox.valign = Gtk.Align.CENTER;
+ stack.add_named (first_vbox, "first-run");
+ stack.set_visible_child_name ("first-run");
+ stack.show_all ();
+ return stack;
+ }
+
protected override void startup ()
{
base.startup ();
@@ -114,7 +163,18 @@ public class SwellFoop : Gtk.Application
/* Create a clutter renderer widget */
clutter_embed = new GtkClutter.Embed ();
clutter_embed.show ();
- vbox.pack_start (clutter_embed, true, true);
+ var first_run = settings.get_boolean ("first-run");
+
+ if (first_run)
+ {
+ var stack = build_first_run_stack ();
+ stack.add_named (clutter_embed, "game");
+ vbox.pack_start (stack, true, true);
+ }
+ else
+ {
+ vbox.pack_start (clutter_embed, true, true);
+ }
stage = (Clutter.Stage) clutter_embed.get_stage ();
stage.background_color = Clutter.Color.from_string ("#000000"); /* background color is black */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]