Example #1
0
    def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data, unused_info, timestamp):
        if not self.clip:
            # Indicate that a drop will not be accepted.
            Gdk.drag_status(drag_context, 0, timestamp)
            return
        dest_row = treeview.get_dest_row_at_pos(x, y)
        if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
            # An effect dragged probably from the effects list.
            factory_name = str(selection_data.get_data(), "UTF-8")
            drop_index = self.__get_new_effect_index(dest_row)
            effect_info = self.app.effects.getInfo(factory_name)
            pipeline = self._project.pipeline
            with self.app.action_log.started("add effect",
                                             finalizing_action=CommitTimelineFinalizingAction(pipeline),
                                             toplevel=True):
                effect = self.clip.ui.add_effect(effect_info)
                if effect:
                    self.clip.set_top_effect_priority(effect, drop_index)
        elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
            # An effect dragged from the same treeview to change its position.
            # Source
            source_index, drop_index = self.__get_move_indexes(
                dest_row, treeview.get_model())
            self.__move_effect(self.clip, source_index, drop_index)

        drag_context.finish(True, False, timestamp)
Example #2
0
    def traceTreeview_drag_motion_cb(self, treeView, context, x, y, time):
        """This callbacks helps managing highlight of the dest
        treeview when draging data onto it. Here, we highlight
        treeView only when target is a 'Session' and that it's not a
        new item (but rather, data are droped into it)."""

        dropInfo = treeView.get_dest_row_at_pos(x, y)

        if dropInfo is not None:
            (path, position) = dropInfo
            model = treeView.get_model()

            # We only allow to drop data *into* a row (and not before
            # and after) and to drop data in a session, items that
            # have a parent.
            if model[path].get_parent() is not None:
                if position in (Gtk.TreeViewDropPosition.INTO_OR_BEFORE, Gtk.TreeViewDropPosition.INTO_OR_AFTER):
                    treeView.drag_highlight()
                    Gdk.drag_status(context, 0, time)
                    return False
            else:
                # We are on an ImportedTrace item, we try to expand
                # it.
                treeView.expand_to_path(path)

        treeView.drag_unhighlight()
        Gdk.drag_status(context, 0, time)
        return True
Example #3
0
	def drag_motion_cb(self, senderID, context, x, y, time):
		Gdk.drag_status(context, Gdk.DragAction.COPY, time)
		if self.abox.get_dest_row_at_pos(x, y) == None:
			return True
		path, pos = self.abox.get_dest_row_at_pos(x, y)
		self.abox.set_drag_dest_row(path, pos)
		return True
Example #4
0
    def _dragMotionCb(self, widget, context, x, y, time):
        target = widget.drag_dest_find_target(context, None)
        if target.name() not in ["text/uri-list", "pitivi/effect"]:
            return False
        if not self.dropDataReady:
            widget.drag_get_data(context, target, time)
            Gdk.drag_status(context, 0, time)
        else:
            x, y = self._transposeXY(x, y)

            # dragged from the media library
            if not self.timeline.ghostClips and self.isDraggedClip:
                for uri in self.dropData:
                    asset = self.app.gui.medialibrary.getAssetForUri(uri)
                    if asset is None:
                        self.isDraggedClip = False
                        break
                    self.timeline.addGhostClip(asset, x, y)

            if self.isDraggedClip:
                self.timeline.updateGhostClips(x, y)

            Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            if not self.dropHighlight:
                widget.drag_highlight()
                self.dropHighlight = True
        return True
Example #5
0
 def drag_motion_cb(self, senderID, context, x, y, time):
     Gdk.drag_status(context, Gdk.DragAction.COPY, time)
     if self.abox.get_dest_row_at_pos(x, y) == None:
         return True
     path, pos = self.abox.get_dest_row_at_pos(x, y)
     self.abox.set_drag_dest_row(path, pos)
     return True
Example #6
0
    def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data,
                            unused_info, timestamp):
        if not self.clip:
            # Indicate that a drop will not be accepted.
            Gdk.drag_status(drag_context, 0, timestamp)
            return
        dest_row = treeview.get_dest_row_at_pos(x, y)
        if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
            # An effect dragged probably from the effects list.
            factory_name = str(selection_data.get_data(), "UTF-8")
            drop_index = self.__get_new_effect_index(dest_row)
            effect_info = self.app.effects.getInfo(factory_name)
            pipeline = self._project.pipeline
            with self.app.action_log.started(
                    "add effect",
                    finalizing_action=CommitTimelineFinalizingAction(pipeline),
                    toplevel=True):
                effect = self.clip.ui.add_effect(effect_info)
                if effect:
                    self.clip.set_top_effect_priority(effect, drop_index)
        elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
            # An effect dragged from the same treeview to change its position.
            # Source
            source_index, drop_index = self.__get_move_indexes(
                dest_row, treeview.get_model())
            self.__move_effect(self.clip, source_index, drop_index)

        drag_context.finish(True, False, timestamp)
    def traceTreeview_drag_motion_cb(self, treeView, context, x, y, time):
        """This callbacks helps managing highlight of the dest
        treeview when draging data onto it. Here, we highlight
        treeView only when target is a 'Session' and that it's not a
        new item (but rather, data are droped into it)."""

        dropInfo = treeView.get_dest_row_at_pos(x, y)

        if dropInfo is not None:
            (path, position) = dropInfo
            model = treeView.get_model()

            # We only allow to drop data *into* a row (and not before
            # and after) and to drop data in a session, items that
            # have a parent.
            if model[path].get_parent() is not None:
                if position in (Gtk.TreeViewDropPosition.INTO_OR_BEFORE,
                                Gtk.TreeViewDropPosition.INTO_OR_AFTER):
                    treeView.drag_highlight()
                    Gdk.drag_status(context, 0, time)
                    return False
            else:
                # We are on an ImportedTrace item, we try to expand
                # it.
                treeView.expand_to_path(path)

        treeView.drag_unhighlight()
        Gdk.drag_status(context, 0, time)
        return True
