Skip to content
Prev Previous commit
Next Next commit
Check if system upgrade is available
  • Loading branch information
meisenzahl committed Jan 29, 2022
commit 156ad43a9c6d0d291f7511474a52e5b17cdc9fec
32 changes: 32 additions & 0 deletions src/Utils/SystemUpgrade.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,36 @@ public class About.SystemUpgrade {
}
}
}

public static bool system_upgrade_available {
get {
get_system_upgrade_instance ();

if (system_upgrade_instance == null) {
return false;
}

return system_upgrade_instance.system_upgrade_available;
}
}

[DBus (name = "io.elementary.SystemUpgrade")]
interface SystemUpgradeInterface : Object {
public abstract bool system_upgrade_available { get; }
}

private static SystemUpgradeInterface? system_upgrade_instance;
private static void get_system_upgrade_instance () {
if (system_upgrade_instance == null) {
try {
system_upgrade_instance = Bus.get_proxy_sync (
BusType.SESSION,
"io.elementary.settings-daemon",
"/io/elementary/settings_daemon"
);
} catch (GLib.Error e) {
warning ("%s", e.message);
}
}
}
}
2 changes: 1 addition & 1 deletion src/Views/OperatingSystemView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class About.OperatingSystemView : Gtk.Grid {

var upgrade_revealer = new Gtk.Revealer ();
upgrade_revealer.add (upgrade_button);
upgrade_revealer.reveal_child = true;
upgrade_revealer.reveal_child = SystemUpgrade.system_upgrade_available;

var bug_button = new Gtk.Button.with_label (_("Send Feedback"));

Expand Down