27
27
Gtk.Label package_name;
28
28
Gtk.Label package_summary;
30
public Gtk.Button update_button;
30
// The action button covers Install and Update
31
public Gtk.Button action_button;
32
public Gtk.Button uninstall_button;
33
Gtk.ProgressBar progress_bar;
34
Gtk.Label progress_label;
31
35
public Gtk.Button cancel_button;
32
public Gtk.Stack action_stack;
34
Gtk.ProgressBar update_progressbar;
35
Gtk.Label update_label;
36
Gtk.Stack action_stack;
37
38
public PackageRow (Package package) {
38
39
this.package = package;
62
63
image.gicon = new ThemedIcon (icon_name);
66
if (package.update_available) {
67
action_button.label = _("Update");
68
} else if (package.installed) {
69
action_button.no_show_all = true;
70
action_button.hide ();
72
uninstall_button.no_show_all = true;
73
uninstall_button.hide ();
65
76
package.notify["installed"].connect (() => {
77
if (package.installed && package.update_available) {
78
action_button.label = _("Update");
79
action_button.no_show_all = false;
80
} else if (package.installed) {
81
action_button.hide ();
82
action_button.no_show_all = true;
84
action_button.label = _("Install");
85
action_button.no_show_all = false;
86
uninstall_button.no_show_all = true;
87
uninstall_button.hide ();
69
92
package.notify["update-available"].connect (() => {
93
if (package.update_available) {
94
action_button.label = _("Update");
95
action_button.no_show_all = false;
96
action_button.show ();
98
action_button.no_show_all = true;
99
action_button.hide ();
100
131
((Gtk.Misc) package_summary).xalign = 0;
102
133
action_stack = new Gtk.Stack ();
104
update_button = new Gtk.Button.with_label (_("Update"));
105
update_button.halign = Gtk.Align.END;
106
update_button.valign = Gtk.Align.CENTER;
107
update_button.margin_end = 6;
108
update_button.clicked.connect (() => update_package.begin ());
110
update_label = new Gtk.Label (null);
111
update_progressbar = new Gtk.ProgressBar ();
112
update_progressbar.margin_end = 12;
114
cancel_button = new Gtk.Button.with_label (_("Cancel"));
134
action_stack.transition_type = Gtk.StackTransitionType.CROSSFADE;
135
action_stack.margin_end = 6;
137
progress_bar = new Gtk.ProgressBar ();
139
progress_label = new Gtk.Label (null);
141
cancel_button = new Gtk.Button.from_icon_name ("process-stop-symbolic", Gtk.IconSize.MENU);
142
cancel_button.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
115
143
cancel_button.valign = Gtk.Align.CENTER;
116
cancel_button.margin_end = 6;
118
update_grid = new Gtk.Grid ();
119
update_grid.attach (update_label, 0, 0, 1, 1);
120
update_grid.attach (update_progressbar, 0, 1, 1, 1);
121
update_grid.attach (cancel_button, 1, 0, 1, 2);
123
action_stack.add (update_button);
124
action_stack.add (update_grid);
145
action_button = new Gtk.Button.with_label (_("Install"));
146
action_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
147
action_button.get_style_context ().add_class ("h3");
148
action_button.clicked.connect (() => action_clicked.begin ());
150
uninstall_button = new Gtk.Button.with_label (_("Uninstall"));
151
uninstall_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
152
uninstall_button.get_style_context ().add_class ("h3");
153
uninstall_button.clicked.connect (() => uninstall_clicked.begin ());
155
var button_grid = new Gtk.Grid ();
156
button_grid.halign = Gtk.Align.END;
157
button_grid.valign = Gtk.Align.CENTER;
158
button_grid.column_spacing = 12;
159
button_grid.orientation = Gtk.Orientation.HORIZONTAL;
160
button_grid.add (uninstall_button);
161
button_grid.add (action_button);
163
var progress_grid = new Gtk.Grid ();
164
progress_grid.valign = Gtk.Align.CENTER;
165
progress_grid.row_spacing = 6;
166
progress_grid.attach (progress_label, 0, 0, 1, 1);
167
progress_grid.attach (progress_bar, 0, 1, 1, 1);
168
progress_grid.attach (cancel_button, 1, 0, 1, 2);
170
action_stack.add_named (button_grid, "buttons");
171
action_stack.add_named (progress_grid, "progress");
126
173
grid.attach (image, 0, 0, 1, 2);
127
174
grid.attach (package_name, 1, 0, 1, 1);
137
private async void update_package () {
139
update_button.sensitive = false;
140
yield package.update ();
142
critical (e.message);
145
update_button.sensitive = true;
148
184
private void update_status () {
149
update_label.label = package.change_information.get_status ();
185
progress_label.label = package.change_information.get_status ();
152
188
private void update_progress () {
153
189
var progress = package.change_information.get_progress ();
154
190
if (progress < 1.0f) {
155
action_stack.set_visible_child (update_grid);
156
update_progressbar.fraction = progress;
191
action_stack.set_visible_child_name ("progress");
192
progress_bar.fraction = progress;
158
action_stack.set_visible_child (update_button);
194
action_stack.set_visible_child_name ("buttons");
198
private async void action_clicked () {
200
if (package.update_available) {
201
yield package.update ();
202
action_button.no_show_all = true;
203
action_button.hide ();
205
yield package.install ();
206
action_button.no_show_all = true;
207
action_button.hide ();
208
if (package.component.id != "xxx-os-updates") {
209
uninstall_button.no_show_all = false;
210
uninstall_button.show ();
214
critical (e.message);
215
action_stack.set_visible_child_name ("buttons");
219
private async void uninstall_clicked () {
221
yield package.uninstall ();
222
action_button.label = _("Install");
223
uninstall_button.no_show_all = true;
224
uninstall_button.hide ();
225
action_button.no_show_all = false;
226
action_button.show ();
228
critical (e.message);
229
action_stack.set_visible_child_name ("buttons");