Example #8
0
    def drag_motion_cb(self, widget, context, x, y, t):
        if "application/x-color" not in map(str, context.list_targets()):
            return False

        # Default action: copy means insert or overwrite
        action = Gdk.DragAction.COPY

        # Update the insertion marker
        i = self.get_index_at_pos(x, y)
        if i != self._drag_insertion_index:
            self.queue_draw()
        self._drag_insertion_index = i

        # Dragging around inside the widget implies moving, by default
        source_widget = Gtk.drag_get_source_widget(context)
        if source_widget is self:
            action = Gdk.DragAction.MOVE
            if i is None:
                action = Gdk.DragAction.DEFAULT  # it'll be ignored
            else:
                mgr = self.get_color_manager()
                if mgr.palette.get_color(i) is None:
                    # Empty swatch, convert moves to copies
                    action = Gdk.DragAction.COPY

        # Cursor and status update
        Gdk.drag_status(context, action, t)
    def on_drag_motion(self, widget, drag_context, x, y, time):
        path = False

        try:
            path, pos = widget.get_dest_row_at_pos(x, y)
        except:
            pass

        result = False
        
        if path and (pos == Gtk.TreeViewDropPosition.BEFORE or pos == Gtk.TreeViewDropPosition.AFTER):
            if pos == Gtk.TreeViewDropPosition.BEFORE:
                widget.set_drag_dest_row(None, Gtk.TreeViewDropPosition.INTO_OR_BEFORE)
            else:
                widget.set_drag_dest_row(None, Gtk.TreeViewDropPosition.INTO_OR_AFTER)
            #Gdk.drag_status(drag_context, 0, time)
            path = None
            
        if path:
            dest_source = self.treestore_filter[path][1]

            try:
                # note - some sources dont have a can_paste method so need to trap this case
                if not dest_source:
                    result = False
                elif dest_source.can_paste():
                    result = True
            except:
                result = False
                
            if dest_source and result:
                if dest_source != self._drag_dest_source:
                    if self._drag_motion_counter != -1:
                        self._drag_motion_counter = 0
                    self._drag_dest_source = dest_source

                def delayed(*args):
                    if self._drag_motion_counter < 2 and self._drag_dest_source:
                        self._drag_motion_counter += 1
                        return True

                    if self._drag_dest_source and self._drag_motion_counter >= 2:
                        if self.shell.props.display_page_tree:
                            self.shell.props.display_page_tree.select(self._drag_dest_source)
                            self.rbtree.expand_all()

                    self._drag_motion_counter = -1
                    return False

                if self._drag_motion_counter == -1:
                    self._drag_motion_counter = 0
                    GLib.timeout_add_seconds(1, delayed)

        if result:
            Gdk.drag_status(drag_context, Gdk.DragAction.COPY, time)
        else:
            Gdk.drag_status(drag_context, 0, time)
            self._drag_dest_source = None

        return not result
Example #10
0
 def on_drag_motion(self, widget, context, x, y, time):
     mask = keyboard.get_mask(self)
     if mask & Gdk.ModifierType.CONTROL_MASK:
         Gdk.drag_status(context, Gdk.DragAction.COPY, time)
     else:
         Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
     return True
Example #11
0
    def _on_drag_motion(self, canvas, drag_context, mouse_x, mouse_y, time):
        Gdk.drag_status(drag_context, Gdk.DragAction.MOVE, time)
        # issue a redraw order on our current position
        self.redraw()

        self.active = True

        mouse_x += self.canvas.offset[0]
        mouse_y += self.canvas.offset[1]

        distances = [(self.distance(mouse_x, mouse_y, drawer.position,
                                    drawer.size), drawer)
                     for drawer in self.__main_win.page_drawers]

        # we must to provide a position for a fake page -1
        first_page_position = (0, 0)
        first_page_size = (0, 0)
        if len(self.__main_win.page_drawers) > 0:
            first_page_position = self.__main_win.page_drawers[0].position
            first_page_size = self.__main_win.page_drawers[0].size
        first_page_position = (0, first_page_position[1])

        distances.append((self.distance(mouse_x, mouse_y, first_page_position,
                                        first_page_size), None))
        distances.sort()

        if len(distances) <= 0:
            self.target_previous_page_drawer = None
        else:
            self.target_previous_page_drawer = distances[0][1]

        # issue a redraw order on our new position
        GLib.idle_add(self.redraw)
        return True
