[gnome-chess/gnome-3-14] Set a limit on the max amount of time per game



commit 4900b073e15de9ad4d27ab820be98c24b5e47f4f
Author: Sahil Sareen <sahil sareen hotmail com>
Date:   Thu Dec 4 23:38:04 2014 +0530

    Set a limit on the max amount of time per game
    
    Setting a limit on hours to 10 and minutes to 600 in
    custom game duration in preferences.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726953

 data/preferences.ui  |    2 +-
 src/gnome-chess.vala |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/data/preferences.ui b/data/preferences.ui
index 1a66ee5..83d3aa8 100644
--- a/data/preferences.ui
+++ b/data/preferences.ui
@@ -43,7 +43,7 @@
   </object>
   <object class="GtkAdjustment" id="duration_adjustment">
     <property name="lower">1</property>
-    <property name="upper">86400</property>
+    <property name="upper">10</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
     <signal name="value-changed" handler="duration_changed_cb" swapped="no"/>
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index 5113f0f..97f18e8 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -1846,6 +1846,28 @@ public class ChessApplication : Gtk.Application
         int multiplier = 1;
         if (custom_duration_units_combo.get_active_iter (out iter))
             custom_duration_units_combo.model.get (iter, 1, out multiplier, -1);
+
+        switch (multiplier)
+        {
+        case 60:
+            if (duration_adjustment.get_upper () != 600)
+                duration_adjustment.set_upper (600);
+            break;
+        case 3600:
+            if (duration_adjustment.get_upper () != 10)
+            {
+                duration_adjustment.set_upper (10);
+                if (duration_adjustment.value > 10)
+                {
+                    duration_adjustment.value = 10;
+                    magnitude = 10;
+                }
+            }
+            break;
+        default:
+            assert_not_reached ();
+        }
+
         return magnitude * multiplier;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]