Merge lp:~donadigo/wingpanel-indicator-notifications/close-notification-support into lp:~wingpanel-devs/wingpanel-indicator-notifications/wingpanel-indicator-notifications
- close-notification-support
- Merge into wingpanel-indicator-notifi...
Proposed by
Adam Bieńkowski
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Danielle Foré | ||||
Proposed branch: | lp:~donadigo/wingpanel-indicator-notifications/close-notification-support | ||||
Merge into: | lp:~wingpanel-devs/wingpanel-indicator-notifications/wingpanel-indicator-notifications | ||||
Diff against target: |
532 lines (+260/-28) (has conflicts) 7 files modified
src/CMakeLists.txt (+1/-1) src/Indicator.vala (+14/-0) src/Services/Notification.vala (+29/-1) src/Services/NotificationMonitor.vala (+56/-26) src/Widgets/AppEntry.vala (+14/-0) src/Widgets/NotificationEntry.vala (+27/-0) src/Widgets/NotificationsList.vala (+119/-0) Text conflict in src/Indicator.vala Text conflict in src/Services/Notification.vala Text conflict in src/Widgets/AppEntry.vala Text conflict in src/Widgets/NotificationEntry.vala Text conflict in src/Widgets/NotificationsList.vala |
||||
To merge this branch: | bzr merge lp:~donadigo/wingpanel-indicator-notifications/close-notification-support | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
elementary Pantheon team | Pending | ||
Review via email: mp+308067@code.launchpad.net |
Commit message
* Add CloseNotification support.
Description of the change
This branch adds CloseNotification call support so apps can withdraw the notifications and they will get removed from the indicator.
To post a comment you must log in.
Unmerged revisions
- 98. By Adam Bieńkowski
-
Added close notification support
- 97. By Adam Bieńkowski
-
Clicking a notification now opens / focuses the app; general code improvements
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/CMakeLists.txt' | |||
2 | --- src/CMakeLists.txt 2016-05-27 15:10:53 +0000 | |||
3 | +++ src/CMakeLists.txt 2016-10-10 16:00:06 +0000 | |||
4 | @@ -20,7 +20,7 @@ | |||
5 | 20 | Widgets/NotificationEntry.vala | 20 | Widgets/NotificationEntry.vala |
6 | 21 | Widgets/AppEntry.vala | 21 | Widgets/AppEntry.vala |
7 | 22 | Widgets/SeparatorEntry.vala | 22 | Widgets/SeparatorEntry.vala |
9 | 23 | Services/NotificationsMonitor.vala | 23 | Services/NotificationMonitor.vala |
10 | 24 | Services/Notification.vala | 24 | Services/Notification.vala |
11 | 25 | Services/NotifySettings.vala | 25 | Services/NotifySettings.vala |
12 | 26 | Services/Session.vala | 26 | Services/Session.vala |
13 | 27 | 27 | ||
14 | === modified file 'src/Indicator.vala' | |||
15 | --- src/Indicator.vala 2016-08-03 06:28:36 +0000 | |||
16 | +++ src/Indicator.vala 2016-10-10 16:00:06 +0000 | |||
17 | @@ -103,6 +103,7 @@ | |||
18 | 103 | nlist.close_popover.connect (() => close ()); | 103 | nlist.close_popover.connect (() => close ()); |
19 | 104 | nlist.switch_stack.connect (on_switch_stack); | 104 | nlist.switch_stack.connect (on_switch_stack); |
20 | 105 | NotificationMonitor.get_instance ().received.connect (on_notification_received); | 105 | NotificationMonitor.get_instance ().received.connect (on_notification_received); |
21 | 106 | NotificationMonitor.get_instance ().close_notification.connect (on_notification_closed); | ||
22 | 106 | 107 | ||
23 | 107 | NotifySettings.get_instance ().changed[NotifySettings.DO_NOT_DISTURB_KEY].connect (() => { | 108 | NotifySettings.get_instance ().changed[NotifySettings.DO_NOT_DISTURB_KEY].connect (() => { |
24 | 108 | not_disturb_switch.get_switch ().active = NotifySettings.get_instance ().do_not_disturb; | 109 | not_disturb_switch.get_switch ().active = NotifySettings.get_instance ().do_not_disturb; |
25 | @@ -160,6 +161,15 @@ | |||
26 | 160 | dynamic_icon.set_main_icon_name (get_display_icon_name ()); | 161 | dynamic_icon.set_main_icon_name (get_display_icon_name ()); |
27 | 161 | } | 162 | } |
28 | 162 | 163 | ||
29 | 164 | private void on_notification_closed (uint32 id) { | ||
30 | 165 | foreach (var item in nlist.items) { | ||
31 | 166 | if (item.notification.id == id) { | ||
32 | 167 | item.notification.close (); | ||
33 | 168 | return; | ||
34 | 169 | } | ||
35 | 170 | } | ||
36 | 171 | } | ||
37 | 172 | |||
38 | 163 | private void on_switch_stack (bool show_list) { | 173 | private void on_switch_stack (bool show_list) { |
39 | 164 | clear_all_btn.sensitive = show_list; | 174 | clear_all_btn.sensitive = show_list; |
40 | 165 | if (show_list) { | 175 | if (show_list) { |
41 | @@ -181,7 +191,11 @@ | |||
42 | 181 | private string get_display_icon_name () { | 191 | private string get_display_icon_name () { |
43 | 182 | if (NotifySettings.get_instance ().do_not_disturb) { | 192 | if (NotifySettings.get_instance ().do_not_disturb) { |
44 | 183 | return "notification-disabled-symbolic"; | 193 | return "notification-disabled-symbolic"; |
45 | 194 | <<<<<<< TREE | ||
46 | 184 | } else if (nlist != null && nlist.get_entries_length () > 0) { | 195 | } else if (nlist != null && nlist.get_entries_length () > 0) { |
47 | 196 | ======= | ||
48 | 197 | } else if (nlist != null && nlist.items.length () > 0) { | ||
49 | 198 | >>>>>>> MERGE-SOURCE | ||
50 | 185 | return "notification-new-symbolic"; | 199 | return "notification-new-symbolic"; |
51 | 186 | } | 200 | } |
52 | 187 | 201 | ||
53 | 188 | 202 | ||
54 | === modified file 'src/Services/Notification.vala' | |||
55 | --- src/Services/Notification.vala 2016-08-03 06:28:36 +0000 | |||
56 | +++ src/Services/Notification.vala 2016-10-10 16:00:06 +0000 | |||
57 | @@ -37,6 +37,7 @@ | |||
58 | 37 | public string desktop_id; | 37 | public string desktop_id; |
59 | 38 | public AppInfo? app_info = null; | 38 | public AppInfo? app_info = null; |
60 | 39 | 39 | ||
61 | 40 | public signal void closed (); | ||
62 | 40 | public signal bool time_changed (TimeSpan span); | 41 | public signal bool time_changed (TimeSpan span); |
63 | 41 | 42 | ||
64 | 42 | private enum Column { | 43 | private enum Column { |
65 | @@ -126,6 +127,7 @@ | |||
66 | 126 | } | 127 | } |
67 | 127 | 128 | ||
68 | 128 | public bool get_is_valid () { | 129 | public bool get_is_valid () { |
69 | 130 | <<<<<<< TREE | ||
70 | 129 | return app_info != null && hints.lookup_value (X_CANONICAL_PRIVATE_KEY, null) == null; | 131 | return app_info != null && hints.lookup_value (X_CANONICAL_PRIVATE_KEY, null) == null; |
71 | 130 | } | 132 | } |
72 | 131 | 133 | ||
73 | @@ -150,6 +152,32 @@ | |||
74 | 150 | } | 152 | } |
75 | 151 | 153 | ||
76 | 152 | return window; | 154 | return window; |
77 | 155 | ======= | ||
78 | 156 | return app_name in OTHER_WHITELIST || appinfo != null; | ||
79 | 157 | } | ||
80 | 158 | |||
81 | 159 | public bool run_default_action () { | ||
82 | 160 | if (DEFAULT_ACTION in actions) { | ||
83 | 161 | INotifications? notifications_iface = NotificationMonitor.get_notifications_iface (); | ||
84 | 162 | if (notifications_iface != null) { | ||
85 | 163 | notifications_iface.action_invoked (DEFAULT_ACTION, id); | ||
86 | 164 | return true; | ||
87 | 165 | } | ||
88 | 166 | } | ||
89 | 167 | |||
90 | 168 | return false; | ||
91 | 169 | } | ||
92 | 170 | |||
93 | 171 | public void close () { | ||
94 | 172 | closed (); | ||
95 | 173 | } | ||
96 | 174 | |||
97 | 175 | private void set_properties () { | ||
98 | 176 | if (app_name in OTHER_WHITELIST) { | ||
99 | 177 | display_name = _("Other"); | ||
100 | 178 | app_icon = "dialog-information"; | ||
101 | 179 | } | ||
102 | 180 | >>>>>>> MERGE-SOURCE | ||
103 | 153 | } | 181 | } |
104 | 154 | 182 | ||
105 | 155 | private void setup_pid () { | 183 | private void setup_pid () { |
106 | @@ -167,7 +195,7 @@ | |||
107 | 167 | } | 195 | } |
108 | 168 | 196 | ||
109 | 169 | try { | 197 | try { |
111 | 170 | IDBus? dbus_iface = Bus.get_proxy_sync (BusType.SESSION, "org.freedesktop.DBus", "/"); | 198 | IDBus? dbus_iface = NotificationMonitor.get_dbus_iface (); |
112 | 171 | if (dbus_iface != null && dbus_iface.name_has_owner (sender)) { | 199 | if (dbus_iface != null && dbus_iface.name_has_owner (sender)) { |
113 | 172 | pid = dbus_iface.get_connection_unix_process_id (sender); | 200 | pid = dbus_iface.get_connection_unix_process_id (sender); |
114 | 173 | } | 201 | } |
115 | 174 | 202 | ||
116 | === renamed file 'src/Services/NotificationsMonitor.vala' => 'src/Services/NotificationMonitor.vala' | |||
117 | --- src/Services/NotificationsMonitor.vala 2016-06-20 12:40:25 +0000 | |||
118 | +++ src/Services/NotificationMonitor.vala 2016-10-10 16:00:06 +0000 | |||
119 | @@ -23,17 +23,20 @@ | |||
120 | 23 | public class NotificationMonitor : Object { | 23 | public class NotificationMonitor : Object { |
121 | 24 | private const string NOTIFY_IFACE = "org.freedesktop.Notifications"; | 24 | private const string NOTIFY_IFACE = "org.freedesktop.Notifications"; |
122 | 25 | private const string NOTIFY_PATH = "/org/freedesktop/Notifications"; | 25 | private const string NOTIFY_PATH = "/org/freedesktop/Notifications"; |
124 | 26 | private const string MATCH_STRING = "eavesdrop='true',type='method_call',interface='org.freedesktop.Notifications',member='Notify'"; | 26 | private const string DBUS_IFACE = "org.freedesktop.DBus"; |
125 | 27 | private const string DBUS_PATH = "/"; | ||
126 | 28 | private const string MATCH_STRING = "eavesdrop='true',type='method_call',interface='org.freedesktop.Notifications'"; | ||
127 | 27 | private const uint32 REASON_DISMISSED = 2; | 29 | private const uint32 REASON_DISMISSED = 2; |
128 | 28 | 30 | ||
129 | 29 | private static NotificationMonitor? instance = null; | 31 | private static NotificationMonitor? instance = null; |
130 | 32 | private static INotifications? notifications_iface = null; | ||
131 | 33 | private static IDBus? dbus_iface = null; | ||
132 | 30 | 34 | ||
133 | 31 | private DBusConnection connection; | 35 | private DBusConnection connection; |
134 | 32 | public INotifications? notifications_iface = null; | ||
135 | 33 | public IDBus? dbus_iface = null; | ||
136 | 34 | private uint32 id_counter = 0; | 36 | private uint32 id_counter = 0; |
137 | 35 | 37 | ||
138 | 36 | public signal void received (DBusMessage message, uint32 id); | 38 | public signal void received (DBusMessage message, uint32 id); |
139 | 39 | public signal void close_notification (uint32 id); | ||
140 | 37 | 40 | ||
141 | 38 | public static NotificationMonitor get_instance () { | 41 | public static NotificationMonitor get_instance () { |
142 | 39 | if (instance == null) { | 42 | if (instance == null) { |
143 | @@ -43,6 +46,30 @@ | |||
144 | 43 | return instance; | 46 | return instance; |
145 | 44 | } | 47 | } |
146 | 45 | 48 | ||
147 | 49 | public static INotifications? get_notifications_iface () { | ||
148 | 50 | if (notifications_iface == null) { | ||
149 | 51 | try { | ||
150 | 52 | notifications_iface = Bus.get_proxy_sync (BusType.SESSION, NOTIFY_IFACE, NOTIFY_PATH); | ||
151 | 53 | } catch (Error e) { | ||
152 | 54 | warning ("%s\n", e.message); | ||
153 | 55 | } | ||
154 | 56 | } | ||
155 | 57 | |||
156 | 58 | return notifications_iface; | ||
157 | 59 | } | ||
158 | 60 | |||
159 | 61 | public static IDBus? get_dbus_iface () { | ||
160 | 62 | if (dbus_iface == null) { | ||
161 | 63 | try { | ||
162 | 64 | dbus_iface = Bus.get_proxy_sync (BusType.SESSION, DBUS_IFACE, DBUS_PATH); | ||
163 | 65 | } catch (Error e) { | ||
164 | 66 | warning ("%s\n", e.message); | ||
165 | 67 | } | ||
166 | 68 | } | ||
167 | 69 | |||
168 | 70 | return dbus_iface; | ||
169 | 71 | } | ||
170 | 72 | |||
171 | 46 | private NotificationMonitor () { | 73 | private NotificationMonitor () { |
172 | 47 | try { | 74 | try { |
173 | 48 | connection = Bus.get_sync (BusType.SESSION); | 75 | connection = Bus.get_sync (BusType.SESSION); |
174 | @@ -61,12 +88,6 @@ | |||
175 | 61 | var body = new Variant.parsed ("(%s,)", MATCH_STRING); | 88 | var body = new Variant.parsed ("(%s,)", MATCH_STRING); |
176 | 62 | message.set_body (body); | 89 | message.set_body (body); |
177 | 63 | 90 | ||
178 | 64 | try { | ||
179 | 65 | notifications_iface = Bus.get_proxy_sync (BusType.SESSION, NOTIFY_IFACE, NOTIFY_PATH); | ||
180 | 66 | } catch (Error e) { | ||
181 | 67 | error ("%s\n", e.message); | ||
182 | 68 | } | ||
183 | 69 | |||
184 | 70 | id_counter = get_current_notification_id (); | 91 | id_counter = get_current_notification_id (); |
185 | 71 | try { | 92 | try { |
186 | 72 | connection.send_message (message, DBusSendMessageFlags.NONE, null); | 93 | connection.send_message (message, DBusSendMessageFlags.NONE, null); |
187 | @@ -78,24 +99,33 @@ | |||
188 | 78 | } | 99 | } |
189 | 79 | 100 | ||
190 | 80 | private DBusMessage message_filter (DBusConnection con, owned DBusMessage message, bool incoming) { | 101 | private DBusMessage message_filter (DBusConnection con, owned DBusMessage message, bool incoming) { |
201 | 81 | if (incoming) { | 102 | if (incoming) { |
202 | 82 | if ((message.get_message_type () == DBusMessageType.METHOD_CALL) && | 103 | if (message.get_message_type () == DBusMessageType.METHOD_CALL && |
203 | 83 | (message.get_interface () == NOTIFY_IFACE) && | 104 | message.get_interface () == NOTIFY_IFACE) { |
204 | 84 | (message.get_member () == "Notify")) { | 105 | if (message.get_member () == "Notify") { |
205 | 85 | uint32 replaces_id = message.get_body ().get_child_value (1).get_uint32 (); | 106 | uint32 replaces_id = message.get_body ().get_child_value (1).get_uint32 (); |
206 | 86 | uint32 current_id = replaces_id; | 107 | uint32 current_id = replaces_id; |
207 | 87 | 108 | ||
208 | 88 | if (replaces_id == 0) { | 109 | if (replaces_id == 0) { |
209 | 89 | id_counter++; | 110 | id_counter++; |
210 | 90 | current_id = id_counter; | 111 | current_id = id_counter; |
211 | 112 | } | ||
212 | 113 | |||
213 | 114 | Idle.add (() => { | ||
214 | 115 | received (message, current_id); | ||
215 | 116 | message = null; | ||
216 | 117 | return false; | ||
217 | 118 | }); | ||
218 | 119 | } else if (message.get_member () == "CloseNotification") { | ||
219 | 120 | uint32 id = message.get_body ().get_child_value (0).get_uint32 (); | ||
220 | 121 | |||
221 | 122 | Idle.add (() => { | ||
222 | 123 | close_notification (id); | ||
223 | 124 | message = null; | ||
224 | 125 | return false; | ||
225 | 126 | }); | ||
226 | 91 | } | 127 | } |
227 | 92 | 128 | ||
228 | 93 | Idle.add (() => { | ||
229 | 94 | this.received (message, current_id); | ||
230 | 95 | message = null; | ||
231 | 96 | return false; | ||
232 | 97 | }); | ||
233 | 98 | |||
234 | 99 | return null; | 129 | return null; |
235 | 100 | } | 130 | } |
236 | 101 | } | 131 | } |
237 | @@ -109,7 +139,7 @@ | |||
238 | 109 | hints.insert ("suppress-sound", new Variant.boolean (true)); | 139 | hints.insert ("suppress-sound", new Variant.boolean (true)); |
239 | 110 | string[] actions = {}; | 140 | string[] actions = {}; |
240 | 111 | try { | 141 | try { |
242 | 112 | return notifications_iface.notify ("", 0, "", "", "", actions, hints, 1); | 142 | return get_notifications_iface ().notify ("", 0, "", "", "", actions, hints, 1); |
243 | 113 | } catch (Error e) { | 143 | } catch (Error e) { |
244 | 114 | error ("%s\n", e.message); | 144 | error ("%s\n", e.message); |
245 | 115 | } | 145 | } |
246 | 116 | 146 | ||
247 | === modified file 'src/Widgets/AppEntry.vala' | |||
248 | --- src/Widgets/AppEntry.vala 2016-07-20 20:11:51 +0000 | |||
249 | +++ src/Widgets/AppEntry.vala 2016-10-10 16:00:06 +0000 | |||
250 | @@ -66,8 +66,22 @@ | |||
251 | 66 | return null; | 66 | return null; |
252 | 67 | } | 67 | } |
253 | 68 | 68 | ||
254 | 69 | <<<<<<< TREE | ||
255 | 69 | var entry = app_notifications.first ().data; | 70 | var entry = app_notifications.first ().data; |
256 | 70 | return entry.notification.get_app_window (); | 71 | return entry.notification.get_app_window (); |
257 | 72 | ======= | ||
258 | 73 | public void update_app_window () { | ||
259 | 74 | if (app_notifications.length () == 0) { | ||
260 | 75 | return; | ||
261 | 76 | } | ||
262 | 77 | |||
263 | 78 | var notification_entry = app_notifications.nth_data (0); | ||
264 | 79 | app_window = notification_entry.get_app_window (); | ||
265 | 80 | } | ||
266 | 81 | |||
267 | 82 | public unowned List<NotificationEntry> get_notifications () { | ||
268 | 83 | return app_notifications; | ||
269 | 84 | >>>>>>> MERGE-SOURCE | ||
270 | 71 | } | 85 | } |
271 | 72 | 86 | ||
272 | 73 | public void add_notification_entry (NotificationEntry entry) { | 87 | public void add_notification_entry (NotificationEntry entry) { |
273 | 74 | 88 | ||
274 | === modified file 'src/Widgets/NotificationEntry.vala' | |||
275 | --- src/Widgets/NotificationEntry.vala 2016-07-20 20:36:57 +0000 | |||
276 | +++ src/Widgets/NotificationEntry.vala 2016-10-10 16:00:06 +0000 | |||
277 | @@ -53,8 +53,35 @@ | |||
278 | 53 | return active; | 53 | return active; |
279 | 54 | }); | 54 | }); |
280 | 55 | 55 | ||
281 | 56 | notification.closed.connect (() => { | ||
282 | 57 | clear (); | ||
283 | 58 | }); | ||
284 | 59 | |||
285 | 56 | hexpand = true; | 60 | hexpand = true; |
286 | 61 | <<<<<<< TREE | ||
287 | 57 | 62 | ||
288 | 63 | ======= | ||
289 | 64 | add_widgets (); | ||
290 | 65 | |||
291 | 66 | if (notification.data_session) { | ||
292 | 67 | notification.time_changed (notification.timestamp.difference (new DateTime.now_local ())); | ||
293 | 68 | } | ||
294 | 69 | } | ||
295 | 70 | |||
296 | 71 | public Wnck.Window? get_app_window () { | ||
297 | 72 | Wnck.Window? window = null; | ||
298 | 73 | Wnck.Screen.get_default ().get_windows ().@foreach ((_window) => { | ||
299 | 74 | if (_window.get_pid () == notification.pid) { | ||
300 | 75 | window = _window; | ||
301 | 76 | return; | ||
302 | 77 | } | ||
303 | 78 | }); | ||
304 | 79 | |||
305 | 80 | return window; | ||
306 | 81 | } | ||
307 | 82 | |||
308 | 83 | private void add_widgets () { | ||
309 | 84 | >>>>>>> MERGE-SOURCE | ||
310 | 58 | var grid = new Gtk.Grid (); | 85 | var grid = new Gtk.Grid (); |
311 | 59 | grid.margin_start = 40; | 86 | grid.margin_start = 40; |
312 | 60 | grid.margin_end = 6; | 87 | grid.margin_end = 6; |
313 | 61 | 88 | ||
314 | === modified file 'src/Widgets/NotificationsList.vala' | |||
315 | --- src/Widgets/NotificationsList.vala 2016-07-21 12:52:41 +0000 | |||
316 | +++ src/Widgets/NotificationsList.vala 2016-10-10 16:00:06 +0000 | |||
317 | @@ -18,7 +18,11 @@ | |||
318 | 18 | public class NotificationsList : Gtk.ListBox { | 18 | public class NotificationsList : Gtk.ListBox { |
319 | 19 | public signal void switch_stack (bool show_list); | 19 | public signal void switch_stack (bool show_list); |
320 | 20 | public signal void close_popover (); | 20 | public signal void close_popover (); |
321 | 21 | <<<<<<< TREE | ||
322 | 21 | 22 | ||
323 | 23 | ======= | ||
324 | 24 | public List<NotificationEntry> items; | ||
325 | 25 | >>>>>>> MERGE-SOURCE | ||
326 | 22 | private List<AppEntry> app_entries; | 26 | private List<AppEntry> app_entries; |
327 | 23 | private HashTable<string, int> table; | 27 | private HashTable<string, int> table; |
328 | 24 | private int counter = 0; | 28 | private int counter = 0; |
329 | @@ -47,9 +51,24 @@ | |||
330 | 47 | 51 | ||
331 | 48 | switch_stack (true); | 52 | switch_stack (true); |
332 | 49 | 53 | ||
333 | 54 | <<<<<<< TREE | ||
334 | 50 | app_entry.clear.connect (clear_app_entry); | 55 | app_entry.clear.connect (clear_app_entry); |
335 | 51 | 56 | ||
336 | 52 | counter += 2; | 57 | counter += 2; |
337 | 58 | ======= | ||
338 | 59 | app_entry.add_notification_entry (entry); | ||
339 | 60 | resort_app_entry (app_entry); | ||
340 | 61 | |||
341 | 62 | entry.clear.connect (() => { | ||
342 | 63 | destroy_notification_entry.begin (entry); | ||
343 | 64 | }); | ||
344 | 65 | |||
345 | 66 | app_entry.destroy_entry.connect (() => { | ||
346 | 67 | destroy_app_entry (app_entry); | ||
347 | 68 | }); | ||
348 | 69 | |||
349 | 70 | counter += 2; | ||
350 | 71 | >>>>>>> MERGE-SOURCE | ||
351 | 53 | 72 | ||
352 | 54 | Session.get_instance ().add_notification (entry.notification); | 73 | Session.get_instance ().add_notification (entry.notification); |
353 | 55 | 74 | ||
354 | @@ -57,11 +76,14 @@ | |||
355 | 57 | show_all (); | 76 | show_all (); |
356 | 58 | } | 77 | } |
357 | 59 | 78 | ||
358 | 79 | <<<<<<< TREE | ||
359 | 60 | 80 | ||
360 | 61 | public uint get_entries_length () { | 81 | public uint get_entries_length () { |
361 | 62 | return app_entries.length (); | 82 | return app_entries.length (); |
362 | 63 | } | 83 | } |
363 | 64 | 84 | ||
364 | 85 | ======= | ||
365 | 86 | >>>>>>> MERGE-SOURCE | ||
366 | 65 | public void clear_all () { | 87 | public void clear_all () { |
367 | 66 | app_entries.foreach ((app_entry) => { | 88 | app_entries.foreach ((app_entry) => { |
368 | 67 | app_entry.clear (); | 89 | app_entry.clear (); |
369 | @@ -109,15 +131,30 @@ | |||
370 | 109 | AppEntry? app_entry = null; | 131 | AppEntry? app_entry = null; |
371 | 110 | bool add = !(entry.notification.desktop_id in construct_desktop_id_list ()); | 132 | bool add = !(entry.notification.desktop_id in construct_desktop_id_list ()); |
372 | 111 | if (add) { | 133 | if (add) { |
373 | 134 | <<<<<<< TREE | ||
374 | 112 | app_entry = new AppEntry (entry); | 135 | app_entry = new AppEntry (entry); |
375 | 136 | ======= | ||
376 | 137 | var window = entry.get_app_window (); | ||
377 | 138 | app_entry = new AppEntry (entry, window); | ||
378 | 139 | |||
379 | 140 | screen.active_window_changed.connect (() => { | ||
380 | 141 | if (screen.get_active_window () == app_entry.app_window) { | ||
381 | 142 | app_entry.clear_btn_entry.clicked (); | ||
382 | 143 | } | ||
383 | 144 | }); | ||
384 | 145 | >>>>>>> MERGE-SOURCE | ||
385 | 113 | 146 | ||
386 | 114 | app_entries.append (app_entry); | 147 | app_entries.append (app_entry); |
387 | 115 | prepend (app_entry); | 148 | prepend (app_entry); |
388 | 116 | insert (entry, 1); | 149 | insert (entry, 1); |
389 | 117 | table.insert (app_entry.app_info.get_id (), 0); | 150 | table.insert (app_entry.app_info.get_id (), 0); |
390 | 118 | } else { | 151 | } else { |
391 | 152 | <<<<<<< TREE | ||
392 | 119 | app_entry = get_app_entry_from_desktop_id (entry.notification.desktop_id); | 153 | app_entry = get_app_entry_from_desktop_id (entry.notification.desktop_id); |
393 | 120 | 154 | ||
394 | 155 | ======= | ||
395 | 156 | app_entry = get_from_app_name (entry.notification.app_name); | ||
396 | 157 | >>>>>>> MERGE-SOURCE | ||
397 | 121 | if (app_entry != null) { | 158 | if (app_entry != null) { |
398 | 122 | resort_app_entry (app_entry); | 159 | resort_app_entry (app_entry); |
399 | 123 | app_entry.add_notification_entry (entry); | 160 | app_entry.add_notification_entry (entry); |
400 | @@ -130,6 +167,7 @@ | |||
401 | 130 | return app_entry; | 167 | return app_entry; |
402 | 131 | } | 168 | } |
403 | 132 | 169 | ||
404 | 170 | <<<<<<< TREE | ||
405 | 133 | private void monitor_active_window () { | 171 | private void monitor_active_window () { |
406 | 134 | var screen = Wnck.Screen.get_default (); | 172 | var screen = Wnck.Screen.get_default (); |
407 | 135 | screen.active_window_changed.connect (() => { | 173 | screen.active_window_changed.connect (() => { |
408 | @@ -142,6 +180,22 @@ | |||
409 | 142 | } | 180 | } |
410 | 143 | 181 | ||
411 | 144 | private void clear_app_entry (AppEntry app_entry) { | 182 | private void clear_app_entry (AppEntry app_entry) { |
412 | 183 | ======= | ||
413 | 184 | private async void destroy_notification_entry (NotificationEntry entry) { | ||
414 | 185 | entry.destroy (); | ||
415 | 186 | items.remove (entry); | ||
416 | 187 | entry.active = false; | ||
417 | 188 | |||
418 | 189 | Session.get_instance ().remove_notification (entry.notification); | ||
419 | 190 | if (items.length () == 0) { | ||
420 | 191 | clear_all (); | ||
421 | 192 | } | ||
422 | 193 | |||
423 | 194 | update_separators (); | ||
424 | 195 | } | ||
425 | 196 | |||
426 | 197 | private void destroy_app_entry (AppEntry app_entry) { | ||
427 | 198 | >>>>>>> MERGE-SOURCE | ||
428 | 145 | app_entries.remove (app_entry); | 199 | app_entries.remove (app_entry); |
429 | 146 | 200 | ||
430 | 147 | app_entry.app_notifications.foreach ((notification_entry) => { | 201 | app_entry.app_notifications.foreach ((notification_entry) => { |
431 | @@ -154,6 +208,7 @@ | |||
432 | 154 | if (get_entries_length () == 0) { | 208 | if (get_entries_length () == 0) { |
433 | 155 | clear_all (); | 209 | clear_all (); |
434 | 156 | } | 210 | } |
435 | 211 | <<<<<<< TREE | ||
436 | 157 | } | 212 | } |
437 | 158 | 213 | ||
438 | 159 | private AppEntry? get_app_entry_from_desktop_id (string desktop_id) { | 214 | private AppEntry? get_app_entry_from_desktop_id (string desktop_id) { |
439 | @@ -161,6 +216,31 @@ | |||
440 | 161 | app_entries.foreach ((_app_entry) => { | 216 | app_entries.foreach ((_app_entry) => { |
441 | 162 | if (_app_entry.app_info.get_id () == desktop_id && app_entry == null) { | 217 | if (_app_entry.app_info.get_id () == desktop_id && app_entry == null) { |
442 | 163 | app_entry = _app_entry; | 218 | app_entry = _app_entry; |
443 | 219 | ======= | ||
444 | 220 | |||
445 | 221 | update_separators (); | ||
446 | 222 | } | ||
447 | 223 | |||
448 | 224 | private void resort_app_entry (AppEntry app_entry) { | ||
449 | 225 | if (get_row_at_index (0) != app_entry) { | ||
450 | 226 | remove (app_entry); | ||
451 | 227 | prepend (app_entry); | ||
452 | 228 | int counter = 1; | ||
453 | 229 | app_entry.get_notifications ().@foreach ((notification_entry) => { | ||
454 | 230 | remove (notification_entry); | ||
455 | 231 | add_item (notification_entry); | ||
456 | 232 | counter++; | ||
457 | 233 | }); | ||
458 | 234 | } | ||
459 | 235 | } | ||
460 | 236 | |||
461 | 237 | private AppEntry? get_from_app_name (string app_name) { | ||
462 | 238 | AppEntry? entry = null; | ||
463 | 239 | app_entries.@foreach ((_entry) => { | ||
464 | 240 | if (_entry.app_name == app_name) { | ||
465 | 241 | entry = _entry; | ||
466 | 242 | return; | ||
467 | 243 | >>>>>>> MERGE-SOURCE | ||
468 | 164 | } | 244 | } |
469 | 165 | }); | 245 | }); |
470 | 166 | 246 | ||
471 | @@ -177,6 +257,7 @@ | |||
472 | 177 | } | 257 | } |
473 | 178 | 258 | ||
474 | 179 | private void on_row_activated (Gtk.ListBoxRow row) { | 259 | private void on_row_activated (Gtk.ListBoxRow row) { |
475 | 260 | <<<<<<< TREE | ||
476 | 180 | bool close = true; | 261 | bool close = true; |
477 | 181 | 262 | ||
478 | 182 | if (row is AppEntry) { | 263 | if (row is AppEntry) { |
479 | @@ -200,10 +281,34 @@ | |||
480 | 200 | 281 | ||
481 | 201 | if (close) { | 282 | if (close) { |
482 | 202 | close_popover (); | 283 | close_popover (); |
483 | 284 | ======= | ||
484 | 285 | if (row is AppEntry) { | ||
485 | 286 | var app_entry = (AppEntry)row; | ||
486 | 287 | if (app_entry.app_window == null) { | ||
487 | 288 | app_entry.update_app_window (); | ||
488 | 289 | } | ||
489 | 290 | |||
490 | 291 | focus_notification_app (app_entry.app_window, | ||
491 | 292 | app_entry.appinfo); | ||
492 | 293 | |||
493 | 294 | app_entry.clear_btn_entry.clicked (); | ||
494 | 295 | close_popover (); | ||
495 | 296 | } else if (row is NotificationEntry) { | ||
496 | 297 | var notification_entry = (NotificationEntry)row; | ||
497 | 298 | if (!notification_entry.notification.run_default_action ()) { | ||
498 | 299 | focus_notification_app (notification_entry.get_app_window (), | ||
499 | 300 | notification_entry.notification.appinfo); | ||
500 | 301 | } | ||
501 | 302 | |||
502 | 303 | notification_entry.clear (); | ||
503 | 304 | notification_entry.active = false; | ||
504 | 305 | close_popover (); | ||
505 | 306 | >>>>>>> MERGE-SOURCE | ||
506 | 203 | } | 307 | } |
507 | 204 | 308 | ||
508 | 205 | update_separators (); | 309 | update_separators (); |
509 | 206 | } | 310 | } |
510 | 311 | <<<<<<< TREE | ||
511 | 207 | 312 | ||
512 | 208 | private bool focus_notification_app (Wnck.Window? app_window, AppInfo? app_info) { | 313 | private bool focus_notification_app (Wnck.Window? app_window, AppInfo? app_info) { |
513 | 209 | if (app_window != null) { | 314 | if (app_window != null) { |
514 | @@ -220,4 +325,18 @@ | |||
515 | 220 | 325 | ||
516 | 221 | return false; | 326 | return false; |
517 | 222 | } | 327 | } |
518 | 328 | ======= | ||
519 | 329 | |||
520 | 330 | private void focus_notification_app (Wnck.Window? app_window, AppInfo? appinfo) { | ||
521 | 331 | if (app_window != null) { | ||
522 | 332 | app_window.unminimize (Gtk.get_current_event_time ()); | ||
523 | 333 | } else if (appinfo != null) { | ||
524 | 334 | try { | ||
525 | 335 | appinfo.launch (null, null); | ||
526 | 336 | } catch (Error e) { | ||
527 | 337 | warning ("%s\n", e.message); | ||
528 | 338 | } | ||
529 | 339 | } | ||
530 | 340 | } | ||
531 | 341 | >>>>>>> MERGE-SOURCE | ||
532 | 223 | } | 342 | } |