[gnome-nibbles] Add a CSS provider. Update New Game menu



commit 08991e8ae45203eeffa500c518d53aa647e6050e
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Sat Jul 11 23:55:51 2015 +0300

    Add a CSS provider. Update New Game menu

 data/Makefile.am                   |    3 +-
 data/gnome-nibbles.ui              |   49 ------------------
 data/nibbles.css                   |   12 +++++
 data/nibbles.ui                    |   95 ++++++++++++++++++++++++++++++++++++
 src/gnome-nibbles.gresource.xml.in |    4 +-
 src/gnome-nibbles.vala             |    9 +++-
 src/nibbles.gresource.xml          |    5 +--
 7 files changed, 120 insertions(+), 57 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 12dec82..2a86164 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -16,7 +16,8 @@ gsettings_SCHEMAS = org.gnome.nibbles.gschema.xml
 dist_man_MANS = gnome-nibbles.6
 
 dist_noinst_DATA = \
-       gnome-nibbles.ui
+       nibbles.ui \
+       nibbles.css
 
 EXTRA_DIST = \
        $(gsettings_SCHEMAS)
diff --git a/data/nibbles.css b/data/nibbles.css
new file mode 100644
index 0000000..0537d79
--- /dev/null
+++ b/data/nibbles.css
@@ -0,0 +1,12 @@
+GtkApplicationWindow.main-window {
+    background: rgba (255, 255, 255, 0);
+}
+.welcome {
+  font-size:1.5em;
+}
+.tip {
+  font-size: 1em;
+}
+.play {
+  font-size: 1em;
+}
diff --git a/data/nibbles.ui b/data/nibbles.ui
new file mode 100644
index 0000000..789f69c
--- /dev/null
+++ b/data/nibbles.ui
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+    <object class="GtkHeaderBar">
+        <property name="title" translatable="yes">Nibbles</property>
+    </object>
+    <object class="GtkApplicationWindow" id="nibbles-window">
+        <property name="title" translatable="yes">Nibbles</property>
+        <style><class name="main-window"/></style>
+        <child>
+            <object class="GtkBox" id="vbox">
+                <property name="orientation">vertical</property>
+                <property name="visible">True</property>
+                <child>
+                    <object class="GtkStack" id="main_stack">
+                        <property name="visible">True</property>
+                        <property name="homogeneous">True</property>
+                        <property name="margin">25</property>
+                        <property name="expand">True</property>
+                        <child>
+                            <object class="GtkBox" id="start_box">
+                                <property name="orientation">vertical</property>
+                                <property name="visible">True</property>
+                                <property name="halign">center</property>
+                                <property name="valign">center</property>
+                                <property name="homogeneous">True</property>
+                                <property name="margin">0</property>
+                                <property name="width-request">350</property>
+                                <property name="height-request">350</property>
+                                <child>
+                                    <object class="GtkImage">
+                                        <property name="visible">True</property>
+                                        <property name="icon-name">gnome-nibbles</property>
+                                        <property name="icon-size">6</property> <!-- DIALOG -->
+                                        <property name="pixel-size">96</property>
+                                        <property name="valign">2</property>
+                                    </object>
+                                    <packing>
+                                        <property name="pack-type">start</property>
+                                    </packing>
+                                </child>
+                                <child>
+                                    <object class="GtkLabel">
+                                        <property name="visible">True</property>
+                                        <property name="label" translatable="yes">Welcome, worms.</property>
+
+                                        <style><class name="welcome"/></style>
+                                    </object>
+                                    <packing>
+                                        <property name="pack-type">start</property>
+                                    </packing>
+                                </child>
+                                <child>
+                                    <object class="GtkLabel">
+                                        <property name="visible">True</property>
+                                        <property name="label" translatable="yes">Eat the treats before the 
other worms, but don't hit anything!</property>
+                                        <property name="valign">1</property> <!-- START -->
+                                        <style><class name="tip"/></style>
+                                    </object>
+                                    <packing>
+                                        <property name="pack-type">start</property>
+                                    </packing>
+                                </child>
+                                <child>
+                                    <object class="GtkButton" id="new_game_button">
+                                        <property name="visible">True</property>
+                                        <property name="use-underline">True</property>
+                                        <property name="label" translatable="yes">Let's _Play</property>
+                                        <property name="action-name">app.start-game</property>
+                                        <property name="halign">3</property>
+                                        <property name="valign">3</property>
+                                        <property name="width-request">140</property>
+                                        <property name="height-request">40</property>
+                                        <style>
+                                            <class name="suggested-action"/>
+                                            <class name="play"/>
+                                        </style>
+                                    </object>
+                                    <packing>
+                                        <property name="pack-type">end</property>
+                                    </packing>
+                                </child>
+                            </object>
+                            <packing>
+                                <property name="name">start_box</property>
+                            </packing>
+                        </child>
+                    </object> <!-- End of main_stack -->
+                    <packing>
+                        <property name="pack-type">end</property>
+                    </packing>
+                </child>
+            </object> <!-- End of vbox -->
+        </child>
+    </object> <!-- End of nibbles_app -->
+</interface>
diff --git a/src/gnome-nibbles.gresource.xml.in b/src/gnome-nibbles.gresource.xml.in
index c01dbcd..58a5401 100644
--- a/src/gnome-nibbles.gresource.xml.in
+++ b/src/gnome-nibbles.gresource.xml.in
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/nibbles/ui">
-    <file preprocess="xml-stripblanks" alias="gnome-nibbles.ui">@top_srcdir@/data/gnome-nibbles.ui</file>
+    <file preprocess="xml-stripblanks" alias="nibbles.ui">@top_srcdir@/data/nibbles.ui</file>
+    <file alias="nibbles.css">@top_srcdir@/data/nibbles.css</file>
   </gresource>
 </gresources>
