[gnome-shell/f17] New version of unmount notification

Owen Taylor otaylor at fedoraproject.org
Wed May 16 20:45:16 UTC 2012


commit 855ab8876a2f0e3d4654d3d86394124a7fddd0bf
Author: Owen W. Taylor <otaylor at fishsoup.net>
Date:   Wed May 16 16:44:58 2012 -0400

    New version of unmount notification

 ...add-a-notification-when-unmounting-drives.patch |   72 ++++++++++++-------
 gnome-shell.spec                                   |    5 +-
 2 files changed, 49 insertions(+), 28 deletions(-)
---
diff --git a/autorun-add-a-notification-when-unmounting-drives.patch b/autorun-add-a-notification-when-unmounting-drives.patch
index 4dc0aa0..c2cba97 100644
--- a/autorun-add-a-notification-when-unmounting-drives.patch
+++ b/autorun-add-a-notification-when-unmounting-drives.patch
@@ -1,4 +1,4 @@
-From b5b3ccd2b0007877401ee9e6f3d29dc43c8731cc Mon Sep 17 00:00:00 2001
+From 7fde1d8c46badad36c25d2444bd0aba760169b38 Mon Sep 17 00:00:00 2001
 From: Cosimo Cecchi <cosimoc at gnome.org>
 Date: Mon, 14 May 2012 18:33:06 -0400
 Subject: [PATCH] autorun: add a notification when unmounting drives
@@ -9,52 +9,52 @@ https://bugzilla.redhat.com/show_bug.cgi?id=819492
 
 https://bugzilla.gnome.org/show_bug.cgi?id=676125
 ---
- js/ui/autorunManager.js |  100 +++++++++++++++++++++++++++++++++++++++++++----
- 1 file changed, 92 insertions(+), 8 deletions(-)
+ js/ui/autorunManager.js |  119 +++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 111 insertions(+), 8 deletions(-)
 
 diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
-index 27d89e8..6f799d7 100644
+index 27d89e8..f62dbcb 100644
 --- a/js/ui/autorunManager.js
 +++ b/js/ui/autorunManager.js
