diff options
author | Kevin <[email protected]> | 2024-10-16 00:49:16 -0300 |
---|---|---|
committer | Kevin <[email protected]> | 2024-10-16 00:49:16 -0300 |
commit | 2b1e8501b46056b79d97e90c6ec94e3ad36d0ab2 (patch) | |
tree | 6486e98bd1ba523b1aeb4bd2566d1ff6e5c41798 /core/src/time.vala | |
parent | 03f2c4706faba7dac5aee71b10255eac218cbeec (diff) | |
parent | 236487001ab2a6c9c8e87e5db0ced9e5ab3ed791 (diff) |
Merge branch 'adapt-upstream-changes'
Diffstat (limited to 'core/src/time.vala')
-rw-r--r-- | core/src/time.vala | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/core/src/time.vala b/core/src/time.vala deleted file mode 100644 index 4034c04..0000000 --- a/core/src/time.vala +++ /dev/null @@ -1,73 +0,0 @@ -namespace Astal { -public class Time : Object { - public signal void now (); - public signal void cancelled (); - private Cancellable cancellable; - private uint timeout_id; - private bool fulfilled = false; - - construct { - cancellable = new Cancellable(); - cancellable.cancelled.connect(() => { - if (!fulfilled) { - Source.remove(timeout_id); - cancelled(); - dispose(); - } - }); - } - - private void connect_closure(Closure? closure) { - if (closure == null) - return; - - now.connect(() => { - Value ret = Value(Type.POINTER); // void - closure.invoke(ref ret, {}); - }); - } - - public Time.interval_prio(uint interval, int prio = Priority.DEFAULT, Closure? fn) { - connect_closure(fn); - Idle.add_once(() => now()); - timeout_id = Timeout.add(interval, () => { - now(); - return Source.CONTINUE; - }, prio); - } - - public Time.timeout_prio(uint timeout, int prio = Priority.DEFAULT, Closure? fn) { - connect_closure(fn); - timeout_id = Timeout.add(timeout, () => { - now(); - fulfilled = true; - return Source.REMOVE; - }, prio); - } - - public Time.idle_prio(int prio = Priority.DEFAULT_IDLE, Closure? fn) { - connect_closure(fn); - timeout_id = Idle.add(() => { - now(); - fulfilled = true; - return Source.REMOVE; - }, prio); - } - - public static Time interval(uint interval, Closure? fn) { - return new Time.interval_prio(interval, Priority.DEFAULT, fn); - } - - public static Time timeout(uint timeout, Closure? fn) { - return new Time.timeout_prio(timeout, Priority.DEFAULT, fn); - } - - public static Time idle(Closure? fn) { - return new Time.idle_prio(Priority.DEFAULT_IDLE, fn); - } - - public void cancel() { - cancellable.cancel(); - } -} -} |