[libadwaita/wip/exalm/dismiss] toast: Allow repeat dismiss() calls
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/dismiss] toast: Allow repeat dismiss() calls
- Date: Tue, 3 May 2022 16:05:09 +0000 (UTC)
commit bfd733a7d465461f2264e49237605477b760fdfc
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue May 3 20:04:35 2022 +0400
toast: Allow repeat dismiss() calls
Remove the critical, document it and add tests.
src/adw-toast.c | 9 ++++-----
tests/test-toast.c | 6 ++++++
2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/adw-toast.c b/src/adw-toast.c
index c488c29b..ad89bad2 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -886,6 +886,9 @@ adw_toast_set_timeout (AdwToast *self,
*
* Dismisses @self.
*
+ * Does nothing if @self has already been dismissed, or hasn't been added to an
+ * [class@ToastOverlay].
+ *
* Since: 1.0
*/
void
@@ -893,12 +896,8 @@ adw_toast_dismiss (AdwToast *self)
{
g_return_if_fail (ADW_IS_TOAST (self));
- if (!self->added) {
- g_critical ("Trying to dismiss the toast '%s', but it isn't in an "
- "AdwToastOverlay yet", adw_toast_get_title (self));
-
+ if (!self->added)
return;
- }
g_signal_emit (self, signals[SIGNAL_DISMISSED], 0, NULL);
}
diff --git a/tests/test-toast.c b/tests/test-toast.c
index 5b168c5a..23e422dc 100644
--- a/tests/test-toast.c
+++ b/tests/test-toast.c
@@ -230,6 +230,12 @@ test_adw_toast_dismiss (void)
adw_toast_overlay_add_toast (overlay, g_object_ref (toast));
adw_toast_dismiss (toast);
+ /* Repeat dismiss() calls should no-op */
+ adw_toast_overlay_add_toast (overlay, g_object_ref (toast));
+ adw_toast_dismiss (toast);
+ adw_toast_dismiss (toast);
+ adw_toast_dismiss (toast);
+
g_assert_finalize_object (overlay);
g_assert_finalize_object (toast);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]