+
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index ca7ec9b..36ddaaa 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -72,6 +72,10 @@ public class Nibbles : Gtk.Application
     {
         base.startup ();
 
+        var css_provider = new Gtk.CssProvider ();
+        css_provider.load_from_resource ("/org/gnome/nibbles/ui/nibbles.css");
+        Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, 
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
         add_action_entries (action_entries, this);
 
         settings = new Settings ("org.gnome.nibbles");
@@ -84,11 +88,13 @@ public class Nibbles : Gtk.Application
 
         set_accels_for_action ("app.quit", {"<Primary>q"});
 
-        var builder = new Gtk.Builder.from_resource ("/org/gnome/nibbles/ui/gnome-nibbles.ui");
+        var builder = new Gtk.Builder.from_resource ("/org/gnome/nibbles/ui/nibbles.ui");
         window = builder.get_object ("nibbles-window") as Gtk.ApplicationWindow;
         window.size_allocate.connect (size_allocate_cb);
         window.window_state_event.connect (window_state_event_cb);
         window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
+
+        var rgba = Gdk.RGBA () { red = 1, green = 1, blue = 1, alpha = 1 };
         if (settings.get_boolean ("window-is-maximized"))
             window.maximize ();
 
@@ -97,7 +103,6 @@ public class Nibbles : Gtk.Application
         window.set_titlebar (headerbar);
 
         add_window (window);
-        start_game_cb ();
     }
 
     protected override void activate ()
diff --git a/src/nibbles.gresource.xml b/src/nibbles.gresource.xml
index 96211f8..c3647cf 100644
--- a/src/nibbles.gresource.xml
+++ b/src/nibbles.gresource.xml
@@ -1,11 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <!-- <gresource prefix="/org/gnome/nibbles/ui">
+  <gresource prefix="/org/gnome/nibbles/ui">
     <file preprocess="xml-stripblanks" alias="nibbles.ui">../data/nibbles.ui</file>
     <file alias="nibbles.css">../data/nibbles.css</file>
-  </gresource> -->
-  <gresource prefix="/org/gnome/nibbles/gtk">
-    <file preprocess="xml-stripblanks" alias="menus.ui">../data/nibbles-menus.ui</file>
   </gresource>
 </gresources>
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]