[gnome-nibbles/arnaudb/modernize-code: 52/58] Split FirstRun.



commit 9c96caca56a45db330c67f536bdeea913c16f74e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Mon Jun 1 19:54:27 2020 +0200

    Split FirstRun.

 data/first-run.ui                | 90 ++++++++++++++++++++++++++++++++++++++++
 data/gnome-nibbles.gresource.xml |  1 +
 data/nibbles.ui                  | 73 +-------------------------------
 po/POTFILES.in                   |  1 +
 src/nibbles-window.vala          | 14 ++++++-
 5 files changed, 106 insertions(+), 73 deletions(-)
---
diff --git a/data/first-run.ui b/data/first-run.ui
new file mode 100644
index 0000000..b6bcbc9
--- /dev/null
+++ b/data/first-run.ui
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   This file is part of GNOME Nibbles.
+
+   Copyright (C) 2015-2016 Iulian Radu
+   Copyright (C) 2020 Arnaud Bonatti
+
+   GNOME Nibbles is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   GNOME Nibbles is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this GNOME Nibbles.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<interface>
+  <template class="FirstRun" parent="GtkBox">
+    <property name="orientation">vertical</property>
+    <property name="width-request">350</property>
+    <property name="height-request">350</property>
+    <child>
+      <object class="GtkButton">
+        <property name="visible">True</property>
+        <property name="use-underline">True</property>
+        <property name="label" translatable="yes">Let’s _Play</property>
+        <property name="action-name">win.show-new-game-screen</property>
+        <property name="halign">center</property>
+        <property name="valign">end</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>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="homogeneous">True</property>
+        <property name="valign">center</property>
+        <property name="vexpand">True</property>
+        <child>
+          <object class="GtkImage">
+            <property name="visible">True</property>
+            <property name="icon-name">org.gnome.Nibbles</property>
+            <property name="icon-size">6</property> <!-- DIALOG -->
+            <property name="pixel-size">96</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="menu-title"/></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">start</property>
+            <style><class name="tip"/></style>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+  </template>
+</interface>
diff --git a/data/gnome-nibbles.gresource.xml b/data/gnome-nibbles.gresource.xml
index 2464792..60b64d7 100644
--- a/data/gnome-nibbles.gresource.xml
+++ b/data/gnome-nibbles.gresource.xml
@@ -3,6 +3,7 @@
   <gresource prefix="/org/gnome/nibbles/ui">
     <file preprocess="xml-stripblanks"                  >controls.ui</file>
     <file preprocess="xml-stripblanks"                  >controls-grid.ui</file>
+    <file preprocess="xml-stripblanks" compressed="true">first-run.ui</file>
     <file>nibbles.css</file>
     <file preprocess="xml-stripblanks"                  >nibbles.ui</file>
     <file preprocess="xml-stripblanks"                  >players.ui</file>
diff --git a/data/nibbles.ui b/data/nibbles.ui
index 9200961..91aa5b4 100644
--- a/data/nibbles.ui
+++ b/data/nibbles.ui
@@ -106,79 +106,8 @@
                 <property name="homogeneous">True</property>
                 <property name="margin">25</property>
                 <property name="expand">True</property>
-                <property name="transition-type">5</property> <!-- SLIDE_UP -->
+                <property name="transition-type">slide-up</property>
                 <property name="transition-duration">500</property>
-                <child>
-                  <object class="GtkBox">
-                    <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="width-request">350</property>
-                    <property name="height-request">350</property>
-                    <child>
-                      <object class="GtkButton">
-                        <property name="visible">True</property>
-                        <property name="use-underline">True</property>
-                        <property name="label" translatable="yes">Let’s _Play</property>
-                        <property name="action-name">win.show-new-game-screen</property>
-                        <property name="halign">center</property>
-                        <property name="valign">end</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>
-                    <child>
-                      <object class="GtkBox">
-                        <property name="visible">True</property>
-                        <property name="orientation">vertical</property>
-                        <property name="homogeneous">True</property>
-                        <property name="valign">center</property>
-                        <property name="vexpand">True</property>
-                        <child>
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
-                            <property name="icon-name">org.gnome.Nibbles</property>
-                            <property name="icon-size">6</property> <!-- DIALOG -->
-                            <property name="pixel-size">96</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="menu-title"/></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>
-                      </object>
-                      <packing>
-                        <property name="pack-type">end</property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
                 <child>
                   <object class="Players" id="players">
                     <property name="visible">True</property>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b5e7a5f..33059c1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
 # Please keep this file in alphabetical order.
 data/controls.ui
 data/controls-grid.ui
+data/first-run.ui
 data/nibbles.ui
 data/org.gnome.Nibbles.appdata.xml.in
 data/org.gnome.Nibbles.desktop.in
diff --git a/src/nibbles-window.vala b/src/nibbles-window.vala
index 295b519..2841e73 100644
--- a/src/nibbles-window.vala
+++ b/src/nibbles-window.vala
@@ -160,7 +160,14 @@ private class NibblesWindow : ApplicationWindow
 
         /* Check whether to display the first run screen */
         var first_run = settings.get_boolean ("first-run");
-        if (!first_run)
+        if (first_run)
+        {
+            FirstRun first_run_panel = new FirstRun ();
+            first_run_panel.show ();
+            main_stack.add (first_run_panel);
+            main_stack.set_visible_child (first_run_panel);
+        }
+        else
             show_new_game_screen_cb ();
 
         /* Create scores */
@@ -821,3 +828,8 @@ private class NibblesWindow : ApplicationWindow
         back_action.set_enabled (false);
     }
 }
+
+[GtkTemplate (ui = "/org/gnome/nibbles/ui/first-run.ui")]
+private class FirstRun : Box
+{
+}


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