Ticket #3819: frame_dnd_3819.patch

File frame_dnd_3819.patch, 3.8 KB (added by manuq, 11 years ago)

API fixes, unfinished patch, still some work to do

  • src/jarabe/frame/clipboardtray.py

    diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py
    index abc885e..6e5127b 100644
    a b class ClipboardTray(tray.VTray): 
    7676        return False
    7777
    7878    def _add_selection(self, object_id, selection):
    79         if not selection.data:
     79        if not selection.get_data():
    8080            return
    8181
    82         logging.debug('ClipboardTray: adding type %r', selection.type)
     82        selection_data = selection.get_data()
     83        selection_type = selection.get_data_type()
     84
     85        logging.debug('ClipboardTray: adding type %r', selection_type)
    8386
    8487        cb_service = clipboard.get_instance()
    85         if selection.type == 'text/uri-list':
    86             uris = selection.data.split('\n')
     88        if selection_type == 'text/uri-list':
     89            uris = selection_data.split('\n')
    8790            if len(uris) > 1:
    8891                raise NotImplementedError('Multiple uris in text/uri-list' \
    8992                                          ' still not supported.')
    9093
    9194            cb_service.add_object_format(object_id,
    92                                          selection.type,
     95                                         selection_type,
    9396                                         uris[0],
    9497                                         on_disk=True)
    9598        else:
    9699            cb_service.add_object_format(object_id,
    97                                          selection.type,
    98                                          selection.data,
     100                                         selection_type,
     101                                         selection_data,
    99102                                         on_disk=False)
    100103
    101104    def _object_added_cb(self, cb_service, cb_object):
    class ClipboardTray(tray.VTray): 
    132135        logging.debug('ClipboardTray._drag_motion_cb')
    133136
    134137        if self._internal_drag(context):
    135             context.drag_status(Gdk.DragAction.MOVE, time)
     138            Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
    136139        else:
    137             context.drag_status(Gdk.DragAction.COPY, time)
     140            Gdk.drag_status(context, Gdk.DragAction.COPY, time)
    138141            self.props.drag_active = True
    139142
    140143        return True
    class ClipboardTray(tray.VTray): 
    154157        cb_service = clipboard.get_instance()
    155158        object_id = cb_service.add_object(name="")
    156159
    157         self._context_map.add_context(context, object_id, len(context.targets))
     160        context_targets = context.list_targets()
     161        self._context_map.add_context(context, object_id, len(context_targets))
    158162
    159         for target in context.targets:
     163        for target in context_targets:
    160164            if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
    161165                widget.drag_get_data(context, target, time)
    162166
    class ClipboardTray(tray.VTray): 
    167171    def drag_data_received_cb(self, widget, context, x, y, selection,
    168172                              targetType, time):
    169173        logging.debug('ClipboardTray: got data for target %r',
    170             selection.target)
     174            selection.get_target())
    171175
    172176        object_id = self._context_map.get_object_id(context)
    173177        try:
    174178            if selection is None:
    175179                logging.warn('ClipboardTray: empty selection for target %s',
    176                     selection.target)
     180                    selection.get_target())
    177181            else:
    178182                self._add_selection(object_id, selection)
    179183
    class ClipboardTray(tray.VTray): 
    184188                context.drop_finish(True, Gtk.get_current_event_time())
    185189
    186190    def _internal_drag(self, context):
    187         source_widget = context.get_source_widget()
     191        source_widget = Gtk.drag_get_source_widget(context)
    188192        if source_widget is None:
    189193            return False
    190194        view_ancestor = source_widget.get_ancestor(Gtk.Viewport)