[gnome-games] gnobots2: Use gsettings
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] gnobots2: Use gsettings
- Date: Tue, 3 Jan 2012 02:23:31 +0000 (UTC)
commit 996b1f7b45415afa98fd5bbab295fdcd70cc250f
Author: Thomas Hindoe Paaboel Andersen <phomes gmail com>
Date: Tue Jan 3 03:22:02 2012 +0100
gnobots2: Use gsettings
based on patch by Marc Ruiz
GNOME Bug #625904
gnobots2/data/Makefile.am | 18 +--
gnobots2/data/gnobots2.schemas.in | 236 -----------------------
gnobots2/data/org.gnome.gnobots2.gschema.xml.in | 120 ++++++++++++
gnobots2/src/gnobots.c | 9 +-
gnobots2/src/gnobots.h | 1 +
gnobots2/src/properties.c | 65 +++----
po/POTFILES.in | 2 +-
7 files changed, 163 insertions(+), 288 deletions(-)
---
diff --git a/gnobots2/data/Makefile.am b/gnobots2/data/Makefile.am
index 89a207b..b3b94b1 100644
--- a/gnobots2/data/Makefile.am
+++ b/gnobots2/data/Makefile.am
@@ -1,10 +1,9 @@
SUBDIRS = icons
-schema_in_files = gnobots2.schemas.in
-if HAVE_GNOME
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-endif
+gsettings_in_file = org.gnome.gnobots2.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
@INTLTOOL_SCHEMAS_RULE@
@@ -49,14 +48,9 @@ EXTRA_DIST = $(cursor_files) \
$(theme_DATA) \
$(Games_DATA) \
$(config_DATA) \
- $(schema_in_files) \
+ $(gsettings_in_files) \
$(man_MANS)
-install-data-local:
-if GCONF_SCHEMAS_INSTALL
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/gnobots2/data/$(schema_DATA)
-endif
-
-DISTCLEANFILES = $(Games_DATA) $(schema_DATA)
+DISTCLEANFILES = $(Games_DATA) $(gsettings_DATA)
-include $(top_srcdir)/git.mk
diff --git a/gnobots2/data/org.gnome.gnobots2.gschema.xml.in b/gnobots2/data/org.gnome.gnobots2.gschema.xml.in
new file mode 100644
index 0000000..861bb7b
--- /dev/null
+++ b/gnobots2/data/org.gnome.gnobots2.gschema.xml.in
@@ -0,0 +1,120 @@
+<schemalist>
+ <schema id="org.gnome.gnobots2" path="/org/gnome/gnobots2/" gettext-domain="gnome-games">
+
+ <key name="show-toolbar" type="b">
+ <default>true</default>
+ <_summary>Show toolbar</_summary>
+ <_description>Show toolbar. A standard option for toolbars.</_description>
+ </key>
+
+ <key name="theme" type="s">
+ <default>"robots"</default>
+ <_summary>Robot image theme</_summary>
+ <_description>Robot image theme. The theme of the images to use for the robots.</_description>
+ </key>
+
+ <key name="background-color" type="s">
+ <default>"#7590AE"</default>
+ <_summary>Background color</_summary>
+ <_description>Background color. The hex specification of the background color.</_description>
+ </key>
+
+ <key name="configuration" type="s">
+ <default>"classic_robots"</default>
+ <_summary>Game type</_summary>
+ <_description>Game type. The name of the game variation to use.</_description>
+ </key>
+
+ <key name="use-safe-moves" type="b">
+ <default>true</default>
+ <_summary>Use safe moves</_summary>
+ <_description>Use safe moves. The safe moves option will help you to avoid being killed due to a mistake. If you try to make a move that would lead to your death when there is a safe move available you will not be allowed to proceed.</_description>
+ </key>
+
+ <key name="use-super-safe-moves" type="b">
+ <default>true</default>
+ <_summary>Use super safe moves</_summary>
+ <_description>Use super safe moves. The player is alerted when there is no safe move and the only option is to teleport out.</_description>
+ </key>
+
+ <key name="enable-sound" type="b">
+ <default>true</default>
+ <_summary>Enable game sounds</_summary>
+ <_description>Enable game sounds. Play sounds for various events throughout the game.</_description>
+ </key>
+
+
+ <key name="key00" type="i">
+ <default>65429</default>
+ <_summary>Key to move NW</_summary>
+ <_description>The key used to move north-west.</_description>
+ </key>
+
+ <key name="key01" type="i">
+ <default>65431</default>
+ <_summary>Key to move N</_summary>
+ <_description>The key used to move north.</_description>
+ </key>
+
+ <key name="key02" type="i">
+ <default>65434</default>
+ <_summary>Key to move NE</_summary>
+ <_description>The key used to move north-east.</_description>
+ </key>
+
+ <key name="key03" type="i">
+ <default>65430</default>
+ <_summary>Key to move W</_summary>
+ <_description>The key used to move west.</_description>
+ </key>
+
+ <key name="key04" type="i">
+ <default>65437</default>
+ <_summary>Key to hold</_summary>
+ <_description>The key used to hold still.</_description>
+ </key>
+
+ <key name="key05" type="i">
+ <default>65432</default>
+ <_summary>Key to move E</_summary>
+ <_description>The key used to move east.</_description>
+ </key>
+
+ <key name="key06" type="i">
+ <default>65436</default>
+ <_summary>Key to move SW</_summary>
+ <_description>The key used to move south-west.</_description>
+ </key>
+
+ <key name="key07" type="i">
+ <default>65433</default>
+ <_summary>Key to move S</_summary>
+ <_description>The key used to move south.</_description>
+ </key>
+
+ <key name="key08" type="i">
+ <default>65435</default>
+ <_summary>Key to move SE</_summary>
+ <_description>The key used to move south-east.</_description>
+ </key>
+
+ <key name="key09" type="i">
+ <default>65451</default>
+ <_summary>Key to teleport</_summary>
+ <_description>The key used to teleport safely (if possible).</_description>
+ </key>
+
+ <key name="key10" type="i">
+ <default>65450</default>
+ <_summary>Key to teleport randomly</_summary>
+ <_description>The key used to teleport randomly.</_description>
+ </key>
+
+ <key name="key11" type="i">
+ <default>65421</default>
+ <_summary>Key to wait</_summary>
+ <_description>The key used to wait.</_description>
+ </key>
+
+ </schema>
+</schemalist>
diff --git a/gnobots2/src/gnobots.c b/gnobots2/src/gnobots.c
index ee150a7..7c00bcd 100644
--- a/gnobots2/src/gnobots.c
+++ b/gnobots2/src/gnobots.c
@@ -28,10 +28,10 @@
#include <glib/gi18n.h>
#include <glib.h>
-#include <libgames-support/games-conf.h>
#include <libgames-support/games-gridframe.h>
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
+#include <libgames-support/games-settings.h>
#include <libgames-support/games-stock.h>
#include "gbdefs.h"
@@ -59,6 +59,7 @@
GtkWidget *app = NULL;
GtkWidget *game_area = NULL;
GamesScores *highscores;
+GSettings *settings;
/**********************************************************************/
@@ -167,7 +168,7 @@ main (int argc, char *argv[])
0 /* default category */,
GAMES_SCORES_STYLE_PLAIN_DESCENDING);
- games_conf_initialise ("Gnobots2");
+ settings = g_settings_new ("org.gnome.gnobots2");
gtk_window_set_default_icon_name ("gnobots2");
@@ -175,7 +176,7 @@ main (int argc, char *argv[])
gtk_window_set_title (GTK_WINDOW (app), _("Robots"));
gtk_window_set_default_size (GTK_WINDOW (app), DEFAULT_WIDTH, DEFAULT_HEIGHT);
- games_conf_add_window (GTK_WINDOW (app), KEY_GEOMETRY_GROUP);
+ games_settings_bind_window_state ("/org/gnome/gnobots2/", GTK_WINDOW (app));
g_signal_connect (G_OBJECT (app), "delete_event",
G_CALLBACK (quit_game), NULL);
@@ -284,7 +285,7 @@ main (int argc, char *argv[])
gtk_main ();
- games_conf_shutdown ();
+ g_settings_sync();
return 0;
}
diff --git a/gnobots2/src/gnobots.h b/gnobots2/src/gnobots.h
index 7e4fff4..d9da9a0 100644
--- a/gnobots2/src/gnobots.h
+++ b/gnobots2/src/gnobots.h
@@ -8,6 +8,7 @@
extern GtkWidget *app;
extern GtkWidget *game_area;
extern GamesScores *highscores;
+extern GSettings *settings;
/**********************************************************************/
diff --git a/gnobots2/src/properties.c b/gnobots2/src/properties.c
index bab3fbc..12d72dd 100644
--- a/gnobots2/src/properties.c
+++ b/gnobots2/src/properties.c
@@ -32,7 +32,7 @@
#include <libgames-support/games-file-list.h>
#include <libgames-support/games-scores.h>
#include <libgames-support/games-scores-dialog.h>
-#include <libgames-support/games-conf.h>
+#include <libgames-support/games-settings.h>
#include "properties.h"
#include "gameconfig.h"
@@ -52,12 +52,12 @@
#define KB_TEXT_HEIGHT 32
#define KEY_PREFERENCES_GROUP "preferences"
-#define KEY_BACKGROUND_COLOR "background_color"
+#define KEY_BACKGROUND_COLOR "background-color"
#define KEY_CONFIGURATION "configuration"
-#define KEY_ENABLE_SOUND "enable_sound"
-#define KEY_SAFE_MOVES "use_safe_moves"
-#define KEY_SHOW_TOOLBAR "show_toolbar"
-#define KEY_SUPER_SAFE_MOVES "use_super_safe_moves"
+#define KEY_ENABLE_SOUND "enable-sound"
+#define KEY_SAFE_MOVES "use-safe-moves"
+#define KEY_SHOW_TOOLBAR "show-toolbar"
+#define KEY_SUPER_SAFE_MOVES "use-super-safe-moves"
#define KEY_THEME "theme"
#define KEY_CONTROL_KEY "key%02d"
@@ -545,7 +545,7 @@ show_properties_dialog (void)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox);
- controls_list = games_controls_list_new (KEY_PREFERENCES_GROUP);
+ controls_list = games_controls_list_new_settings (settings);
games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list),
"key00", _("Key to move NW"), default_keys[0],
"key01", _("Key to move N"), default_keys[1],
@@ -603,16 +603,13 @@ load_properties (void)
load_keys ();
- bgcolour = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
- KEY_BACKGROUND_COLOR, "#7590AE");
+ bgcolour = g_settings_get_string (settings, KEY_BACKGROUND_COLOR);
gdk_color_parse (bgcolour, &properties.bgcolour);
set_background_color (properties.bgcolour);
- properties.themename = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
- KEY_THEME, "robots");
+ properties.themename = g_settings_get_string (settings, KEY_THEME);
- cname = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
- KEY_CONFIGURATION, "classic_robots");
+ cname = g_settings_get_string (settings, KEY_CONFIGURATION);
properties.selected_config = 0;
for (i = 0; i < num_game_configs (); ++i) {
@@ -626,15 +623,14 @@ load_properties (void)
}
g_free (cname);
- properties.safe_moves = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
- KEY_SAFE_MOVES, NULL);
- properties.super_safe_moves = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
- KEY_SUPER_SAFE_MOVES,
- NULL);
- properties.sound = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
- KEY_ENABLE_SOUND, NULL);
- properties.show_toolbar = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
- KEY_SHOW_TOOLBAR, NULL);
+ properties.safe_moves = g_settings_get_boolean (settings,
+ KEY_SAFE_MOVES);
+ properties.super_safe_moves = g_settings_get_boolean (settings,
+ KEY_SUPER_SAFE_MOVES);
+ properties.sound = g_settings_get_boolean (settings,
+ KEY_ENABLE_SOUND);
+ properties.show_toolbar = g_settings_get_boolean (settings,
+ KEY_SHOW_TOOLBAR);
set_game_graphics (properties.themename);
set_game_config (properties.selected_config);
@@ -649,19 +645,15 @@ load_keys (void)
gint i;
for (i = 0; i < 12; i++) {
- properties.keys[i] = default_keys[i];
-
g_snprintf (buffer, sizeof (buffer), KEY_CONTROL_KEY, i);
-
- properties.keys[i] = games_conf_get_keyval_with_default (KEY_PREFERENCES_GROUP,
- buffer, default_keys[i]);
+ properties.keys[i] = g_settings_get_int (settings, buffer);
}
}
void
conf_set_theme (gchar * value)
{
- games_conf_set_string (KEY_PREFERENCES_GROUP, KEY_THEME, value);
+ g_settings_set_string (settings, KEY_THEME, value);
}
static void
@@ -671,45 +663,48 @@ conf_set_background_color (GdkColor * c)
g_snprintf (colour, sizeof (colour), "#%04x%04x%04x", c->red, c->green, c->blue);
- games_conf_set_string (KEY_PREFERENCES_GROUP, KEY_BACKGROUND_COLOR, colour);
+ g_settings_set_string (settings, KEY_BACKGROUND_COLOR, colour);
}
void
conf_set_configuration (gchar * value)
{
- games_conf_set_string (KEY_PREFERENCES_GROUP, KEY_CONFIGURATION, value);
+ g_settings_set_string (settings, KEY_CONFIGURATION, value);
}
void
conf_set_use_safe_moves (gboolean value)
{
- games_conf_set_boolean (KEY_PREFERENCES_GROUP, KEY_SAFE_MOVES, value);
+ g_settings_set_boolean (settings, KEY_SAFE_MOVES, value);
}
void
conf_set_use_super_safe_moves (gboolean value)
{
- games_conf_set_boolean (KEY_PREFERENCES_GROUP, KEY_SUPER_SAFE_MOVES, value);
+ g_settings_set_boolean (settings, KEY_SUPER_SAFE_MOVES, value);
}
void
conf_set_enable_sound (gboolean value)
{
- games_conf_set_boolean (KEY_PREFERENCES_GROUP, KEY_ENABLE_SOUND, value);
+ g_settings_set_boolean (settings, KEY_ENABLE_SOUND, value);
}
void
conf_set_show_toolbar (gboolean value)
{
- games_conf_set_boolean (KEY_PREFERENCES_GROUP, KEY_SHOW_TOOLBAR, value);
+ g_settings_set_boolean (settings, KEY_SHOW_TOOLBAR, value);
}
void
conf_set_control_key (gint i, guint keyval)
{
char buffer[64];
+ gchar *keyval_name;
+
g_snprintf (buffer, sizeof (buffer), KEY_CONTROL_KEY, i);
- games_conf_set_keyval (KEY_PREFERENCES_GROUP, buffer, keyval);
+ keyval_name = gdk_keyval_name (keyval);
+ g_settings_set_string (settings, buffer, keyval_name);
}
/**
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2983ca3..045210c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -41,7 +41,7 @@ gnibbles/src/main.c
gnibbles/src/preferences.c
gnibbles/src/scoreboard.c
gnobots2/data/gnobots2.desktop.in.in
-gnobots2/data/gnobots2.schemas.in
+gnobots2/data/org.gnome.gnobots2.gschema.xml.in
gnobots2/src/game.c
gnobots2/src/gnobots.c
gnobots2/src/graphics.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]