Skip to content

Commit

Permalink
ErrorRevealer: GTK4 preparations (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 authored Sep 25, 2023
1 parent af64d3b commit e2e24a3
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/Widgets/ErrorRevealer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,38 @@
* Boston, MA 02110-1301 USA
*/

private class SwitchboardPlugUserAccounts.ErrorRevealer : Gtk.Revealer {
public Gtk.Label label_widget;
private class SwitchboardPlugUserAccounts.ErrorRevealer : Gtk.Box {
public Gtk.Label label_widget { get; construct; }

private string _label;
public string label {
get {
return _label;
}
construct set {
_label = value;

if (label_widget != null) {
label_widget.label = "<span font_size=\"small\">%s</span>".printf (value);
}
set {
label_widget.label = "<span font_size=\"small\">%s</span>".printf (value);
}
}

public bool reveal_child { get; set; default = false; }

public ErrorRevealer (string label) {
Object (label: label);
this.label = label;
}

construct {
label_widget = new Gtk.Label ("<span font_size=\"small\">%s</span>".printf (_label));
label_widget.halign = Gtk.Align.END;
label_widget.justify = Gtk.Justification.RIGHT;
label_widget.max_width_chars = 55;
label_widget.use_markup = true;
label_widget.wrap = true;
label_widget.xalign = 1;
label_widget = new Gtk.Label ("") {
justify = RIGHT,
max_width_chars = 55,
use_markup = true,
wrap = true,
xalign = 1
};

var revealer = new Gtk.Revealer () {
child = label_widget,
transition_type = CROSSFADE,
halign = END
};
bind_property ("reveal-child", revealer, "reveal-child", SYNC_CREATE);

transition_type = Gtk.RevealerTransitionType.CROSSFADE;
add (label_widget);
orientation = VERTICAL;
add (revealer);
}
}

0 comments on commit e2e24a3

Please sign in to comment.