Example #12
0
    def drag_motion_cb(self, widget, context, x, y, t):
        if "application/x-color" not in map(str, context.list_targets()):
            return False

        # Default action: copy means insert or overwrite
        action = Gdk.DragAction.COPY

        # Update the insertion marker
        i = self.get_index_at_pos(x, y)
        if i != self._drag_insertion_index:
            self.queue_draw()
        self._drag_insertion_index = i

        # Dragging around inside the widget implies moving, by default
        source_widget = Gtk.drag_get_source_widget(context)
        if source_widget is self:
            action = Gdk.DragAction.MOVE
            if i is None:
                action = Gdk.DragAction.DEFAULT  # it'll be ignored
            else:
                mgr = self.get_color_manager()
                if mgr.palette.get_color(i) is None:
                    # Empty swatch, convert moves to copies
                    action = Gdk.DragAction.COPY

        # Cursor and status update
        Gdk.drag_status(context, action, t)
Example #13
0
 def do_drag_data_received(self, context, x, y, data, info, time):
     self.dnd_data = data.get_text().strip()
     if self.dnd_data.endswith('.epub'):
         self.accept_dnd = ACCEPT
         Gdk.drag_status(context, Gdk.DragAction.COPY, time)
     else:
         self.accept_dnd = REJECT
         Gdk.drag_status(context, 0, time)
Example #14
0
	def motion_cb(self, wid, context, x, y, time):
		if (x < self._parent.cell_width):
			self.drag_drop_x = self._parent.cell_width
		elif self.drag_drop_x > self._parent.cell_width * self.grid_width:
			self.drag_drop_x = self._parent.cell_width * self.grid_width
		else:
			self.drag_drop_x = x
		Gdk.drag_status(context,Gdk.DragAction.COPY, time)
		return True
Example #15
0
 def drag_motion(self, treeview, context, x, y, time):
     try:
         treeview.set_drag_dest_row(*treeview.get_dest_row_at_pos(x, y))
     except TypeError:
         treeview.set_drag_dest_row(
             Gtk.TreePath(len(treeview.get_model()) - 1),
             Gtk.TreeViewDropPosition.AFTER)
     Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
     return True
Example #16
0
    def drag_motion_cb(self, widget, context, x, y, time):
        logging.debug('ClipboardTray._drag_motion_cb')

        if self._internal_drag(context):
            Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
        else:
            Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            self.props.drag_active = True

        return True
Example #17
0
    def drag_motion_cb(self, widget, context, x, y, time):
        logging.debug('ClipboardTray._drag_motion_cb')

        if self._internal_drag(context):
            Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
        else:
            Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            self.props.drag_active = True

        return True
Example #18
0
    def drag_motion_cb(self, widget, context, x, y, time):
        self.logger.debug('drag_motion_cb')
        # checks whether a drop is possible
        targets = context.list_targets()
        for mimetype in targets:
            if str(mimetype) in ("text/thumb", "text/plain", "text/uri-list"):
                Gdk.drag_status(context, Gdk.DragAction.COPY, time)
                return True

        Gdk.drag_status(context, 0, time)
        self.logger.debug('drag_motion_cb done')
        return False
Example #19
0
    def drag_motion_cb(self, widget, context, x, y, time):
        self.logger.debug('drag_motion_cb')
        # checks whether a drop is possible
        targets = context.list_targets()
        for mimetype in targets:
            if str(mimetype) in ("text/thumb", "text/plain", "text/uri-list"):
                Gdk.drag_status(context, Gdk.DragAction.COPY, time)
                return True

        Gdk.drag_status(context, 0, time)
        self.logger.debug('drag_motion_cb done')
        return False
Example #20
0
 def do_drag_motion(self, context, x, y, time, user_data=None):
     if self.accept_dnd is REJECT:
         Gdk.drag_status(context, 0, time)
     elif self.accept_dnd is NONE:
         target = self.drag_dest_find_target(context, None)
         if target == 0: #Gdk.NONE:
             self.accept_dnd = REJECT
             Gdk.drag_status(context, 0, time)
         else:
             self.drag_get_data(context, target, time)
             self.accept_dnd = WAITING
     return True  # Use drag_status to say yes or no; otherwise drag_leave called
Example #21
0
 def __onDragMotion (self, arrow, context, x, y, timestamp):
     position = self.__getButtonAtPoint(x, y)
     if self.currentHovered != position:
         self.currentHovered = position
         if position > -1:
             self.emit("hovered", position, Gtk.drag_get_source_widget(context))
         else: self.emit("left")
     
     if position > -1:
         Gdk.drag_status(context, Gdk.DragAction.MOVE, timestamp)
         return True
     Gdk.drag_status(context, Gdk.DragAction.DEFAULT, timestamp)
Example #22
0
 def do_drag_motion(self, context, x, y, time):
     dest = self.get_dest_row_at_pos(x, y)
     if dest is None:
         return False
     self.set_drag_dest_row(*dest)
     if context.get_actions(
     ) & Gdk.DragAction.MOVE and not Gdk.Keymap.get_default(
     ).get_modifier_state() & Gdk.ModifierType.CONTROL_MASK:
         action = Gdk.DragAction.MOVE
     else:
         action = Gdk.DragAction.COPY
     Gdk.drag_status(context, action, time)
     return True
