autorunManager: Use a regular urgent notification

According to the design, hotplug notifications should no longer offer
an eject action and use regular notification buttons (but using icon
and text), the default action when clicking the notification itself
is to launch the file browser.
Also as the corresponding resident notification is gone, it no
longer makes sense to make the notification transient.

https://bugzilla.gnome.org/show_bug.cgi?id=744815
This commit is contained in:
Florian Müllner 2015-02-12 15:38:17 +01:00
parent a4fb55b4ca
commit aa2ae29ad8

View File

@ -167,7 +167,7 @@ const AutorunManager = new Lang.Class({
this._session = new GnomeSession.SessionManager(); this._session = new GnomeSession.SessionManager();
this._volumeMonitor = Gio.VolumeMonitor.get(); this._volumeMonitor = Gio.VolumeMonitor.get();
this._transDispatcher = new AutorunTransientDispatcher(this); this._dispatcher = new AutorunDispatcher(this);
}, },
enable: function() { enable: function() {
@ -187,13 +187,13 @@ const AutorunManager = new Lang.Class({
return; return;
let discoverer = new ContentTypeDiscoverer(Lang.bind(this, function(mount, apps, contentTypes) { let discoverer = new ContentTypeDiscoverer(Lang.bind(this, function(mount, apps, contentTypes) {
this._transDispatcher.addMount(mount, apps, contentTypes); this._dispatcher.addMount(mount, apps, contentTypes);
})); }));
discoverer.guessContentTypes(mount); discoverer.guessContentTypes(mount);
}, },
_onMountRemoved: function(monitor, mount) { _onMountRemoved: function(monitor, mount) {
this._transDispatcher.removeMount(mount); this._dispatcher.removeMount(mount);
}, },
ejectMount: function(mount) { ejectMount: function(mount) {
@ -256,8 +256,8 @@ const AutorunManager = new Lang.Class({
}, },
}); });
const AutorunTransientDispatcher = new Lang.Class({ const AutorunDispatcher = new Lang.Class({
Name: 'AutorunTransientDispatcher', Name: 'AutorunDispatcher',
_init: function(manager) { _init: function(manager) {
this._manager = manager; this._manager = manager;
@ -303,7 +303,7 @@ const AutorunTransientDispatcher = new Lang.Class({
return; return;
// add a new source // add a new source
this._sources.push(new AutorunTransientSource(this._manager, mount, apps)); this._sources.push(new AutorunSource(this._manager, mount, apps));
}, },
addMount: function(mount, apps, contentTypes) { addMount: function(mount, apps, contentTypes) {
@ -352,8 +352,8 @@ const AutorunTransientDispatcher = new Lang.Class({
} }
}); });
const AutorunTransientSource = new Lang.Class({ const AutorunSource = new Lang.Class({
Name: 'AutorunTransientSource', Name: 'AutorunSource',
Extends: MessageTray.Source, Extends: MessageTray.Source,
_init: function(manager, mount, apps) { _init: function(manager, mount, apps) {
@ -363,7 +363,7 @@ const AutorunTransientSource = new Lang.Class({
this.parent(mount.get_name()); this.parent(mount.get_name());
this._notification = new AutorunTransientNotification(this._manager, this); this._notification = new AutorunNotification(this._manager, this);
// add ourselves as a source, and popup the notification // add ourselves as a source, and popup the notification
Main.messageTray.add(this); Main.messageTray.add(this);
@ -375,34 +375,24 @@ const AutorunTransientSource = new Lang.Class({
} }
}); });
const AutorunTransientNotification = new Lang.Class({ const AutorunNotification = new Lang.Class({
Name: 'AutorunTransientNotification', Name: 'AutorunNotification',
Extends: MessageTray.Notification, Extends: MessageTray.Notification,
_init: function(manager, source) { _init: function(manager, source) {
this.parent(source, source.title, null, { customContent: true }); this.parent(source, source.title);
this._manager = manager; this._manager = manager;
this._box = new St.BoxLayout({ style_class: 'hotplug-transient-box',
vertical: true });
this.addActor(this._box);
this._mount = source.mount; this._mount = source.mount;
source.apps.forEach(Lang.bind(this, function (app) { source.apps.forEach(Lang.bind(this, function (app) {
let actor = this._buttonForApp(app); let actor = this._buttonForApp(app);
if (actor) if (actor)
this._box.add(actor, { x_fill: true, this.addButton(actor);
x_align: St.Align.START });
})); }));
this._box.add(this._buttonForEject(), { x_fill: true, // set the notification to urgent, so that it expands out
x_align: St.Align.START });
// set the notification to transient and urgent, so that it
// expands out
this.setTransient(true);
this.setUrgency(MessageTray.Urgency.CRITICAL); this.setUrgency(MessageTray.Urgency.CRITICAL);
}, },
@ -432,29 +422,11 @@ const AutorunTransientNotification = new Lang.Class({
return button; return button;
}, },
_buttonForEject: function() { _onClicked: function() {
let box = new St.BoxLayout(); this.parent();
let icon = new St.Icon({ icon_name: 'media-eject-symbolic',
style_class: 'hotplug-notification-item-icon' });
box.add(icon);
let label = new St.Bin({ y_align: St.Align.MIDDLE, let app = Gio.app_info_get_default_for_type('inode/directory', false);
child: new St.Label startAppForMount(app, this._mount);
({ text: _("Eject") })
});
box.add(label);
let button = new St.Button({ child: box,
x_fill: true,
x_align: St.Align.START,
button_mask: St.ButtonMask.ONE,
style_class: 'hotplug-notification-item' });
button.connect('clicked', Lang.bind(this, function() {
this._manager.ejectMount(this._mount);
}));
return button;
} }
}); });