Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-09-25 17:45:52 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-09-26 11:48:39 (GMT)
commitb0ac7a02f9e1cd5a3d4408e5ecd4fe7d4a70d9b7 (patch)
tree772396192d11edf7319333d13a8f74f8b192c452
parent1570f7742e606d09e9fb9079711dd6a43346784d (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>
-rw-r--r--extensions/deviceicon/volume.py13
-rw-r--r--src/jarabe/journal/volumestoolbar.py7
-rw-r--r--src/jarabe/view/palettes.py14
3 files changed, 19 insertions, 15 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)
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index 8f4692d..1fc368e 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -251,13 +251,6 @@ class VolumesToolbar(Gtk.Toolbar):
if button.props.active:
self.emit('volume-changed', button.mount_point)
- def _unmount_activated_cb(self, menu_item, mount):
- logging.debug('VolumesToolbar._unmount_activated_cb: %r', mount)
- mount.unmount(self.__unmount_cb)
-
- def __unmount_cb(self, source, result):
- logging.debug('__unmount_cb %r %r', source, result)
-
def _get_button_for_mount(self, mount):
mount_point = mount.get_root().get_path()
for button in self.get_children():
diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py
index 35475d0..10844ea 100644
--- a/src/jarabe/view/palettes.py
+++ b/src/jarabe/view/palettes.py
@@ -246,11 +246,17 @@ class VolumePalette(Palette):
self.connect('popup', self.__popup_cb)
def __unmount_activate_cb(self, menu_item):
- self._mount.unmount(self.__unmount_cb)
-
- def __unmount_cb(self, mount, result):
+ flags = 0
+ mount_operation = Gtk.MountOperation( \
+ parent=self.content_box.get_toplevel())
+ cancellable = None
+ user_data = None
+ self._mount.unmount_with_operation(flags, mount_operation, cancellable,
+ self.__unmount_cb, user_data)
+
+ def __unmount_cb(self, mount, result, user_data):
logging.debug('__unmount_cb %r %r', mount, result)
- mount.unmount_finish(result)
+ mount.unmount_with_operation_finish(result)
def __popup_cb(self, palette):
mount_point = self._mount.get_root().get_path()