-@@ -193,6 +193,7 @@ const AutorunManager = new Lang.Class({
+@@ -193,6 +193,8 @@ const AutorunManager = new Lang.Class({
  
      ejectMount: function(mount) {
          let mountOp = new ShellMountOperation.ShellMountOperation(mount);
-+        let unmountNotifier;
++        let unmountNotifier = new UnmountNotifier(mountOp.mountOp, mount);
++        let didEject = true;
  
          // first, see if we have a drive
          let drive = mount.get_drive();
-@@ -201,28 +202,35 @@ const AutorunManager = new Lang.Class({
-         if (drive &&
+@@ -202,27 +204,34 @@ const AutorunManager = new Lang.Class({
              drive.get_start_stop_type() == Gio.DriveStartStopType.SHUTDOWN &&
              drive.can_stop()) {
-+            unmountNotifier = new UnmountNotifier(mountOp.mountOp, drive);
              drive.stop(0, mountOp.mountOp, null,
 -                       Lang.bind(this, this._onStop));
 +                       Lang.bind(this, this._onStop, unmountNotifier));
          } else {
              if (mount.can_eject()) {
-+                unmountNotifier = new UnmountNotifier(mountOp.mountOp, mount);
                  mount.eject_with_operation(0, mountOp.mountOp, null,
 -                                           Lang.bind(this, this._onEject));
 +                                           Lang.bind(this, this._onEject, unmountNotifier));
              } else if (volume && volume.can_eject()) {
-+                unmountNotifier = new UnmountNotifier(mountOp.mountOp, volume);
                  volume.eject_with_operation(0, mountOp.mountOp, null,
 -                                            Lang.bind(this, this._onEject));
 +                                            Lang.bind(this, this._onEject, unmountNotifier));
              } else if (drive && drive.can_eject()) {
-+                unmountNotifier = new UnmountNotifier(mountOp.mountOp, drive);
                  drive.eject_with_operation(0, mountOp.mountOp, null,
 -                                           Lang.bind(this, this._onEject));
 +                                           Lang.bind(this, this._onEject, unmountNotifier));
              } else if (mount.can_unmount()) {
-+                unmountNotifier = new UnmountNotifier(mountOp.mountOp, mount);
                  mount.unmount_with_operation(0, mountOp.mountOp, null,
 -                                             Lang.bind(this, this._onUnmount));
 +                                             Lang.bind(this, this._onUnmount, unmountNotifier));
++            } else {
++                didEject = false;
              }
          }
++
++        if (didEject)
++            unmountNotifier.show();
      },
  
 -    _onUnmount: function(mount, res) {
@@ -66,7 +66,7 @@ index 27d89e8..6f799d7 100644
          } catch (e) {
              // FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
              // but we can't access the error code from JS.
-@@ -230,11 +238,15 @@ const AutorunManager = new Lang.Class({
+@@ -230,11 +239,15 @@ const AutorunManager = new Lang.Class({
              log('Unable to eject the mount ' + mount.get_name() 
                  + ': ' + e.toString());
          }
@@ -83,7 +83,7 @@ index 27d89e8..6f799d7 100644
          } catch (e) {
              // FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
              // but we can't access the error code from JS.
-@@ -242,11 +254,15 @@ const AutorunManager = new Lang.Class({
+@@ -242,11 +255,15 @@ const AutorunManager = new Lang.Class({
              log('Unable to eject the drive ' + source.get_name() 
                  + ': ' + e.toString());
          }
@@ -100,7 +100,7 @@ index 27d89e8..6f799d7 100644
          } catch (e) {
              // FIXME: we need to ignore G_IO_ERROR_FAILED_HANDLED errors here
              // but we can't access the error code from JS.
-@@ -254,7 +270,75 @@ const AutorunManager = new Lang.Class({
+@@ -254,7 +271,93 @@ const AutorunManager = new Lang.Class({
              log('Unable to stop the drive ' + drive.get_name() 
                  + ': ' + e.toString());
          }
@@ -113,10 +113,15 @@ index 27d89e8..6f799d7 100644
 +    Name: 'UnmountNotifier',
 +    Extends: MessageTray.Source,
 +
-+    _init: function(mountOperation, device) {
++    _init: function(mountOperation, mount) {
 +        this.parent('');
-+        this._deviceName = device.get_name();
 +
++        this._notification = null;
++        this._shouldNotify = this._shouldNotifyForMount(mount);
++        if (!this._shouldNotify)
++            return;
++
++        this._mountName = mount.get_name();
 +        mountOperation.connect('show-processes-2', Lang.bind(this,
 +            function() {
 +                this.done(false);
@@ -125,21 +130,34 @@ index 27d89e8..6f799d7 100644
 +            function(mountOp, res) {
 +                // "Unmount Anyway" choice
 +                if (mountOp.choice == 0)
-+                    this._show();
++                    this.show();
 +            }));
 +        mountOperation.connect('aborted', Lang.bind(this,
 +            function() {
 +                this.done(false);
 +            }));
 +
-+        this._notification = null;
 +        Main.messageTray.add(this);
-+
-+        this._show();
 +    },
 +
-+    _show: function() {
-+        let header = _("Writing data to %s").format(this._deviceName);
++    _shouldNotifyForMount: function(mount) {
++        let deviceId = null;
++        let volume = mount.get_volume();
++        if (volume)
++            deviceId = volume.get_identifier(Gio.VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
++
++        // if the unix device id matches /dev/sr* (optical media), don't notify
++        if (deviceId != null)
++            return (deviceId.match(new RegExp('/dev/sr[0-9]+', 'g')) == null);
++        else
++            return true;
+     },
++
++    show: function() {
++        if (!this._shouldNotify)
++            return;
++
++        let header = _("Writing data to %s").format(this._mountName);
 +        let text = _("Don't unplug until finished");
 +
 +        if (!this._notification) {
@@ -151,7 +169,7 @@ index 27d89e8..6f799d7 100644
 +        this._notification.setTransient(true);
 +        this._notification.setUrgency(MessageTray.Urgency.CRITICAL);
 +        this.notify(this._notification);
-     },
++    },
 +
 +    done: function(success) {
 +        if (this._notification) {
@@ -159,8 +177,8 @@ index 27d89e8..6f799d7 100644
 +            this._notification = null;
 +        }
 +
-+        if (success) {
-+            let header = _("You can now unplug %s").format(this._deviceName);
++        if (success && this._shouldNotify) {
++            let header = _("You can now unplug %s").format(this._mountName);
 +            let notification = new MessageTray.Notification(this, header, null);
 +            notification.setTransient(true);
 +
diff --git a/gnome-shell.spec b/gnome-shell.spec
index 822c204..15645b6 100644
--- a/gnome-shell.spec
+++ b/gnome-shell.spec
@@ -1,6 +1,6 @@
 Name:           gnome-shell
 Version:        3.4.1
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Window management and application launching for GNOME
 
 Group:          User Interface/Desktops
@@ -155,6 +155,9 @@ glib-compile-schemas --allow-any-name %{_datadir}/glib-2.0/schemas &> /dev/null
 %exclude %{_datadir}/gtk-doc
 
 %changelog
+* Wed May 16 2012 Owen Taylor <otaylor at redhat.com> - 3.4.1-5
+- New version of unmount notification
+
 * Tue May 15 2012 Owen Taylor <otaylor at redhat.com> - 3.4.1-4
 - Add a patch to display a notification until it's safe to remove a drive (#819492)
 


More information about the scm-commits mailing list