[gnome-shell/wip/fmuellner/notification-redux: 8/93] autorunManager: Remove resident notification
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/notification-redux: 8/93] autorunManager: Remove resident notification
- Date: Sun, 15 Feb 2015 19:15:02 +0000 (UTC)
commit a2787f87bce875bbe5fce39bcb9d4303f600cf0a
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 12 15:15:51 2015 +0100
autorunManager: Remove resident notification
data/theme/gnome-shell.css | 42 --------
js/ui/components/autorunManager.js | 193 ++----------------------------------
2 files changed, 7 insertions(+), 228 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index f528219..010ecba 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -421,7 +421,6 @@ StScrollBar StButton#vhandle:active {
.notification-button,
.notification-icon-button,
.hotplug-notification-item,
-.hotplug-resident-eject-button,
.modal-dialog-button,
.app-view-control {
border: 1px solid #8b8b8b;
@@ -438,7 +437,6 @@ StScrollBar StButton#vhandle:active {
.notification-button:hover,
.notification-icon-button:hover,
.hotplug-notification-item:hover,
-.hotplug-resident-eject-button:hover,
.modal-dialog-button:hover {
background-gradient-start: rgba(255, 255, 255, 0.3);
background-gradient-end: rgba(255, 255, 255, 0.1);
@@ -462,7 +460,6 @@ StScrollBar StButton#vhandle:active {
.notification-button:active,
.notification-icon-button:active,
.hotplug-notification-item:active,
-.hotplug-resident-eject-button:active,
.modal-dialog-button:active,
.modal-dialog-button:pressed,
.app-view-control:checked {
@@ -1700,45 +1697,6 @@ StScrollBar StButton#vhandle:active {
padding: 2px 5px;
}
-.hotplug-resident-box {
- spacing: 8px;
-}
-
-.hotplug-resident-mount {
- spacing: 8px;
- border-radius: 4px;
-
- color: #ccc;
-}
-
-.hotplug-resident-mount:hover {
- background-gradient-direction: horizontal;
- background-gradient-start: rgba(255, 255, 255, 0.1);
- background-gradient-end: rgba(255, 255, 255, 0);
-
- color: #fff;
-}
-
-.hotplug-resident-mount-label {
- color: inherit;
- padding-left: 6px;
-}
-
-.hotplug-resident-mount-icon {
- icon-size: 24px;
- padding-left: 6px;
-}
-
-.hotplug-resident-eject-icon {
- icon-size: 16px;
-}
-
-.hotplug-resident-eject-button {
- padding: 7px;
- border-radius: 5px;
- color: #ccc;
-}
-
.chat-log-message {
color: #888888;
}
diff --git a/js/ui/components/autorunManager.js b/js/ui/components/autorunManager.js
index 8f716cc..3c6514c 100644
--- a/js/ui/components/autorunManager.js
+++ b/js/ui/components/autorunManager.js
@@ -24,11 +24,11 @@ const AutorunSetting = {
};
// misc utils
-function shouldAutorunMount(mount, forTransient) {
+function shouldAutorunMount(mount) {
let root = mount.get_root();
let volume = mount.get_volume();
- if (!volume || (!volume.allowAutorun && forTransient))
+ if (!volume || !volume.allowAutorun)
return false;
if (root.is_native() && isMountRootHidden(root))
@@ -170,62 +170,30 @@ const AutorunManager = new Lang.Class({
this._transDispatcher = new AutorunTransientDispatcher(this);
},
- _ensureResidentSource: function() {
- if (this._residentSource)
- return;
-
- this._residentSource = new AutorunResidentSource(this);
- let destroyId = this._residentSource.connect('destroy', Lang.bind(this, function() {
- this._residentSource.disconnect(destroyId);
- this._residentSource = null;
- }));
- },
-
enable: function() {
- this._scanMounts();
-
this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded));
this._mountRemovedId = this._volumeMonitor.connect('mount-removed', Lang.bind(this,
this._onMountRemoved));
},
disable: function() {
- if (this._residentSource)
- this._residentSource.destroy();
this._volumeMonitor.disconnect(this._mountAddedId);
this._volumeMonitor.disconnect(this._mountRemovedId);
},
- _processMount: function(mount, hotplug) {
- let discoverer = new ContentTypeDiscoverer(Lang.bind(this, function(mount, apps, contentTypes) {
- this._ensureResidentSource();
- this._residentSource.addMount(mount, apps);
-
- if (hotplug)
- this._transDispatcher.addMount(mount, apps, contentTypes);
- }));
- discoverer.guessContentTypes(mount);
- },
-
- _scanMounts: function() {
- let mounts = this._volumeMonitor.get_mounts();
- mounts.forEach(Lang.bind(this, function(mount) {
- this._processMount(mount, false);
- }));
- },
-
_onMountAdded: function(monitor, mount) {
// don't do anything if our session is not the currently
// active one
if (!this._session.SessionIsActive)
return;
- this._processMount(mount, true);
+ let discoverer = new ContentTypeDiscoverer(Lang.bind(this, function(mount, apps, contentTypes) {
+ this._transDispatcher.addMount(mount, apps, contentTypes);
+ }));
+ discoverer.guessContentTypes(mount);
},
_onMountRemoved: function(monitor, mount) {
this._transDispatcher.removeMount(mount);
- if (this._residentSource)
- this._residentSource.removeMount(mount);
},
ejectMount: function(mount) {
@@ -288,153 +256,6 @@ const AutorunManager = new Lang.Class({
},
});
-const AutorunResidentSource = new Lang.Class({
- Name: 'AutorunResidentSource',
- Extends: MessageTray.Source,
-
- _init: function(manager) {
- this.parent(_("Removable Devices"), 'media-removable');
- this.resident = true;
-
- this._mounts = [];
-
- this._manager = manager;
- this._notification = new AutorunResidentNotification(this._manager, this);
- },
-
- _createPolicy: function() {
- return new MessageTray.NotificationPolicy({ showInLockScreen: false });
- },
-
- buildRightClickMenu: function() {
- return null;
- },
-
- addMount: function(mount, apps) {
- if (!shouldAutorunMount(mount, false))
- return;
-
- let filtered = this._mounts.filter(function (element) {
- return (element.mount == mount);
- });
-
- if (filtered.length != 0)
- return;
-
- let element = { mount: mount, apps: apps };
- this._mounts.push(element);
- this._redisplay();
- },
-
- removeMount: function(mount) {
- this._mounts =
- this._mounts.filter(function (element) {
- return (element.mount != mount);
- });
-
- this._redisplay();
- },
-
- _redisplay: function() {
- if (this._mounts.length == 0) {
- this._notification.destroy();
- this.destroy();
-
- return;
- }
-
- this._notification.updateForMounts(this._mounts);
-
- // add ourselves as a source, and push the notification
- if (!Main.messageTray.contains(this)) {
- Main.messageTray.add(this);
- this.pushNotification(this._notification);
- }
- }
-});
-
-const AutorunResidentNotification = new Lang.Class({
- Name: 'AutorunResidentNotification',
- Extends: MessageTray.Notification,
-
- _init: function(manager, source) {
- this.parent(source, source.title, null, { customContent: true });
-
- // set the notification as resident
- this.setResident(true);
-
- this._layout = new St.BoxLayout ({ style_class: 'hotplug-resident-box',
- vertical: true });
- this._manager = manager;
-
- this.addActor(this._layout,
- { x_expand: true,
- x_fill: true });
- },
-
- updateForMounts: function(mounts) {
- // remove all the layout content
- this._layout.destroy_all_children();
-
- for (let idx = 0; idx < mounts.length; idx++) {
- let element = mounts[idx];
-
- let actor = this._itemForMount(element.mount, element.apps);
- this._layout.add(actor, { x_fill: true,
- expand: true });
- }
- },
-
- _itemForMount: function(mount, apps) {
- let item = new St.BoxLayout();
-
- // prepare the mount button content
- let mountLayout = new St.BoxLayout();
-
- let mountIcon = new St.Icon({ gicon: mount.get_icon(),
- style_class: 'hotplug-resident-mount-icon' });
- mountLayout.add_actor(mountIcon);
-
- let labelBin = new St.Bin({ y_align: St.Align.MIDDLE });
- let mountLabel =
- new St.Label({ text: mount.get_name(),
- style_class: 'hotplug-resident-mount-label',
- track_hover: true,
- reactive: true });
- labelBin.add_actor(mountLabel);
- mountLayout.add_actor(labelBin);
-
- let mountButton = new St.Button({ child: mountLayout,
- x_align: St.Align.START,
- x_fill: true,
- style_class: 'hotplug-resident-mount',
- button_mask: St.ButtonMask.ONE });
- item.add(mountButton, { x_align: St.Align.START,
- expand: true });
-
- let ejectIcon =
- new St.Icon({ icon_name: 'media-eject-symbolic',
- style_class: 'hotplug-resident-eject-icon' });
-
- let ejectButton =
- new St.Button({ style_class: 'hotplug-resident-eject-button',
- button_mask: St.ButtonMask.ONE,
- child: ejectIcon });
- item.add(ejectButton, { x_align: St.Align.END });
-
- // now connect signals
- mountButton.connect('clicked', Lang.bind(this, function(actor, event) {
- startAppForMount(apps[0], mount);
- }));
-
- ejectButton.connect('clicked', Lang.bind(this, function() {
- this._manager.ejectMount(mount);
- }));
-
- return item;
- },
-});
-
const AutorunTransientDispatcher = new Lang.Class({
Name: 'AutorunTransientDispatcher',
@@ -491,7 +312,7 @@ const AutorunTransientDispatcher = new Lang.Class({
return;
// if the mount doesn't want to be autorun, return
- if (!shouldAutorunMount(mount, true))
+ if (!shouldAutorunMount(mount))
return;
let setting = this._getAutorunSettingForType(contentTypes[0]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]