Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug: check for AppCenter before creating updates button #98

Merged
merged 3 commits into from Aug 15, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/Plug.vala
Expand Up @@ -212,15 +212,15 @@ public class About.Plug : Switchboard.Plug {
}
});

// Update button
var update_button = new Gtk.Button.with_label (_("Check for Updates"));
update_button.clicked.connect (() => {
try {
Process.spawn_command_line_async ("io.elementary.appcenter --show-updates");
} catch (Error e) {
warning (e.message);
}
});
Gtk.Button? update_button = null;
var appcenter_info = new GLib.DesktopAppInfo ("io.elementary.appcenter.desktop");
if (appcenter_info != null) {
update_button = new Gtk.Button.with_label (_("Check for Updates"));
update_button.clicked.connect (() => {
appcenter_info.launch_action ("ShowUpdates", new GLib.AppLaunchContext ());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL that's a thing 🤯️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that an approve :p

});
}


// Restore settings button
var settings_restore_button = new Gtk.Button.with_label (_("Restore Default Settings"));
Expand All @@ -234,7 +234,11 @@ public class About.Plug : Switchboard.Plug {
button_grid.add (settings_restore_button);
button_grid.add (translate_button);
button_grid.add (bug_button);
button_grid.add (update_button);

if (update_button != null) {
button_grid.add (update_button);
}

button_grid.set_child_non_homogeneous (help_button, true);

var software_grid = new Gtk.Grid ();
Expand Down