[gnome-clocks] Use {add,remove}_css_class directly



commit 8e5a6d47473953d41961f99ab0e02b6f121642ef
Author: Maximiliano Sandoval R <msandova gnome org>
Date:   Tue Dec 14 00:24:23 2021 +0100

    Use {add,remove}_css_class directly

 src/alarm-row.vala          |  8 ++++----
 src/stopwatch-face.vala     | 32 ++++++++++++++++----------------
 src/timer-row.vala          | 24 ++++++++++++------------
 src/timer-setup-dialog.vala |  2 +-
 src/widgets.vala            |  2 +-
 src/window.vala             |  3 +--
 src/world-row.vala          | 13 ++++++-------
 7 files changed, 41 insertions(+), 43 deletions(-)
---
diff --git a/src/alarm-row.vala b/src/alarm-row.vala
index 927886f2..18c4ea3d 100644
--- a/src/alarm-row.vala
+++ b/src/alarm-row.vala
@@ -61,16 +61,16 @@ private class Row : Gtk.ListBoxRow {
 
     private void update () {
         if (alarm.active) {
-            get_style_context ().add_class ("active");
+            add_css_class ("active");
         } else {
-            get_style_context ().remove_class ("active");
+            remove_css_class ("active");
         }
 
         if (alarm.state == Item.State.SNOOZING) {
-            get_style_context ().add_class ("snoozing");
+            add_css_class ("snoozing");
             time.label = alarm.snooze_time_label;
         } else {
-            get_style_context ().remove_class ("snoozing");
+            remove_css_class ("snoozing");
             time.label = alarm.time_label;
         }
 
diff --git a/src/stopwatch-face.vala b/src/stopwatch-face.vala
index dd478fcf..ac7163b1 100644
--- a/src/stopwatch-face.vala
+++ b/src/stopwatch-face.vala
@@ -160,15 +160,15 @@ public class Face : Gtk.Box, Clocks.Clock {
         state = State.RUNNING;
         add_tick ();
         start_btn.set_label (_("Pause"));
-        start_btn.get_style_context ().remove_class ("suggested-action");
+        start_btn.remove_css_class ("suggested-action");
 
         clear_btn.set_sensitive (true);
         clear_btn.set_label (_("Lap"));
-        clear_btn.get_style_context ().remove_class ("destructive-action");
+        clear_btn.remove_css_class ("destructive-action");
 
-        time_container.get_style_context ().add_class ("running-stopwatch");
-        time_container.get_style_context ().remove_class ("paused-stopwatch");
-        time_container.get_style_context ().remove_class ("stopped-stopwatch");
+        time_container.add_css_class ("running-stopwatch");
+        time_container.remove_css_class ("paused-stopwatch");
+        time_container.remove_css_class ("stopped-stopwatch");
     }
 
     private void stop () {
@@ -176,15 +176,15 @@ public class Face : Gtk.Box, Clocks.Clock {
         state = State.STOPPED;
         remove_tick ();
         start_btn.set_label (_("Resume"));
-        start_btn.get_style_context ().remove_class ("destructive-action");
-        start_btn.get_style_context ().add_class ("suggested-action");
+        start_btn.remove_css_class ("destructive-action");
+        start_btn.add_css_class ("suggested-action");
         clear_btn.set_sensitive (true);
         clear_btn.set_label (_("Clear"));
-        clear_btn.get_style_context ().add_class ("destructive-action");
+        clear_btn.add_css_class ("destructive-action");
 
-        time_container.get_style_context ().add_class ("paused-stopwatch");
-        time_container.get_style_context ().remove_class ("running-stopwatch");
-        time_container.get_style_context ().remove_class ("stopped-stopwatch");
+        time_container.add_css_class ("paused-stopwatch");
+        time_container.remove_css_class ("running-stopwatch");
+        time_container.remove_css_class ("stopped-stopwatch");
     }
 
     private void reset () {
@@ -197,15 +197,15 @@ public class Face : Gtk.Box, Clocks.Clock {
         current_lap = 0;
 
         start_btn.set_label (_("Start"));
-        start_btn.get_style_context ().add_class ("suggested-action");
+        start_btn.add_css_class ("suggested-action");
 
         clear_btn.set_sensitive (false);
         clear_btn.set_label (_("Lap"));
-        clear_btn.get_style_context ().remove_class ("destructive-action");
+        clear_btn.remove_css_class ("destructive-action");
 
-        time_container.get_style_context ().add_class ("stopped-stopwatch");
-        time_container.get_style_context ().remove_class ("paused-stopwatch");
-        time_container.get_style_context ().remove_class ("running-stopwatch");
+        time_container.add_css_class ("stopped-stopwatch");
+        time_container.remove_css_class ("paused-stopwatch");
+        time_container.remove_css_class ("running-stopwatch");
         laps.remove_all ();
     }
 
diff --git a/src/timer-row.vala b/src/timer-row.vala
index bec09e7a..ca81f309 100644
--- a/src/timer-row.vala
+++ b/src/timer-row.vala
@@ -100,9 +100,9 @@ public class Row : Gtk.ListBoxRow {
         reset_stack.visible_child_name = "empty";
         delete_stack.visible_child_name = "button";
 
-        countdown_label.get_style_context ().remove_class ("timer-paused");
-        countdown_label.get_style_context ().remove_class ("timer-ringing");
-        countdown_label.get_style_context ().remove_class ("timer-running");
+        countdown_label.remove_css_class ("timer-paused");
+        countdown_label.remove_css_class ("timer-ringing");
+        countdown_label.remove_css_class ("timer-running");
         start_stack.visible_child_name = "start";
         name_stack.visible_child_name = "edit";
 
@@ -110,9 +110,9 @@ public class Row : Gtk.ListBoxRow {
     }
 
     private void start () {
-        countdown_label.get_style_context ().add_class ("timer-running");
-        countdown_label.get_style_context ().remove_class ("timer-ringing");
-        countdown_label.get_style_context ().remove_class ("timer-paused");
+        countdown_label.add_css_class ("timer-running");
+        countdown_label.remove_css_class ("timer-ringing");
+        countdown_label.remove_css_class ("timer-paused");
 
         reset_stack.visible_child_name = "empty";
         delete_stack.visible_child_name = "empty";
@@ -122,15 +122,15 @@ public class Row : Gtk.ListBoxRow {
     }
 
     private void ring () {
-        countdown_label.get_style_context ().add_class ("timer-ringing");
-        countdown_label.get_style_context ().remove_class ("timer-paused");
-        countdown_label.get_style_context ().remove_class ("timer-running");
+        countdown_label.add_css_class ("timer-ringing");
+        countdown_label.remove_css_class ("timer-paused");
+        countdown_label.remove_css_class ("timer-running");
     }
 
     private void pause () {
-        countdown_label.get_style_context ().add_class ("timer-paused");
-        countdown_label.get_style_context ().remove_class ("timer-ringing");
-        countdown_label.get_style_context ().remove_class ("timer-running");
+        countdown_label.add_css_class ("timer-paused");
+        countdown_label.remove_css_class ("timer-ringing");
+        countdown_label.remove_css_class ("timer-running");
 
         reset_stack.visible_child_name = "button";
         delete_stack.visible_child_name = "button";
diff --git a/src/timer-setup-dialog.vala b/src/timer-setup-dialog.vala
index f4adfe37..4b8ec713 100644
--- a/src/timer-setup-dialog.vala
+++ b/src/timer-setup-dialog.vala
@@ -29,7 +29,7 @@ public class SetupDialog: Gtk.Dialog {
 
         add_button (_("Cancel"), Gtk.ResponseType.CANCEL);
         var create_button = add_button (_("Add"), Gtk.ResponseType.ACCEPT);
-        create_button.get_style_context ().add_class ("suggested-action");
+        create_button.add_css_class ("suggested-action");
 
         timer_setup = new Setup ();
         this.get_content_area ().append (timer_setup);
diff --git a/src/widgets.vala b/src/widgets.vala
index 493392c1..d5aae60d 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -171,7 +171,7 @@ public class AmPmToggleButton : Gtk.Button {
     public AmPmToggleButton () {
         stack = new Gtk.Stack ();
 
-        get_style_context ().add_class ("clocks-ampm-toggle-button");
+        add_css_class ("clocks-ampm-toggle-button");
 
         var str = (new GLib.DateTime.utc (1, 1, 1, 0, 0, 0)).format ("%p");
         am_label = new Gtk.Label (str);
diff --git a/src/window.vala b/src/window.vala
index 6a14f750..d7fc5a59 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -142,9 +142,8 @@ public class Window : Adw.ApplicationWindow {
             timer_stack_page.needs_attention = timer.is_running;
         });
 
-        Gtk.StyleContext style = get_style_context ();
         if (Config.PROFILE == "Devel") {
-            style.add_class ("devel");
+            add_css_class ("devel");
         }
 
         const uint BUTTON_BACK = 8;
diff --git a/src/world-row.vala b/src/world-row.vala
index 8cf5d195..a3f078bf 100644
--- a/src/world-row.vala
+++ b/src/world-row.vala
@@ -40,13 +40,12 @@ private class Row : Adw.ActionRow {
     }
 
     private void update () {
-        var ctx = get_style_context ();
-        ctx.remove_class ("night");
-        ctx.remove_class ("astro");
-        ctx.remove_class ("naut");
-        ctx.remove_class ("civil");
-        ctx.remove_class ("day");
-        ctx.add_class (location.state_class);
+        remove_css_class ("night");
+        remove_css_class ("astro");
+        remove_css_class ("naut");
+        remove_css_class ("civil");
+        remove_css_class ("day");
+        add_css_class (location.state_class);
 
         var message = Utils.get_time_difference_message ((double) location.local_offset);
 


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