Example #23
0
    def on_drag_motion(self, widget, context, x, y, time):
        is_self_source = context.get_source_window() is self.drag_start_win
        is_external_add = self.is_external_add()
        # if reorder or append
        if is_self_source or is_external_add:
            found = self.list_view.get_dest_row_at_pos(x, y)
            if found:
                path, pos = found
                pos = self.fix_drag_pos(pos)

                self.list_view.set_drag_dest_row(path, pos)
            Gdk.drag_status(context, Gdk.DragAction.COPY if is_external_add else Gdk.DragAction.MOVE, time)
            return True
Example #24
0
 def on_trv_groups_drag_motion(self, widget, context, drag_x, drag_y, time):
     """Handle trv_groups.drag_motion event."""
     # Don't allow dropping in the empty space of the treeview, or inside
     # the 'Detected clients' group, or inside the currently selected group
     drag_info = widget.get_dest_row_at_pos(drag_x, drag_y)
     act = 0
     if drag_info:
         path, pos = drag_info
         if pos:
             if path != self.gstore.get_path(self.get_selected_group()[0]) \
                     and path != self.default_group_ref.get_path():
                 act = context.get_suggested_action()
     Gdk.drag_status(context, act, time)
     return True
Example #25
0
 def __drag_motion(self, view, ctx, x, y, time):
     if self.__drop_by_row:
         self.set_drag_dest(x, y)
         self.scroll_motion(x, y)
         if Gtk.drag_get_source_widget(ctx) == self:
             kind = Gdk.DragAction.MOVE
         else:
             kind = Gdk.DragAction.COPY
         Gdk.drag_status(ctx, kind, time)
         return True
     else:
         self.get_parent().drag_highlight()
         Gdk.drag_status(ctx, Gdk.DragAction.COPY, time)
         return True
Example #26
0
  def _do_drag_motion(self, widget, context, x, y, timestamp):

    log.debug("%s Do drag-motion at w(%d, %d)", self, x, y)

    self._enable_auto()

    valid = False

    row_info = widget.get_dest_row_at_pos(x, y)
    if row_info:

      target = self._find_target(widget, context)
      if target:

        path = row_info[0]
        pos = row_info[1] if row_info[1] in target.pos else target.pos[0]

        coords = widget.convert_widget_to_bin_window_coords(x, y)
        col = widget.get_path_at_pos(*coords)[1]

        log.debug("%s Target info: %s", self, target.gtk_target)
        log.debug("%s Target action: %s", self, target.action)
        log.debug("%s Dest path: %s, %s", self, path, pos)
        log.debug("%s Dest column: %r %s", self, col.get_title(), col)

        if target.aux_func:

          log.debug("%s Sending peek request", self)

          context._dnd_request_info = (path, col, pos)
          context._dnd_request_type = "peek"

          widget.drag_get_data(context, target.atom, timestamp)

        else:

          Gdk.drag_status(context, target.action, timestamp)
          widget.set_drag_dest_row(path, pos)

        valid = True

    if not valid:

      log.debug("%s Drop zone: Invalid", self)

      Gdk.drag_status(context, 0, timestamp)

    log.debug("%s Do drag-motion ended", self)

    return True
Example #27
0
 def __drag_motion(self, view, ctx, x, y, time):
     if self.__drop_by_row:
         self.set_drag_dest(x, y)
         self.scroll_motion(x, y)
         if Gtk.drag_get_source_widget(ctx) == self:
             kind = Gdk.DragAction.MOVE
         else:
             kind = Gdk.DragAction.COPY
         Gdk.drag_status(ctx, kind, time)
         return True
     else:
         self.get_parent().drag_highlight()
         Gdk.drag_status(ctx, Gdk.DragAction.COPY, time)
         return True
Example #28
0
    def onDragMotion(self, tree, context, x, y, time):
        """
        Allow the following drops:
        - tracks onto and into dir
        - tracks between dirs
        - dir between dirs

        -> Prevent the drops:
        - dir into dir
        - anything into track
        """
        # Disable default handler.
        self.stop_emission('drag-motion')

        drop = self.get_dest_row_at_pos(int(x), int(y))

        pos_ok = True

        if drop is not None:
            iter = self.store.get_iter(drop[0])
            depth = self.store.iter_depth(iter)
            track = self.getTrack(iter)

            drop_into = drop[1] in [
                Gtk.TreeViewDropPosition.INTO_OR_AFTER,
                Gtk.TreeViewDropPosition.INTO_OR_BEFORE
            ]
            drop_around = not drop_into

            # At least one dir is being dropped
            if self.dir_selected:
                # Dirs can only be dropped at the top level
                if drop_into or ((drop_around) and depth > 0):
                    # do not let the user drop anything here
                    pos_ok = False
            else:
                # Tracks can also be dropped into dirs (but not into tracks)
                if (track and drop_into):  # or (drop_into and depth > 0):
                    pos_ok = False

        target_names = [atom.name() for atom in context.list_targets()]
        internal_reordering = (consts.DND_INTERNAL_TARGET_NAME in target_names)
        if internal_reordering:
            action = Gdk.DragAction.MOVE
        else:
            action = Gdk.DragAction.COPY
        Gdk.drag_status(context, action, time)

        # Return whether the cursor position is in a drop zone.
        return pos_ok
