[gnome-clocks] window: Fix notifications are immediately withdrawn
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] window: Fix notifications are immediately withdrawn
- Date: Sun, 7 Aug 2022 09:49:41 +0000 (UTC)
commit e989de6e50b6a8a8695416014f8337fa9403af71
Author: Sophie Herold <sophie hemio de>
Date: Sun Aug 7 09:49:40 2022 +0000
window: Fix notifications are immediately withdrawn
data/ui/window.ui | 6 +-----
src/application.vala | 6 +++++-
src/window.vala | 6 ++++--
3 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 8cd9e797..99c80529 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -2,16 +2,12 @@
<interface>
<template class="ClocksWindow" parent="AdwApplicationWindow">
<property name="hide-on-close">True</property>
+ <signal name="notify::is-active" handler="on_window_active"/>
<child>
<object class="GtkEventControllerKey">
<signal name="key-pressed" handler="key_press_cb"/>
</object>
</child>
- <child>
- <object class="GtkEventControllerFocus">
- <signal name="enter" handler="enter_cb"/>
- </object>
- </child>
<child>
<object class="AdwLeaflet" id="alarm_leaflet">
<property name="orientation">vertical</property>
diff --git a/src/application.vala b/src/application.vala
index 6c1e39af..589f13c5 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -144,13 +144,17 @@ public class Application : Adw.Application {
public new void send_notification (string notification_id, GLib.Notification notification) {
base.send_notification (notification_id, notification);
- system_notifications.append (notification_id);
+ if (system_notifications.find (notification_id) == null) {
+ system_notifications.append (notification_id);
+ }
}
public void withdraw_notifications () {
foreach (var notification in system_notifications) {
withdraw_notification (notification);
}
+
+ system_notifications = new List<string> ();
}
public override void shutdown () {
diff --git a/src/window.vala b/src/window.vala
index 0f2cfbab..c6eb9d17 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -229,8 +229,10 @@ public class Window : Adw.ApplicationWindow {
}
[GtkCallback]
- private void enter_cb (Gtk.EventControllerFocus controller) {
- ((Application) application).withdraw_notifications ();
+ private void on_window_active () {
+ if (is_active) {
+ ((Application) application).withdraw_notifications ();
+ }
}
[GtkCallback]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]