[Sugar-devel] [PATCH] Fix external media mounting (#3911)
Simon Schampijer
simon at schampijer.de
Wed Sep 26 07:51:52 EDT 2012
Excellent work Daniel. I just did make the mount/unmount args more
verbose and added a link to the upstream discussion on user_data
arguments [1].
Pushed as: b0ac7a02f9e1cd5a3d4408e5ecd4fe7d4a70d9b7
Regards,
Simon
[1]
https://mail.gnome.org/archives/python-hackers-list/2012-September/msg00009.html
On 09/25/2012 07:45 PM, Daniel Drake wrote:
> 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.
> ---
> extensions/deviceicon/volume.py | 10 ++++++----
> src/jarabe/journal/volumestoolbar.py | 7 -------
> src/jarabe/view/palettes.py | 8 +++++---
> 3 files changed, 11 insertions(+), 14 deletions(-)
>
> diff --git a/extensions/deviceicon/volume.py b/extensions/deviceicon/volume.py
> index ec7b2e2..fe9e0e3 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,17 @@ 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)
> + volume.mount(0, Gtk.MountOperation(parent=tray.get_toplevel()), None,
> + _mount_cb, None)
>
>
> -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..89d47db 100644
> --- a/src/jarabe/view/palettes.py
> +++ b/src/jarabe/view/palettes.py
> @@ -246,11 +246,13 @@ class VolumePalette(Palette):
> self.connect('popup', self.__popup_cb)
>
> def __unmount_activate_cb(self, menu_item):
> - self._mount.unmount(self.__unmount_cb)
> + mount_op = Gtk.MountOperation(parent=self.content_box.get_toplevel())
> + self._mount.unmount_with_operation(0, mount_op, None,
> + self.__unmount_cb, None)
>
> - def __unmount_cb(self, mount, result):
> + 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()
>
More information about the Sugar-devel
mailing list