mount-operation: implement show-unmount-progress
Show a notification when we receive a show-unmount-progress signal on the mount operation we use for unmounting. The notification will either turn fade out automatically with a completion message when the unmount successfully completes, or will disappear in case the operation is aborted underway (for example because the device has been unplugged in the meantime). https://bugzilla.gnome.org/show_bug.cgi?id=676125
This commit is contained in:
parent
f906cfe5f6
commit
168e0b5a42
@ -117,6 +117,8 @@ const ShellMountOperation = new Lang.Class({
|
||||
Lang.bind(this, this._onShowProcesses2));
|
||||
this.mountOp.connect('aborted',
|
||||
Lang.bind(this, this.close));
|
||||
this.mountOp.connect('show-unmount-progress',
|
||||
Lang.bind(this, this._onShowUnmountProgress));
|
||||
|
||||
this._gicon = source.get_icon();
|
||||
},
|
||||
@ -178,6 +180,11 @@ const ShellMountOperation = new Lang.Class({
|
||||
this._dialog.close();
|
||||
this._dialog = null;
|
||||
}
|
||||
|
||||
if (this._notifier) {
|
||||
this._notifier.done();
|
||||
this._notifier = null;
|
||||
}
|
||||
},
|
||||
|
||||
_onShowProcesses2: function(op) {
|
||||
@ -208,6 +215,16 @@ const ShellMountOperation = new Lang.Class({
|
||||
this._processesDialog.update(message, processes, choices);
|
||||
},
|
||||
|
||||
_onShowUnmountProgress: function(op, message, timeLeft, bytesLeft) {
|
||||
if (!this._notifier)
|
||||
this._notifier = new ShellUnmountNotifier();
|
||||
|
||||
if (bytesLeft == 0)
|
||||
this._notifier.done(message);
|
||||
else
|
||||
this._notifier.show(message);
|
||||
},
|
||||
|
||||
borrowDialog: function() {
|
||||
if (this._dialogId != 0) {
|
||||
this._dialog.disconnect(this._dialogId);
|
||||
@ -218,6 +235,46 @@ const ShellMountOperation = new Lang.Class({
|
||||
}
|
||||
});
|
||||
|
||||
const ShellUnmountNotifier = new Lang.Class({
|
||||
Name: 'ShellUnmountNotifier',
|
||||
Extends: MessageTray.Source,
|
||||
|
||||
_init: function() {
|
||||
this.parent('', 'media-removable', St.IconType.FULLCOLOR);
|
||||
|
||||
this._notification = null;
|
||||
Main.messageTray.add(this);
|
||||
},
|
||||
|
||||
show: function(message) {
|
||||
let [header, text] = message.split('\n', 2);
|
||||
|
||||
if (!this._notification) {
|
||||
this._notification = new MessageTray.Notification(this, header, text);
|
||||
this._notification.setTransient(true);
|
||||
this._notification.setUrgency(MessageTray.Urgency.CRITICAL);
|
||||
} else {
|
||||
this._notification.update(header, text);
|
||||
}
|
||||
|
||||
this.notify(this._notification);
|
||||
},
|
||||
|
||||
done: function(message) {
|
||||
if (this._notification) {
|
||||
this._notification.destroy();
|
||||
this._notification = null;
|
||||
}
|
||||
|
||||
if (message) {
|
||||
let notification = new MessageTray.Notification(this, message, null);
|
||||
notification.setTransient(true);
|
||||
|
||||
this.notify(notification);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const ShellMountQuestionDialog = new Lang.Class({
|
||||
Name: 'ShellMountQuestionDialog',
|
||||
Extends: ModalDialog.ModalDialog,
|
||||
|
Loading…
Reference in New Issue
Block a user