Example #29
0
 def _view_drag_motion_cb(self, view, context, x, y, t):
     win = view.get_window()
     w, x, y, modifiers = win.get_pointer()
     statusbar = self.app.statusbar
     statusbar_cid = self._drag_statusbar_context_id
     statusbar.remove_all(statusbar_cid)
     if modifiers & Gdk.ModifierType.SHIFT_MASK:
         Gdk.drag_status(context, Gdk.DragAction.PRIVATE, t)
         self._treemodel.allow_drag_into = True
         statusbar.push(statusbar_cid, self.STATUSBAR_DRAG_INTO_MSG)
     else:
         Gdk.drag_status(context, Gdk.DragAction.MOVE, t)
         self._treemodel.allow_drag_into = False
         statusbar.push(statusbar_cid, self.STATUSBAR_DRAG_MSG)
     return False
Example #30
0
    def dnd_get_data_for_file_managers(self, _treeview, context, selection,
                                       _info, timestamp):

        if not os.path.isdir(self.config.current_musicdir):
            # Prevent the DND mouse cursor from looking like we can DND
            # when we clearly can't.
            return

        Gdk.drag_status(context, Gdk.DragAction.COPY, timestamp)

        filenames = self.get_selected_filenames(True)
        uris = ["file://%s" % urllib.parse.quote(filename)
            for filename in filenames]

        selection.set_uris(uris)
Example #31
0
 def _view_drag_motion_cb(self, view, context, x, y, t):
     win = view.get_window()
     w, x, y, modifiers = win.get_pointer()
     statusbar = self.app.statusbar
     statusbar_cid = self._drag_statusbar_context_id
     statusbar.remove_all(statusbar_cid)
     if modifiers & Gdk.ModifierType.SHIFT_MASK:
         Gdk.drag_status(context, Gdk.DragAction.PRIVATE, t)
         self._treemodel.allow_drag_into = True
         statusbar.push(statusbar_cid, self.STATUSBAR_DRAG_INTO_MSG)
     else:
         Gdk.drag_status(context, Gdk.DragAction.MOVE, t)
         self._treemodel.allow_drag_into = False
         statusbar.push(statusbar_cid, self.STATUSBAR_DRAG_MSG)
     return False
Example #32
0
    def dnd_get_data_for_file_managers(self, _treeview, context, selection,
                                       _info, timestamp):

        if not os.path.isdir(self.config.musicdir[self.config.profile_num]):
            # Prevent the DND mouse cursor from looking like we can DND
            # when we clearly can't.
            return

        Gdk.drag_status(context, Gdk.DragAction.COPY, timestamp)

        filenames = self.get_selected_filenames(True)
        uris = [
            "file://%s" % urllib.parse.quote(filename)
            for filename in filenames
        ]

        selection.set_uris(uris)
Example #33
0
    def _dragmotion_cb(self, widget, context, x, y, time):  # pylint: disable=too-many-arguments
        # if not 'screenlayout-output' in context.list_targets():  # from outside
            # return False
        if not self._draggingoutput:  # from void; should be already aborted
            return False

        Gdk.drag_status(context, Gdk.DragAction.MOVE, time)

        rel = x - self._draggingfrom[0], y - self._draggingfrom[1]

        oldpos = self._xrandr.configuration.outputs[self._draggingoutput].position
        newpos = Position(
            (oldpos[0] + self.factor * rel[0], oldpos[1] + self.factor * rel[1]))
        self._xrandr.configuration.outputs[
            self._draggingoutput
        ].tentative_position = self._draggingsnap.suggest(newpos)
        self._force_repaint()

        return True
Example #34
0
    def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data, unused_info, timestamp):
        if not self.clips or len(self.clips) > 1:
            # Indicate that a drop will not be accepted.
            Gdk.drag_status(drag_context, 0, timestamp)
            return
        clip = self.clips[0]
        dest_row = treeview.get_dest_row_at_pos(x, y)
        if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
            # An effect dragged probably from the effects list.
            factory_name = str(selection_data.get_data(), "UTF-8")
            drop_index = self.__get_new_effect_index(dest_row)
            self.addEffectToClip(clip, factory_name, drop_index)
        elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
            # An effect dragged from the same treeview to change its position.
            # Source
            source_index, drop_index = self.__get_move_indexes(
                dest_row, treeview.get_model())
            self.__move_effect(clip, source_index, drop_index)

        drag_context.finish(True, False, timestamp)
Example #35
0
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = Gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = Gdk.DragAction.MOVE
     else:
         # Dragging from another widget, is always a copy
         action = Gdk.DragAction.COPY
     Gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
Example #36
0
 def __configure_drag_drop(self):
     self.drag_dest_set(0, [], 0)
     self.connect("drag-motion", lambda widget, context, x, y, time:(
           Gdk.drag_status(context, Gdk.DragAction.COPY, time)
         , True
     ))
     self.connect("drag-drop", lambda widget, context, x, y, time:(
           widget.drag_get_data(context, context.list_targets()[-1], time)
         , context.finish(True, False, time)
     ))
     self.connect("drag-data-received", self.__on_drag_data_received)
