11/*
2- * Copyright 2020 elementary, Inc. (https://elementary.io)
2+ * Copyright 2020-2025 elementary, Inc. (https://elementary.io)
33*
44* This program is free software; you can redistribute it and/or
55* modify it under the terms of the GNU General Public
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+
2131public class Notifications.AbstractBubble : Gtk .Window {
22- public signal void closed (uint32 reason ) {
32+ public signal void closed (CloseReason reason ) {
2333 close ();
2434 }
2535
@@ -31,6 +41,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
3141
3242 private Gtk . Revealer close_revealer;
3343 private Gtk . Box draw_area;
44+ private Gtk . Overlay overlay;
3445
3546 private uint timeout_id;
3647
@@ -72,7 +83,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
7283 overflow = VISIBLE
7384 };
7485
75- var overlay = new Gtk .Overlay () {
86+ overlay = new Gtk .Overlay () {
7687 child = draw_area
7788 };
7889 overlay. add_overlay (close_revealer);
@@ -92,12 +103,8 @@ public class Notifications.AbstractBubble : Gtk.Window {
92103 can_focus = false ;
93104 set_titlebar (new Gtk .Grid ());
94105
95- carousel. page_changed. connect ((index) = > {
96- if (index == 0 ) {
97- closed (Notifications . Server . CloseReason . DISMISSED );
98- }
99- });
100- close_button. clicked. connect (() = > closed (Notifications . Server . CloseReason . DISMISSED ));
106+ carousel. page_changed. connect (on_page_changed);
107+ close_button. clicked. connect (() = > closed (CloseReason . DISMISSED ));
101108
102109 var motion_controller = new Gtk .EventControllerMotion ();
103110 motion_controller. enter. connect (pointer_enter);
@@ -114,18 +121,7 @@ public class Notifications.AbstractBubble : Gtk.Window {
114121 }
115122 });
116123
117- carousel. notify[" position" ]. connect (() = > {
118- current_swipe_progress = carousel. position;
119-
120- if (desktop_panel != null ) {
121- int left, right;
122- get_blur_margins (out left, out right);
123-
124- desktop_panel. add_blur (left, right, 16 , 16 , 9 );
125- } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
126- x11_update_mutter_hints ();
127- }
128- });
124+ carousel. notify[" position" ]. connect (update_swipe_progress);
129125
130126 transparency_settings. changed[" use-transparency" ]. connect (update_transparency);
131127 update_transparency ();
@@ -139,6 +135,27 @@ public class Notifications.AbstractBubble : Gtk.Window {
139135 }
140136 }
141137
138+ private void on_page_changed (Adw .Carousel carousel , uint index ) {
139+ if (carousel. get_nth_page (index) != overlay) {
140+ closed (CloseReason . DISMISSED );
141+ }
142+ }
143+
144+ private void update_swipe_progress (Object obj , ParamSpec pspec ) {
145+ var carousel = (Adw . Carousel ) obj;
146+
147+ current_swipe_progress = carousel. position;
148+
149+ if (desktop_panel != null ) {
150+ int left, right;
151+ get_blur_margins (out left, out right);
152+
153+ desktop_panel. add_blur (left, right, 16 , 16 , 9 );
154+ } else if (Gdk . Display . get_default () is Gdk . X11. Display ) {
155+ x11_update_mutter_hints ();
156+ }
157+ }
158+
142159 public new void present () {
143160 if (timeout_id != 0 ) {
144161 Source . remove (timeout_id);
@@ -170,11 +187,10 @@ public class Notifications.AbstractBubble : Gtk.Window {
170187 }
171188
172189 private bool timeout_expired () {
173- closed (Notifications . Server . CloseReason . EXPIRED );
190+ closed (CloseReason . EXPIRED );
174191 return Source . REMOVE ;
175192 }
176193
177-
178194 private void get_blur_margins (out int left , out int right ) {
179195 var width = get_width ();
180196 var distance = (1 - current_swipe_progress) * width;
0 commit comments