Skip to content
46 changes: 38 additions & 8 deletions src/Confirmation.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,46 @@
public class Notifications.Confirmation : AbstractBubble {
public new string icon_name { get; construct set; }
public double progress { get; construct set; }
public string confirmation_type {
get {
return _confirmation_type;
}
set {
if (value == _confirmation_type) {
return;
}

public Confirmation (string icon_name, double progress) {
_confirmation_type = value;

if (icon_name_binding != null) {
icon_name_binding.unbind ();
}
if (progress_binding != null) {
progress_binding.unbind ();
}

var contents = create_contents ();
content_area.add (contents);
content_area.visible_child = contents;
}
}

private string _confirmation_type;
private Binding? icon_name_binding;
private Binding? progress_binding;

public Confirmation (string confirmation_type, string icon_name, double progress) {
Object (
confirmation_type: confirmation_type,
icon_name: icon_name,
progress: progress,
timeout: 2000
);

get_style_context ().add_class ("confirmation");
}

construct {
private Gtk.Widget create_contents () {
var image = new Gtk.Image.from_icon_name (icon_name, Gtk.IconSize.DIALOG) {
valign = Gtk.Align.START,
pixel_size = 48
Expand All @@ -40,7 +70,8 @@ public class Notifications.Confirmation : AbstractBubble {
hexpand = true,
valign = Gtk.Align.CENTER,
margin_end = 6,
width_request = 258
width_request = 258,
fraction = progress
};
progressbar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);

Expand All @@ -49,12 +80,11 @@ public class Notifications.Confirmation : AbstractBubble {
};
contents.attach (image, 0, 0);
contents.attach (progressbar, 1, 0);
contents.show_all ();

content_area.add (contents);

get_style_context ().add_class ("confirmation");
icon_name_binding = bind_property ("icon-name", image, "icon-name");
progress_binding = bind_property ("progress", progressbar, "fraction");

bind_property ("icon-name", image, "icon-name");
bind_property ("progress", progressbar, "fraction");
return contents;
}
}
2 changes: 2 additions & 0 deletions src/DBus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ public class Notifications.Server : Object {

if (confirmation == null) {
confirmation = new Notifications.Confirmation (
confirmation_type,
icon_name,
progress_value
);
confirmation.destroy.connect (() => {
confirmation = null;
});
} else {
confirmation.confirmation_type = confirmation_type;
confirmation.icon_name = icon_name;
confirmation.progress = progress_value;
}
Expand Down