41
41
Gtk.Button cancel_button;
42
42
Gtk.Stack action_stack;
44
public AppInfoView (AppCenterCore.Package package) {
44
bool is_os_updates = false;
46
public AppInfoView (Package package) {
45
47
this.package = package;
46
48
app_name.label = package.get_name ();
47
49
app_summary.label = package.get_summary ();
48
50
parse_description (package.component.get_description ());
49
51
app_icon.gicon = package.get_icon (128);
52
is_os_updates = package.component.id == "xxx-os-updates";
51
54
if (package.component.get_extensions ().length > 0) {
52
55
extension_box = new Gtk.ListBox ();
63
66
load_extensions.begin ();
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 ();
76
if (package.component.id == "xxx-os-updates") {
77
uninstall_button.no_show_all = true;
78
uninstall_button.hide ();
81
package.notify["installed"].connect (() => update_buttons ());
82
package.notify["update-available"].connect (() => update_buttons ());
69
package.notify["state"].connect (update_state);
84
71
package.change_information.bind_property ("can-cancel", cancel_button, "sensitive", GLib.BindingFlags.SYNC_CREATE);
85
package.change_information.progress_changed.connect (() => update_progress ());
86
package.change_information.status_changed.connect (() => update_status ());
72
package.change_information.progress_changed.connect (update_progress);
73
package.change_information.status_changed.connect (update_progress_status);
75
update_progress_status ();
87
76
update_progress ();
259
private void update_status () {
260
progress_bar.text = package.change_information.get_status ();
261
if (package.change_information.status == Pk.Status.FINISHED) {
262
action_stack.set_visible_child_name ("buttons");
264
action_stack.set_visible_child_name ("progress");
248
private void update_progress_status () {
249
progress_bar.text = package.change_information.get_status ();
268
252
private void update_progress () {
269
var progress = package.change_information.get_progress ();
253
double progress = package.change_information.get_progress ();
270
254
if (progress < 1.0f) {
271
action_stack.set_visible_child_name ("progress");
272
255
progress_bar.fraction = progress;
259
private void update_state () {
260
if (package.state != Package.State.NOT_INSTALLED && !is_os_updates) {
261
uninstall_button.no_show_all = false;
262
uninstall_button.show_all ();
274
action_stack.set_visible_child_name ("buttons");
264
uninstall_button.no_show_all = true;
265
uninstall_button.hide ();
278
private void update_buttons () {
279
if (package.installed) {
280
if (package.update_available) {
268
switch (package.state) {
269
case Package.State.NOT_INSTALLED:
270
action_button.label = _("Install");
271
action_button.no_show_all = false;
272
action_button.show_all ();
274
action_stack.set_visible_child_name ("buttons");
276
case Package.State.INSTALLED:
277
action_button.no_show_all = true;
278
action_button.hide ();
280
action_stack.set_visible_child_name ("buttons");
282
case Package.State.UPDATE_AVAILABLE:
281
283
action_button.label = _("Update");
282
284
action_button.no_show_all = false;
283
action_button.show_all ();
285
action_button.no_show_all = true;
286
action_button.hide ();
287
uninstall_button.no_show_all = false;
288
uninstall_button.show_all ();
291
action_button.label = _("Install");
292
action_button.no_show_all = false;
293
action_button.show_all ();
285
action_button.show_all ();
287
action_stack.set_visible_child_name ("buttons");
289
case Package.State.INSTALLING:
290
case Package.State.UPDATING:
291
case Package.State.REMOVING:
292
action_stack.set_visible_child_name ("progress");
297
297
private void action_cancelled () {
303
303
if (package.update_available) {
304
304
yield package.update ();
305
action_button.no_show_all = true;
306
action_button.hide ();
308
306
yield package.install ();
309
action_button.no_show_all = true;
310
action_button.hide ();
311
if (package.component.id != "xxx-os-updates") {
312
uninstall_button.no_show_all = false;
313
uninstall_button.show_all ();
316
308
// Add this app to the Installed Apps View
317
309
MainWindow.installed_view.add_app.begin (package);
319
311
} catch (Error e) {
320
312
critical (e.message);
321
action_stack.set_visible_child_name ("buttons");
325
316
private async void uninstall_clicked () {
327
318
yield package.uninstall ();
328
action_button.label = _("Install");
329
uninstall_button.no_show_all = true;
330
uninstall_button.hide ();
332
320
// Remove this app from the Installed Apps View
333
321
MainWindow.installed_view.remove_app.begin (package);
334
322
} catch (Error e) {
335
323
critical (e.message);
336
action_stack.set_visible_child_name ("buttons");