Example #37
0
 def drag_motion_cb(self, widget, context, x, y, time):
     if not self.dragging_allowed:
         return False
     action = None
     source_widget = Gtk.drag_get_source_widget(context)
     if self is source_widget:
         # Only moves are possible
         action = Gdk.DragAction.MOVE
     else:
         # Dragging from another widget, is always a copy
         action = Gdk.DragAction.COPY
     Gdk.drag_status(context, action, time)
     if not self.drag_highlighted:
         self.drag_highlighted = True
         self.queue_draw()
     if self.drag_highlighted:
         i = self.index(x, y)
         if i != self.drag_insertion_index:
             self.queue_draw()
             self.drag_insertion_index = i
Example #38
0
    def _dragmotion_cb(self, widget, context, x, y, time):  # pylint: disable=too-many-arguments
        # if not 'screenlayout-output' in context.list_targets():  # from outside
        # return False
        if not self._draggingoutput:  # from void; should be already aborted
            return False

        Gdk.drag_status(context, Gdk.DragAction.MOVE, time)

        rel = x - self._draggingfrom[0], y - self._draggingfrom[1]

        oldpos = self._xrandr.configuration.outputs[
            self._draggingoutput].position
        newpos = Position((oldpos[0] + self.factor * rel[0],
                           oldpos[1] + self.factor * rel[1]))
        self._xrandr.configuration.outputs[
            self.
            _draggingoutput].tentative_position = self._draggingsnap.suggest(
                newpos)
        self._force_repaint()

        return True
Example #39
0
    def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data,
                            unused_info, timestamp):
        if not self.clips or len(self.clips) > 1:
            # Indicate that a drop will not be accepted.
            Gdk.drag_status(drag_context, 0, timestamp)
            return
        clip = self.clips[0]
        dest_row = treeview.get_dest_row_at_pos(x, y)
        if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
            # An effect dragged probably from the effects list.
            factory_name = str(selection_data.get_data(), "UTF-8")
            drop_index = self.__get_new_effect_index(dest_row)
            self.addEffectToClip(clip, factory_name, drop_index)
        elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
            # An effect dragged from the same treeview to change its position.
            # Source
            source_index, drop_index = self.__get_move_indexes(
                dest_row, treeview.get_model())
            self.__move_effect(clip, source_index, drop_index)

        drag_context.finish(True, False, timestamp)
Example #40
0
    def _on_drag_motion(self, canvas, drag_context, x, y, time):
        target_row = self.gui['list'].get_row_at_y(y)
        if not target_row or target_row not in self.model['by_row']:
            self._on_drag_leave(canvas, drag_context, time)
            return False

        target_docid = self.model['by_row'][target_row]
        try:
            target_doc = self.__main_win.docsearch.get(target_docid)
        except KeyError:
            target_doc = self.get_new_doc()

        if not target_doc.can_edit:
            self._on_drag_leave(canvas, drag_context, time)
            return False

        Gdk.drag_status(drag_context, Gdk.DragAction.MOVE, time)

        self.gui['list'].drag_unhighlight_row()
        self.gui['list'].drag_highlight_row(target_row)
        return True
Example #41
0
    def _drag_data_received_cb(self, widget, drag_context, x, y,
                               selection_data, unused_info, timestamp):
        if not self.clip:
            # Indicate that a drop will not be accepted.
            Gdk.drag_status(drag_context, 0, timestamp)
            return

        if self.effects_listbox.get_row_at_y(y):
            # Drop happened inside the lisbox
            drop_index = widget.get_index()
        else:
            drop_index = len(self.effects_listbox.get_children()) - 1

        if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
            # An effect dragged probably from the effects list.
            factory_name = str(selection_data.get_data(), "UTF-8")

            top_effect_index = drop_index + len(self.__get_time_effects())
            self.debug(
                "Effect dragged at position %s - computed top effect index %s",
                drop_index, top_effect_index)
            effect_info = self.app.effects.get_info(factory_name)
            pipeline = self.app.project_manager.current_project.pipeline
            with self.app.action_log.started(
                    "add effect",
                    finalizing_action=CommitTimelineFinalizingAction(pipeline),
                    toplevel=True):
                effect = self.clip.ui.add_effect(effect_info)
                if effect:
                    self.clip.set_top_effect_index(effect, top_effect_index)

        elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
            # An effect dragged from the same listbox to change its position.
            source_eventbox = Gtk.drag_get_source_widget(drag_context)
            source_row = source_eventbox.get_parent()
            source_index = source_row.get_index()

            self._move_effect(self.clip, source_index, drop_index)

        drag_context.finish(True, False, timestamp)
Example #42
0
    def on_drag_data_received(self,
                              widget,
                              context,
                              x,
                              y,
                              data,
                              info,
                              time,
                              user_data=None):
        if not self.pulse.online:
            print("not online")
            Gdk.drag_status(context, 0, time)
            return

        if not self.dropping:
            if self.blocking_new_sends:
                Gdk.drag_status(context, 0, time)
            else:
                Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            return
        if data:
            if context.get_selected_action() == Gdk.DragAction.COPY:
                uris = data.get_uris()
                self.file_sender.send_files(uris)

        Gtk.drag_finish(context, True, False, time)
        self.dropping = False
