diff --git a/Nasal/canvas/gui/dialogs/AircraftCenter.nas b/Nasal/canvas/gui/dialogs/AircraftCenter.nas index 926dac140..c63bf803e 100644 --- a/Nasal/canvas/gui/dialogs/AircraftCenter.nas +++ b/Nasal/canvas/gui/dialogs/AircraftCenter.nas @@ -122,39 +122,35 @@ var AircraftCenter = { (func { var p = package; var b = gui.widgets.Button.new(me._scroll_content, style, {}); - var installed = p.installed; var install_text = sprintf("Install (%.1fMB)", p.fileSize/1024/1024); - if( installed ) + if( p.installed ) b.setText("Remove"); else b.setText(install_text); b.listen("clicked", func { - if( installed ) + if( p.installed ) { p.uninstall(); - installed = 0; b.setText(install_text); } else { - b.setEnabled(0) - .setText("Wait..."); - p.install() - .progress(func(i, cur, total) - b.setText(sprintf("%.1f%%", (cur / total) * 100)) - ) - .fail(func b.setText('Failed')) - .done(func { - installed = 1; - b.setText("Remove") - .setEnabled(1); - }); + b.setText("Wait...").setEnabled(0); + p.install(); } }); + p.existingInstall(func(pkg, ins) { + ins.progress(func(i, cur, total) + b.setText(sprintf("%.1f%%", (cur / total) * 100)) + ); + ins.fail(func b.setText('Failed')); + ins.done(func b.setText("Remove").setEnabled(1)); + }); + title_box.addItem(b); })(); diff --git a/Nasal/canvas/gui/widgets/Button.nas b/Nasal/canvas/gui/widgets/Button.nas index c388a2aee..03ba3a5e2 100644 --- a/Nasal/canvas/gui/widgets/Button.nas +++ b/Nasal/canvas/gui/widgets/Button.nas @@ -15,7 +15,8 @@ gui.widgets.Button = { }, setText: func(text) { - me._view.setText(me, text); + if( me._view != nil ) + me._view.setText(me, text); return me; }, setCheckable: func(checkable)