[gnome-clocks] Replaced switch with passing page name and using visible_child_name.



commit 26c615bd8545cf8d63b5d6ce406b7dc2edf0ea6b
Author: Radush Niemczyk <radoslaw n protonmail com>
Date:   Tue Jan 19 07:18:12 2021 +0100

    Replaced switch with passing page name and using visible_child_name.

 src/window.vala | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
---
diff --git a/src/window.vala b/src/window.vala
index 5d6a093..9bc57b0 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -137,22 +137,22 @@ public class Window : Hdy.ApplicationWindow {
                                      Gdk.Key.@1,
                                      Gdk.ModifierType.MOD1_MASK,
                                      "set-page", 1,
-                                     typeof (int), 1);
+                                     typeof (string), "world");
         Gtk.BindingEntry.add_signal (binding_set,
                                      Gdk.Key.@2,
                                      Gdk.ModifierType.MOD1_MASK,
                                      "set-page", 1,
-                                     typeof (int), 2);
+                                     typeof (string), "alarm");
         Gtk.BindingEntry.add_signal (binding_set,
                                      Gdk.Key.@3,
                                      Gdk.ModifierType.MOD1_MASK,
                                      "set-page", 1,
-                                     typeof (int), 3);
+                                     typeof (string), "stopwatch");
         Gtk.BindingEntry.add_signal (binding_set,
                                      Gdk.Key.@4,
                                      Gdk.ModifierType.MOD1_MASK,
                                      "set-page", 1,
-                                     typeof (int), 4);
+                                     typeof (string), "timer");
 
         Gtk.StyleContext style = get_style_context ();
         if (Config.PROFILE == "Devel") {
@@ -203,24 +203,8 @@ public class Window : Hdy.ApplicationWindow {
     }
 
     [Signal (action = true)]
-    public virtual signal void set_page (int index) {
-        switch (index) {
-            case 1:
-                stack.visible_child = world;
-                break;
-            case 2:
-                stack.visible_child = alarm;
-                break;
-            case 3:
-                stack.visible_child = stopwatch;
-                break;
-            case 4:
-                stack.visible_child = timer;
-                break;
-            default:
-                stack.error_bell ();
-                break;
-        }
+    public virtual signal void set_page (string page) {
+        stack.visible_child_name = page;
     }
 
     private void on_show_primary_menu_activate (SimpleAction action) {


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