[five-or-more/vala-port] More porting
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [five-or-more/vala-port] More porting
- Date: Sun, 4 Nov 2012 22:44:42 +0000 (UTC)
commit c1a195481d3615d16841504251e82e8d6bdc88d5
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Sun Nov 4 23:44:23 2012 +0100
More porting
data/org.gnome.five-or-more.gschema.xml.in | 21 +-
src/Makefile.am | 22 +-
src/application.vala | 58 ++-
src/games-score.c | 191 ---------
src/games-score.h | 70 ----
src/games-scores-backend.c | 352 ----------------
src/games-scores-backend.h | 67 ---
src/games-scores-dialog.c | 610 ----------------------------
src/games-scores-dialog.h | 81 ----
src/games-scores.c | 525 ------------------------
src/games-scores.h | 92 -----
src/games-setgid-io.c | 558 -------------------------
src/games-setgid-io.h | 38 --
13 files changed, 45 insertions(+), 2640 deletions(-)
---
diff --git a/data/org.gnome.five-or-more.gschema.xml.in b/data/org.gnome.five-or-more.gschema.xml.in
index 1cda033..1e2ae01 100644
--- a/data/org.gnome.five-or-more.gschema.xml.in
+++ b/data/org.gnome.five-or-more.gschema.xml.in
@@ -1,9 +1,9 @@
<schemalist>
<schema id="org.gnome.five-or-more" path="/org/gnome/five-or-more/" gettext-domain="gnome-games">
- <key name="size" type="i">
- <default>2</default>
+ <key name="size" type="s">
+ <default>'Small'</default>
<_summary>Playing field size</_summary>
- <_description>Playing field size. 1=Small, 2=Medium, 3=Large. Any other value is invalid.</_description>
+ <_description>Playing field size. Small, Medium, Large.</_description>
</key>
<key name="ball-theme" type="s">
<default>'balls.svg'</default>
@@ -20,21 +20,6 @@
<_summary>Time between moves</_summary>
<_description>Time between moves in milliseconds.</_description>
</key>
- <key name="score" type="i">
- <default>0</default>
- <_summary>Game score</_summary>
- <_description>Game score from last saved session.</_description>
- </key>
- <key name="field" type="s">
- <default>''</default>
- <_summary>Game field</_summary>
- <_description>Game field from last saved session.</_description>
- </key>
- <key name="preview" type="s">
- <default>''</default>
- <_summary>Game preview</_summary>
- <_description>Game preview from last saved session.</_description>
- </key>
<key name="window-width" type="i">
<default>600</default>
<_summary>Width of the window in pixels</_summary>
diff --git a/src/Makefile.am b/src/Makefile.am
index 58f7cc1..2252504 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,14 +9,6 @@ five_or_more_SOURCES = \
games-gridframe.h \
games-preimage.c \
games-preimage.h \
- games-score.h \
- games-score.c \
- games-scores.c \
- games-scores.h \
- games-scores-dialog.c \
- games-scores-dialog.h \
- games-scores-backend.c \
- games-scores-backend.h \
games-stock.c \
games-stock.h \
config.vapi \
@@ -24,18 +16,14 @@ five_or_more_SOURCES = \
application.vala \
board.vala \
field.vala \
+ history.vala \
piece.vala \
preview-queue.vala \
+ score-dialog.vala \
view-2d.vala \
view-cli.vala \
$(BUILT_SOURCES)
-if ENABLE_SETGID
-five_or_more_SOURCES += \
- games-setgid-io.c \
- games-setgid-io.h
-endif # ENABLE_SETGID
-
five_or_more_CPPFLAGS = \
-I$(top_srcdir) \
$(AM_CPPFLAGS)
@@ -45,7 +33,6 @@ five_or_more_CFLAGS = \
-DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
-DDATA_DIRECTORY=\"$(datadir)/five-or-more\" \
-DICON_THEME_DIRECTORY="\"$(datadir)/icons\"" \
- -DSCORESDIR="\"$(scoredir)\"" \
$(FIVE_OR_MORE_CFLAGS)
five_or_more_LDADD = \
@@ -63,9 +50,4 @@ five-or-more-resources.c: five-or-more.gresource.xml $(shell $(GLIB_COMPILE_RESO
EXTRA_DIST = \
five-or-more.gresource.xml
-install-exec-hook:
- -if test "$(setgid)" = "true"; then \
- chgrp $(scores_group) $(DESTDIR)$(bindir)/five-or-more && chmod 2555 $(DESTDIR)$(bindir)/five-or-more ;\
- fi
-
-include $(top_srcdir)/git.mk
diff --git a/src/application.vala b/src/application.vala
index c485e20..8da708a 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -5,7 +5,9 @@ namespace FiveOrMore
private Gtk.ApplicationWindow window;
private Settings settings;
private Gtk.Builder builder;
- //private GnomeGamesSupport.Scores highscores;
+ private History history;
+ private Size[] sizes;
+ private GlinesBoard board;
private Gtk.Dialog preferences_dialog;
@@ -18,19 +20,10 @@ namespace FiveOrMore
{ "about", about_cb },
{ "quit", quit_cb }
};
-
- //private const GnomeGamesSupport.ScoresCategory scorecats[] =
- //{
- // { "Small", NC_("board size", "Small") },
- // { "Medium", NC_("board size", "Medium") },
- // { "Large", NC_("board size", "Large") }
- //};
private const string[] authors = { "Thomas Andersen <phomes gmail com>", "Robert Szokovacs <szo appaloosacorp hu>", "Szabolcs B\xc3\xa1n <shooby gnome hu>" };
//private const string[] documenters = { "Tiffany Antopolski", "Lanka Rathnayaka" };
- private GlinesBoard board = new GlinesBoard(10, 10, 5, 3);
-
public FiveOrMoreApp ()
{
Object (application_id: "org.gnome.five-or-more", flags: ApplicationFlags.FLAGS_NONE);
@@ -44,8 +37,6 @@ namespace FiveOrMore
settings = new Settings ("org.gnome.five-or-more");
- //highscores = new GnomeGamesSupport.Scores ("glines", scorecats, "board size", null, 0, GnomeGamesSupport.ScoreStyle.PLAIN_DESCENDING);
-
builder = new Gtk.Builder ();
try
{
@@ -57,6 +48,11 @@ namespace FiveOrMore
GLib.warning ("Could not load UI: %s", e.message);
}
+ sizes = new Size[3];
+ sizes[0] = { "small", _("Small"), 7, 7, 5, 3 };
+ sizes[1] = { "medium", _("Medium"), 9, 9, 7, 3 };
+ sizes[2] = { "large", _("Large"), 20, 15, 7, 7 };
+
var menu = new Menu ();
var section = new Menu ();
@@ -75,6 +71,9 @@ namespace FiveOrMore
section.append (_("_Quit"), "app.quit");
set_app_menu (menu);
+ var size = get_current_size ();
+ board = new GlinesBoard(size.columns, size.rows, size.ncolors, size.npieces);
+
var box = (Gtk.Box) builder.get_object ("vbox");
var view2d = new View2D (board);
box.add (view2d);
@@ -82,6 +81,9 @@ namespace FiveOrMore
window = (Gtk.ApplicationWindow) builder.get_object ("glines_window");
add_window (window);
+
+ history = new History (Path.build_filename (Environment.get_user_data_dir (), "five-or-more", "history"));
+ history.load ();
}
public override void activate ()
@@ -99,12 +101,12 @@ namespace FiveOrMore
private void scores_cb ()
{
- stdout.printf ("FIXME: Showing scores does not currently work\n");
+ var dialog = new ScoreDialog (history);
+ dialog.modal = true;
+ dialog.transient_for = window;
- //var scores_dialog = new GnomeGamesSupport.ScoresDialog (window, highscores, _("GNOME Five or More"));
- //scores_dialog.set_category_description (_("_Board size:"));
- //scores_dialog.run ();
- //scores_dialog.destroy ();
+ dialog.run ();
+ dialog.destroy ();
}
private void preferences_cb ()
@@ -151,7 +153,27 @@ namespace FiveOrMore
{
window.destroy ();
}
+
+ private Size get_current_size ()
+ {
+ var id = settings.get_string ("size");
+ for (var i = 0; i < sizes.length; i++)
+ {
+ if (sizes[i].id == id)
+ return sizes[i];
+ }
+
+ return sizes[0];
+ }
}
}
-
+public struct Size
+{
+ public string id;
+ public string name;
+ public int columns;
+ public int rows;
+ public int ncolors;
+ public int npieces;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]