From aa5cefd789c5f1caa12ac8f737faa92b57845d21 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 29 Jul 2010 07:59:07 +0000 Subject: [PATCH] Refactored listviews to be able to select multiple items for dnd svn: r15656 --- src/gui/views/listview.py | 13 +++++++++++-- src/plugins/lib/libpersonview.py | 6 ------ src/plugins/view/mediaview.py | 20 -------------------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/gui/views/listview.py b/src/gui/views/listview.py index 50cbcdffa..574d9f731 100644 --- a/src/gui/views/listview.py +++ b/src/gui/views/listview.py @@ -62,6 +62,7 @@ import Utils from QuestionDialog import QuestionDialog, QuestionDialog2 from gui.filtereditor import FilterEditor from gen.ggettext import sgettext as _ +from DdTargets import DdTargets #---------------------------------------------------------------- # @@ -437,7 +438,10 @@ class ListView(NavigationView): return None def drag_list_info(self): - return None + """ + Specify the drag type for a multiple selected rows + """ + return DdTargets.LINK_LIST def drag_begin(self, widget, context): widget.drag_source_set_icon_stock(self.get_stock()) @@ -446,9 +450,14 @@ class ListView(NavigationView): def drag_data_get(self, widget, context, sel_data, info, time): selected_ids = self.selected_handles() - if selected_ids: + if len(selected_ids) == 1: data = (self.drag_info().drag_type, id(self), selected_ids[0], 0) sel_data.set(sel_data.target, 8 , pickle.dumps(data)) + elif len(selected_ids) > 1: + data = (self.drag_list_info().drag_type, id(self), + [(self.drag_info().drag_type, handle) for handle in selected_ids], + 0) + sel_data.set(sel_data.target, 8 , pickle.dumps(data)) return True def set_column_order(self): diff --git a/src/plugins/lib/libpersonview.py b/src/plugins/lib/libpersonview.py index 48e1eca6a..5efa194ef 100644 --- a/src/plugins/lib/libpersonview.py +++ b/src/plugins/lib/libpersonview.py @@ -155,12 +155,6 @@ class BasePersonView(ListView): """ return DdTargets.PERSON_LINK - def drag_list_info(self): - """ - Specify the drag type for a multiple selected rows - """ - return DdTargets.PERSON_LINK_LIST - def exact_search(self): """ Returns a tuple indicating columns requiring an exact search diff --git a/src/plugins/view/mediaview.py b/src/plugins/view/mediaview.py index 905ba39c3..e6b9a4c45 100644 --- a/src/plugins/view/mediaview.py +++ b/src/plugins/view/mediaview.py @@ -158,26 +158,6 @@ class MediaView(ListView): #self.list.connect('drag_data_get', self.drag_data_get) self.list.connect('drag_data_received', self.drag_data_received) - def drag_data_get(self, widget, context, sel_data, info, time): - """ - Provide the drag_data_get function, which passes a tuple consisting of: - - 1) Drag type defined by the .drag_type field specified by the value - assigned to _DND_TYPE - 2) The id value of this object, used for the purpose of determining - the source of the object. If the source of the object is the same - as the object, we are doing a reorder instead of a normal drag - and drop - 3) Pickled data. The pickled version of the selected object - 4) Source row. Used for a reorder to determine the original position - of the object - """ - - selected_ids = self.selected_handles() - if selected_ids: - data = (self.drag_info().drag_type, id(self), selected_ids[0], 0) - sel_data.set(sel_data.target, 8, pickle.dumps(data)) - def drag_info(self): """ Return the type of DND targets that this view will accept. For Media