Example #43
0
 def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data,
                         unused_info, timestamp):
     if not self.clips or len(self.clips) > 1:
         # Indicate that a drop will not be accepted.
         Gdk.drag_status(drag_context, 0, timestamp)
         return
     clip = self.clips[0]
     model = treeview.get_model()
     if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
         # An effect dragged probably from the effects list.
         factory_name = str(selection_data.get_data(), "UTF-8")
         # Target
         dest_row = treeview.get_dest_row_at_pos(x, y)
         if dest_row:
             drop_path, drop_pos = dest_row
             drop_index = drop_path.get_indices()[0]
             if drop_pos != Gtk.TreeViewDropPosition.BEFORE:
                 drop_index += 1
         else:
             # This should happen when dragging after the last row.
             drop_index = None
         self.addEffectToClip(clip, factory_name, drop_index)
     elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
         # An effect dragged from the same treeview to change its position.
         # Source
         source_index = self.storemodel.source_index
         self.storemodel.source_index = None
         # Target
         dest_row = treeview.get_dest_row_at_pos(x, y)
         if dest_row:
             drop_path, drop_pos = dest_row
             drop_index = drop_path.get_indices()[0]
             drop_index = self.calculateEffectPriority(
                 source_index, drop_index, drop_pos)
         else:
             # This should happen when dragging after the last row.
             drop_index = len(model) - 1
             drop_pos = Gtk.TreeViewDropPosition.INTO_OR_BEFORE
         self.moveEffect(clip, source_index, drop_index)
     drag_context.finish(True, False, timestamp)
Example #44
0
    def on_drag_motion(self, widget: Gtk.Widget, context: Gdk.DragContext,
                       x: int, y: int, time: int) -> bool:
        # Change cursor icon based on drop target.
        # if the user move mouse over the folder - it becomes MOVE action
        model_path = self.view.get_path_at_pos(x, y)
        if not model_path:
            return False
        model_iter = self.model.get_iter(model_path)
        item_id = self.model.get_value(model_iter, 3)

        # Select hover cell, make it interactive for the user
        self.view.select_path(model_path)

        # Folder could have an ID, so this condition going to change
        if item_id == -1:
            Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
            # TODO: Change folder icon on hover
            # self.model.set_value(model_iter, 0, Pixbuf.new_from_resource(RESOURCE_PREFIX + '/icons/folder-open.svg'))
        else:
            Gdk.drag_status(context, Gdk.DragAction.COPY, time)

        return True
Example #45
0
 def _dragDataReceivedCb(self, treeview, drag_context, x, y, selection_data, unused_info, timestamp):
     if not self.clips or len(self.clips) > 1:
         # Indicate that a drop will not be accepted.
         Gdk.drag_status(drag_context, 0, timestamp)
         return
     clip = self.clips[0]
     model = treeview.get_model()
     if drag_context.get_suggested_action() == Gdk.DragAction.COPY:
         # An effect dragged probably from the effects list.
         factory_name = str(selection_data.get_data(), "UTF-8")
         # Target
         dest_row = treeview.get_dest_row_at_pos(x, y)
         if dest_row:
             drop_path, drop_pos = dest_row
             drop_index = drop_path.get_indices()[0]
             if drop_pos != Gtk.TreeViewDropPosition.BEFORE:
                 drop_index += 1
         else:
             # This should happen when dragging after the last row.
             drop_index = None
         self.addEffectToClip(clip, factory_name, drop_index)
     elif drag_context.get_suggested_action() == Gdk.DragAction.MOVE:
         # An effect dragged from the same treeview to change its position.
         # Source
         source_index = self.storemodel.source_index
         self.storemodel.source_index = None
         # Target
         dest_row = treeview.get_dest_row_at_pos(x, y)
         if dest_row:
             drop_path, drop_pos = dest_row
             drop_index = drop_path.get_indices()[0]
             drop_index = self.calculateEffectPriority(
                 source_index, drop_index, drop_pos)
         else:
             # This should happen when dragging after the last row.
             drop_index = len(model) - 1
             drop_pos = Gtk.TreeViewDropPosition.INTO_OR_BEFORE
         self.moveEffect(clip, source_index, drop_index)
     drag_context.finish(True, False, timestamp)
Example #46
0
    def onDragMotion(self, oWidget, oDragContext, nX, nY, nTime):

        if oDragContext.list_targets()[0].name() == 'treeview-row':

            lstPaths = oWidget.get_selection().get_selected_rows()[1]

            if len(lstPaths) == 0:
                return False

            oPathDest = self.set_drag_dest(nX, nY)[0]

            if oPathDest.get_indices()[0] in [oPath.get_indices()[0] for oPath in lstPaths]:
                return False

            Gdk.drag_status(oDragContext, Gdk.DragAction.MOVE, nTime)

        else:

            oWidget.drag_highlight()
            Gdk.drag_status(oDragContext, Gdk.DragAction.COPY, nTime)

        return True
 def drag_motion(self, widget, drag_context, x, y, timestamp):
     result = self.get_path_at_pos(x, y)
     if result is not None:
         path = result[0]
         if not self.selection.path_is_selected(path):
             tree_iter = self.get_iter(path)
             has_obj_push = self._has_objpush(self.get(tree_iter, "device")["device"])
             if has_obj_push:
                 Gdk.drag_status(drag_context, Gdk.DragAction.COPY, timestamp)
                 self.set_cursor(path)
                 return True
             else:
                 Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
                 return False
     else:
         Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
         return False
