A Sibling projects menu item, shown when any are installed, says which have a newer version (from `sibling check --porcelain`, run with each update check). It opens a dialog listing each sibling's version and state, with buttons to run `sibling update` for one or all of them in a terminal. A newer sibling also counts as an available update for the Update pill, the header and the top bar dot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,13 +11,17 @@ know whether you're up to date or to start an update.
|
||||
| Restart to finish updating | `gnome-session-quit --reboot` | Shown only while `~/.local/state/coredesktop/reboot-needed` exists |
|
||||
| Update | `update` in a terminal | **New version** pill when `version --check` finds one; **Running…** while it runs |
|
||||
| Refresh | `refresh` in a terminal | First, a dialog explaining what refresh does (this can be turned off) |
|
||||
| Check for updates | `version --check` | Leaves the menu open; shows when it last checked and when you last updated |
|
||||
| Sibling projects | `sibling check --porcelain` | Shown only if you have sibling projects. Says which have a newer version, with an **N new** pill. Opens a dialog listing each sibling's installed version and **Up to date**, **New version** or **Couldn't check**, with an **Update** button that runs `sibling update <name>` in a terminal (and **Update all** for `sibling update`) |
|
||||
| Check for updates | `version --check` and `sibling check --porcelain` | Leaves the menu open; shows when it last checked and when you last updated |
|
||||
| Configure | `configure --list` | **N to do** pill. Opens a dialog listing every item with **Done** or **To do**, its description from `configure.d`, and a **Set up** or **Change** button that runs `configure <item>` |
|
||||
| Version | `version` | A dialog with the full report: newer versions highlighted, plus **Copy** and **Update now** buttons |
|
||||
| Network audit | `audit` in a terminal | |
|
||||
| Report a problem | `report` in a terminal | |
|
||||
| Latest update log | | Opens the newest log in `~/.local/state/coredesktop/logs` |
|
||||
|
||||
A sibling project with a newer version counts as an update too: `update`
|
||||
updates siblings, so it gets the **New version** pill and the header says so.
|
||||
|
||||
The top bar icon gets a **blue dot** when an update is available and an
|
||||
**orange dot** when a restart is needed. It **pulses** while update or refresh runs.
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
|
||||
|
||||
import * as Cli from './lib/cli.js';
|
||||
import {ConfigureDialog, ConfirmDialog, VersionDialog} from './lib/dialogs.js';
|
||||
import {ConfigureDialog, ConfirmDialog, SiblingsDialog, VersionDialog} from './lib/dialogs.js';
|
||||
|
||||
// What each command is called, what it does in a few words, and its icon
|
||||
const COMMANDS = {
|
||||
@@ -55,6 +55,12 @@ const COMMANDS = {
|
||||
},
|
||||
};
|
||||
|
||||
// Runs that change the system, so only one may run at a time. `sibling update`
|
||||
// runs as "siblings" for all of them, or "sibling-<name>" for one.
|
||||
function changesSystem(name) {
|
||||
return name === 'update' || name === 'refresh' || name === 'siblings' || name.startsWith('sibling-');
|
||||
}
|
||||
|
||||
// Icons for configure's items, by name
|
||||
const CONFIGURE_ICONS = {
|
||||
'core': 'network-server-symbolic',
|
||||
@@ -181,6 +187,8 @@ class Indicator extends PanelMenu.Button {
|
||||
this._titles = new Map(); // status name -> title for notifications
|
||||
this._rebootNeeded = false;
|
||||
this._configureTodo = 0;
|
||||
this._siblingNames = []; // installed, from disk
|
||||
this._siblings = null; // the last `sibling check`, or null before one
|
||||
this._checkCancellable = null;
|
||||
this._timeouts = new Set();
|
||||
|
||||
@@ -243,6 +251,15 @@ class Indicator extends PanelMenu.Button {
|
||||
this._items = {};
|
||||
this._items.update = this._addCommand('update');
|
||||
this._items.refresh = this._addCommand('refresh');
|
||||
// Shown only when there are sibling projects
|
||||
this._siblingsItem = new ActionItem({
|
||||
icon: 'application-x-addon-symbolic',
|
||||
title: 'Sibling projects',
|
||||
description: '',
|
||||
});
|
||||
this._siblingsItem.visible = false;
|
||||
this._siblingsItem.connect('activate', () => this._openSiblings());
|
||||
this.menu.addMenuItem(this._siblingsItem);
|
||||
this._checkItem = new ActionItem({
|
||||
icon: 'system-search-symbolic',
|
||||
title: 'Check for updates',
|
||||
@@ -297,6 +314,23 @@ class Indicator extends PanelMenu.Button {
|
||||
}).open();
|
||||
}
|
||||
|
||||
_openSiblings() {
|
||||
// Until the first check, list what's installed with nothing known about it
|
||||
const known = this._siblings ?? this._siblingNames.map(name =>
|
||||
({name, installed: '', modified: false, state: 'unknown', available: null}));
|
||||
new SiblingsDialog({
|
||||
siblings: known,
|
||||
isRunning: name => this._running.has('update') || this._running.has('siblings') ||
|
||||
this._running.has(`sibling-${name}`),
|
||||
onChecked: siblings => {
|
||||
this._siblings = siblings;
|
||||
this._updateIndicator();
|
||||
},
|
||||
onUpdate: name => this._runTracked(`sibling-${name}`, `Update ${name}`, ['sibling', 'update', name]),
|
||||
onUpdateAll: () => this._runTracked('siblings', 'Update sibling projects', ['sibling', 'update']),
|
||||
}).open();
|
||||
}
|
||||
|
||||
// Everything that can be read locally without the network
|
||||
async _refreshLocal() {
|
||||
const version = await Cli.localVersion();
|
||||
@@ -308,6 +342,14 @@ class Indicator extends PanelMenu.Button {
|
||||
this._rebootNeeded = GLib.file_test(Cli.REBOOT_NEEDED, GLib.FileTest.EXISTS);
|
||||
this._lastUpdate = Cli.mtime(Cli.PACMAN_UPDATE_LOG);
|
||||
|
||||
const names = await Cli.installedSiblings();
|
||||
if (!this._header)
|
||||
return;
|
||||
this._siblingNames = names;
|
||||
// Forget removed siblings; ones added since the last check show at the next
|
||||
if (this._siblings)
|
||||
this._siblings = this._siblings.filter(s => names.includes(s.name));
|
||||
|
||||
try {
|
||||
const items = await Cli.configureItems();
|
||||
if (!this._header)
|
||||
@@ -340,10 +382,13 @@ class Indicator extends PanelMenu.Button {
|
||||
async _checkNow() {
|
||||
if (this._checkCancellable)
|
||||
return;
|
||||
this._checkCancellable = new Gio.Cancellable();
|
||||
const cancellable = this._checkCancellable = new Gio.Cancellable();
|
||||
this._checkItem.pill.setState('Checking…', 'running');
|
||||
try {
|
||||
const result = await Cli.checkForUpdate(this._checkCancellable);
|
||||
const [result] = await Promise.all([
|
||||
Cli.checkForUpdate(cancellable),
|
||||
this._checkSiblings(cancellable),
|
||||
]);
|
||||
this._update = {...result, checkedAt: GLib.get_real_time() / 1e6};
|
||||
} catch {
|
||||
return; // cancelled: the extension is being disabled
|
||||
@@ -354,6 +399,23 @@ class Indicator extends PanelMenu.Button {
|
||||
this._updateIndicator();
|
||||
}
|
||||
|
||||
// Look for newer versions of the sibling projects. Keeps the last result
|
||||
// if sibling can't run; throws only when cancelled.
|
||||
async _checkSiblings(cancellable) {
|
||||
this._siblingNames = await Cli.installedSiblings();
|
||||
if (this._siblingNames.length === 0) {
|
||||
this._siblings = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this._siblings = await Cli.checkSiblings(cancellable);
|
||||
} catch (e) {
|
||||
if (e.matches?.(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
|
||||
throw e;
|
||||
console.warn(`CoreDesktop: couldn't check sibling projects: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Bring the menu, header and top bar icon in line with what's known
|
||||
_updateIndicator() {
|
||||
if (!this._header)
|
||||
@@ -361,6 +423,9 @@ class Indicator extends PanelMenu.Button {
|
||||
const {state, version, checkedAt} = this._update;
|
||||
const running = [...this._running.keys()];
|
||||
const updating = this._running.has('update') || this._running.has('refresh');
|
||||
const siblings = this._siblings ?? [];
|
||||
const newerSiblings = siblings.filter(s => s.state === 'available').length;
|
||||
const somethingNewer = state === 'available' || newerSiblings > 0;
|
||||
|
||||
// Header status line
|
||||
if (this._running.has('update'))
|
||||
@@ -371,6 +436,10 @@ class Indicator extends PanelMenu.Button {
|
||||
this._header.setStatus('Restart to finish the last update', 'warning');
|
||||
else if (state === 'available')
|
||||
this._header.setStatus(`${version} is available`, 'accent');
|
||||
else if (state === 'current' && newerSiblings > 0)
|
||||
this._header.setStatus(newerSiblings === 1
|
||||
? 'A sibling project has a newer version'
|
||||
: `${newerSiblings} sibling projects have newer versions`, 'accent');
|
||||
else if (state === 'current')
|
||||
this._header.setStatus('Up to date', 'success');
|
||||
else if (checkedAt)
|
||||
@@ -383,16 +452,18 @@ class Indicator extends PanelMenu.Button {
|
||||
this._checkItem.description.text = checkedAt
|
||||
? `Last checked ${Cli.timeAgo(checkedAt)}${this._lastUpdate
|
||||
? ` · last updated ${Cli.timeAgo(this._lastUpdate)}` : ''}`
|
||||
: 'See whether a newer CoreDesktop is out';
|
||||
: 'See whether a newer CoreDesktop or sibling project is out';
|
||||
|
||||
this._rebootItem.visible = this._rebootNeeded && !updating;
|
||||
|
||||
this._updateSiblingsItem(running);
|
||||
|
||||
// Pills on the commands
|
||||
const configuring = running.some(k => k === 'configure' || k.startsWith('configure-'));
|
||||
for (const [key, item] of Object.entries(this._items)) {
|
||||
if (this._running.has(key) || (key === 'configure' && configuring))
|
||||
item.pill.setState('Running…', 'running');
|
||||
else if (key === 'update' && state === 'available')
|
||||
else if (key === 'update' && somethingNewer)
|
||||
item.pill.setState('New version', 'accent');
|
||||
else if (key === 'configure' && this._configureTodo > 0)
|
||||
item.pill.setState(`${this._configureTodo} to do`, 'warning');
|
||||
@@ -412,7 +483,7 @@ class Indicator extends PanelMenu.Button {
|
||||
});
|
||||
}
|
||||
const badge = this._settings.get_boolean('show-badge') && !updating &&
|
||||
(this._rebootNeeded || state === 'available');
|
||||
(this._rebootNeeded || somethingNewer);
|
||||
this._badge.visible = badge;
|
||||
this._badge.remove_style_class_name('warning');
|
||||
if (this._rebootNeeded)
|
||||
@@ -423,11 +494,39 @@ class Indicator extends PanelMenu.Button {
|
||||
accessible += ', updating';
|
||||
else if (this._rebootNeeded)
|
||||
accessible += ', restart needed';
|
||||
else if (state === 'available')
|
||||
else if (somethingNewer)
|
||||
accessible += ', update available';
|
||||
this.accessible_name = accessible;
|
||||
}
|
||||
|
||||
// The Sibling projects item: how many, and whether any is newer
|
||||
_updateSiblingsItem(running) {
|
||||
const count = this._siblingNames.length;
|
||||
this._siblingsItem.visible = count > 0;
|
||||
if (count === 0)
|
||||
return;
|
||||
const siblings = this._siblings ?? [];
|
||||
const newer = siblings.filter(s => s.state === 'available');
|
||||
const unknown = siblings.filter(s => s.state === 'unknown').length;
|
||||
let description;
|
||||
if (newer.length > 0)
|
||||
description = `Newer: ${newer.map(s => s.name).join(', ')}`;
|
||||
else if (!this._siblings)
|
||||
description = `${count} installed`;
|
||||
else if (unknown > 0)
|
||||
description = `${count} installed, couldn't check ${unknown}`;
|
||||
else
|
||||
description = count === 1 ? '1 installed, up to date' : `${count} installed, all up to date`;
|
||||
this._siblingsItem.description.text = description;
|
||||
|
||||
if (running.some(k => k === 'update' || k === 'siblings' || k.startsWith('sibling-')))
|
||||
this._siblingsItem.pill.setState('Running…', 'running');
|
||||
else if (newer.length > 0)
|
||||
this._siblingsItem.pill.setState(newer.length === 1 ? '1 new' : `${newer.length} new`, 'accent');
|
||||
else
|
||||
this._siblingsItem.pill.setState(null);
|
||||
}
|
||||
|
||||
_runCommand(key) {
|
||||
if (key === 'version') {
|
||||
new VersionDialog({onUpdate: () => this._runCommand('update')}).open();
|
||||
@@ -458,10 +557,9 @@ class Indicator extends PanelMenu.Button {
|
||||
this._notify(`${title} is already running`, 'Look for its terminal window.');
|
||||
return;
|
||||
}
|
||||
if ((name === 'update' || name === 'refresh') &&
|
||||
(this._running.has('update') || this._running.has('refresh'))) {
|
||||
if (changesSystem(name) && [...this._running.keys()].some(changesSystem)) {
|
||||
this._notify('Wait for the current run to finish',
|
||||
'Update and refresh both change the system, so run one at a time.');
|
||||
'Update, refresh and sibling updates all change the system, so run one at a time.');
|
||||
return;
|
||||
}
|
||||
const ok = Cli.runInTerminal(this._ext.path, this._settings.get_string('terminal'),
|
||||
@@ -559,9 +657,14 @@ class Indicator extends PanelMenu.Button {
|
||||
const title = this._titles.get(name) ?? COMMANDS[name]?.title ?? name;
|
||||
this._titles.delete(name);
|
||||
|
||||
const sibling = name === 'siblings' || name.startsWith('sibling-');
|
||||
if (name === 'update' && code === 0)
|
||||
this._update = {state: 'current', version: null, checkedAt: GLib.get_real_time() / 1e6};
|
||||
this._refreshLocal().then(() => {
|
||||
// Update and sibling update change the siblings' versions: look again
|
||||
if (name === 'update' || sibling)
|
||||
this._checkSiblingsNow();
|
||||
|
||||
if (!this._settings.get_boolean('notify-finished'))
|
||||
return;
|
||||
if (code === 0) {
|
||||
@@ -571,6 +674,9 @@ class Indicator extends PanelMenu.Button {
|
||||
'success', restart ? [['Restart now', () => this._restart()]] : []);
|
||||
} else if (code === 129 || code === 130) {
|
||||
this._notify(`${title} was stopped`, 'Its window was closed before it finished.', 'warning');
|
||||
} else if (sibling) {
|
||||
this._notify(`${title} ran into problems`,
|
||||
'Its terminal window says what went wrong.', 'error');
|
||||
} else {
|
||||
const actions = [['Open log', () => this._openLatestLog()]];
|
||||
if (name === 'update' || name === 'refresh')
|
||||
@@ -581,6 +687,21 @@ class Indicator extends PanelMenu.Button {
|
||||
});
|
||||
}
|
||||
|
||||
// Check the siblings alone, unless a full check is already running
|
||||
async _checkSiblingsNow() {
|
||||
if (this._checkCancellable)
|
||||
return;
|
||||
const cancellable = this._checkCancellable = new Gio.Cancellable();
|
||||
try {
|
||||
await this._checkSiblings(cancellable);
|
||||
} catch {
|
||||
return; // cancelled: the extension is being disabled
|
||||
} finally {
|
||||
this._checkCancellable = null;
|
||||
}
|
||||
this._updateIndicator();
|
||||
}
|
||||
|
||||
_restart() {
|
||||
// GNOME's own restart dialog, with its countdown and cancel button
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@ export const STATE = GLib.build_filenamev([HOME, '.local', 'state', 'coredesktop
|
||||
export const LOGS = GLib.build_filenamev([STATE, 'logs']);
|
||||
export const REBOOT_NEEDED = GLib.build_filenamev([STATE, 'reboot-needed']);
|
||||
export const PACMAN_UPDATE_LOG = GLib.build_filenamev([STATE, 'pacman-update.log']);
|
||||
export const SIBLINGS = GLib.build_filenamev([HOME, '.local', 'share', 'siblings']);
|
||||
export const STATUS_DIR = GLib.build_filenamev([GLib.get_user_runtime_dir(), 'coredesktop-extension']);
|
||||
|
||||
// Terminals and how each runs a command, in the order CoreDesktop's
|
||||
@@ -83,6 +84,46 @@ export async function checkForUpdate(cancellable) {
|
||||
return {state: 'unknown'};
|
||||
}
|
||||
|
||||
// Names of the sibling projects installed with `sibling`, alphabetically. Read
|
||||
// from disk, so it's quick and needs no network.
|
||||
export async function installedSiblings() {
|
||||
const names = [];
|
||||
for (const file of await listFiles(Gio.File.new_for_path(SIBLINGS))) {
|
||||
if (GLib.file_test(GLib.build_filenamev([file.get_path(), '.git']), GLib.FileTest.IS_DIR))
|
||||
names.push(file.get_basename());
|
||||
}
|
||||
return names.sort();
|
||||
}
|
||||
|
||||
// sibling check --porcelain, which fetches each sibling's remote:
|
||||
// [{name, installed, modified, state: 'available' | 'current' | 'unknown', available}]
|
||||
// Throws if sibling itself couldn't run.
|
||||
export async function checkSiblings(cancellable) {
|
||||
const {status, stdout, stderr} = await run([bin('sibling'), 'check', '--porcelain'], cancellable);
|
||||
if (status !== 0)
|
||||
throw new Error(stripAnsi(stderr || stdout).trim() || `sibling exited with status ${status}`);
|
||||
const siblings = [];
|
||||
for (const line of stdout.split('\n')) {
|
||||
const [name, installedField, available = ''] = line.split('\t');
|
||||
if (!name || installedField === undefined)
|
||||
continue;
|
||||
const modified = installedField.endsWith(', modified');
|
||||
let state = 'available';
|
||||
if (available === '')
|
||||
state = 'current';
|
||||
else if (available === '?')
|
||||
state = 'unknown';
|
||||
siblings.push({
|
||||
name,
|
||||
installed: modified ? installedField.slice(0, -', modified'.length) : installedField,
|
||||
modified,
|
||||
state,
|
||||
available: state === 'available' ? available : null,
|
||||
});
|
||||
}
|
||||
return siblings;
|
||||
}
|
||||
|
||||
// configure --list, with each item's description from its configure.d file:
|
||||
// [{name, title, description, done}]
|
||||
export async function configureItems() {
|
||||
@@ -187,7 +228,8 @@ export function runInTerminal(extensionPath, preference, name, argv) {
|
||||
return false;
|
||||
const tracked = GLib.build_filenamev([extensionPath, 'bin', 'run-tracked']);
|
||||
const command = ['systemd-run', '--user', '--quiet', '--collect',
|
||||
`--unit=coredesktop-${name}-${Date.now()}`, '--',
|
||||
// A sibling's name can hold characters a unit name can't
|
||||
`--unit=coredesktop-${name.replace(/[^A-Za-z0-9:_.-]/g, '_')}-${Date.now()}`, '--',
|
||||
...terminal, 'bash', tracked, name, ...argv];
|
||||
GLib.mkdir_with_parents(STATUS_DIR, 0o700);
|
||||
Gio.Subprocess.new(command, Gio.SubprocessFlags.NONE);
|
||||
|
||||
@@ -98,6 +98,150 @@ class ConfigureDialog extends ModalDialog.ModalDialog {
|
||||
}
|
||||
});
|
||||
|
||||
// The sibling projects on this machine, each with its version and whether a
|
||||
// newer one is out, and buttons to update them. Checks afresh when it opens.
|
||||
// siblings: what's already known, shown while checking (or [] for nothing)
|
||||
// isRunning(name): whether `sibling update` is running for that sibling
|
||||
// onChecked(siblings): called with each check's result
|
||||
// onUpdate(name): update one sibling; onUpdateAll(): update every one
|
||||
export const SiblingsDialog = GObject.registerClass(
|
||||
class SiblingsDialog extends ModalDialog.ModalDialog {
|
||||
_init({siblings, isRunning, onChecked, onUpdate, onUpdateAll}) {
|
||||
super._init({styleClass: 'coredesktop-dialog coredesktop-configure-dialog'});
|
||||
this._isRunning = isRunning;
|
||||
this._onChecked = onChecked;
|
||||
this._onUpdate = onUpdate;
|
||||
this._onUpdateAll = onUpdateAll;
|
||||
this._cancellable = new Gio.Cancellable();
|
||||
|
||||
this._content = new Dialog.MessageDialogContent({title: 'Sibling projects', description: ''});
|
||||
this.contentLayout.add_child(this._content);
|
||||
|
||||
this._list = new St.BoxLayout({orientation: Clutter.Orientation.VERTICAL, style_class: 'coredesktop-configure-list'});
|
||||
const scroll = new St.ScrollView({
|
||||
style_class: 'coredesktop-configure-scroll',
|
||||
hscrollbar_policy: St.PolicyType.NEVER,
|
||||
vscrollbar_policy: St.PolicyType.AUTOMATIC,
|
||||
overlay_scrollbars: true,
|
||||
});
|
||||
scroll.set_child(this._list);
|
||||
this.contentLayout.add_child(scroll);
|
||||
|
||||
this.connect('destroy', () => this._cancellable.cancel());
|
||||
this._show(siblings, true);
|
||||
this._load();
|
||||
}
|
||||
|
||||
async _load() {
|
||||
let siblings;
|
||||
try {
|
||||
siblings = await Cli.checkSiblings(this._cancellable);
|
||||
} catch (e) {
|
||||
if (e.matches?.(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
|
||||
return;
|
||||
this._content.description = `Couldn't check for newer versions: ${e.message}`;
|
||||
this._setButtons([]);
|
||||
return;
|
||||
}
|
||||
this._onChecked(siblings);
|
||||
this._show(siblings, false);
|
||||
}
|
||||
|
||||
_show(siblings, checking) {
|
||||
const newer = siblings.filter(s => s.state === 'available');
|
||||
const unknown = siblings.filter(s => s.state === 'unknown');
|
||||
if (checking)
|
||||
this._content.description = 'Checking for newer versions…';
|
||||
else if (siblings.length === 0)
|
||||
this._content.description = 'No sibling projects are installed. Add one in a terminal with: sibling add <url>';
|
||||
else if (newer.length > 0)
|
||||
this._content.description = `${newer.length} of ${siblings.length} ${newer.length === 1 ? 'has' : 'have'} a newer version. Update also updates them.`;
|
||||
else if (unknown.length > 0)
|
||||
this._content.description = `Couldn't check ${unknown.length} of ${siblings.length} for a newer version. The rest are up to date.`;
|
||||
else
|
||||
this._content.description = siblings.length === 1
|
||||
? 'It\'s up to date.' : `All ${siblings.length} are up to date.`;
|
||||
|
||||
this._list.remove_all_children();
|
||||
for (const sibling of siblings)
|
||||
this._list.add_child(this._row(sibling, checking));
|
||||
this._setButtons(checking ? [] : newer);
|
||||
}
|
||||
|
||||
_row(sibling, checking) {
|
||||
const row = new St.BoxLayout({style_class: 'coredesktop-configure-row'});
|
||||
row.add_child(new St.Icon({
|
||||
icon_name: 'application-x-addon-symbolic',
|
||||
style_class: 'coredesktop-configure-icon',
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
}));
|
||||
const text = new St.BoxLayout({
|
||||
orientation: Clutter.Orientation.VERTICAL,
|
||||
x_expand: true,
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
});
|
||||
text.add_child(new St.Label({text: sibling.name, style_class: 'coredesktop-item-title'}));
|
||||
let description = sibling.installed ? `Installed: ${sibling.installed}` : 'Checking…';
|
||||
if (sibling.modified)
|
||||
description += ', with local changes';
|
||||
if (sibling.available)
|
||||
description += ` · ${sibling.available} is available`;
|
||||
text.add_child(new St.Label({text: description, style_class: 'coredesktop-item-description'}));
|
||||
row.add_child(text);
|
||||
|
||||
const running = this._isRunning(sibling.name);
|
||||
let state = null, kind;
|
||||
if (running)
|
||||
[state, kind] = ['Running…', 'running'];
|
||||
else if (checking)
|
||||
state = null;
|
||||
else if (sibling.state === 'available')
|
||||
[state, kind] = ['New version', 'accent'];
|
||||
else if (sibling.state === 'current')
|
||||
[state, kind] = ['Up to date', 'success'];
|
||||
else
|
||||
[state, kind] = ['Couldn\'t check', 'warning'];
|
||||
if (state) {
|
||||
row.add_child(new St.Label({
|
||||
text: state,
|
||||
style_class: `coredesktop-pill ${kind}`,
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
}));
|
||||
}
|
||||
|
||||
if (sibling.state === 'available' && !checking) {
|
||||
const button = new St.Button({
|
||||
label: 'Update',
|
||||
style_class: 'button coredesktop-configure-button default',
|
||||
y_align: Clutter.ActorAlign.CENTER,
|
||||
can_focus: true,
|
||||
reactive: !running,
|
||||
});
|
||||
button.connect('clicked', () => {
|
||||
this.close();
|
||||
this._onUpdate(sibling.name);
|
||||
});
|
||||
row.add_child(button);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
_setButtons(newer) {
|
||||
const buttons = [];
|
||||
if (newer.length > 1) {
|
||||
buttons.push({
|
||||
label: 'Update all',
|
||||
action: () => {
|
||||
this.close();
|
||||
this._onUpdateAll();
|
||||
},
|
||||
});
|
||||
}
|
||||
buttons.push({label: 'Close', action: () => this.close(), key: Clutter.KEY_Escape, default: true});
|
||||
this.setButtons(buttons);
|
||||
}
|
||||
});
|
||||
|
||||
// Ask before running something. onConfirm runs if the user agrees.
|
||||
export const ConfirmDialog = GObject.registerClass(
|
||||
class ConfirmDialog extends ModalDialog.ModalDialog {
|
||||
|
||||
Reference in New Issue
Block a user