[gnome-games] swell-foop: Use GSettings
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] swell-foop: Use GSettings
- Date: Wed, 11 Jan 2012 13:58:14 +0000 (UTC)
commit 15e3154198a5958a6a71f851abe7b33c3aeb3f26
Author: Robert Ancell <robert ancell canonical com>
Date: Wed Jan 11 14:58:06 2012 +0100
swell-foop: Use GSettings
swell-foop/data/Makefile.am | 28 +++-------
.../data/org.gnome.swell-foop.gschema.xml.in | 24 +++++++++
swell-foop/data/swell-foop.schemas.in | 54 --------------------
swell-foop/src/Settings.js | 53 ++++---------------
4 files changed, 43 insertions(+), 116 deletions(-)
---
diff --git a/swell-foop/data/Makefile.am b/swell-foop/data/Makefile.am
index 70f381b..80f24a0 100644
--- a/swell-foop/data/Makefile.am
+++ b/swell-foop/data/Makefile.am
@@ -1,16 +1,15 @@
SUBDIRS = icons themes
+gsettings_in_file = org.gnome.swell-foop.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
swelldir=$(pkgdatadir)/swell-foop
swell_DATA = \
swell-foop.ui \
settings.ui
-schema_in_files = swell-foop.schemas.in
-if HAVE_GNOME
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-endif
-
desktop_in_files = swell-foop.desktop.in.in
desktopdir = $(datadir)/applications
desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
@@ -18,27 +17,16 @@ desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
EXTRA_DIST = \
$(swell_DATA) \
- $(schema_in_files) \
+ $(gsettings_in_file) \
$(desktop_in_files)
-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
-
-install-data-local: install-schemas-local
-
CLEANFILES = \
$(desktop_DATA) \
- $(schema_DATA)
+ $(gsettings_SCHEMAS)
DISTCLEANFILES = \
$(desktop_DATA) \
- $(schema_DATA)
+ $(gsettings_SCHEMAS)
@INTLTOOL_SCHEMAS_RULE@
diff --git a/swell-foop/data/org.gnome.swell-foop.gschema.xml.in b/swell-foop/data/org.gnome.swell-foop.gschema.xml.in
new file mode 100644
index 0000000..539d655
--- /dev/null
+++ b/swell-foop/data/org.gnome.swell-foop.gschema.xml.in
@@ -0,0 +1,24 @@
+<schemalist>
+ <schema id="org.gnome.swell-foop" path="/org/gnome/swell-foop/" gettext-domain="gnome-games">
+ <key name="theme" type="s">
+ <default>'Shapes and Colors'</default>
+ <_summary>The theme to use</_summary>
+ <_description>The title of the tile theme to use.</_description>
+ </key>
+ <key name="size" type="i">
+ <default>1</default>
+ <_summary>Board size</_summary>
+ <_description>The size of the game board.</_description>
+ </key>
+ <key name="colors" type="i">
+ <default>3</default>
+ <_summary>Board color count</_summary>
+ <_description>The number of colors of tiles to use in the game.</_description>
+ </key>
+ <key name="zealous" type="b">
+ <default>true</default>
+ <_summary>Zealous animation</_summary>
+ <_description>Use more flashy, but slower, animations.</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/swell-foop/src/Settings.js b/swell-foop/src/Settings.js
index b60e13b..39b0a6f 100644
--- a/swell-foop/src/Settings.js
+++ b/swell-foop/src/Settings.js
@@ -4,7 +4,6 @@ GtkBuilder = imports.gtkbuilder;
main = imports.main;
ThemeLoader = imports.ThemeLoader;
GnomeGamesSupport = imports.gi.GnomeGamesSupport;
-ggsconf = GnomeGamesSupport.Conf;
_ = imports.gettext.gettext;
@@ -21,12 +20,14 @@ var sizes = [{name: _("Small"), columns: 6, rows: 5},
{name: _("Normal"), columns: 15, rows: 10},
{name: _("Large"), columns: 20, rows: 15}];
+settings = new Gio.Settings ({schema_id: "org.gnome.swell-foop"});
+
try
{
- theme = themes[ggsconf.get_string(null, "theme")];
- size = ggsconf.get_integer(null, "size");
- colors = ggsconf.get_integer(null, "colors");
- zealous = ggsconf.get_boolean(null, "zealous");
+ theme = themes[settings.get_string("theme")];
+ size = settings.get_int("size");
+ colors = settings.get_int("colors");
+ zealous = settings.get_boolean("zealous");
if(colors < 2 || colors > 4)
colors = default_colors;
@@ -36,7 +37,7 @@ try
}
catch(e)
{
- print("Couldn't load settings from ggsconf.");
+ print("Couldn't load settings: " + e.message);
theme = themes[default_theme];
size = default_size;
colors = default_colors;
@@ -70,29 +71,13 @@ handlers = {
theme = new_theme;
ThemeLoader.load_theme(main.stage, theme);
- try
- {
- ggsconf.set_string(null, "theme", selector.get_active_text());
- }
- catch(e)
- {
- print("Couldn't save settings to ggsconf.");
- }
-
+ settings.set_string("theme", selector.get_active_text());
Watcher.signal.theme_changed.emit();
},
set_zealous_animation: function(widget, ud)
{
zealous = widget.active;
-
- try
- {
- ggsconf.set_boolean(null, "zealous", zealous);
- }
- catch(e)
- {
- print("Couldn't save settings to ggsconf.");
- }
+ settings.set_boolean("zealous", zealous);
},
update_size: function(widget, ud)
{
@@ -103,15 +88,7 @@ handlers = {
size = new_size;
- try
- {
- ggsconf.set_integer(null, "size", size);
- }
- catch(e)
- {
- print("Couldn't save settings to ggsconf.");
- }
-
+ settings.set_int("size", size);
Watcher.signal.size_changed.emit();
},
update_colors: function(widget, ud)
@@ -123,15 +100,7 @@ handlers = {
colors = new_colors;
- try
- {
- ggsconf.set_integer(null, "colors", colors);
- }
- catch(e)
- {
- print("Couldn't save settings to ggsconf.");
- }
-
+ settings.set_int("colors", colors);
Watcher.signal.colors_changed.emit();
},
reset_defaults: function(widget, ud)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]