Example #48
0
 def drag_motion(self, widget, drag_context, x, y, timestamp):
     result = self.get_path_at_pos(x, y)
     if result is not None:
         path = result[0]
         if not self.selection.path_is_selected(path):
             tree_iter = self.get_iter(path)
             has_obj_push = self._has_objpush(self.get(tree_iter, "device")["device"])
             if has_obj_push:
                 Gdk.drag_status(drag_context, Gdk.DragAction.COPY, timestamp)
                 self.set_cursor(path)
                 return True
             else:
                 Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
                 return False
     else:
         Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
         return False
Example #49
0
 def drag_motion(self, _widget: Gtk.Widget, drag_context: Gdk.DragContext, x: int, y: int, timestamp: int) -> bool:
     result = self.get_path_at_pos(x, y)
     if result is not None:
         path = result[0]
         assert path is not None
         if not self.selection.path_is_selected(path):
             tree_iter = self.get_iter(path)
             assert tree_iter is not None
             has_obj_push = self._has_objpush(self.get(tree_iter, "device")["device"])
             if has_obj_push:
                 Gdk.drag_status(drag_context, Gdk.DragAction.COPY, timestamp)
                 self.set_cursor(path)
                 return True
             else:
                 Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
                 return False
         return False
     else:
         Gdk.drag_status(drag_context, Gdk.DragAction.DEFAULT, timestamp)
         return False
Example #50
0
 def __motion(self, wid, context, x, y, time):
     Gdk.drag_status(context, Gdk.DragAction.COPY, time)
     return True
Example #51
0
 def __drag_motion_cb(self, widget, context, x, y, time):
     Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
     return True
Example #52
0
    def drag_motion(self, tv, context, x, y, time):
        """
            Sets the appropriate drag action based on what we are hovering over

            hovering over playlists causes the copy action to occur
            hovering over tracks within the same playlist causes the move
                action to occur
            hovering over tracks within different playlist causes the move 
                action to occur

            Called on the destination widget
        """
        # Reset any target to be default to moving tracks
        self.tree.enable_model_drag_dest([self.track_target],
            Gdk.DragAction.DEFAULT)
        # Determine where the drag is coming from
        dragging_playlist = False
        if tv == self.tree:
            selected_playlist = self.tree.get_selected_page()
            if selected_playlist is not None:
                dragging_playlist = True

        # Find out where they are dropping onto
        drop_info = tv.get_dest_row_at_pos(x, y)
        if drop_info:
            path, position = drop_info
            iter = self.model.get_iter(path)
            drop_target = self.model.get_value(iter, 2)

            if isinstance(drop_target, playlist.Playlist):
                if dragging_playlist:
                    # If we drag onto  we copy, if we drag between we move
                    if position == Gtk.TreeViewDropPosition.INTO_OR_BEFORE or \
                        position == Gtk.TreeViewDropPosition.INTO_OR_AFTER:
                        Gdk.drag_status(context, Gdk.DragAction.COPY, time)
                    else:
                        Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
                        # Change target as well
                        self.tree.enable_model_drag_dest([self.playlist_target],
                                                         Gdk.DragAction.DEFAULT)
                else:
                    Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            elif isinstance(drop_target, TrackWrapper):
                # We are dragging onto another track
                # make it a move operation if we are only dragging
                # tracks within our widget
                # We do a copy if we are draggin from another playlist
                if Gtk.drag_get_source_widget(context) == tv and \
                    dragging_playlist == False:
                    Gdk.drag_status(context, Gdk.DragAction.MOVE, time)
                else:
                    Gdk.drag_status(context, Gdk.DragAction.COPY, time)
            else:
                # Prevent drop operation by changing the targets
                self.tree.enable_model_drag_dest(self.deny_targets,
                                                 Gdk.DragAction.DEFAULT)
                return False
            return True
        else: # No drop info
            if dragging_playlist:
                context.drag_status(Gdk.DragAction.MOVE, time)
                # Change target as well
                self.tree.enable_model_drag_dest([self.playlist_target],
                                                     Gdk.DragAction.DEFAULT)
Example #53
0
 def drag_motion_cb(self, view, context, x, y, time):
     gdk.drag_status(context, gdk.DragAction.MOVE, time)
     return True
Example #54
0
 def _drag_motion_cb(self, widget, drag_context, x, y, timestamp):
     Gdk.drag_status(drag_context, 0, timestamp)
     self._notify_enter()
     return True
Example #55
0
 def on_wmain_window_drag_motion(self, wid, context, x, y, time):
     Gdk.drag_status(context, Gdk.DragAction.COPY, time)
     return True
Example #56
0
File: dbman.py Project: toxn/gramps
def drag_motion(wid, context, xpos, ypos, time_stamp):
    """
    DND callback that is called on a DND drag motion begin
    """
    Gdk.drag_status(context, Gdk.DragAction.COPY, time_stamp)
    return True
Example #57
0
 def __drag_motion_cb(self, widget, context, x, y, time):
     if self._last_clicked_icon is not None:
         Gdk.drag_status(context, context.get_suggested_action(), time)
         return True
     else:
         return False