diff options
author | Daniel Drake <dsd@laptop.org> | 2012-09-25 17:45:52 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2012-09-26 11:48:39 (GMT) |
commit | b0ac7a02f9e1cd5a3d4408e5ecd4fe7d4a70d9b7 (patch) | |
tree | 772396192d11edf7319333d13a8f74f8b192c452 /extensions | |
parent | 1570f7742e606d09e9fb9079711dd6a43346784d (diff) |
Fix external media mounting, SL #3911
The GVolumeMonitor used for mounting devices must not drop out
of scope, otherwise it will be destroyed, and no signals will be
receieved. Move it into global scope.
Update mount and unmount calls for introspection.
Remove dead code from volumestoolbar.
The user data argument that needs to be passed to the mount/unmount
method is discussed at [1].
[1] https://mail.gnome.org/archives/python-hackers-list/2012-September/msg00009.html
Signed-off-by: Daniel Drake <dsd@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/deviceicon/volume.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/extensions/deviceicon/volume.py b/extensions/deviceicon/volume.py index ec7b2e2..f1f223c 100644 --- a/extensions/deviceicon/volume.py +++ b/extensions/deviceicon/volume.py @@ -34,6 +34,7 @@ from jarabe.frame.frameinvoker import FrameWidgetInvoker _icons = {} +volume_monitor = None class DeviceView(TrayIcon): @@ -100,6 +101,7 @@ def setup(tray): def _setup_volumes(tray): + global volume_monitor volume_monitor = Gio.VolumeMonitor.get() for volume in volume_monitor.get_volumes(): @@ -121,17 +123,20 @@ def _mount(volume, tray): # Follow Nautilus behaviour here # since it has the same issue with removable device # and it would be good to not invent our own workflow - if hasattr(volume, 'should_automount') and not volume.should_automount(): + if not volume.should_automount(): return #TODO: should be done by some other process, like gvfs-hal-volume-monitor - #TODO: use volume.should_automount() when it gets into pygtk if volume.get_mount() is None and volume.can_mount(): #TODO: pass None as mount_operation, or better, SugarMountOperation - volume.mount(Gtk.MountOperation(tray.get_toplevel()), _mount_cb) + flags = 0 + mount_operation = Gtk.MountOperation(parent=tray.get_toplevel()) + cancellable = None + user_data = None + volume.mount(flags, mount_operation, cancellable, _mount_cb, user_data) -def _mount_cb(volume, result): +def _mount_cb(volume, result, user_data): logging.debug('_mount_cb %r %r', volume, result) volume.mount_finish(result) |