[gnome-chess/chess-telepathy-networking-support-664946-rebase: 43/64] [GSettings] Have more context specific schemas
- From: Chandni Verma <vchandni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/chess-telepathy-networking-support-664946-rebase: 43/64] [GSettings] Have more context specific schemas
- Date: Sun, 23 Dec 2012 03:42:14 +0000 (UTC)
commit 1339e6477e094c1eee1a8f0a6ab1229327666c4e
Author: Chandni Verma <chandniverma2112 gmail com>
Date: Sat Sep 8 13:33:04 2012 +0530
[GSettings] Have more context specific schemas
org.gnome.gnome-chess - general settings for whole module
org.gnome.gnome-chess.games-common - settings for each game instance
data/org.gnome.gnome-chess.gschema.xml.in | 206 ++++++++++++++++------------
src/chess-launcher.vala | 39 +++---
src/gnome-chess-application.vala | 68 +++++-----
src/gnome-chess-channel-handler.vala | 47 +++++++-
4 files changed, 220 insertions(+), 140 deletions(-)
---
diff --git a/data/org.gnome.gnome-chess.gschema.xml.in b/data/org.gnome.gnome-chess.gschema.xml.in
index 668ac50..7aaba38 100644
--- a/data/org.gnome.gnome-chess.gschema.xml.in
+++ b/data/org.gnome.gnome-chess.gschema.xml.in
@@ -1,4 +1,4 @@
-ï<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id="org.gnome.gnome-chess.PieceType">
<value value="0" nick="pawn"/>
@@ -30,136 +30,166 @@
<value value="2" nick="hard"/>
</enum>
- <schema id="org.gnome.gnome-chess.Settings" path="/org/gnome/gnome-chess/" gettext-domain="gnome-games">
- <key name="welcome-screen-width" type="i">
+ <schema path="/org/gnome/gnome-chess/" id="org.gnome.gnome-chess" gettext-domain="gnome-chess">
+ <key type="b" name="advertise-capability">
+ <default>false</default>
+ <summary>Advertise chess playing capability to online contacts</summary>
+ <description>Advertise chess playing capability to your online contacts.
+ You'll be able to accept incoming gaming requests whenever you get online.</description>
+ </key>
+ <key type="i" name="welcome-screen-width">
<default>600</default>
- <_summary>The width of welcome screen</_summary>
- <_description>The width of welcome screen in pixels.</_description>
+ <summary>The width of welcome screen</summary>
+ <description>The width of welcome screen in pixels.</description>
</key>
- <key name="welcome-screen-height" type="i">
+ <key type="i" name="welcome-screen-height">
<default>300</default>
- <_summary>The height of the welcome screen</_summary>
- <_description>The height of the welcome screen in pixels.</_description>
+ <summary>The height of the welcome screen</summary>
+ <description>The height of the welcome screen in pixels.</description>
</key>
- <key name="remote-player-selector-width" type="i">
+ <key type="i" name="remote-player-selector-width">
<default>600</default>
- <_summary>The width of the welcome screen</_summary>
- <_description>The width of the welcome screen in pixels.</_description>
+ <summary>The width of the welcome screen</summary>
+ <description>The width of the welcome screen in pixels.</description>
</key>
- <key name="remote-player-selector-height" type="i">
+ <key type="i" name="remote-player-selector-height">
<default>400</default>
- <_summary>The height of remote player selector screen</_summary>
- <_description>The height of remote player selector screen in pixels.</_description>
+ <summary>The height of remote player selector screen</summary>
+ <description>The height of remote player selector screen in pixels.</description>
</key>
- <key name="preferences-screen-width" type="i">
+ <key type="i" name="preferences-screen-width">
<default>600</default>
- <_summary>The width of preferences screen</_summary>
- <_description>The width of preferences screen in pixels.</_description>
+ <summary>The width of preferences screen</summary>
+ <description>The width of preferences screen in pixels.</description>
</key>
- <key name="preferences-screen-height" type="i">
+ <key type="i" name="preferences-screen-height">
<default>300</default>
- <_summary>The height of preferences screen</_summary>
- <_description>The height of preferences screen in pixels.</_description>
+ <summary>The height of preferences screen</summary>
+ <description>The height of preferences screen in pixels.</description>
</key>
- <key name="game-screen-width" type="i">
+ <key type="i" name="game-screen-width">
<default>500</default>
- <_summary>The width of the window</_summary>
- <_description>The width of the main window in pixels.</_description>
+ <summary>The width of window for gaming with a local player or a robot</summary>
+ <description>The width of window for gaming with a local player or a robot.</description>
</key>
- <key name="game-screen-height" type="i">
+ <key type="i" name="game-screen-height">
<default>550</default>
- <_summary>The height of the window</_summary>
- <_description>The height of the main window in pixels.</_description>
+ <summary>The height of the window</summary>
+ <description>The height of the main window in pixels.</description>
</key>
- <key name="maximized" type="b">
+ <key type="b" name="maximized">
<default>false</default>
- <_summary>A flag to enable maximized mode</_summary>
- <_description>A flag to enable maximized mode</_description>
+ <summary>A flag to enable maximized mode</summary>
+ <description>A flag to enable maximized mode</description>
</key>
- <key name="fullscreen" type="b">
+ <key type="b" name="fullscreen">
<default>false</default>
- <_summary>A flag to enable fullscreen mode</_summary>
- <_description>A flag to enable fullscreen mode</_description>
+ <summary>A flag to enable fullscreen mode</summary>
+ <description>A flag to enable fullscreen mode</description>
</key>
- <key name="show-3d" type="b">
+ <key type="i" name="network-window-width">
+ <default>500</default>
+ <summary>The width of window for gaming with a local player or a robot</summary>
+ <description>The width of window for gaming with a local player or a robot.</description>
+ </key>
+ <key type="i" name="network-window-height">
+ <default>550</default>
+ <summary>The height of the window</summary>
+ <description>The height of the main window in pixels.</description>
+ </key>
+ <key type="b" name="network-window-maximized">
+ <default>false</default>
+ <summary>A flag to enable maximized mode of channel-handler</summary>
+ <description>A flag to enable maximized mode of channel-handler</description>
+ </key>
+ <key type="b" name="network-window-fullscreen">
+ <default>false</default>
+ <summary>A flag to enable fullscreen mode of channel-handler</summary>
+ <description>A flag to enable fullscreen mode of channel-handler</description>
+ </key>
+ <child name="games-common" schema="org.gnome.gnome-chess.games-common"/>
+ </schema>
+
+ <schema path="/org/gnome/gnome-chess/games-common/" id="org.gnome.gnome-chess.games-common" gettext-domain="gnome-chess">
+ <key type="i" name="duration">
+ <default>0</default>
+ <summary>The duration of a game in seconds (0 for no limit)</summary>
+ <description>The duration of a game in seconds (0 for no limit)</description>
+ </key>
+ <key type="b" name="play-as-white">
+ <default>true</default>
+ <summary>true if the human player is playing white</summary>
+ <description>true if the human player is playing white</description>
+ </key>
+ <key type="s" name="opponent-type">
+ <default>'robot'</default>
+ <summary>The kind of opponent player</summary>
+ <description>Can be 'robot' to play against a chess engine, 'local-player' to play against a local player or 'remote-player' to play against a remote contact</description>
+ </key>
+ <key type="s" name="opponent">
+ <default>''</default>
+ <summary>The opponent player</summary>
+ <description>Can be 'human' (play against another human player), '' (use the first available chess engine), the name of a specific engine to play against or a string uniquely identifying a remote player</description>
+ </key>
+ <key name="difficulty" enum="org.gnome.gnome-chess.Difficulty">
+ <default>'easy'</default>
+ <summary>Difficulty of the opponent chess engine</summary>
+ <description>Difficulty of the opponent chess engine</description>
+ </key>
+ <key type="b" name="show-3d">
<default>false</default>
- <_summary>A flag to enable 3D mode</_summary>
- <_description>A flag to enable 3D mode</_description>
+ <summary>A flag to enable 3D mode</summary>
+ <description>A flag to enable 3D mode</description>
</key>
- <key name="show-3d-smooth" type="b">
+ <key type="b" name="show-3d-smooth">
<default>false</default>
- <_summary>A flag to smooth (anti-alias) the 3D display</_summary>
- <_description>A flag to smooth (anti-alias) the 3D display</_description>
+ <summary>A flag to smooth (anti-alias) the 3D display</summary>
+ <description>A flag to smooth (anti-alias) the 3D display</description>
</key>
- <key name="piece-theme" type="s">
+ <key type="s" name="piece-theme">
<default>'simple'</default>
- <_summary>The piece theme to use</_summary>
- <_description>The piece theme to use</_description>
+ <summary>The piece theme to use</summary>
+ <description>The piece theme to use</description>
</key>
- <key name="show-move-hints" type="b">
+ <key type="b" name="show-move-hints">
<default>true</default>
- <_summary>A flag to enable move hints</_summary>
- <_description>A flag to enable move hints</_description>
+ <summary>A flag to enable move hints</summary>
+ <description>A flag to enable move hints</description>
</key>
- <key name="show-numbering" type="b">
+ <key type="b" name="show-numbering">
<default>false</default>
- <_summary>A flag to enable board numbering</_summary>
- <_description>A flag to enable board numbering</_description>
+ <summary>A flag to enable board numbering</summary>
+ <description>A flag to enable board numbering</description>
</key>
- <key name="show-history" type="b">
+ <key type="b" name="show-history">
<default>true</default>
- <_summary>A flag to enable the move history browser</_summary>
- <_description>A flag to enable the move history browser</_description>
+ <summary>A flag to enable the move history browser</summary>
+ <description>A flag to enable the move history browser</description>
</key>
- <key name="show-toolbar" type="b">
+ <key type="b" name="show-toolbar">
<default>false</default>
- <_summary>A flag to enable the toolbar</_summary>
- <_description>A flag to enable the toolbar</_description>
+ <summary>A flag to enable the toolbar</summary>
+ <description>A flag to enable the toolbar</description>
</key>
- <key name="save-directory" type="s">
+ <key type="s" name="save-directory">
<default>''</default>
- <_summary>The directory to open the save game dialog in</_summary>
- <_description>The directory to open the save game dialog in</_description>
+ <summary>The directory to open the save game dialog in</summary>
+ <description>The directory to open the save game dialog in</description>
</key>
- <key name="load-directory" type="s">
+ <key type="s" name="load-directory">
<default>''</default>
- <_summary>The directory to open the load game dialog in</_summary>
- <_description>The directory to open the load game dialog in</_description>
+ <summary>The directory to open the load game dialog in</summary>
+ <description>The directory to open the load game dialog in</description>
</key>
<key name="move-format" enum="org.gnome.gnome-chess.MoveFormat">
<default>'human'</default>
- <_summary>The format to display moves in</_summary>
- <_description>The format to display moves in</_description>
+ <summary>The format to display moves in</summary>
+ <description>The format to display moves in</description>
</key>
<key name="board-side" enum="org.gnome.gnome-chess.BoardSide">
<default>'human'</default>
- <_summary>The side of the board that is in the foreground</_summary>
- <_description>The side of the board that is in the foreground</_description>
- </key>
- <key name="duration" type="i">
- <default>0</default>
- <_summary>The duration of a game in seconds (0 for no limit)</_summary>
- <_description>The duration of a game in seconds (0 for no limit)</_description>
- </key>
- <key name="play-as-white" type="b">
- <default>true</default>
- <_summary>true if the human player is playing white</_summary>
- <_description>true if the human player is playing white</_description>
- </key>
- <key name="opponent-type" type="s">
- <default>'robot'</default>
- <_summary>The kind of opponent player</_summary>
- <_description>Can be 'robot' to play against a chess engine, 'local-player' to play against a local player or 'remote-player' to play against a remote contact</_description>
- </key>
- <key name="opponent" type="s">
- <default>''</default>
- <_summary>The opponent player</_summary>
- <_description>Can be 'human' (play against another human player), '' (use the first available chess engine), the name of a specific engine to play against or a string uniquely identifying a remote player</_description>
- </key>
- <key name="difficulty" enum="org.gnome.gnome-chess.Difficulty">
- <default>'easy'</default>
- <_summary>Difficulty of the opponent chess engine</_summary>
- <_description>Difficulty of the opponent chess engine</_description>
+ <summary>The side of the board that is in the foreground</summary>
+ <description>The side of the board that is in the foreground</description>
</key>
</schema>
</schemalist>
diff --git a/src/chess-launcher.vala b/src/chess-launcher.vala
index 5838768..710aeb4 100644
--- a/src/chess-launcher.vala
+++ b/src/chess-launcher.vala
@@ -25,6 +25,7 @@ public class ChessLauncher : Gtk.Window
{
private Gtk.Builder builder;
private Settings settings;
+ private Settings settings_common;
public signal void start_game ();
public signal void load_game (File file, bool from_history);
@@ -81,7 +82,8 @@ public class ChessLauncher : Gtk.Window
{
this.history = history;
- settings = new Settings ("org.gnome.gnome-chess.Settings");
+ settings = new Settings ("org.gnome.gnome-chess");
+ settings_common = new Settings ("org.gnome.gnome-chess.games-common");
builder = new Gtk.Builder ();
try
{
@@ -207,7 +209,7 @@ public class ChessLauncher : Gtk.Window
individual_view as Gtk.Widget);
individual_view.set_live_search (search_widget);
- /* Add filter for contacts capable of playing glchess */
+ /* Add filter for contacts capable of playing chess */
individual_view.set_custom_filter ((model, iter, data)=>{
return (data as GamesContacts.IndividualView).filter_default (
model, iter, GamesContacts.ActionType.PLAY_GLCHESS);
@@ -231,6 +233,7 @@ public class ChessLauncher : Gtk.Window
save_duration_cb ();
settings.sync ();
+ settings_common.sync ();
}
private bool launcher_configure_event_cb (Gtk.Widget widget,
@@ -345,7 +348,7 @@ public class ChessLauncher : Gtk.Window
grid_preferences.hide ();
/* Present settings */
- string difficulty = settings.get_string ("difficulty");
+ string difficulty = settings_common.get_string ("difficulty");
if (difficulty == "easy")
radioaction_easy.activate ();
else
@@ -354,13 +357,13 @@ public class ChessLauncher : Gtk.Window
else
radioaction_difficult.activate ();
- bool play_as_white = settings.get_boolean ("play-as-white");
+ bool play_as_white = settings_common.get_boolean ("play-as-white");
if (play_as_white)
radioaction_white.activate ();
else
radioaction_black.activate ();
- set_duration (settings.get_int ("duration"));
+ set_duration (settings_common.get_int ("duration"));
}
private void show_robot_installation_choice (bool install)
@@ -403,7 +406,7 @@ public class ChessLauncher : Gtk.Window
string robot = null;
robot_list_model.get (iter, 0, &robot, -1);
- if (settings.get_string ("opponent") == robot)
+ if (settings_common.get_string ("opponent") == robot)
{
var robot_selection = treeview_robots.get_selection ();
robot_selection.select_iter (iter);
@@ -411,7 +414,7 @@ public class ChessLauncher : Gtk.Window
break;
}
- if (settings.get_string ("opponent-type") == "robot")
+ if (settings_common.get_string ("opponent-type") == "robot")
{
treeview_robots.sensitive = true;
done_button.label = _("_Done");
@@ -467,7 +470,7 @@ public class ChessLauncher : Gtk.Window
{
if (action == radioaction_opponent_robot)
{
- settings.set_string ("opponent-type", "robot");
+ settings_common.set_string ("opponent-type", "robot");
show_robot_opponent_widgets (true);
show_game_options ();
@@ -477,12 +480,12 @@ public class ChessLauncher : Gtk.Window
show_robot_opponent_widgets (false);
if (action == radioaction_opponent_local_player)
{
- settings.set_string ("opponent-type", "local-player");
+ settings_common.set_string ("opponent-type", "local-player");
show_game_options ();
}
else
{
- settings.set_string ("opponent-type", "remote-player");
+ settings_common.set_string ("opponent-type", "remote-player");
show_remote_player_selector ();
}
}
@@ -533,9 +536,9 @@ public class ChessLauncher : Gtk.Window
individual, GamesContacts.ActionType.PLAY_GLCHESS);
string opponent;
- settings.set_string ("opponent", contact.id);
+ settings_common.set_string ("opponent", contact.id);
- opponent = settings.get_string ("opponent");
+ opponent = settings_common.get_string ("opponent");
debug ("opponent selected: %s\n", opponent);
show_game_options ();
@@ -554,19 +557,19 @@ public class ChessLauncher : Gtk.Window
{
bool play_as_white = (action == radioaction_white) ? true : false;
- settings.set_boolean ("play-as-white", play_as_white);
+ settings_common.set_boolean ("play-as-white", play_as_white);
}
[CCode (cname = "G_MODULE_EXPORT difficulty_changed_cb", instance_pos = -1)]
public void difficulty_changed_cb (Gtk.Action action)
{
if (action == radioaction_easy)
- settings.set_string ("difficulty", "easy");
+ settings_common.set_string ("difficulty", "easy");
else
if (action == radioaction_normal)
- settings.set_string ("difficulty", "normal");
+ settings_common.set_string ("difficulty", "normal");
else
- settings.set_string ("difficulty", "hard");
+ settings_common.set_string ("difficulty", "hard");
}
private void ensure_legacy_channel_async ()
@@ -697,7 +700,7 @@ public class ChessLauncher : Gtk.Window
string selected_robot_opponent = null;
treeview_robots.model.get (iter, 0, &selected_robot_opponent);
- settings.set_string ("opponent", selected_robot_opponent);
+ settings_common.set_string ("opponent", selected_robot_opponent);
show_game_options ();
}
@@ -771,7 +774,7 @@ public class ChessLauncher : Gtk.Window
private bool save_duration_cb ()
{
- settings.set_int ("duration", get_duration ());
+ settings_common.set_int ("duration", get_duration ());
Source.remove (save_duration_timeout);
save_duration_timeout = 0;
return false;
diff --git a/src/gnome-chess-application.vala b/src/gnome-chess-application.vala
index 3f57c53..aceabfd 100644
--- a/src/gnome-chess-application.vala
+++ b/src/gnome-chess-application.vala
@@ -4,6 +4,7 @@ extern void gtk_file_filter_set_name (Gtk.FileFilter filter, string name);
public class Application : Gtk.Application
{
protected Settings settings;
+ protected Settings settings_common;
private History history;
private Gtk.Builder builder;
protected Gtk.Builder preferences_builder;
@@ -63,7 +64,8 @@ public class Application : Gtk.Application
{
base.startup ();
- settings = new Settings ("org.gnome.gnome-chess.Settings");
+ settings = new Settings ("org.gnome.gnome-chess");
+ settings_common = new Settings ("org.gnome.gnome-chess.games-common");
var data_dir = File.new_for_path (Path.build_filename (Environment.get_user_data_dir (), "gnome-chess", null));
DirUtils.create_with_parents (data_dir.get_path (), 0755);
@@ -114,6 +116,7 @@ public class Application : Gtk.Application
}
}
+ settings_common.changed.connect (settings_changed_cb);
}
private ChessLauncher create_launcher (string engines_file,
@@ -154,8 +157,8 @@ public class Application : Gtk.Application
white_time_label = (Gtk.Widget) builder.get_object ("white_time_label");
black_time_label = (Gtk.Widget) builder.get_object ("black_time_label");
- settings.bind ("show-toolbar", builder.get_object ("toolbar"), "visible", SettingsBindFlags.DEFAULT);
- settings.bind ("show-history", builder.get_object ("navigation_box"), "visible", SettingsBindFlags.DEFAULT);
+ settings_common.bind ("show-toolbar", builder.get_object ("toolbar"), "visible", SettingsBindFlags.DEFAULT);
+ settings_common.bind ("show-history", builder.get_object ("navigation_box"), "visible", SettingsBindFlags.DEFAULT);
var view_box = (Gtk.VBox) builder.get_object ("view_box");
view_container = (Gtk.Container) builder.get_object ("view_container");
@@ -180,14 +183,14 @@ public class Application : Gtk.Application
scene.is_human.connect ((p) => { return p == human_player; } );
scene.changed.connect (scene_changed_cb);
scene.choose_promotion_type.connect (show_promotion_type_selector);
- settings.bind ("show-move-hints", scene, "show-move-hints", SettingsBindFlags.GET);
- settings.bind ("show-numbering", scene, "show-numbering", SettingsBindFlags.GET);
- settings.bind ("piece-theme", scene, "theme-name", SettingsBindFlags.GET);
- settings.bind ("show-3d-smooth", scene, "show-3d-smooth", SettingsBindFlags.GET);
- settings.bind ("move-format", scene, "move-format", SettingsBindFlags.GET);
- settings.bind ("board-side", scene, "board-side", SettingsBindFlags.GET);
+ settings_common.bind ("show-move-hints", scene, "show-move-hints", SettingsBindFlags.GET);
+ settings_common.bind ("show-numbering", scene, "show-numbering", SettingsBindFlags.GET);
+ settings_common.bind ("piece-theme", scene, "theme-name", SettingsBindFlags.GET);
+ settings_common.bind ("show-3d-smooth", scene, "show-3d-smooth", SettingsBindFlags.GET);
+ settings_common.bind ("move-format", scene, "move-format", SettingsBindFlags.GET);
+ settings_common.bind ("board-side", scene, "board-side", SettingsBindFlags.GET);
- settings_changed_cb (settings, "show-3d");
+ settings_changed_cb (settings_common, "show-3d");
}
protected override void shutdown ()
@@ -290,6 +293,7 @@ public class Application : Gtk.Application
{
autosave ();
settings.sync ();
+ settings_common.sync ();
if (launcher != null)
{
launcher.destroy ();
@@ -331,7 +335,7 @@ public class Application : Gtk.Application
}
}
- protected void settings_changed_cb (Settings settings, string key)
+ protected void settings_changed_cb (Settings settings_common, string key)
{
if (key == "show-3d")
{
@@ -340,7 +344,7 @@ public class Application : Gtk.Application
view_container.remove (view);
view.destroy ();
}
- if (settings.get_boolean ("show-3d"))
+ if (settings_common.get_boolean ("show-3d"))
view = new ChessView3D ();
else
view = new ChessView2D ();
@@ -1199,27 +1203,27 @@ public class Application : Gtk.Application
}
preferences_dialog = (Gtk.Dialog) preferences_builder.get_object ("preferences");
- settings.bind ("show-numbering", preferences_builder.get_object ("show_numbering_check"),
+ settings_common.bind ("show-numbering", preferences_builder.get_object ("show_numbering_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-move-hints", preferences_builder.get_object ("show_move_hints_check"),
+ settings_common.bind ("show-move-hints", preferences_builder.get_object ("show_move_hints_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-toolbar", preferences_builder.get_object ("show_toolbar_check"),
+ settings_common.bind ("show-toolbar", preferences_builder.get_object ("show_toolbar_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-history", preferences_builder.get_object ("show_history_check"),
+ settings_common.bind ("show-history", preferences_builder.get_object ("show_history_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-3d", preferences_builder.get_object ("show_3d_check"),
+ settings_common.bind ("show-3d", preferences_builder.get_object ("show_3d_check"),
"active", SettingsBindFlags.DEFAULT);
- settings.bind ("show-3d-smooth", preferences_builder.get_object ("show_3d_smooth_check"),
+ settings_common.bind ("show-3d-smooth", preferences_builder.get_object ("show_3d_smooth_check"),
"active", SettingsBindFlags.DEFAULT);
var orientation_combo = (Gtk.ComboBox) preferences_builder.get_object ("orientation_combo");
- set_combo (orientation_combo, 1, settings.get_string ("board-side"));
+ set_combo (orientation_combo, 1, settings_common.get_string ("board-side"));
var move_combo = (Gtk.ComboBox) preferences_builder.get_object ("move_format_combo");
- set_combo (move_combo, 1, settings.get_string ("move-format"));
+ set_combo (move_combo, 1, settings_common.get_string ("move-format"));
var theme_combo = (Gtk.ComboBox) preferences_builder.get_object ("piece_style_combo");
- set_combo (theme_combo, 1, settings.get_string ("piece-theme"));
+ set_combo (theme_combo, 1, settings_common.get_string ("piece-theme"));
preferences_builder.connect_signals (this);
@@ -1270,7 +1274,7 @@ public class Application : Gtk.Application
[CCode (cname = "G_MODULE_EXPORT piece_style_combo_changed_cb", instance_pos = -1)]
public void piece_style_combo_changed_cb (Gtk.ComboBox combo)
{
- settings.set_string ("piece-theme", get_combo (combo, 1));
+ settings_common.set_string ("piece-theme", get_combo (combo, 1));
}
[CCode (cname = "G_MODULE_EXPORT show_3d_toggle_cb", instance_pos = -1)]
@@ -1286,13 +1290,13 @@ public class Application : Gtk.Application
[CCode (cname = "G_MODULE_EXPORT move_format_combo_changed_cb", instance_pos = -1)]
public void move_format_combo_changed_cb (Gtk.ComboBox combo)
{
- settings.set_string ("move-format", get_combo (combo, 1));
+ settings_common.set_string ("move-format", get_combo (combo, 1));
}
[CCode (cname = "G_MODULE_EXPORT orientation_combo_changed_cb", instance_pos = -1)]
public void orientation_combo_changed_cb (Gtk.ComboBox combo)
{
- settings.set_string ("board-side", get_combo (combo, 1));
+ settings_common.set_string ("board-side", get_combo (combo, 1));
}
[CCode (cname = "G_MODULE_EXPORT help_cb", instance_pos = -1)]
@@ -1525,13 +1529,13 @@ public class Application : Gtk.Application
private void start_new_game ()
{
- string opponent_type = settings.get_string ("opponent-type");
+ string opponent_type = settings_common.get_string ("opponent-type");
if (opponent_type == "remote-player")
{
- string contact_id = settings.get_string ("opponent");
+ string contact_id = settings_common.get_string ("opponent");
debug ("Opponent type selected: %s", opponent_type);
debug ("Contact-id: %s", contact_id);
- debug ("Requested a glchess channel to %s. glchess-channel-handler takes charge. Now quitting", contact_id);
+ debug ("Requested a chess channel to %s. gnome-chess-channel-handler takes charge. Now quitting", contact_id);
quit_game ();
}
@@ -1551,17 +1555,17 @@ public class Application : Gtk.Application
var now = new DateTime.now_local ();
pgn_game.date = now.format ("%Y.%m.%d");
pgn_game.time = now.format ("%H:%M:%S");
- var duration = settings.get_int ("duration");
+ var duration = settings_common.get_int ("duration");
if (duration > 0)
pgn_game.time_control = "%d".printf (duration);
- if (settings.get_string ("opponent-type") == "robot")
+ if (settings_common.get_string ("opponent-type") == "robot")
{
- var engine_name = settings.get_string ("opponent");
- var engine_level = settings.get_string ("difficulty");
+ var engine_name = settings_common.get_string ("opponent");
+ var engine_level = settings_common.get_string ("difficulty");
if (engine_name != null)
{
- if (settings.get_boolean ("play-as-white"))
+ if (settings_common.get_boolean ("play-as-white"))
{
pgn_game.tags.insert ("BlackAI", engine_name);
pgn_game.tags.insert ("BlackLevel", engine_level);
diff --git a/src/gnome-chess-channel-handler.vala b/src/gnome-chess-channel-handler.vala
index 15b2755..3b7a479 100644
--- a/src/gnome-chess-channel-handler.vala
+++ b/src/gnome-chess-channel-handler.vala
@@ -50,7 +50,8 @@ public class HandlerApplication : Application
application_id: TelepathyGLib.CLIENT_BUS_NAME_BASE + "Gnome.Chess",
flags: ApplicationFlags.FLAGS_NONE);
- settings = new Settings ("org.gnome.gnome-chess.Settings");
+ settings = new Settings ("org.gnome.gnome-chess");
+ settings_common = new Settings ("org.gnome.gnome-chess.games-common");
builder = new Gtk.Builder ();
try
@@ -63,12 +64,20 @@ public class HandlerApplication : Application
warning ("Could not load UI: %s", e.message);
}
- settings.changed.connect (settings_changed_cb);
+ settings_common.changed.connect (settings_changed_cb);
create_handler_window ();
/* Associate the window to this application */
handler_window.application = this;
+ if (settings.get_boolean ("network-window-fullscreen"))
+ handler_window.fullscreen ();
+ else if (settings.get_boolean ("network-window-maximized"))
+ handler_window.maximize ();
+
+ handler_window.resize (settings.get_int ("network-window-width"),
+ settings.get_int ("network-window-height"));
+
handler_window.show_all ();
}
@@ -167,6 +176,7 @@ public class HandlerApplication : Application
public new void quit_game ()
{
settings.sync ();
+ settings_common.sync ();
}
public override void activate ()
@@ -176,6 +186,39 @@ public class HandlerApplication : Application
handler_window.present ();
}
+ [CCode (cname = "G_MODULE_EXPORT network_window_configure_event_cb", instance_pos = -1)]
+ public bool network_window_configure_event_cb (Gtk.Widget widget, Gdk.EventConfigure event)
+ {
+ if (!settings.get_boolean ("network-window-maximized") &&
+ !settings.get_boolean ("network-window-fullscreen"))
+ {
+ settings.set_int ("network-window-width", event.width);
+ settings.set_int ("network-window-height", event.height);
+ }
+
+ return false;
+ }
+
+ [CCode (cname = "G_MODULE_EXPORT network_window_window_state_event_cb", instance_pos = -1)]
+ public bool network_window_window_state_event_cb (Gtk.Widget widget, Gdk.EventWindowState event)
+ {
+ if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)
+ {
+ var is_maximized = (event.new_window_state & Gdk.WindowState.MAXIMIZED) != 0;
+ settings.set_boolean ("network-window-maximized", is_maximized);
+ }
+ if ((event.changed_mask & Gdk.WindowState.FULLSCREEN) != 0)
+ {
+ bool is_fullscreen = (event.new_window_state & Gdk.WindowState.FULLSCREEN) != 0;
+ settings.set_boolean ("network-window-fullscreen", is_fullscreen);
+ fullscreen_menu.label = is_fullscreen ? Gtk.Stock.LEAVE_FULLSCREEN : Gtk.Stock.FULLSCREEN;
+ }
+
+ return false;
+ }
+
+
+
[CCode (cname = "G_MODULE_EXPORT new_game_cb", instance_pos = -1)]
private new void new_game_cb (Gtk.Widget widget)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]