def drag_data_received(self, treeview, context, x, y, selection, info, etime): treeview.stop_emission_by_name('drag-data-received') try: selection_data = selection.data except AttributeError: selection_data = selection.get_data() if not selection_data: return selection_data = selection_data.decode('utf-8') store = treeview.get_model() data_iters = [ store.get_iter((int(i), )) for i in selection_data.split(',') ] drop_info = treeview.get_dest_row_at_pos(x, y) if drop_info: path, position = drop_info pos = store.get_iter(path) else: pos = store.get_iter((len(store) - 1, )) position = Gtk.TreeViewDropPosition.AFTER if position == Gtk.TreeViewDropPosition.AFTER: data_iters = reversed(data_iters) for item in data_iters: if position == Gtk.TreeViewDropPosition.BEFORE: store.move_before(item, pos) else: store.move_after(item, pos) Gdk.drop_finish(context, False, etime) return True
def drag_data_cb(self, view, context, x, y, data, info, time): uris = json.dumps(data.get_uris()) script = "widget.fireDrop({}, {}, '{}');".format(x, y, uris) self.execute_script(script) gdk.drop_finish(context, True, time)
def drag_data_received_cb(self, widget, context, x, y, selection, targetType, time): logging.debug('ClipboardTray: got data for target %r', selection.get_target()) object_id = self._context_map.get_object_id(context) try: if selection is None: logging.warn('ClipboardTray: empty selection for target %s', selection.get_target()) else: self._add_selection(object_id, selection) finally: # If it's the last target to be processed, finish # the dnd transaction if not self._context_map.has_context(context): Gdk.drop_finish(context, True, Gtk.get_current_event_time())
def drag_data_received_cb(self, widget, context, x, y, selection, targetType, time): logging.debug('ClipboardTray: got data for target %r', selection.get_target()) object_id = self._context_map.get_object_id(context) try: if selection is None: logging.warn('ClipboardTray: empty selection for target %s', selection.get_target()) else: self._add_selection(object_id, selection) finally: # If it's the last target to be processed, finish # the dnd transaction if not self._context_map.has_context(context): Gdk.drop_finish(context, True, Gtk.get_current_event_time())
def drag_drop_cb(self, widget, context, x, y, time): logging.debug('ClipboardTray._drag_drop_cb') if self._internal_drag(context): # TODO: We should move the object within the clipboard here if not self._context_map.has_context(context): Gdk.drop_finish(context, False, Gtk.get_current_event_time()) return False cb_service = clipboard.get_instance() object_id = cb_service.add_object(name="") context_targets = context.list_targets() self._context_map.add_context(context, object_id, len(context_targets)) for target in context_targets: if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'): widget.drag_get_data(context, target, time) cb_service.set_object_percent(object_id, percent=100) return True
def drag_drop_cb(self, widget, context, x, y, time): logging.debug('ClipboardTray._drag_drop_cb') if self._internal_drag(context): # TODO: We should move the object within the clipboard here if not self._context_map.has_context(context): Gdk.drop_finish(context, False, Gtk.get_current_event_time()) return False cb_service = clipboard.get_instance() object_id = cb_service.add_object(name="") context_targets = context.list_targets() self._context_map.add_context(context, object_id, len(context_targets)) for target in context_targets: if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'): widget.drag_get_data(context, target, time) cb_service.set_object_percent(object_id, percent=100) return True
def drag_data_received(self, treeview, context, x, y, selection, info, etime): treeview.stop_emission_by_name('drag-data-received') if self.attributes.get('sequence'): field = self.group.fields[self.attributes['sequence']] for record in self.group: if field.get_state_attrs( record).get('readonly', False): return try: selection_data = selection.data except AttributeError: selection_data = selection.get_data() if not selection_data: return selection_data = selection_data.decode('utf-8') # Don't received if the treeview was editing because it breaks the # internal state of the cursor. cursor, column = treeview.get_cursor() if column: for renderer in column.get_cells(): if renderer.props.editing: return model = treeview.get_model() try: data = json.loads(selection_data) except ValueError: return record = model.group.get_by_path(data) record_path = record.get_index_path(model.group) drop_info = treeview.get_dest_row_at_pos(x, y) def check_recursion(from_, to): if not from_ or not to: return True if from_ == to: return False length = min(len(from_), len(to)) if len(from_) < len(to) and from_[:length] == to[:length]: return False return True if drop_info: path, position = drop_info check_path = tuple(path) if position in [ Gtk.TreeViewDropPosition.BEFORE, Gtk.TreeViewDropPosition.AFTER]: check_path = path[:-1] if not check_recursion(record_path, check_path): return if position == Gtk.TreeViewDropPosition.BEFORE: model.move_before(record, path) elif position == Gtk.TreeViewDropPosition.AFTER: model.move_after(record, path) elif self.children_field: model.move_into(record, path) else: model.move_after(record, (len(model) - 1,)) Gdk.drop_finish(context, False, etime) selection = self.treeview.get_selection() selection.unselect_all() selection.select_path(record.get_index_path(model.group)) if self.attributes.get('sequence'): record.group.set_sequence(field=self.attributes['sequence']) return True
def __drag_data_received_cb(self, widget, context, x, y, selection_data, info, time): Gdk.drop_finish(context, success=True, time_=time)
def __drag_data_received_cb(self, widget, context, x, y, selection_data, info, time): Gdk.drop_finish(context, success=True, time_=time)