[gnome-chess/chess-telepathy-networking-support-664946-rebase: 7/64] [Glchess Screen] Set up game duration
- From: Chandni Verma <vchandni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-chess/chess-telepathy-networking-support-664946-rebase: 7/64] [Glchess Screen] Set up game duration
- Date: Sun, 23 Dec 2012 03:39:12 +0000 (UTC)
commit da990aca5ab538e809172c1c4d370d00a7229f98
Author: Chandni Verma <chandniverma2112 gmail com>
Date: Mon Apr 30 20:01:49 2012 +0530
[Glchess Screen] Set up game duration
data/gnome-chess.ui | 180 +++++++++++++++++++++++++++++++++++++++-----------
src/gnome-chess.vala | 20 ++++--
2 files changed, 153 insertions(+), 47 deletions(-)
---
diff --git a/data/gnome-chess.ui b/data/gnome-chess.ui
index 6bb6232..305fa73 100644
--- a/data/gnome-chess.ui
+++ b/data/gnome-chess.ui
@@ -2,17 +2,6 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAccelGroup" id="accelgroup"/>
- <object class="GtkRadioAction" id="radioaction_black">
- <property name="group">radioaction_white</property>
- <signal name="activate" handler="color_selection_changed_cb" swapped="no"/>
- </object>
- <object class="GtkRadioAction" id="radioaction_difficult">
- <property name="group">radioaction_easy</property>
- <signal name="activate" handler="difficulty_changed_cb" swapped="no"/>
- </object>
- <object class="GtkRadioAction" id="radioaction_easy">
- <signal name="activate" handler="difficulty_changed_cb" swapped="no"/>
- </object>
<object class="GtkRadioAction" id="radioaction_new_game">
<property name="group">radioaction_previous_game</property>
<signal name="activate" handler="game_selected_cb" swapped="no"/>
@@ -38,36 +27,76 @@
<object class="GtkRadioAction" id="radioaction_white">
<signal name="activate" handler="color_selection_changed_cb" swapped="no"/>
</object>
- <object class="GtkListStore" id="game_duration_model">
+ <object class="GtkListStore" id="custom_duration_units_model">
+ <columns>
+ <!-- column-name label -->
+ <column type="gchararray"/>
+ <!-- column-name multiplier -->
+ <column type="gint"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0">seconds</col>
+ <col id="1">1</col>
+ </row>
+ <row>
+ <col id="0">minutes</col>
+ <col id="1">60</col>
+ </row>
+ <row>
+ <col id="0">hours</col>
+ <col id="1">3600</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkAdjustment" id="duration_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">86400</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ <signal name="value-changed" handler="duration_changed_cb" swapped="no"/>
+ </object>
+ <object class="GtkRadioAction" id="radioaction_black">
+ <property name="group">radioaction_white</property>
+ <signal name="activate" handler="color_selection_changed_cb" swapped="no"/>
+ </object>
+ <object class="GtkRadioAction" id="radioaction_difficult">
+ <property name="group">radioaction_easy</property>
+ <signal name="activate" handler="difficulty_changed_cb" swapped="no"/>
+ </object>
+ <object class="GtkRadioAction" id="radioaction_easy">
+ <signal name="activate" handler="difficulty_changed_cb" swapped="no"/>
+ </object>
+ <object class="GtkListStore" id="duration_model">
<columns>
- <!-- column-name duration_text -->
+ <!-- column-name label -->
<column type="gchararray"/>
- <!-- column-name duration_in_seconds -->
+ <!-- column-name duration -->
<column type="gint"/>
</columns>
<data>
<row>
- <col id="0" translatable="yes">No limit</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for no game timer">No limit</col>
<col id="1">0</col>
</row>
<row>
- <col id="0" translatable="yes">One minute</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for game timer of one minute">One minute</col>
<col id="1">60</col>
</row>
<row>
- <col id="0" translatable="yes">Five minutes</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for game timer of five minutes">Five minutes</col>
<col id="1">300</col>
</row>
<row>
- <col id="0" translatable="yes">Thirty minutes</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for game timer of thirty minutes">30 minutes</col>
<col id="1">1800</col>
</row>
<row>
- <col id="0" translatable="yes">One hour</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for game timer of one hour">One hour</col>
<col id="1">3600</col>
</row>
<row>
- <col id="0" translatable="yes">Custom</col>
+ <col id="0" translatable="yes" comments="Preferences Dialog: Combo box entry for custom game timer">Custom</col>
<col id="1">-1</col>
</row>
</data>
@@ -393,7 +422,7 @@
<property name="row_spacing">12</property>
<property name="column_spacing">6</property>
<property name="column_homogeneous">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">8</property>
<child>
<object class="GtkLabel" id="label_game_options">
@@ -411,13 +440,19 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_game_duration">
+ <object class="GtkComboBox" id="duration_combo">
<property name="height_request">30</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="model">game_duration_model</property>
- <signal name="changed" handler="duration_changed_cb" swapped="no"/>
+ <property name="model">duration_model</property>
+ <signal name="changed" handler="duration_combo_changed_cb" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText" id="duration_cellrenderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
@@ -441,7 +476,7 @@
</object>
<packing>
<property name="left_attach">2</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
@@ -569,7 +604,7 @@
</object>
<packing>
<property name="left_attach">7</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -594,12 +629,79 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
+ <object class="GtkAlignment" id="custom_duration_box">
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="left_padding">18</property>
+ <child>
+ <object class="GtkHBox" id="hbox22">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkSpinButton" id="custom_duration_spin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="adjustment">duration_adjustment</property>
+ <property name="climb_rate">1</property>
+ <property name="numeric">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="custom_duration_units_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">custom_duration_units_model</property>
+ <signal name="changed" handler="duration_units_changed_cb" swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText" id="custom_duration_units_cellrenderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="width">4</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
@@ -701,18 +803,6 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
<object class="GtkGrid" id="grid_installable_robots">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -767,6 +857,18 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 8388c77..1aab737 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -35,7 +35,11 @@ public class Application : Gtk.Application
private Gtk.Action radioaction_difficult;
private Gtk.Action radioaction_white;
private Gtk.Action radioaction_black;
- private Gtk.ListStore game_duration_model;
+ private Gtk.ComboBox duration_combo;
+ private Gtk.Adjustment duration_adjustment;
+ private Gtk.Container custom_duration_box;
+ private Gtk.ComboBox custom_duration_units_combo;
+
private Gtk.TreeView treeview_robots;
private Gtk.ListStore robot_list_model;
@@ -67,10 +71,6 @@ public class Application : Gtk.Application
private Gtk.Widget black_time_label;
private Gtk.Dialog? preferences_dialog = null;
- private Gtk.ComboBox duration_combo;
- private Gtk.Adjustment duration_adjustment;
- private Gtk.Container custom_duration_box;
- private Gtk.ComboBox custom_duration_units_combo;
private uint save_duration_timeout = 0;
private Gtk.FileChooserDialog? open_dialog = null;
private Gtk.InfoBar? open_dialog_info_bar = null;
@@ -176,7 +176,11 @@ public class Application : Gtk.Application
radioaction_difficult = (Gtk.Action) builder.get_object ("radioaction_difficult");
radioaction_white = (Gtk.Action) builder.get_object ("radioaction_white");
radioaction_black = (Gtk.Action) builder.get_object ("radioaction_black");
- game_duration_model = (Gtk.ListStore) builder.get_object ("game_duration_model");
+ duration_combo = (Gtk.ComboBox) builder.get_object ("duration_combo");
+ duration_adjustment = (Gtk.Adjustment) builder.get_object ("duration_adjustment");
+ custom_duration_box = (Gtk.Container) builder.get_object ("custom_duration_box");
+ custom_duration_units_combo = (Gtk.ComboBox) builder.get_object ("custom_duration_units_combo");
+
treeview_robots = (Gtk.TreeView) builder.get_object ("treeview_robots");
robot_list_model = (Gtk.ListStore) treeview_robots.model;
@@ -1199,6 +1203,8 @@ public class Application : Gtk.Application
radioaction_white.activate ();
else
radioaction_black.activate ();
+
+ set_duration (settings.get_int ("duration"));
}
private void show_robot_installation_choice (bool install)
@@ -1351,8 +1357,6 @@ public class Application : Gtk.Application
settings.set_string ("difficulty", "hard");
}
-// [CCode (cname = "G_MODULE_EXPORT duration_changed_cb", instance_pos = -1)]
-
[CCode (cname = "G_MODULE_EXPORT start_game_clicked_cb", instance_pos = -1)]
public void start_game_clicked_cb (Gtk.Button button)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]