Introduce updates indicator
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/466
This commit is contained in:
parent
20d73be57d
commit
47a2e58d45
@ -121,6 +121,7 @@
|
|||||||
<file>ui/components/keyring.js</file>
|
<file>ui/components/keyring.js</file>
|
||||||
|
|
||||||
<file>ui/status/accessibility.js</file>
|
<file>ui/status/accessibility.js</file>
|
||||||
|
<file>ui/status/automaticUpdates.js</file>
|
||||||
<file>ui/status/brightness.js</file>
|
<file>ui/status/brightness.js</file>
|
||||||
<file>ui/status/location.js</file>
|
<file>ui/status/location.js</file>
|
||||||
<file>ui/status/keyboard.js</file>
|
<file>ui/status/keyboard.js</file>
|
||||||
|
@ -774,10 +774,17 @@ class AggregateMenu extends PanelMenu.Button {
|
|||||||
this._nightLight = new imports.ui.status.nightLight.Indicator();
|
this._nightLight = new imports.ui.status.nightLight.Indicator();
|
||||||
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
|
this._thunderbolt = new imports.ui.status.thunderbolt.Indicator();
|
||||||
|
|
||||||
|
if (Main.sessionMode.components.includes('updates'))
|
||||||
|
this._automaticUpdates = new imports.ui.status.automaticUpdates.Indicator();
|
||||||
|
else
|
||||||
|
this._automaticUpdates = null;
|
||||||
|
|
||||||
this._indicators.add_child(this._thunderbolt.indicators);
|
this._indicators.add_child(this._thunderbolt.indicators);
|
||||||
this._indicators.add_child(this._screencast.indicators);
|
this._indicators.add_child(this._screencast.indicators);
|
||||||
this._indicators.add_child(this._location.indicators);
|
this._indicators.add_child(this._location.indicators);
|
||||||
this._indicators.add_child(this._nightLight.indicators);
|
this._indicators.add_child(this._nightLight.indicators);
|
||||||
|
if (this._automaticUpdates)
|
||||||
|
this._indicators.add_child(this._automaticUpdates.indicators);
|
||||||
if (this._network) {
|
if (this._network) {
|
||||||
this._indicators.add_child(this._network.indicators);
|
this._indicators.add_child(this._network.indicators);
|
||||||
}
|
}
|
||||||
@ -796,6 +803,8 @@ class AggregateMenu extends PanelMenu.Button {
|
|||||||
if (this._network) {
|
if (this._network) {
|
||||||
this.menu.addMenuItem(this._network.menu);
|
this.menu.addMenuItem(this._network.menu);
|
||||||
}
|
}
|
||||||
|
if (this._automaticUpdates)
|
||||||
|
this.menu.addMenuItem(this._automaticUpdates.menu);
|
||||||
if (this._bluetooth) {
|
if (this._bluetooth) {
|
||||||
this.menu.addMenuItem(this._bluetooth.menu);
|
this.menu.addMenuItem(this._bluetooth.menu);
|
||||||
}
|
}
|
||||||
|
144
js/ui/status/automaticUpdates.js
Normal file
144
js/ui/status/automaticUpdates.js
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
//
|
||||||
|
// Copyright (C) 2018 Endless Mobile, Inc.
|
||||||
|
//
|
||||||
|
// This is a GNOME Shell component to wrap the interactions over
|
||||||
|
// D-Bus with the Mogwai system daemon.
|
||||||
|
//
|
||||||
|
// Licensed under the GNU General Public License Version 2
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU General Public License
|
||||||
|
// as published by the Free Software Foundation; either version 2
|
||||||
|
// of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
const { Gio, GLib, Shell, St } = imports.gi;
|
||||||
|
|
||||||
|
const UpdateManager = imports.misc.updateManager;
|
||||||
|
|
||||||
|
const Main = imports.ui.main;
|
||||||
|
const MessageTray = imports.ui.messageTray;
|
||||||
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
|
|
||||||
|
const NM_SETTING_AUTOMATIC_UPDATES_NOTIFICATION_TIME = "connection.automatic-updates-notification-time";
|
||||||
|
const NM_SETTING_ALLOW_DOWNLOADS = 'connection.allow-downloads';
|
||||||
|
const NM_SETTING_TARIFF_ENABLED = "connection.tariff-enabled";
|
||||||
|
|
||||||
|
const SchedulerInterface = '\
|
||||||
|
<node> \
|
||||||
|
<interface name="com.endlessm.DownloadManager1.Scheduler"> \
|
||||||
|
<property name="ActiveEntryCount" type="u" access="read" /> \
|
||||||
|
<property name="EntryCount" type="u" access="read" /> \
|
||||||
|
</interface> \
|
||||||
|
</node>';
|
||||||
|
|
||||||
|
const SchedulerProxy = Gio.DBusProxy.makeProxyWrapper(SchedulerInterface);
|
||||||
|
|
||||||
|
var Indicator = class extends PanelMenu.SystemIndicator {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this._indicator = this._addIndicator();
|
||||||
|
this._indicator.visible = false;
|
||||||
|
|
||||||
|
this._item = new PopupMenu.PopupSubMenuMenuItem("", true);
|
||||||
|
this._toggleItem = this._item.menu.addAction("", this._toggleAutomaticUpdates.bind(this));
|
||||||
|
this._item.menu.addAction(_("Updates Queue"), () => {
|
||||||
|
let params = new GLib.Variant('(sava{sv})', [ 'set-mode', [ new GLib.Variant('s', 'updates') ], {} ]);
|
||||||
|
Gio.DBus.session.call('org.gnome.Software',
|
||||||
|
'/org/gnome/Software',
|
||||||
|
'org.gtk.Actions',
|
||||||
|
'Activate',
|
||||||
|
params,
|
||||||
|
null,
|
||||||
|
Gio.DBusCallFlags.NONE,
|
||||||
|
5000,
|
||||||
|
null,
|
||||||
|
(conn, result) => {
|
||||||
|
try {
|
||||||
|
conn.call_finish(result);
|
||||||
|
} catch (e) {
|
||||||
|
logError(e, 'Failed to start gnome-software');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
this._item.menu.addSettingsAction(_("Set a Schedule"), 'gnome-updates-panel.desktop');
|
||||||
|
this.menu.addMenuItem(this._item);
|
||||||
|
|
||||||
|
this._manager = UpdateManager.getUpdateManager();
|
||||||
|
this._manager.connect('notify::state', this._updateState.bind(this));
|
||||||
|
|
||||||
|
this._updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateState() {
|
||||||
|
this._updateStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
_sessionUpdated() {
|
||||||
|
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
|
||||||
|
this.menu.setSensitive(sensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateStatus() {
|
||||||
|
// Toggle item name
|
||||||
|
this._updateItem();
|
||||||
|
|
||||||
|
// Icons
|
||||||
|
let icon = this._getIcon()
|
||||||
|
|
||||||
|
this._item.icon.gicon = icon;
|
||||||
|
this._indicator.gicon = icon;
|
||||||
|
|
||||||
|
// Only show the Automatic Updates icon at the bottom bar when it is
|
||||||
|
// both enabled, and there are updates being downloaded or installed.
|
||||||
|
this._updateVisibility();
|
||||||
|
|
||||||
|
// The status label
|
||||||
|
this._item.label.text = _("Automatic Updates");
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateItem() {
|
||||||
|
let state = this._manager.state;
|
||||||
|
|
||||||
|
if (state == UpdateManager.State.DISABLED)
|
||||||
|
this._toggleItem.label.text = _("Turn On");
|
||||||
|
else
|
||||||
|
this._toggleItem.label.text = _("Turn Off");
|
||||||
|
}
|
||||||
|
|
||||||
|
_toggleAutomaticUpdates() {
|
||||||
|
this._manager.toggleAutomaticUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
_getIcon() {
|
||||||
|
let state = this._manager.state;
|
||||||
|
let iconName = UpdateManager.stateToIconName(state);
|
||||||
|
|
||||||
|
if (!iconName)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
let iconFile = Gio.File.new_for_uri(iconName);
|
||||||
|
let gicon = new Gio.FileIcon({ file: iconFile });
|
||||||
|
|
||||||
|
return gicon;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateVisibility() {
|
||||||
|
let state = this._manager.state;
|
||||||
|
|
||||||
|
this._item.actor.visible = (state != UpdateManager.State.DISCONNECTED);
|
||||||
|
this._indicator.visible = (state == UpdateManager.State.DOWNLOADING);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user