[gnome-tetravex] Start implementing the new design
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tetravex] Start implementing the new design
- Date: Wed, 9 Oct 2013 22:01:23 +0000 (UTC)
commit 4c11c1023a46f3d236c88c1679135e9681695c51
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Thu Oct 10 02:01:05 2013 +0200
Start implementing the new design
Adds a header bar and uses symbolic icons.
Design from:
https://raw.github.com/gnome-design-team/gnome-mockups/master/games/tetravex/tetravex.png
src/Makefile.am | 3 +-
src/app-menu.ui | 99 ++++++++++++++++++++++++++++++++++
src/gnome-tetravex.gresource.xml | 1 +
src/gnome-tetravex.ui | 110 +++++---------------------------------
src/gnome-tetravex.vala | 95 ++++++++++++---------------------
5 files changed, 150 insertions(+), 158 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index aadf0bb..2ea72c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,8 @@ gnome_tetravex_SOURCES = \
$(BUILT_SOURCES)
UI_FILES = \
- gnome-tetravex.ui
+ gnome-tetravex.ui \
+ app-menu.ui
gnome_tetravex_VALAFLAGS = \
--pkg posix \
diff --git a/src/app-menu.ui b/src/app-menu.ui
new file mode 100644
index 0000000..1a0b8ae
--- /dev/null
+++ b/src/app-menu.ui
@@ -0,0 +1,99 @@
+<interface>
+ <menu id="gnome-tetravex-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_New Game</attribute>
+ <attribute name="action">app.new-game</attribute>
+ <attribute name="accel"><Primary>n</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Pause</attribute>
+ <attribute name="action">app.pause</attribute>
+ <attribute name="accel">p</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Solve</attribute>
+ <attribute name="action">app.solve</attribute>
+ </item>
+ <submenu>
+ <attribute name="label" translatable="yes">_Move</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Up</attribute>
+ <attribute name="action">app.move-up</attribute>
+ <attribute name="accel"><Primary>Up</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Left</attribute>
+ <attribute name="action">app.move-left</attribute>
+ <attribute name="accel"><Primary>Left</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Right</attribute>
+ <attribute name="action">app.move-right</attribute>
+ <attribute name="accel"><Primary>Right</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Down</attribute>
+ <attribute name="action">app.move-down</attribute>
+ <attribute name="accel"><Primary>Down</attribute>
+ </item>
+ </section>
+ </submenu>
+ <item>
+ <attribute name="label" translatable="yes">_Scores</attribute>
+ <attribute name="action">app.scores</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">_Size</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_2x2</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">2</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_3x3</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">3</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_4x4</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">4</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_5x5</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">5</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_6x6</attribute>
+ <attribute name="action">app.size</attribute>
+ <attribute name="target">6</attribute>
+ </item>
+ </section>
+ </submenu>
+ </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>
+ </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/src/gnome-tetravex.gresource.xml b/src/gnome-tetravex.gresource.xml
index b03f1c2..caca0a0 100644
--- a/src/gnome-tetravex.gresource.xml
+++ b/src/gnome-tetravex.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/tetravex">
<file preprocess="xml-stripblanks">gnome-tetravex.ui</file>
+ <file preprocess="xml-stripblanks">app-menu.ui</file>
</gresource>
</gresources>
diff --git a/src/gnome-tetravex.ui b/src/gnome-tetravex.ui
index 1a0b8ae..57565ce 100644
--- a/src/gnome-tetravex.ui
+++ b/src/gnome-tetravex.ui
@@ -1,99 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.0 on Thu Oct 10 00:37:10 2013 -->
<interface>
- <menu id="gnome-tetravex-menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">_New Game</attribute>
- <attribute name="action">app.new-game</attribute>
- <attribute name="accel"><Primary>n</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Pause</attribute>
- <attribute name="action">app.pause</attribute>
- <attribute name="accel">p</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Solve</attribute>
- <attribute name="action">app.solve</attribute>
- </item>
- <submenu>
- <attribute name="label" translatable="yes">_Move</attribute>
- <section>
- <item>
- <attribute name="label" translatable="yes">_Up</attribute>
- <attribute name="action">app.move-up</attribute>
- <attribute name="accel"><Primary>Up</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Left</attribute>
- <attribute name="action">app.move-left</attribute>
- <attribute name="accel"><Primary>Left</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Right</attribute>
- <attribute name="action">app.move-right</attribute>
- <attribute name="accel"><Primary>Right</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_Down</attribute>
- <attribute name="action">app.move-down</attribute>
- <attribute name="accel"><Primary>Down</attribute>
- </item>
- </section>
- </submenu>
- <item>
- <attribute name="label" translatable="yes">_Scores</attribute>
- <attribute name="action">app.scores</attribute>
- </item>
- </section>
- <section>
- <submenu>
- <attribute name="label" translatable="yes">_Size</attribute>
- <section>
- <item>
- <attribute name="label" translatable="yes">_2x2</attribute>
- <attribute name="action">app.size</attribute>
- <attribute name="target">2</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_3x3</attribute>
- <attribute name="action">app.size</attribute>
- <attribute name="target">3</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_4x4</attribute>
- <attribute name="action">app.size</attribute>
- <attribute name="target">4</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_5x5</attribute>
- <attribute name="action">app.size</attribute>
- <attribute name="target">5</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">_6x6</attribute>
- <attribute name="action">app.size</attribute>
- <attribute name="target">6</attribute>
- </item>
- </section>
- </submenu>
- </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>
- </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-requires gtk+ 3.10 -->
+ <object class="GtkApplicationWindow" id="gnome-tetravex-window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Tetravex</property>
+ <child>
+ <object class="GtkGrid" id="grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/gnome-tetravex.vala b/src/gnome-tetravex.vala
index a39b4fe..fe77623 100644
--- a/src/gnome-tetravex.vala
+++ b/src/gnome-tetravex.vala
@@ -20,14 +20,14 @@ public class Tetravex : Gtk.Application
private PuzzleView view;
- private Gtk.Window window;
+ private Gtk.ApplicationWindow window;
private int window_width;
private int window_height;
private bool is_fullscreen;
private bool is_maximized;
- Gtk.ToolButton pause_button;
- Gtk.ToolButton fullscreen_button;
+ Gtk.Button pause_button;
+ Gtk.Button fullscreen_button;
private const GLib.ActionEntry[] action_entries =
{
@@ -69,11 +69,13 @@ public class Tetravex : Gtk.Application
try
{
builder.add_from_resource ("/org/gnome/tetravex/gnome-tetravex.ui");
+ builder.add_from_resource ("/org/gnome/tetravex/app-menu.ui");
}
catch (Error e)
{
error ("Unable to build menus: %s", e.message);
}
+
set_app_menu (builder.get_object ("gnome-tetravex-menu") as MenuModel);
settings = new Settings ("org.gnome.tetravex");
@@ -81,8 +83,8 @@ public class Tetravex : Gtk.Application
history = new History (Path.build_filename (Environment.get_user_data_dir (), "gnome-tetravex",
"history"));
history.load ();
- window = new Gtk.ApplicationWindow (this);
- window.title = _("Tetravex");
+ window = builder.get_object ("gnome-tetravex-window") as Gtk.ApplicationWindow;
+ this.add_window (window);
window.configure_event.connect (window_configure_event_cb);
window.window_state_event.connect (window_state_event_cb);
window.set_default_size (settings.get_int ("window-width"), settings.get_int ("window-height"));
@@ -93,68 +95,45 @@ public class Tetravex : Gtk.Application
(lookup_action ("size") as SimpleAction).set_state ("%d".printf (settings.get_int (KEY_GRID_SIZE)));
- var grid = new Gtk.Grid ();
- grid.show ();
- window.add (grid);
-
- var toolbar = new Gtk.Toolbar ();
- toolbar.show_arrow = false;
- toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
- toolbar.show ();
- grid.attach (toolbar, 0, 0, 1, 1);
-
- var new_game_button = new Gtk.ToolButton (null, _("_New"));
- new_game_button.use_underline = true;
- new_game_button.icon_name = "document-new";
- new_game_button.action_name = "app.new-game";
- new_game_button.is_important = true;
- new_game_button.show ();
- toolbar.insert (new_game_button, -1);
-
- var solve_button = new Gtk.ToolButton (null, _("Solve"));
- solve_button.action_name = "app.solve";
- solve_button.is_important = true;
- solve_button.show ();
- toolbar.insert (solve_button, -1);
-
- pause_button = new Gtk.ToolButton (null, _("_Pause"));
- pause_button.icon_name = "media-playback-pause";
- pause_button.use_underline = true;
- pause_button.action_name = "app.pause";
- pause_button.show ();
- toolbar.insert (pause_button, -1);
+ var headerbar = new Gtk.HeaderBar ();
+ headerbar.title = _("Tetravex");
+ headerbar.show_close_button = true;
+ headerbar.show ();
+ window.set_titlebar (headerbar);
- fullscreen_button = new Gtk.ToolButton (null, _("_Fullscreen"));
- fullscreen_button.icon_name = "view-fullscreen";
- fullscreen_button.use_underline = true;
+ fullscreen_button = new Gtk.Button.from_icon_name ("view-fullscreen-symbolic", Gtk.IconSize.BUTTON);
fullscreen_button.action_name = "app.fullscreen";
fullscreen_button.show ();
- toolbar.insert (fullscreen_button, -1);
+ headerbar.pack_start (fullscreen_button);
+
+ var grid = builder.get_object ("grid") as Gtk.Grid;
view = new PuzzleView ();
view.hexpand = true;
view.vexpand = true;
view.button_press_event.connect (view_button_press_event);
view.show ();
- grid.attach (view, 0, 1, 1, 1);
+ grid.attach (view, 0, 0, 3, 1);
- var time_item = new Gtk.ToolItem ();
- time_item.set_expand (true);
- time_item.show ();
- toolbar.insert (time_item, -1);
+ var new_game_button = new Gtk.Button.from_icon_name ("view-refresh-symbolic", Gtk.IconSize.BUTTON);
+ new_game_button.action_name = "app.new-game";
+ new_game_button.show ();
+ grid.attach (new_game_button, 0, 1, 1, 1);
- var time_align = new Gtk.Alignment (1.0f, 0.5f, 0.0f, 0.0f);
- time_align.show ();
- time_item.add (time_align);
+ pause_button = new Gtk.Button.from_icon_name ("media-playback-pause-symbolic", Gtk.IconSize.BUTTON);
+ pause_button.action_name = "app.pause";
+ pause_button.show ();
+ grid.attach (pause_button, 1, 1, 1, 1);
- var time_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- time_box.show ();
- time_align.add (time_box);
+ var solve_button = new Gtk.Button.from_icon_name ("dialog-question-symbolic", Gtk.IconSize.BUTTON);
+ solve_button.action_name = "app.solve";
+ solve_button.show ();
+ grid.attach (solve_button, 2, 1, 1, 1);
clock_label = new Gtk.Label ("");
clock_label.show ();
- time_box.pack_start (clock_label, false, false, 0);
tick_cb ();
+ grid.attach (clock_label, 1, 2, 1, 1);
new_game ();
}
@@ -179,13 +158,11 @@ public class Tetravex : Gtk.Application
is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
if (is_fullscreen)
{
- fullscreen_button.label = _("_Leave Fullscreen");
- fullscreen_button.icon_name = "view-restore";
+ fullscreen_button.image = new Gtk.Image.from_icon_name ("view-restore-symbolic",
Gtk.IconSize.BUTTON);
}
else
{
- fullscreen_button.label = _("_Fullscreen");
- fullscreen_button.icon_name = "view-fullscreen";
+ fullscreen_button.image = new Gtk.Image.from_icon_name ("view-fullscreen-symbolic",
Gtk.IconSize.BUTTON);
}
}
return false;
@@ -231,7 +208,7 @@ public class Tetravex : Gtk.Application
var hours = elapsed / 3600;
var minutes = (elapsed - hours * 3600) / 60;
var seconds = elapsed - hours * 3600 - minutes * 60;
- clock_label.set_text ("%s: %02d:%02d:%02d".printf (_("Time"), hours, minutes, seconds));
+ clock_label.set_text ("%02d:%02d:%02d".printf (hours, minutes, seconds));
}
private void solved_cb (Puzzle puzzle)
@@ -365,13 +342,11 @@ public class Tetravex : Gtk.Application
solve.set_enabled (!puzzle.paused);
if (puzzle.paused)
{
- pause_button.icon_name = "media-playback-start";
- pause_button.label = _("Res_ume");
+ pause_button.image = new Gtk.Image.from_icon_name ("media-playback-start-symbolic",
Gtk.IconSize.BUTTON);
}
else
{
- pause_button.icon_name = "media-playback-pause";
- pause_button.label = _("_Pause");
+ pause_button.image = new Gtk.Image.from_icon_name ("media-playback-pause-symbolic",
Gtk.IconSize.BUTTON);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]