Skip to content

Commit badc062

Browse files
authored
Move CloseReason to AbstractBubble (#270)
1 parent b39f66f commit badc062

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

src/AbstractBubble.vala

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@
1818
*
1919
*/
2020

21+
public enum Notifications.CloseReason {
22+
EXPIRED = 1,
23+
DISMISSED = 2,
24+
/**
25+
* This value is unique for org.freedesktop.Notifications server interface and must not be used elsewhere.
26+
*/
27+
CLOSE_NOTIFICATION_CALL = 3,
28+
UNDEFINED = 4
29+
}
30+
2131
public class Notifications.AbstractBubble : Gtk.Window {
22-
public signal void closed (uint32 reason) {
32+
public signal void closed (CloseReason reason) {
2333
close ();
2434
}
2535

@@ -94,7 +104,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
94104
set_titlebar (new Gtk.Grid ());
95105

96106
carousel.page_changed.connect (on_page_changed);
97-
close_button.clicked.connect (() => closed (Notifications.Server.CloseReason.DISMISSED));
107+
close_button.clicked.connect (() => closed (CloseReason.DISMISSED));
98108

99109
var motion_controller = new Gtk.EventControllerMotion ();
100110
motion_controller.enter.connect (pointer_enter);
@@ -127,7 +137,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
127137

128138
private void on_page_changed (Adw.Carousel carousel, uint index) {
129139
if (carousel.get_nth_page (index) != overlay) {
130-
closed (Notifications.Server.CloseReason.DISMISSED);
140+
closed (CloseReason.DISMISSED);
131141
}
132142
}
133143

@@ -177,11 +187,10 @@ public class Notifications.AbstractBubble : Gtk.Window {
177187
}
178188

179189
private bool timeout_expired () {
180-
closed (Notifications.Server.CloseReason.EXPIRED);
190+
closed (CloseReason.EXPIRED);
181191
return Source.REMOVE;
182192
}
183193

184-
185194
private void get_blur_margins (out int left, out int right) {
186195
var width = get_width ();
187196
var distance = (1 - current_swipe_progress) * width;

src/Bubble.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 elementary, Inc. (https://elementary.io)
2+
* Copyright 2019-2025 elementary, Inc. (https://elementary.io)
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*/
55

@@ -56,7 +56,7 @@ public class Notifications.Bubble : AbstractBubble {
5656
notification.app_info.launch_uris_async.begin (null, null, null, (obj, res) => {
5757
try {
5858
((AppInfo) obj).launch_uris_async.end (res);
59-
closed (Server.CloseReason.UNDEFINED);
59+
closed (CloseReason.UNDEFINED);
6060
} catch (Error e) {
6161
warning ("Unable to launch app: %s", e.message);
6262
}

src/DBus.vala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
/*
2-
* Copyright 2019-2023 elementary, Inc. (https://elementary.io)
2+
* Copyright 2019-2025 elementary, Inc. (https://elementary.io)
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*/
55

66
[DBus (name = "org.freedesktop.Notifications")]
77
public class Notifications.Server : Object {
8-
public enum CloseReason {
9-
EXPIRED = 1,
10-
DISMISSED = 2,
11-
CLOSE_NOTIFICATION_CALL = 3,
12-
UNDEFINED = 4
13-
}
14-
158
public signal void action_invoked (uint32 id, string action_key);
169
public signal void notification_closed (uint32 id, uint32 reason);
1710

src/FdoActionGroup.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 elementary, Inc. (https://elementary.io)
2+
* Copyright 2023-2025 elementary, Inc. (https://elementary.io)
33
* SPDX-License-Identifier: GPL-3.0-or-later
44
*
55
* Author: Gustavo Marques <[email protected]>
@@ -95,7 +95,7 @@ public sealed class Notifications.Fdo.ActionGroup : Object, GLib.ActionGroup {
9595
uint32 id;
9696

9797
while (iter.next ("u", out id)) {
98-
server.notification_closed (id, Server.CloseReason.DISMISSED);
98+
server.notification_closed (id, CloseReason.DISMISSED);
9999
}
100100

101101
return;
@@ -120,7 +120,7 @@ public sealed class Notifications.Fdo.ActionGroup : Object, GLib.ActionGroup {
120120
/* GLib says that we are only meant to override list_actions and query_actions,
121121
* however, the gio bindings only have query_action marked as virtual.
122122
*
123-
* FIXME: remove everthing below when we have valac 0.58 as minimal version.
123+
* FIXME: remove everything below when we have valac 0.58 as minimal version.
124124
*/
125125
public bool has_action (string action_name) {
126126
return action_name in (Gee.Collection<string>) actions;

0 commit comments

Comments
 (0)