sugarlabs/sugar — pull request #17 by manuq (2013-04-08 15:10:00+00:00)
Title: Bring back dragging of elements from the activities to the frame clipboa...

...rd - SL #3819

TestCase:

- open an activity like Browse, Read, Log (not Write, is a special case)
- bring up the frame
- drag things to the left side panel of the frame (images, links, or selected text)

The elements should be added to the clipboard which is inside the
panel. They should have the proper icon and they should popup a
palette to act on them.

Note: if the dragged object is a link from Browse, Sugar tries to copy
the html to the disk. But the current implementation looks wrong. I
have opened #4477 to track it: http://bugs.sugarlabs.org/ticket/4477

Note: this doesn't solve the inverse operation: drag from the
clipboard to the activity. This will be done in another patch.

API fixes:

- gtk.SelectionData.type -> Gtk.SelectionData.get_data_type() [1]
- gtk.SelectionData.data -> Gtk.SelectionData.get_data() [2]
- gtk.SelectionData.target -> Gtk.SelectionData.get_target() [3]
- context.targets -> context.list_targets() [4]
- context.drop_finish(...) -> Gdk.drop_finish(context, ...) [5]
- context.drag_status(...) -> Gdk.drag_status(context, ...) [6]
- context.get_source_widget() -> Gdk.drag_get_source_widget(context) [7]

[1] https://developer.gnome.org/gtk3/3.5/gtk3-Selections.html#gtk-selection-data-get-data-type
[2] https://developer.gnome.org/gtk3/3.5/gtk3-Selections.html#gtk-selection-data-get-data
[3] https://developer.gnome.org/gtk3/3.5/gtk3-Selections.html#gtk-selection-data-get-target
[4] https://developer.gnome.org/gdk/stable/gdk-Drag-and-Drop.html#gdk-drag-context-list-targets
[5] https://developer.gnome.org/gdk/stable/gdk-Drag-and-Drop.html#gdk-drop-finish
[6] https://developer.gnome.org/gdk/stable/gdk-Drag-and-Drop.html#gdk-drag-status
[7] https://developer.gnome.org/gtk3/stable/gtk3-Drag-and-Drop.html#gtk-drag-get-source-widget

Cast the type of the Gtk.SelectionData from Gdk.Atom to str. Our code
treats it as str in sugar3.mime and asks methods like startswith which
fails if it is not a str-like object.

The data for the type 'text/uri-list' comes with a character '\x00' at
the end now. But using SelectionData.get_uris() returns a proper list
(thanks to Flavio Danesse for the recommendation). So we can use that
list instead of doing selection.get_data().split('\n') or
sugar3.mime.split_uri_list (which could be obsolete now). In fact,
this change was made a while ago in clipboardpanelwindow.py, but not
in clipboardtray.py. See commit f0d194f3 .

Signed-off-by: Manuel Quiñones