- commit
- ba8f7a467521912c47f0e00dfc911d957ad38eb6
- parent
- 1142001627a375d36b69276ee2f41694cb05db72
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-10-11 09:59
avoid using app_name to identify thread because it is optional see also https://bugzilla.gnome.org/show_bug.cgi?id=766882
Diffstat
| M | notification_hub.py | 16 | +++++++++------- |
1 files changed, 9 insertions, 7 deletions
diff --git a/notification_hub.py b/notification_hub.py
@@ -63,8 +63,8 @@ menu = None 63 63 threads = {} 64 64 65 6566 -1 def clear_thread(item, app_name):67 -1 del threads[app_name]-1 66 def clear_thread(item, key): -1 67 del threads[key] 68 68 menu.remove(item) 69 69 if len(menu) == 0: 70 70 indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE) @@ -74,9 +74,11 @@ def on_add_notification(params, id): 74 74 app_name = params[0] 75 75 replaces_id = params[1] 76 76 summary = params[3] -1 77 hints = params[6] 77 78 78 79 label = f'{app_name}: {summary}'79 -1 thread = threads.get(app_name)-1 80 key = hints.get('desktop-entry', app_name) -1 81 thread = threads.get(key) 80 82 81 83 if thread: 82 84 if replaces_id in thread['ids']: @@ -85,23 +87,23 @@ def on_add_notification(params, id): 85 87 thread['menuitem'].set_label(label) 86 88 else: 87 89 item = Gtk.MenuItem(label=label)88 -1 item.connect('activate', clear_thread, app_name)-1 90 item.connect('activate', clear_thread, key) 89 91 menu.append(item) 90 92 menu.show_all() 91 93 indicator.set_status(AppIndicator3.IndicatorStatus.ATTENTION) 92 9493 -1 threads[app_name] = {-1 95 threads[key] = { 94 96 'menuitem': item, 95 97 'ids': {id}, 96 98 } 97 99 98 100 99 101 def on_close_notification(id):100 -1 for app_name, thread in list(threads.items()):-1 102 for key, thread in list(threads.items()): 101 103 if id in thread['ids']: 102 104 thread['ids'].remove(id) 103 105 if not thread['ids']:104 -1 clear_thread(thread['menuitem'], app_name)-1 106 clear_thread(thread['menuitem'], key) 105 107 106 108 107 109 def on_call(