Skip to content

Commit

Permalink
MessageDialog: Fix large height bug (#616)
Browse files Browse the repository at this point in the history
* MessageDialog: Fix large height bug

* Make sure primary label wraps, add comments

* Update granite.appdata.xml.in
  • Loading branch information
danirabbit authored Jun 17, 2022
1 parent 75b5c59 commit 28e9b60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion data/granite.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ul>
<p>Improvements:</p>
<ul>
<li></li>
<li>MessageDialog: fix a bug that caused large heights to be preserved</li>
<li>Updated translations</li>
</ul>
</description>
Expand Down
40 changes: 22 additions & 18 deletions lib/Widgets/MessageDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();

Expand All @@ -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);

Expand Down

0 comments on commit 28e9b60

Please sign in to comment.