[libadwaita] toast: Add `AdwToast::button-clicked`



commit 6c190b19274d1c0dd5a972868f68a4401f0c5140
Author: Jamie <hello itsjamie dev>
Date:   Fri Aug 5 09:13:42 2022 +0000

    toast: Add `AdwToast::button-clicked`

 src/adw-toast-widget.c |  2 ++
 src/adw-toast.c        | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+)
---
diff --git a/src/adw-toast-widget.c b/src/adw-toast-widget.c
index 28f67e0d..76713b71 100644
--- a/src/adw-toast-widget.c
+++ b/src/adw-toast-widget.c
@@ -104,6 +104,8 @@ action_clicked_cb (AdwToastWidget *self)
 {
   end_timeout (self);
 
+  g_signal_emit_by_name (self->toast, "button-clicked");
+
   /* Keep the widget alive through the idle. Otherwise it may be immediately
    * destroyed if animations are disabled */
   g_idle_add (G_SOURCE_FUNC (close_idle_cb), g_object_ref (self));
diff --git a/src/adw-toast.c b/src/adw-toast.c
index 431d7f4b..8c59c65c 100644
--- a/src/adw-toast.c
+++ b/src/adw-toast.c
@@ -179,6 +179,7 @@ static GParamSpec *props[LAST_PROP];
 
 enum {
   SIGNAL_DISMISSED,
+  SIGNAL_BUTTON_CLICKED,
   SIGNAL_LAST_SIGNAL,
 };
 
@@ -434,6 +435,23 @@ adw_toast_class_init (AdwToastClass *klass)
                   0,
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 0);
+
+  /**
+   * AdwToast::button-clicked:
+   *
+   * Emitted after the button has been clicked.
+   *
+   * It can be used as an alternative to setting an action.
+   *
+   * Since: 1.2
+   */
+  signals[SIGNAL_BUTTON_CLICKED] =
+    g_signal_new ("button-clicked",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0,
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]