[gnome-games] gnotravex: port to GSettings
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnotravex: port to GSettings
- Date: Tue, 24 May 2011 22:35:54 +0000 (UTC)
commit 506933366ffe2448a557f571bffc7f4ee14e1f10
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Wed May 25 00:37:20 2011 +0200
gnotravex: port to GSettings
gnotravex/Makefile.am | 28 +++++++-----------------
gnotravex/gnotravex.c | 21 +++++++++---------
gnotravex/gnotravex.schemas.in | 29 --------------------------
gnotravex/org.gnome.gnotravex.gschema.xml.in | 15 +++++++++++++
po/POTFILES.in | 2 +-
5 files changed, 35 insertions(+), 60 deletions(-)
---
diff --git a/gnotravex/Makefile.am b/gnotravex/Makefile.am
index 3ed7169..b0c65ff 100644
--- a/gnotravex/Makefile.am
+++ b/gnotravex/Makefile.am
@@ -46,33 +46,21 @@ desktopdir = $(datadir)/applications
desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schema_in_files = gnotravex.schemas.in
-if HAVE_GNOME
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-endif
-
- INTLTOOL_SCHEMAS_RULE@
+gsettings_in_file = org.gnome.gnotravex.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
man_MANS = gnotravex.6
EXTRA_DIST = \
README \
- $(schema_in_files) \
+ $(gsettings_in_file) \
$(man_MANS) \
$(NULL)
-CLEANFILES = $(desktop_DATA) $(schema_DATA)
-DISTCLEANFILES = $(desktop_DATA) $(schema_DATA)
-
-install-schemas-local: $(schema_DATA)
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $^ ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p 2>&1 > /dev/null; \
- done \
- fi
-endif
+CLEANFILES = $(desktop_DATA) $(gsettings_SCHEMAS)
+DISTCLEANFILES = $(desktop_DATA) $(gsettings_SCHEMAS)
SCOREFILES = 2 3 4 5 6
@@ -89,6 +77,6 @@ install-exec-hook:
chgrp $(scores_group) $(DESTDIR)$(bindir)/gnotravex && chmod 2555 $(DESTDIR)$(bindir)/gnotravex ;\
fi
-install-data-local: install-schemas-local install-scorefiles-local
+install-data-local: install-scorefiles-local
-include $(top_srcdir)/git.mk
diff --git a/gnotravex/gnotravex.c b/gnotravex/gnotravex.c
index ea46293..1369a69 100644
--- a/gnotravex/gnotravex.c
+++ b/gnotravex/gnotravex.c
@@ -28,11 +28,11 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgames-support/games-clock.h>
-#include <libgames-support/games-conf.h>
#include <libgames-support/games-help.h>
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
#include <libgames-support/games-runtime.h>
+#include <libgames-support/games-settings.h>
#include <libgames-support/games-stock.h>
#include <libgames-support/games-pause-action.h>
#include <libgames-support/games-fullscreen-action.h>
@@ -54,8 +54,8 @@
#define SHORT_COUNT 5
#define DELAY 10
-#define KEY_GRID_SIZE "grid_size"
-#define KEY_CLICK_MOVE "click_to_move"
+#define KEY_GRID_SIZE "grid-size"
+#define KEY_CLICK_MOVE "click-to-move"
#define DEFAULT_WIDTH 320
#define DEFAULT_HEIGHT 240
@@ -95,6 +95,7 @@ typedef enum
PLAYING,
} GameState;
+static GSettings *settings;
static GtkWidget *window = NULL;
static GtkWidget *statusbar = NULL;
static GtkWidget *space = NULL;
@@ -998,7 +999,7 @@ create_window (void)
gtk_window_set_title (GTK_WINDOW (window), _(APPNAME_LONG));
gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- games_conf_add_window (GTK_WINDOW (window), NULL);
+ games_settings_bind_window_state ("/org/gnome/gnotravex/", GTK_WINDOW (window));
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_widget_realize (window);
@@ -1636,7 +1637,7 @@ size_cb (GtkAction * action, gpointer data)
size = newsize;
update_tile_size (width, height);
games_scores_set_category (highscores, scorecats[size - 2].key);
- games_conf_set_integer (NULL, KEY_GRID_SIZE, size);
+ g_settings_set_int (settings, KEY_GRID_SIZE, size);
gtk_action_activate (new_game_action);
}
@@ -1644,7 +1645,7 @@ static void
clickmove_toggle_cb(GtkToggleAction * togglebutton, gpointer data)
{
click_to_move = gtk_toggle_action_get_active (togglebutton);
- games_conf_set_boolean (NULL, KEY_CLICK_MOVE, click_to_move);
+ g_settings_set_boolean (settings, KEY_CLICK_MOVE, click_to_move);
}
static void
@@ -1809,7 +1810,7 @@ main (int argc, char **argv)
g_set_application_name (_(APPNAME_LONG));
- games_conf_initialise (APPNAME);
+ settings = g_settings_new ("org.gnome.gnotravex");
highscores = games_scores_new ("gnotravex",
scorecats, G_N_ELEMENTS (scorecats),
@@ -1830,12 +1831,12 @@ main (int argc, char **argv)
#endif /* WITH_SMCLIENT */
if (size == -1)
- size = games_conf_get_integer (NULL, KEY_GRID_SIZE, NULL);
+ size = g_settings_get_int (settings, KEY_GRID_SIZE);
if (size < 2 || size > 6)
size = 3;
games_scores_set_category (highscores, scorecats[size - 2].key);
- click_to_move = games_conf_get_boolean (NULL, KEY_CLICK_MOVE, NULL);
+ click_to_move = g_settings_get_boolean (settings, KEY_CLICK_MOVE);
load_background ();
create_window ();
@@ -1893,7 +1894,7 @@ main (int argc, char **argv)
gtk_main ();
- games_conf_shutdown ();
+ g_settings_sync();
games_runtime_shutdown ();
diff --git a/gnotravex/org.gnome.gnotravex.gschema.xml.in b/gnotravex/org.gnome.gnotravex.gschema.xml.in
new file mode 100644
index 0000000..8ac6c7a
--- /dev/null
+++ b/gnotravex/org.gnome.gnotravex.gschema.xml.in
@@ -0,0 +1,15 @@
+<schemalist>
+ <schema id="org.gnome.gnotravex" path="/org/gnome/gnotravex/" gettext-domain="gnome-games">
+ <key name="grid-size" type="i">
+ <default>3</default>
+ <range min="2" max="6" />
+ <_summary>The size of the playing grid</_summary>
+ <_description>The value of this key is used to decide the size of the playing grid.</_description>
+ </key>
+ <key name="click-to-move" type="b">
+ <default>false</default>
+ <_summary>Select the style of control</_summary>
+ <_description>Select whether to drag the tiles or to click on the source then the destination.</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 72635f1..0c01245 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -86,7 +86,7 @@ gnomine/gnomine.schemas.in
gnomine/minefield.c
gnotravex/gnotravex.c
gnotravex/gnotravex.desktop.in.in
-gnotravex/gnotravex.schemas.in
+gnotravex/org.gnome.gnotravex.gschema.xml.in
gnotski/gnotski.c
gnotski/gnotski.desktop.in.in
gnotski/gnotski.schemas.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]