[libadwaita/wip/exalm/toasts] toast-overlay: Ignore natural width for toasts without buttons
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/toasts] toast-overlay: Ignore natural width for toasts without buttons
- Date: Wed, 22 Jun 2022 16:20:54 +0000 (UTC)
commit fdb668f64751d5dfa6d6013e0310285311f03072
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Jun 22 19:56:37 2022 +0400
toast-overlay: Ignore natural width for toasts without buttons
Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/497
src/adw-toast-overlay.c | 6 +++++-
src/adw-toast-widget-private.h | 2 ++
src/adw-toast-widget.c | 10 ++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/src/adw-toast-overlay.c b/src/adw-toast-overlay.c
index 28845a3b..1d722211 100644
--- a/src/adw-toast-overlay.c
+++ b/src/adw-toast-overlay.c
@@ -366,7 +366,11 @@ allocate_toast (AdwToastOverlay *self,
gtk_widget_get_preferred_size (info->widget, NULL, &size);
- size.width = MIN (MAX (size.width, NATURAL_WIDTH), width);
+ if (adw_toast_widget_get_button_visible (ADW_TOAST_WIDGET (info->widget)))
+ size.width = MIN (MAX (size.width, NATURAL_WIDTH), width);
+ else
+ size.width = MIN (size.width, width);
+
size.height = MIN (size.height, height);
x = (width - size.width) / 2;
diff --git a/src/adw-toast-widget-private.h b/src/adw-toast-widget-private.h
index 6362899d..d5a17e67 100644
--- a/src/adw-toast-widget-private.h
+++ b/src/adw-toast-widget-private.h
@@ -25,4 +25,6 @@ GtkWidget *adw_toast_widget_new (AdwToast *toast) G_GNUC_WARN_UNUSED_RESULT;
void adw_toast_widget_reset_timeout (AdwToastWidget *self);
+gboolean adw_toast_widget_get_button_visible (AdwToastWidget *self);
+
G_END_DECLS
diff --git a/src/adw-toast-widget.c b/src/adw-toast-widget.c
index 698edcbf..28f67e0d 100644
--- a/src/adw-toast-widget.c
+++ b/src/adw-toast-widget.c
@@ -15,6 +15,7 @@ struct _AdwToastWidget {
GtkWidget parent_instance;
AdwBin *title_bin;
+ GtkWidget *action_button;
AdwToast *toast;
@@ -237,6 +238,7 @@ adw_toast_widget_class_init (AdwToastWidgetClass *klass)
"/org/gnome/Adwaita/ui/adw-toast-widget.ui");
gtk_widget_class_bind_template_child (widget_class, AdwToastWidget, title_bin);
+ gtk_widget_class_bind_template_child (widget_class, AdwToastWidget, action_button);
gtk_widget_class_bind_template_callback (widget_class, string_is_not_empty);
gtk_widget_class_bind_template_callback (widget_class, action_clicked_cb);
@@ -272,3 +274,11 @@ adw_toast_widget_reset_timeout (AdwToastWidget *self)
end_timeout (self);
start_timeout (self);
}
+
+gboolean
+adw_toast_widget_get_button_visible (AdwToastWidget *self)
+{
+ g_assert (ADW_IS_TOAST_WIDGET (self));
+
+ return gtk_widget_get_visible (self->action_button);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]