Beispiel #1
0
    def __drag_data_get(self, view, ctx, sel, tid, etime):
        model, paths = self.get_selection().get_selected_rows()
        if tid == DND_QL:
            songs = [model[path][0] for path in paths
                     if model[path][0].can_add]
            if len(songs) != len(paths):
                qltk.ErrorMessage(
                    qltk.get_top_parent(self), _("Unable to copy songs"),
                    _("The files selected cannot be copied to other "
                      "song lists or the queue.")).run()
                Gdk.drag_abort(ctx, etime)
                return

            qltk.selection_set_songs(sel, songs)

            # DEM 2018/05/25: The below check is a deliberate repetition of
            # code in the drag-motion signal handler.  In MacOS/Quartz, the
            # context action is not propogated between event handlers for
            # drag-motion and drag-data-get using "ctx.get_actions()".  It is
            # unclear if this is a bug or expected behavior.  Regardless, the
            # context widget information is the same so identical behavior can
            # be achieved by simply using the same widget check as in the move
            # action.
            if Gtk.drag_get_source_widget(ctx) == self and \
                    not self.__force_copy:
                self.__drag_iters = list(map(model.get_iter, paths))
            else:
                self.__drag_iters = []
        else:
            uris = [model[path][0]("~uri") for path in paths]
            sel.set_uris(uris)
            self.__drag_iters = []
Beispiel #2
0
    def __drag_data_get(self, view, ctx, sel, tid, etime):
        model, paths = self.get_selection().get_selected_rows()
        if tid == DND_QL:
            songs = [model[path][0] for path in paths
                     if model[path][0].can_add]
            if len(songs) != len(paths):
                qltk.ErrorMessage(
                    qltk.get_top_parent(self), _("Unable to copy songs"),
                    _("The files selected cannot be copied to other "
                      "song lists or the queue.")).run()
                Gdk.drag_abort(ctx, etime)
                return

            qltk.selection_set_songs(sel, songs)

            # DEM 2018/05/25: The below check is a deliberate repitition of
            # code in the drag-motion signal handler.  In MacOS/Quartz, the
            # context action is not propogated between event handlers for
            # drag-motion and drag-data-get using "ctx.get_actions()".  It is
            # unclear if this is a bug or expected behavior.  Regardless, the
            # context widget information is the same so identical behavior can
            # be achieved by simply using the same widget check as in the move
            # action.
            if Gtk.drag_get_source_widget(ctx) == self and \
                    not self.__force_copy:
                self.__drag_iters = list(map(model.get_iter, paths))
            else:
                self.__drag_iters = []
        else:
            uris = [model[path][0]("~uri") for path in paths]
            sel.set_uris(uris)
            self.__drag_iters = []
Beispiel #3
0
    def on_drag_begin(self, widget, context):
        """
        Sets the cover of dragged tracks as drag icon
        """
        self.drag_context = context
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        self.reset_selection_status()

        # Load covers
        drag_cover_icon = None
        get_tracks_for_path = getattr(self, 'get_tracks_for_path', None)
        if get_tracks_for_path:
            model, paths = self.get_selection().get_selected_rows()
            drag_cover_icon = icons.MANAGER.get_drag_cover_icon(
                map(get_tracks_for_path, paths))

        if drag_cover_icon is None:
            # Set default icon
            icon_name = ('gtk-dnd-multiple'
                         if self.get_selection().count_selected_rows() > 1 else
                         'gtk-dnd')
            Gtk.drag_set_icon_name(context, icon_name, 0, 0)
        else:
            Gtk.drag_set_icon_pixbuf(context, drag_cover_icon, 0, 0)
Beispiel #4
0
    def on_drag_begin(self, widget, context):
        """
            Sets the cover of dragged tracks as drag icon
        """
        self.drag_context = context
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        self.reset_selection_status()

        # Load covers
        drag_cover_icon = None
        get_tracks_for_path = getattr(self, 'get_tracks_for_path', None)
        if get_tracks_for_path:
            model, paths = self.get_selection().get_selected_rows()
            drag_cover_icon = icons.MANAGER.get_drag_cover_icon(
                imap(get_tracks_for_path, paths)
            )

        if drag_cover_icon is None:
            # Set default icon
            icon_name = (
                'gtk-dnd-multiple'
                if self.get_selection().count_selected_rows() > 1
                else 'gtk-dnd'
            )
            Gtk.drag_set_icon_name(context, icon_name, 0, 0)
        else:
            Gtk.drag_set_icon_pixbuf(context, drag_cover_icon, 0, 0)
Beispiel #5
0
    def on_drag_begin(self, widget, context):
        """
            Sets the cover of dragged tracks as drag icon
        """
        self.dragging = True
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        if self.get_selection().count_selected_rows() > 1:
            self.drag_source_set_icon_stock(Gtk.STOCK_DND_MULTIPLE)
        else:
            self.drag_source_set_icon_stock(Gtk.STOCK_DND)
        if self.show_cover_drag_icon:
            tracks = self.get_selected_tracks()
            self._on_drag_begin(widget, context, tracks)
Beispiel #6
0
    def on_drag_begin(self, widget, context):
        """
            Sets the cover of dragged tracks as drag icon
        """
        self.dragging = True
        Gdk.drag_abort(context, Gtk.get_current_event_time())

        if self.get_selection().count_selected_rows() > 1:
            self.drag_source_set_icon_stock(Gtk.STOCK_DND_MULTIPLE)
        else:
            self.drag_source_set_icon_stock(Gtk.STOCK_DND)
        if self.show_cover_drag_icon:
            tracks = self.get_selected_tracks()
            self._on_drag_begin(widget, context, tracks)
Beispiel #7
0
    def __drag_data_get(self, view, ctx, sel, tid, etime):
        model, paths = self.get_selection().get_selected_rows()
        if tid == DND_QL:
            songs = [model[path][0] for path in paths
                     if model[path][0].can_add]
            if len(songs) != len(paths):
                qltk.ErrorMessage(
                    qltk.get_top_parent(self), _("Unable to copy songs"),
                    _("The files selected cannot be copied to other "
                      "song lists or the queue.")).run()
                Gdk.drag_abort(ctx, etime)
                return

            qltk.selection_set_songs(sel, songs)
            if ctx.get_actions() & Gdk.DragAction.MOVE:
                self.__drag_iters = map(model.get_iter, paths)
            else:
                self.__drag_iters = []
        else:
            uris = [model[path][0]("~uri") for path in paths]
            sel.set_uris(uris)
            self.__drag_iters = []
Beispiel #8
0
    def __drag_data_get(self, view, ctx, sel, tid, etime):
        model, paths = self.get_selection().get_selected_rows()
        if tid == DND_QL:
            songs = [model[path][0] for path in paths
                     if model[path][0].can_add]
            if len(songs) != len(paths):
                qltk.ErrorMessage(
                    qltk.get_top_parent(self), _("Unable to copy songs"),
                    _("The files selected cannot be copied to other "
                      "song lists or the queue.")).run()
                Gdk.drag_abort(ctx, etime)
                return

            qltk.selection_set_songs(sel, songs)
            if ctx.get_actions() & Gdk.DragAction.MOVE:
                self.__drag_iters = map(model.get_iter, paths)
            else:
                self.__drag_iters = []
        else:
            uris = [model[path][0]("~uri") for path in paths]
            sel.set_uris(uris)
            self.__drag_iters = []