[gnome-break-timer] Rename Util to TimeUnit
- From: Dylan McCall <dylanmccall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-break-timer] Rename Util to TimeUnit
- Date: Sun, 15 Nov 2020 05:42:11 +0000 (UTC)
commit cc7a87c557d31cab242b1c28bc5494b4deb6ad35
Author: Dylan McCall <dylan dylanmccall ca>
Date: Sat Nov 14 19:22:58 2020 -0800
Rename Util to TimeUnit
src/daemon/activity-monitor/ActivityMonitor.vala | 10 +++++-----
src/daemon/activity-monitor/MutterActivityMonitorBackend.vala | 4 ++--
src/daemon/break/BreakController.vala | 4 ++--
src/daemon/break/BreakView.vala | 4 ++--
src/daemon/meson.build | 2 +-
src/daemon/restbreak/RestBreakView.vala | 4 ++--
src/daemon/util/Countdown.vala | 8 ++++----
src/daemon/util/PausableTimeout.vala | 4 ++--
src/daemon/util/{Util.vala => TimeUnit.vala} | 6 +-----
9 files changed, 21 insertions(+), 25 deletions(-)
---
diff --git a/src/daemon/activity-monitor/ActivityMonitor.vala
b/src/daemon/activity-monitor/ActivityMonitor.vala
index 9e57d08..de66c12 100644
--- a/src/daemon/activity-monitor/ActivityMonitor.vala
+++ b/src/daemon/activity-monitor/ActivityMonitor.vala
@@ -80,7 +80,7 @@ public class ActivityMonitor : Object {
private void add_activity (UserActivity activity) {
this.last_activity = activity;
if (activity.is_active ()) {
- this.last_active_timestamp = Util.get_real_time_seconds ();
+ this.last_active_timestamp = TimeUnit.get_real_time_seconds ();
this.detected_activity (activity);
} else {
this.detected_idle (activity);
@@ -98,7 +98,7 @@ public class ActivityMonitor : Object {
int64 sleep_time = backend.pop_sleep_time ();
int64 idle_time = backend.get_idle_seconds ();
- int64 time_since_active = (int64) (Util.get_real_time_seconds () - this.last_active_timestamp);
+ int64 time_since_active = (int64) (TimeUnit.get_real_time_seconds () - this.last_active_timestamp);
// Order is important here: some types of activity (or inactivity)
// happen at the same time, and are only reported once.
@@ -166,14 +166,14 @@ public abstract class ActivityMonitorBackend : Object {
public int64 get_idle_seconds () {
uint64 idle_ms = this.time_since_last_event_ms ();
- return (int64) idle_ms / Util.MILLISECONDS_IN_SECONDS;
+ return (int64) idle_ms / TimeUnit.MILLISECONDS_IN_SECONDS;
}
/** Detect if the device has been asleep using the difference between monotonic time and real time */
public int64 pop_sleep_time () {
int64 sleep_time;
- int64 now_real = Util.get_real_time_seconds ();
- int64 now_monotonic = Util.get_monotonic_time_seconds ();
+ int64 now_real = TimeUnit.get_real_time_seconds ();
+ int64 now_monotonic = TimeUnit.get_monotonic_time_seconds ();
int64 real_time_delta = (int64) (now_real - this.last_real_time);
int64 monotonic_time_delta = (int64) (now_monotonic - this.last_monotonic_time).abs ();
diff --git a/src/daemon/activity-monitor/MutterActivityMonitorBackend.vala
b/src/daemon/activity-monitor/MutterActivityMonitorBackend.vala
index 3eec160..f70e4b4 100644
--- a/src/daemon/activity-monitor/MutterActivityMonitorBackend.vala
+++ b/src/daemon/activity-monitor/MutterActivityMonitorBackend.vala
@@ -94,14 +94,14 @@ public class MutterActivityMonitorBackend : ActivityMonitorBackend {
} catch (GLib.DBusError error) {
GLib.warning ("Error getting mutter idletime: %s", error.message);
}
- this.last_idle_time_update_time_ms = Util.get_monotonic_time_ms ();
+ this.last_idle_time_update_time_ms = TimeUnit.get_monotonic_time_ms ();
}
protected override uint64 time_since_last_event_ms () {
if (this.user_is_active) {
return 0;
} else {
- int64 now = Util.get_monotonic_time_ms ();
+ int64 now = TimeUnit.get_monotonic_time_ms ();
int64 time_since = now - this.last_idle_time_update_time_ms;
uint64 idle_time_ms = this.last_idle_time_ms + time_since;
return idle_time_ms;
diff --git a/src/daemon/break/BreakController.vala b/src/daemon/break/BreakController.vala
index a47debc..1a6adf7 100644
--- a/src/daemon/break/BreakController.vala
+++ b/src/daemon/break/BreakController.vala
@@ -139,7 +139,7 @@ public abstract class BreakController : Object {
*/
public int get_seconds_since_start () {
if (this.activate_timestamp != null) {
- return (int) (Util.get_real_time_seconds () - (int64) this.activate_timestamp);
+ return (int) (TimeUnit.get_real_time_seconds () - (int64) this.activate_timestamp);
} else {
return 0;
}
@@ -152,7 +152,7 @@ public abstract class BreakController : Object {
public void activate () {
if (this.state < State.ACTIVE) {
if (this.activate_timestamp == null) {
- this.activate_timestamp = (int64) Util.get_real_time_seconds ();
+ this.activate_timestamp = (int64) TimeUnit.get_real_time_seconds ();
}
this.state = State.ACTIVE;
this.activated ();
diff --git a/src/daemon/break/BreakView.vala b/src/daemon/break/BreakView.vala
index e30f69d..9deda4e 100644
--- a/src/daemon/break/BreakView.vala
+++ b/src/daemon/break/BreakView.vala
@@ -74,11 +74,11 @@ public abstract class BreakView : UIFragment {
notification.add_action ("info", _("What should I do?"), this.notification_action_info_cb);
}
this.show_notification (notification);
- this.last_break_notification_time = Util.get_real_time_seconds ();
+ this.last_break_notification_time = TimeUnit.get_real_time_seconds ();
}
protected int seconds_since_last_break_notification () {
- int64 now = Util.get_real_time_seconds ();
+ int64 now = TimeUnit.get_real_time_seconds ();
if (this.last_break_notification_time > 0) {
return (int) (now - this.last_break_notification_time);
} else {
diff --git a/src/daemon/meson.build b/src/daemon/meson.build
index 1dc614a..efec58b 100644
--- a/src/daemon/meson.build
+++ b/src/daemon/meson.build
@@ -24,5 +24,5 @@ daemon_sources = files(
'util/PausableTimeout.vala',
'util/SimpleFocusManager.vala',
'util/StatefulTimer.vala',
- 'util/Util.vala'
+ 'util/TimeUnit.vala'
)
diff --git a/src/daemon/restbreak/RestBreakView.vala b/src/daemon/restbreak/RestBreakView.vala
index e3de1c6..d3f8cd1 100644
--- a/src/daemon/restbreak/RestBreakView.vala
+++ b/src/daemon/restbreak/RestBreakView.vala
@@ -88,7 +88,7 @@ public class RestBreakView : TimerBreakView {
private void show_overdue_notification () {
int delay_value;
- int64 now = Util.get_real_time_seconds ();
+ int64 now = TimeUnit.get_real_time_seconds ();
int time_since_start = (int) (now - this.original_start_time);
string delay_text = NaturalTime.instance.get_simplest_label_for_seconds (
time_since_start, out delay_value);
@@ -125,7 +125,7 @@ public class RestBreakView : TimerBreakView {
this.human_is_resting = false;
if (! this.was_skipped) {
- this.original_start_time = Util.get_real_time_seconds ();
+ this.original_start_time = TimeUnit.get_real_time_seconds ();
this.show_start_notification ();
} else {
this.show_overdue_notification ();
diff --git a/src/daemon/util/Countdown.vala b/src/daemon/util/Countdown.vala
index 6e3bcaa..9305f57 100644
--- a/src/daemon/util/Countdown.vala
+++ b/src/daemon/util/Countdown.vala
@@ -43,7 +43,7 @@ public class Countdown : Object {
}
public string serialize () {
- int serialized_time_counted = (int) (Util.get_real_time_seconds () - this.start_time);
+ int serialized_time_counted = (int) (TimeUnit.get_real_time_seconds () - this.start_time);
serialized_time_counted = int.max (0, serialized_time_counted);
return string.joinv (",", {
@@ -147,7 +147,7 @@ public class Countdown : Object {
*/
public void continue_from (int start_offset) {
if (this.state < State.COUNTING) {
- int64 now = Util.get_real_time_seconds ();
+ int64 now = TimeUnit.get_real_time_seconds ();
this.start_time = now + start_offset;
this.state = State.COUNTING;
}
@@ -174,7 +174,7 @@ public class Countdown : Object {
* finished.
*/
public void advance_time (int seconds_off) {
- int64 now = Util.get_real_time_seconds ();
+ int64 now = TimeUnit.get_real_time_seconds ();
if (this.state == State.COUNTING) {
this.start_time = now - seconds_off;
} else {
@@ -242,7 +242,7 @@ public class Countdown : Object {
int time_elapsed = this.stop_time_elapsed;
if (this.state == State.COUNTING) {
- int64 now = Util.get_real_time_seconds ();
+ int64 now = TimeUnit.get_real_time_seconds ();
time_elapsed += (int) (now - this.start_time);
}
diff --git a/src/daemon/util/PausableTimeout.vala b/src/daemon/util/PausableTimeout.vala
index aeeea61..6530aa1 100644
--- a/src/daemon/util/PausableTimeout.vala
+++ b/src/daemon/util/PausableTimeout.vala
@@ -50,7 +50,7 @@ public class PausableTimeout : Object {
}
private bool timeout_wrapper () {
- int64 now = Util.get_monotonic_time ();
+ int64 now = TimeUnit.get_monotonic_time ();
int64 time_delta = now - this.last_time;
this.last_time = now;
@@ -69,7 +69,7 @@ public class PausableTimeout : Object {
Source.remove (this.source_id);
}
- this.last_time = Util.get_monotonic_time ();
+ this.last_time = TimeUnit.get_monotonic_time ();
this.source_id = Timeout.add_seconds (this.frequency, this.timeout_wrapper);
}
diff --git a/src/daemon/util/Util.vala b/src/daemon/util/TimeUnit.vala
similarity index 92%
rename from src/daemon/util/Util.vala
rename to src/daemon/util/TimeUnit.vala
index 2804525..65aaf76 100644
--- a/src/daemon/util/Util.vala
+++ b/src/daemon/util/TimeUnit.vala
@@ -17,11 +17,7 @@
namespace BreakTimer.Daemon {
-/**
- * A collection of handy little functions that can't really be categorized,
- * but end up being used throughout this application.
- */
-public class Util {
+public class TimeUnit {
public const int MILLISECONDS_IN_SECONDS = 1000;
public const int MICROSECONDS_IN_SECONDS = 1000 * 1000;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]