[gnome-break-timer] Change hide_notification to have a clearer function signature
- From: Dylan McCall <dylanmccall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-break-timer] Change hide_notification to have a clearer function signature
- Date: Fri, 20 Nov 2020 04:19:35 +0000 (UTC)
commit 11514967cef687063ba02da278301b1e6d829942
Author: Dylan McCall <dylan dylanmccall ca>
Date: Thu Nov 19 19:26:38 2020 -0800
Change hide_notification to have a clearer function signature
src/daemon/UIFragment.vala | 4 ++--
src/daemon/UIManager.vala | 16 ++++++++++------
src/daemon/break/BreakView.vala | 26 +++++++++++++++++++-------
src/daemon/microbreak/MicroBreakView.vala | 2 +-
src/daemon/restbreak/RestBreakView.vala | 2 +-
5 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/src/daemon/UIFragment.vala b/src/daemon/UIFragment.vala
index e7f4808..bd5e0bc 100644
--- a/src/daemon/UIFragment.vala
+++ b/src/daemon/UIFragment.vala
@@ -82,8 +82,8 @@ public abstract class UIFragment : GLib.Object, IFocusable {
}
}
- protected void hide_notification () {
- this.ui_manager.hide_notification (this.notification);
+ protected void hide_notification (UIManager.HideNotificationMethod method=IMMEDIATE) {
+ this.ui_manager.hide_notification (this.notification, method);
}
/* IFocusable interface */
diff --git a/src/daemon/UIManager.vala b/src/daemon/UIManager.vala
index 7c4db0e..543a529 100644
--- a/src/daemon/UIManager.vala
+++ b/src/daemon/UIManager.vala
@@ -38,6 +38,11 @@ public class UIManager : SimpleFocusManager, GLib.Initable {
private GLib.List<string> notify_capabilities;
+ public enum HideNotificationMethod {
+ IMMEDIATE,
+ DELAYED
+ }
+
public UIManager (Gtk.Application application, ISessionStatus session_status) {
this.application = application;
this.session_status = session_status;
@@ -73,7 +78,7 @@ public class UIManager : SimpleFocusManager, GLib.Initable {
*/
if (notification != this.notification) {
- this.hide_notification (this.notification);
+ this.hide_notification (this.notification, IMMEDIATE);
}
notification.set_hint ("desktop-entry", Config.DAEMON_APPLICATION_ID);
@@ -87,22 +92,21 @@ public class UIManager : SimpleFocusManager, GLib.Initable {
this.notification = notification;
}
- public void hide_notification (Notify.Notification? notification, bool immediate=true) {
+ public void hide_notification (Notify.Notification? notification, HideNotificationMethod
method=IMMEDIATE) {
/**
* Close a notification proactively, if it is still open.
*/
if (notification != null && this.notification == notification) {
try {
- if (immediate) {
+ if (method == IMMEDIATE) {
this.notification.close ();
} else {
this.notification.set_hint ("transient", true);
this.notification.show ();
}
} catch (GLib.Error error) {
- // We ignore this error, because it's usually just noise
- // GLib.warning ("Error closing notification: %s", error.message);
+ GLib.debug ("Error closing notification: %s", error.message);
}
}
this.notification = null;
@@ -153,7 +157,7 @@ public class UIManager : SimpleFocusManager, GLib.Initable {
}
private void hide_lock_notification_cb () {
- this.hide_notification (this.lock_notification, true);
+ this.hide_notification (this.lock_notification, IMMEDIATE);
this.lock_notification = null;
}
}
diff --git a/src/daemon/break/BreakView.vala b/src/daemon/break/BreakView.vala
index a6b56a2..259beb4 100644
--- a/src/daemon/break/BreakView.vala
+++ b/src/daemon/break/BreakView.vala
@@ -33,13 +33,25 @@ public abstract class BreakView : UIFragment {
this.ui_manager = ui_manager;
this.break_controller = break_controller;
- break_controller.enabled.connect ( () => { this.ui_manager.add_break (this); });
- break_controller.disabled.connect ( () => { this.ui_manager.remove_break (this); });
-
- break_controller.warned.connect ( () => { this.request_ui_focus (); });
- break_controller.unwarned.connect ( () => { this.release_ui_focus (); });
- break_controller.activated.connect ( () => { this.request_ui_focus (); });
- break_controller.finished.connect_after ( () => { this.release_ui_focus (); });
+ break_controller.enabled.connect ( () => {
+ this.ui_manager.add_break (this);
+ });
+ break_controller.disabled.connect ( () => {
+ this.ui_manager.remove_break (this);
+ });
+
+ break_controller.warned.connect ( () => {
+ this.request_ui_focus ();
+ });
+ break_controller.unwarned.connect ( () => {
+ this.release_ui_focus ();
+ });
+ break_controller.activated.connect ( () => {
+ this.request_ui_focus ();
+ });
+ break_controller.finished.connect_after ( () => {
+ this.release_ui_focus ();
+ });
}
public abstract string get_status_message ();
diff --git a/src/daemon/microbreak/MicroBreakView.vala b/src/daemon/microbreak/MicroBreakView.vala
index 540d716..2f3c360 100644
--- a/src/daemon/microbreak/MicroBreakView.vala
+++ b/src/daemon/microbreak/MicroBreakView.vala
@@ -110,7 +110,7 @@ public class MicroBreakView : TimerBreakView {
if (reason == BreakController.FinishedReason.SATISFIED && was_active) {
this.show_finished_notification ();
} else {
- this.hide_notification ();
+ this.hide_notification (IMMEDIATE);
}
}
diff --git a/src/daemon/restbreak/RestBreakView.vala b/src/daemon/restbreak/RestBreakView.vala
index 69af105..36f3ed9 100644
--- a/src/daemon/restbreak/RestBreakView.vala
+++ b/src/daemon/restbreak/RestBreakView.vala
@@ -153,7 +153,7 @@ public class RestBreakView : TimerBreakView {
if (was_active && reason == BreakController.FinishedReason.SATISFIED) {
this.show_finished_notification ();
} else {
- this.hide_notification ();
+ this.hide_notification (IMMEDIATE);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]