diff --git a/src/Confirmation.vala b/src/Confirmation.vala index e0b25a54..a811bcc1 100644 --- a/src/Confirmation.vala +++ b/src/Confirmation.vala @@ -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 @@ -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); @@ -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; } } diff --git a/src/DBus.vala b/src/DBus.vala index 3ebcf2ec..09f9de20 100644 --- a/src/DBus.vala +++ b/src/DBus.vala @@ -154,6 +154,7 @@ public class Notifications.Server : Object { if (confirmation == null) { confirmation = new Notifications.Confirmation ( + confirmation_type, icon_name, progress_value ); @@ -161,6 +162,7 @@ public class Notifications.Server : Object { confirmation = null; }); } else { + confirmation.confirmation_type = confirmation_type; confirmation.icon_name = icon_name; confirmation.progress = progress_value; }