Ticket #3999: journal_drag_and_drop_testing.diff
File journal_drag_and_drop_testing.diff, 11.2 KB (added by godiard, 11 years ago) |
---|
-
src/jarabe/frame/clipboardicon.py
diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py index 26af595..cca8d95 100644
a b class ClipboardIcon(RadioToolButton): 76 76 def _drag_data_get_cb(self, widget, context, selection, target_type, 77 77 event_time): 78 78 logging.debug('_drag_data_get_cb: requested target %s', 79 selection. target)80 data = self._cb_object.get_formats()[selection. target].get_data()79 selection.get_target()) 80 data = self._cb_object.get_formats()[selection.get_target()].get_data() 81 81 selection.set(selection.target, 8, data) 82 82 83 83 def _put_in_clipboard(self): … … class ClipboardIcon(RadioToolButton): 161 161 icon_theme = Gtk.IconTheme.get_default() 162 162 pixbuf = icon_theme.load_icon(self._icon.props.icon_name, 163 163 style.STANDARD_ICON_SIZE, 0) 164 context.set_icon_pixbuf(pixbuf, hot_x=pixbuf.props.width / 2, 165 hot_y=pixbuf.props.height / 2) 164 logging.error('drag_begin_cb %s', dir(context)) 165 Gtk.drag_set_icon_pixbuf(context, pixbuf, 166 hot_x=pixbuf.props.width / 2, hot_y=pixbuf.props.height / 2) 166 167 167 168 def _notify_active_cb(self, widget, pspec): 168 169 if self.props.active: -
src/jarabe/frame/clipboardtray.py
diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py index abc885e..09e3eea 100644
a b class ClipboardTray(tray.VTray): 76 76 return False 77 77 78 78 def _add_selection(self, object_id, selection): 79 if not selection. data:79 if not selection.get_data(): 80 80 return 81 81 82 logging.debug('ClipboardTray: adding type %r', selection. type)82 logging.debug('ClipboardTray: adding type %r', selection.get_type()) 83 83 84 84 cb_service = clipboard.get_instance() 85 if selection. type== 'text/uri-list':86 uris = selection. data.split('\n')85 if selection.get_type() == 'text/uri-list': 86 uris = selection.get_data().split('\n') 87 87 if len(uris) > 1: 88 88 raise NotImplementedError('Multiple uris in text/uri-list' \ 89 89 ' still not supported.') 90 90 91 91 cb_service.add_object_format(object_id, 92 selection. type,92 selection.get_type(), 93 93 uris[0], 94 94 on_disk=True) 95 95 else: 96 96 cb_service.add_object_format(object_id, 97 selection. type,98 selection. data,97 selection.get_type(), 98 selection.get_data(), 99 99 on_disk=False) 100 100 101 101 def _object_added_cb(self, cb_service, cb_object): … … class ClipboardTray(tray.VTray): 129 129 logging.debug('ClipboardTray: %r was deleted', object_id) 130 130 131 131 def drag_motion_cb(self, widget, context, x, y, time): 132 logging.debug('ClipboardTray._drag_motion_cb')133 132 134 133 if self._internal_drag(context): 135 context.drag_status(Gdk.DragAction.MOVE, time)134 Gdk.drag_status(context, Gdk.DragAction.MOVE, time) 136 135 else: 137 context.drag_status(Gdk.DragAction.COPY, time)136 Gdk.drag_status(context, Gdk.DragAction.COPY, time) 138 137 self.props.drag_active = True 139 138 140 139 return True … … class ClipboardTray(tray.VTray): 148 147 if self._internal_drag(context): 149 148 # TODO: We should move the object within the clipboard here 150 149 if not self._context_map.has_context(context): 151 context.drop_finish(False, Gtk.get_current_event_time())150 Gdk.drop_finish(context, False, Gtk.get_current_event_time()) 152 151 return False 153 152 154 153 cb_service = clipboard.get_instance() 155 154 object_id = cb_service.add_object(name="") 156 155 157 self._context_map.add_context(context, object_id, len(context.targets)) 156 self._context_map.add_context(context, object_id, 157 len(context.list_targets())) 158 158 159 for target in context. targets:159 for target in context.list_targets(): 160 160 if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'): 161 161 widget.drag_get_data(context, target, time) 162 162 … … class ClipboardTray(tray.VTray): 167 167 def drag_data_received_cb(self, widget, context, x, y, selection, 168 168 targetType, time): 169 169 logging.debug('ClipboardTray: got data for target %r', 170 selection. target)170 selection.get_target()) 171 171 172 172 object_id = self._context_map.get_object_id(context) 173 173 try: 174 174 if selection is None: 175 175 logging.warn('ClipboardTray: empty selection for target %s', 176 selection. target)176 selection.get_target()) 177 177 else: 178 178 self._add_selection(object_id, selection) 179 179 … … class ClipboardTray(tray.VTray): 181 181 # If it's the last target to be processed, finish 182 182 # the dnd transaction 183 183 if not self._context_map.has_context(context): 184 context.drop_finish(True, Gtk.get_current_event_time())184 Gdk.drop_finish(context, True, Gtk.get_current_event_time()) 185 185 186 186 def _internal_drag(self, context): 187 source_wi dget = context.get_source_widget()188 if source_wi dgetis None:187 source_window = context.get_source_window() 188 if source_window is None: 189 189 return False 190 view_ancestor = source_widget.get_ancestor(Gtk.Viewport) 191 if view_ancestor is self._viewport: 190 if source_window is self.get_window(): 192 191 return True 193 192 else: 194 193 return False -
src/jarabe/frame/eventarea.py
diff --git a/src/jarabe/frame/eventarea.py b/src/jarabe/frame/eventarea.py index 433a8dc..5fd7225 100644
a b class EventArea(GObject.GObject): 134 134 self._notify_leave() 135 135 136 136 def _drag_motion_cb(self, widget, drag_context, x, y, timestamp): 137 drag_context.drag_status(0, timestamp) 137 if hasattr(drag_context, "drag_status"): 138 drag_context.drag_status(0, timestamp) 138 139 self._notify_enter() 139 140 return True 140 141 -
src/jarabe/journal/listmodel.py
diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py index b98d01c..124ef8b 100644
a b class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): 236 236 return (False, Gtk.TreeIter()) 237 237 238 238 def do_drag_data_get(self, path, selection): 239 logging.error('DO_DRAG_DATA_GET %s %s target %s', path, selection, selection.get_target()) 239 240 uid = self[path][ListModel.COLUMN_UID] 240 if selection. target== 'text/uri-list':241 if selection.get_target() == 'text/uri-list': 241 242 # Get hold of a reference so the temp file doesn't get deleted 242 243 self._temp_drag_file_path = model.get_file(uid) 243 244 logging.debug('putting %r in selection', self._temp_drag_file_path) 244 selection.set(selection. target, 8, self._temp_drag_file_path)245 selection.set(selection.get_target(), 8, self._temp_drag_file_path) 245 246 return True 246 247 elif selection.target == 'journal-object-id': 247 selection.set(selection. target, 8, uid)248 selection.set(selection.get_target(), 8, uid) 248 249 return True 249 250 250 251 return False -
src/jarabe/journal/listview.py
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 3005d2f..751249c 100644
a b class ListView(BaseListView): 515 515 BaseListView.__init__(self) 516 516 self._is_dragging = False 517 517 518 self.tree_view.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, 519 [('text/uri-list', 0, 0), 520 ('journal-object-id', 0, 0)], 521 Gdk.DragAction.COPY) 522 518 523 self.tree_view.connect('drag-begin', self.__drag_begin_cb) 524 self.tree_view.connect("drag-data-get", self.__drag_data_get_data_cb) 519 525 self.tree_view.connect('button-release-event', 520 526 self.__button_release_event_cb) 521 527 … … class ListView(BaseListView): 536 542 self.tree_view.append_column(column) 537 543 538 544 def __drag_begin_cb(self, widget, drag_context): 545 logging.error('LISTIEW drag_begin_cb list_targets %s', drag_context.list_targets()) 546 for target in drag_context.list_targets(): 547 logging.error('LISTIEW drag_begin_cb targets %s data %s', target, drag_context.get_data(target)) 539 548 self._is_dragging = True 540 549 550 def __drag_data_get_data_cb(self, treeview, context, selection, target_id, 551 etime): 552 553 treeselection = treeview.get_selection() 554 model, treeiter = treeselection.get_selected() 555 logging.error('LISTIEW drag_data_get model: %s, iter: %s target %s', model, treeiter, selection.get_targets()) 556 557 logging.error('LISTIEW drag_data_get SELECTION %s %s', selection.__class__, dir(selection)) 558 #tree_selection = treeview.get_selection() 559 #model, tree_iter = selection.get_selection() 560 #path = model.get_path(tree_iter) 561 562 #logging.error('DO_DRAG_DATA_GET %s %s', path, selection) 563 #uid = model[path][ListModel.COLUMN_UID] 564 if selection.get_target() == 'text/uri-list': 565 logging.error('text/urilist DATA %s', selection.get_data()) 566 # Get hold of a reference so the temp file doesn't get deleted 567 model._temp_drag_file_path = model.get_file(uid) 568 logging.debug('putting %r in selection', 569 model._temp_drag_file_path) 570 selection.set(selection.get_target(), 8, 571 model._temp_drag_file_path) 572 return True 573 elif selection.get_target() == 'journal-object-id': 574 logging.error('text/urilist DATA %s', selection.get_data()) 575 selection.set(selection.get_target(), 8, uid) 576 return True 577 578 return False 579 541 580 def __button_release_event_cb(self, tree_view, event): 542 581 try: 543 582 if self._is_dragging: -
src/jarabe/journal/volumestoolbar.py
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py index e1e6331..cea2bf7 100644
a b class BaseButton(RadioToolButton): 291 291 292 292 def _drag_data_received_cb(self, widget, drag_context, x, y, 293 293 selection_data, info, timestamp): 294 object_id = selection_data.data 294 logging.error('EN volumestoolbar.py _drag_data_received_cb') 295 object_id = selection_data.get_data() 295 296 metadata = model.get(object_id) 296 297 file_path = model.get_file(metadata['uid']) 297 298 if not file_path or not os.path.exists(file_path):