View | Details | Raw Unified | Return to bug 51204
Collapse All | Expand All

(-)a/build-aux/flatpak/org.gnome.clocks.json (+1 lines)
Lines 15-20 Link Here
15
        "--socket=wayland",
15
        "--socket=wayland",
16
        "--socket=pulseaudio",
16
        "--socket=pulseaudio",
17
        "--share=network",
17
        "--share=network",
18
        "--system-talk-name=de.seath.Waked",
18
        "--env=G_MESSAGES_DEBUG=org.gnome.ClocksDevel"
19
        "--env=G_MESSAGES_DEBUG=org.gnome.ClocksDevel"
19
    ],
20
    ],
20
    "build-options": {
21
    "build-options": {
(-)a/meson_options.txt (-1 / +3 lines)
Lines 9-12 option( Link Here
9
  description: 'The build profile for Clock. One of "default" or "development".'
9
  description: 'The build profile for Clock. One of "default" or "development".'
10
)
10
)
11
11
12
option('docs', type : 'boolean', value : false)
12
option('docs', type : 'boolean', value : false)
13
14
option('waked', type : 'boolean', value : false)
(-)a/src/alarm-face.vala (+6 lines)
Lines 84-89 public class Face : Adw.Bin, Clocks.Clock { Link Here
84
            });
84
            });
85
85
86
            row.remove_alarm.connect (() => {
86
            row.remove_alarm.connect (() => {
87
#if HAVE_WAKED
88
                Waked.get_default ().remove_timer.begin (((Item) item).id);
89
#endif
87
                alarms.delete_item ((Item) item);
90
                alarms.delete_item ((Item) item);
88
                if (ring_time_toast != null && item == ring_time_toast_alarm) {
91
                if (ring_time_toast != null && item == ring_time_toast_alarm) {
89
                    ring_time_toast_alarm = null;
92
                    ring_time_toast_alarm = null;
Lines 187-192 public class Face : Adw.Bin, Clocks.Clock { Link Here
187
                alarm.active = true;
190
                alarm.active = true;
188
                save ();
191
                save ();
189
            } else if (response == DELETE_ALARM) {
192
            } else if (response == DELETE_ALARM) {
193
#if HAVE_WAKED
194
                Waked.get_default ().remove_timer.begin (alarm.id);
195
#endif
190
                alarms.delete_item (alarm);
196
                alarms.delete_item (alarm);
191
                save ();
197
                save ();
192
            }
198
            }
(-)a/src/alarm-item.vala (+13 lines)
Lines 87-92 private class Item : Object, ContentItem { Link Here
87
                notify_property ("active");
87
                notify_property ("active");
88
            }
88
            }
89
            notify_property ("ring-time");
89
            notify_property ("ring-time");
90
91
#if HAVE_WAKED
92
            if (value == null) {
93
                Waked.get_default ().remove_timer.begin (id);
94
            } else {
95
                Waked.get_default ().update_timer.begin (id, ring_time);
96
            }
97
#endif
90
        }
98
        }
91
    }
99
    }
92
100
Lines 186-191 private class Item : Object, ContentItem { Link Here
186
        var guid = id != null ? (string) id : GLib.DBus.generate_guid ();
194
        var guid = id != null ? (string) id : GLib.DBus.generate_guid ();
187
        Object (id: guid);
195
        Object (id: guid);
188
    }
196
    }
197
    ~Item () {
198
#if HAVE_WAKED
199
        Waked.get_default ().remove_timer.begin (id);
200
#endif
201
    }
189
202
190
    private void setup_bell () {
203
    private void setup_bell () {
191
        bell = new Utils.Bell (GLib.File.new_for_uri ("resource://org/gnome/clocks/sounds/alarm-clock-elapsed.oga"));
204
        bell = new Utils.Bell (GLib.File.new_for_uri ("resource://org/gnome/clocks/sounds/alarm-clock-elapsed.oga"));
(-)a/src/meson.build (+5 lines)
Lines 24-29 clocks_vala_sources = files( Link Here
24
  'timer-setup.vala',
24
  'timer-setup.vala',
25
  'timer-setup-dialog.vala',
25
  'timer-setup-dialog.vala',
26
  'utils.vala',
26
  'utils.vala',
27
  'waked.vala',
27
  'widgets.vala',
28
  'widgets.vala',
28
  'window.vala',
29
  'window.vala',
29
  'world-face.vala',
30
  'world-face.vala',
Lines 47-52 clocks_sources = [ Link Here
47
  resources
48
  resources
48
]
49
]
49
50
51
if get_option('waked')
52
  add_project_arguments('-D', 'HAVE_WAKED', language: 'vala')
53
endif
54
50
clocks_vala_args = [
55
clocks_vala_args = [
51
  '--target-glib', '2.72',
56
  '--target-glib', '2.72',
52
  '--vapidir', meson.current_source_dir(),
57
  '--vapidir', meson.current_source_dir(),
(-)a/src/waked.vala (+76 lines)
Line 0 Link Here
1
/*
2
 * Copyright (C) 2021 Robin Westermann <waked@seath.de>
3
 *
4
 * This program is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU General Public License
6
 * as published by the Free Software Foundation; either version 2
7
 * of the License, or (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
 */
18
19
namespace Clocks {
20
21
[SingleInstance]
22
public class Waked : GLib.Object {
23
    [DBus (name = "de.seath.Waked")]
24
    internal interface WakedProxy : GLib.Object {
25
        public async abstract void add (string id, uint64 time) throws GLib.Error;
26
        public async abstract void update (string id, uint64 time) throws GLib.Error;
27
        public async abstract void remove (string id) throws GLib.Error;
28
    }
29
30
    static Waked instance;
31
    private WakedProxy _waked_proxy;
32
33
    public static Waked get_default () {
34
        if (instance == null) {
35
            instance = new Waked ();
36
        }
37
38
        return instance;
39
    }
40
41
    async WakedProxy get_proxy () throws GLib.IOError {
42
        if (_waked_proxy == null) {
43
            _waked_proxy =
44
                yield Bus.get_proxy<WakedProxy> (
45
                                                BusType.SYSTEM,
46
                                                "de.seath.Waked",
47
                                                "/de/seath/Waked/Alarm");
48
        }
49
50
        return _waked_proxy;
51
    }
52
53
    public async void update_timer (string id, GLib.DateTime time) {
54
        try {
55
            var waked_proxy = yield get_proxy ();
56
57
            yield waked_proxy.update (id, time.to_unix ());
58
59
        } catch (GLib.Error e) {
60
            stderr.printf ("%s\n", e.message);
61
        }
62
    }
63
64
    public async void remove_timer (string id) {
65
        try {
66
            var waked_proxy = yield get_proxy ();
67
68
            yield waked_proxy.remove (id);
69
70
        } catch (GLib.Error e) {
71
            stderr.printf ("%s\n", e.message);
72
        }
73
    }
74
}
75
76
} // namespace Clocks

Return to bug 51204