From 2141c1ffc226bb6ef5526650e4d9be569aa2db51 Mon Sep 17 00:00:00 2001 From: Anton Lazarev Date: Sat, 26 Aug 2023 19:59:59 -0700 Subject: [PATCH] in-app-notification: compose with GtkBin instead of subclassing GtkRevealer Note that the GtkOverlay must pass-through interactions for this to work, meaning it's no longer possible to interact with the notifications. I'm leaving it like this since I'll need to replace it with AdwToast later anyways. Part-of: --- src/calls-in-app-notification.c | 16 +++++---- src/calls-in-app-notification.h | 2 +- src/ui/account-overview.ui | 3 ++ src/ui/call-window.ui | 3 ++ src/ui/in-app-notification.ui | 58 ++++++++++++++++++--------------- src/ui/main-window.ui | 3 ++ 6 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/calls-in-app-notification.c b/src/calls-in-app-notification.c index 9c36d09..5be1ec8 100644 --- a/src/calls-in-app-notification.c +++ b/src/calls-in-app-notification.c @@ -27,15 +27,16 @@ #define DEFAULT_TIMEOUT_SECONDS 3 struct _CallsInAppNotification { - GtkRevealer parent_instance; + GtkBin parent_instance; - GtkLabel *label; + GtkRevealer *revealer; + GtkLabel *label; - guint timeout; - guint timeout_id; + guint timeout; + guint timeout_id; }; -G_DEFINE_TYPE (CallsInAppNotification, calls_in_app_notification, GTK_TYPE_REVEALER) +G_DEFINE_TYPE (CallsInAppNotification, calls_in_app_notification, GTK_TYPE_BIN) enum { @@ -128,6 +129,7 @@ calls_in_app_notification_class_init (CallsInAppNotificationClass *klass) g_object_class_install_properties (object_class, PROP_LAST_PROP, props); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Calls/ui/in-app-notification.ui"); + gtk_widget_class_bind_template_child (widget_class, CallsInAppNotification, revealer); gtk_widget_class_bind_template_child (widget_class, CallsInAppNotification, label); gtk_widget_class_bind_template_callback (widget_class, calls_in_app_notification_hide); } @@ -157,7 +159,7 @@ calls_in_app_notification_show (CallsInAppNotification *self, const gchar *messa if (self->timeout_id) g_source_remove (self->timeout_id); - gtk_revealer_set_reveal_child (GTK_REVEALER (self), TRUE); + gtk_revealer_set_reveal_child (self->revealer, TRUE); self->timeout_id = g_timeout_add_seconds (self->timeout, (GSourceFunc) timeout_cb, self); } @@ -169,5 +171,5 @@ calls_in_app_notification_hide (CallsInAppNotification *self) g_clear_handle_id (&self->timeout_id, g_source_remove); - gtk_revealer_set_reveal_child (GTK_REVEALER (self), FALSE); + gtk_revealer_set_reveal_child (self->revealer, FALSE); } diff --git a/src/calls-in-app-notification.h b/src/calls-in-app-notification.h index d37d6f7..8cefeda 100644 --- a/src/calls-in-app-notification.h +++ b/src/calls-in-app-notification.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS #define CALLS_TYPE_IN_APP_NOTIFICATION (calls_in_app_notification_get_type ()) -G_DECLARE_FINAL_TYPE (CallsInAppNotification, calls_in_app_notification, CALLS, IN_APP_NOTIFICATION, GtkRevealer) +G_DECLARE_FINAL_TYPE (CallsInAppNotification, calls_in_app_notification, CALLS, IN_APP_NOTIFICATION, GtkBin) CallsInAppNotification * calls_in_app_notification_new (void); void calls_in_app_notification_show (CallsInAppNotification *self, const gchar *message); diff --git a/src/ui/account-overview.ui b/src/ui/account-overview.ui index f2b092a..e4958e1 100644 --- a/src/ui/account-overview.ui +++ b/src/ui/account-overview.ui @@ -35,6 +35,9 @@ True + + True + diff --git a/src/ui/call-window.ui b/src/ui/call-window.ui index 332163d..bd537bc 100644 --- a/src/ui/call-window.ui +++ b/src/ui/call-window.ui @@ -15,6 +15,9 @@ True + + True + diff --git a/src/ui/in-app-notification.ui b/src/ui/in-app-notification.ui index 1cf5d75..a7dbe04 100644 --- a/src/ui/in-app-notification.ui +++ b/src/ui/in-app-notification.ui @@ -1,44 +1,50 @@ -