[gnome-shell] UserMenu: show "Install Updates & Restart" when appropriate
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] UserMenu: show "Install Updates & Restart" when appropriate
- Date: Sat, 7 Jul 2012 16:23:17 +0000 (UTC)
commit 34831796f616d4b8d5fbf7fa74fcf3b6967f1d53
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun Jun 3 17:35:37 2012 +0200
UserMenu: show "Install Updates & Restart" when appropriate
When PackageKit signals that it prepared an update, offer an option
to reboot and apply it, using a helper that will setup the next
reboot and then calling to gnome-session.
https://bugzilla.gnome.org/show_bug.cgi?id=677394
js/misc/gnomeSession.js | 1 +
js/ui/userMenu.js | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js
index dabd1b1..f8bd58e 100644
--- a/js/misc/gnomeSession.js
+++ b/js/misc/gnomeSession.js
@@ -50,6 +50,7 @@ const SessionManagerIface = <interface name="org.gnome.SessionManager">
<arg type="u" direction="in" />
</method>
<method name="Shutdown" />
+<method name="Reboot" />
<method name="CanShutdown">
<arg type="b" direction="out" />
</method>
diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js
index 4dd9057..f8a57d2 100644
--- a/js/ui/userMenu.js
+++ b/js/ui/userMenu.js
@@ -523,6 +523,10 @@ const UserMenuButton = new Lang.Class({
this._updateLogout();
this._updateLockScreen();
+ this._updatesFile = Gio.File.new_for_path('/var/lib/PackageKit/prepared-update');
+ this._updatesMonitor = this._updatesFile.monitor(Gio.FileMonitorFlags.NONE, null);
+ this._updatesMonitor.connect('changed', Lang.bind(this, this._updateInstallUpdates));
+
// Whether shutdown is available or not depends on both lockdown
// settings (disable-log-out) and Polkit policy - the latter doesn't
// notify, so we update the menu item each time the menu opens or
@@ -578,11 +582,17 @@ const UserMenuButton = new Lang.Class({
this._lockScreenItem.actor.visible = allowLockScreen;
},
+ _updateInstallUpdates: function() {
+ let haveUpdates = this._updatesFile.query_exists(null);
+ this._installUpdatesItem.actor.visible = haveUpdates && this._haveShutdown;
+ },
+
_updateHaveShutdown: function() {
this._session.CanShutdownRemote(Lang.bind(this,
function(result, error) {
if (!error) {
this._haveShutdown = result[0];
+ this._updateInstallUpdates();
this._updateSuspendOrPowerOff();
}
}));
@@ -711,6 +721,11 @@ const UserMenuButton = new Lang.Class({
item = new PopupMenu.PopupSeparatorMenuItem();
this.menu.addMenuItem(item);
+ item = new PopupMenu.PopupMenuItem(_("Install Updates & Restart"));
+ item.connect('activate', Lang.bind(this, this._onInstallUpdatesActivate));
+ this.menu.addMenuItem(item);
+ this._installUpdatesItem = item;
+
item = new PopupMenu.PopupAlternatingMenuItem(_("Power Off"),
_("Suspend"));
this.menu.addMenuItem(item);
@@ -769,6 +784,13 @@ const UserMenuButton = new Lang.Class({
this._session.LogoutRemote(0);
},
+ _onInstallUpdatesActivate: function() {
+ Main.overview.hide();
+ Util.spawn(['pkexec', '/usr/libexec/pk-trigger-offline-update']);
+
+ this._session.RebootRemote();
+ },
+
_onSuspendOrPowerOffActivate: function() {
Main.overview.hide();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]