From 28e9b60fc8257b2d8e76412518e96a7e03efc6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 16 Jun 2022 23:28:47 -0700 Subject: [PATCH] MessageDialog: Fix large height bug (#616) * MessageDialog: Fix large height bug * Make sure primary label wraps, add comments * Update granite.appdata.xml.in --- data/granite.appdata.xml.in | 2 +- lib/Widgets/MessageDialog.vala | 40 +++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/data/granite.appdata.xml.in b/data/granite.appdata.xml.in index e769b3193..601756615 100644 --- a/data/granite.appdata.xml.in +++ b/data/granite.appdata.xml.in @@ -19,7 +19,7 @@

Improvements:

diff --git a/lib/Widgets/MessageDialog.vala b/lib/Widgets/MessageDialog.vala index 7435e6ec9..97ad0dfc7 100644 --- a/lib/Widgets/MessageDialog.vala +++ b/lib/Widgets/MessageDialog.vala @@ -254,24 +254,28 @@ public class Granite.MessageDialog : Granite.Dialog { valign = Gtk.Align.END }; - var overlay = new Gtk.Overlay (); - overlay.valign = Gtk.Align.START; - overlay.set_child (image); + var overlay = new Gtk.Overlay () { + child = image, + valign = Gtk.Align.START + }; overlay.add_overlay (badge); - primary_label = new Gtk.Label (null); + primary_label = new Gtk.Label (null) { + max_width_chars = 0, // Wrap, but secondary label sets the width + selectable = true, + wrap = true, + xalign = 0 + }; primary_label.add_css_class (Granite.STYLE_CLASS_TITLE_LABEL); - primary_label.selectable = true; - primary_label.max_width_chars = 50; - primary_label.wrap = true; - primary_label.xalign = 0; - - secondary_label = new Gtk.Label (null); - secondary_label.use_markup = true; - secondary_label.selectable = true; - secondary_label.max_width_chars = 50; - secondary_label.wrap = true; - secondary_label.xalign = 0; + + secondary_label = new Gtk.Label (null) { + max_width_chars = 50, + width_chars = 50, // Prevents a bug where extra height is preserved + selectable = true, + use_markup = true, + wrap = true, + xalign = 0 + }; custom_bin = new SingleWidgetBin (); @@ -280,9 +284,9 @@ public class Granite.MessageDialog : Granite.Dialog { row_spacing = 6 }; message_grid.attach (overlay, 0, 0, 1, 2); - message_grid.attach (primary_label, 1, 0, 1, 1); - message_grid.attach (secondary_label, 1, 1, 1, 1); - message_grid.attach (custom_bin, 1, 3, 1, 1); + message_grid.attach (primary_label, 1, 0); + message_grid.attach (secondary_label, 1, 1); + message_grid.attach (custom_bin, 1, 3); get_content_area ().append (message_grid);