[Sugar-devel] [PATCH 3/3] Journal: fix the API for drag and drop - SL #3999

Flavio Danesse fdanesse at gmail.com
Wed Apr 10 19:07:16 EDT 2013


In my opinion, this can become a source of problems:

if target_name == 'text / uri-list'

I find it best to use just get.uris ()


2013/4/10 Manuel Quiñones <manuq at laptop.org>

> TestCase:
>
> - open Paint activity, draw something
> - go to the Journal
> - drag the Paint entry to the Documents drive
> - insert a USB stick
> - drag the Paint entry to the USB drive
>
> The paint should be in Documents and in the stick
>
> Note: this needs the upstream fix
> https://bugzilla.gnome.org/show_bug.cgi?id=692844 which is not in GTK+
> 3.6 but is added in current olpc builds as gtk3-3.6.4.1.fc18.olpc2.
> So it can be tested on an XO.
>
> Note: this does not fix the unwanted palette popup as described in the
> ticket.  That will be a separate patch.
>
> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
> ---
>  src/jarabe/journal/listmodel.py      | 11 +++++++----
>  src/jarabe/journal/volumestoolbar.py |  2 +-
>  2 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/src/jarabe/journal/listmodel.py
> b/src/jarabe/journal/listmodel.py
> index b98d01c..980db70 100644
> --- a/src/jarabe/journal/listmodel.py
> +++ b/src/jarabe/journal/listmodel.py
> @@ -237,14 +237,17 @@ class ListModel(GObject.GObject, Gtk.TreeModel,
> Gtk.TreeDragSource):
>
>      def do_drag_data_get(self, path, selection):
>          uid = self[path][ListModel.COLUMN_UID]
> -        if selection.target == 'text/uri-list':
> +        target_atom = selection.get_target()
> +        target_name = target_atom.name()
> +        if target_name == 'text/uri-list':
>              # Get hold of a reference so the temp file doesn't get deleted
>              self._temp_drag_file_path = model.get_file(uid)
>              logging.debug('putting %r in selection',
> self._temp_drag_file_path)
> -            selection.set(selection.target, 8, self._temp_drag_file_path)
> +            selection.set(target_atom, 8, self._temp_drag_file_path)
>              return True
> -        elif selection.target == 'journal-object-id':
> -            selection.set(selection.target, 8, uid)
> +        elif target_name == 'journal-object-id':
> +            # uid is unicode but Gtk.SelectionData.set() needs str
> +            selection.set(target_atom, 8, str(uid))
>              return True
>
>          return False
> diff --git a/src/jarabe/journal/volumestoolbar.py
> b/src/jarabe/journal/volumestoolbar.py
> index e1e6331..750aea5 100644
> --- a/src/jarabe/journal/volumestoolbar.py
> +++ b/src/jarabe/journal/volumestoolbar.py
> @@ -291,7 +291,7 @@ class BaseButton(RadioToolButton):
>
>      def _drag_data_received_cb(self, widget, drag_context, x, y,
>                                 selection_data, info, timestamp):
> -        object_id = selection_data.data
> +        object_id = selection_data.get_data()
>          metadata = model.get(object_id)
>          file_path = model.get_file(metadata['uid'])
>          if not file_path or not os.path.exists(file_path):
> --
> 1.8.1.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20130410/0d013ef8/attachment.html>


More information about the Sugar-devel mailing list