From 73402dfb055b1ee1cedc7524f4dddf338a79d755 Mon Sep 17 00:00:00 2001 From: prculley Date: Thu, 25 Oct 2018 11:45:35 -0500 Subject: [PATCH 1/2] Drag/drop only one type of source --- gramps/gui/clipboard.py | 23 ++++++----------------- gramps/gui/views/pageview.py | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/gramps/gui/clipboard.py b/gramps/gui/clipboard.py index de13f63c5..4867c600e 100644 --- a/gramps/gui/clipboard.py +++ b/gramps/gui/clipboard.py @@ -1190,10 +1190,7 @@ class ClipboardListView: def object_drag_data_get(self, widget, context, sel_data, info, time): tree_selection = widget.get_selection() model, paths = tree_selection.get_selected_rows() - if hasattr(context, "targets"): - tgs = context.targets - else: - tgs = context.list_targets() + tgs = context.list_targets() if len(paths) == 1: path = paths[0] node = model.get_iter(path) @@ -1214,10 +1211,7 @@ class ClipboardListView: time, title=None, value=None, dbid=None, dbname=None): model = widget.get_model() - if hasattr(selection, "data"): - sel_data = selection.data - else: - sel_data = selection.get_data() # GtkSelectionData + sel_data = selection.get_data() # In Windows time is always zero. Until that is fixed, use the seconds # of the local time to filter out double drops. real_time = strftime("%S") @@ -1248,10 +1242,7 @@ class ClipboardListView: if dragtype in self._target_type_to_wrapper_class_map: possible_wrappers = [dragtype] else: - if hasattr(context, "targets"): - tgs = context.targets - else: - tgs = [atm.name() for atm in context.list_targets()] + tgs = [atm.name() for atm in context.list_targets()] possible_wrappers = [ target for target in tgs if target in self._target_type_to_wrapper_class_map] @@ -1293,9 +1284,8 @@ class ClipboardListView: data = [_ob.__class__.DRAG_TARGET.drag_type, _ob, None, _ob._type, _ob._value, _ob._dbid, _ob._dbname] contains = model_contains(model, data) - if (contains and not - ((context.action if hasattr(context, "action") else - context.get_actions()) & Gdk.DragAction.MOVE)): + if(contains and not + (context.get_actions() & Gdk.DragAction.MOVE)): continue drop_info = widget.get_dest_row_at_pos(x, y) if drop_info: @@ -1313,8 +1303,7 @@ class ClipboardListView: # FIXME: there is one bug here: if you multi-select and drop # on self, then it moves the first, and copies the rest. - if ((context.action if hasattr(context, "action") else - context.get_actions()) & Gdk.DragAction.MOVE): + if context.get_actions() & Gdk.DragAction.MOVE: context.finish(True, True, time) # remember time for double drop workaround. diff --git a/gramps/gui/views/pageview.py b/gramps/gui/views/pageview.py index 8cdb1a568..687ce546c 100644 --- a/gramps/gui/views/pageview.py +++ b/gramps/gui/views/pageview.py @@ -276,7 +276,7 @@ class PageView(DbGUIElement, metaclass=ABCMeta): def get_data(self): return self.data class Context: - targets = [drag_type.name()] + targets = [Gdk.atom_intern(drag_type.name(), False)] action = 1 def list_targets(self): return Context.targets From 4dd6abfe857bb8dfb0ec95befeefa7e3d8a721fa Mon Sep 17 00:00:00 2001 From: prculley Date: Sat, 27 Oct 2018 15:31:21 -0500 Subject: [PATCH 2/2] Remove old Gtk drag/drop bug fix, no longer needed --- gramps/gui/clipboard.py | 34 ++++----------- gramps/gui/dbman.py | 8 ++-- .../gui/editors/displaytabs/embeddedlist.py | 20 +++------ gramps/gui/editors/displaytabs/gallerytab.py | 20 +++------ gramps/gui/editors/editchildref.py | 9 +--- gramps/gui/editors/editfamily.py | 28 +++--------- gramps/gui/editors/editperson.py | 9 +--- gramps/gui/editors/editpersonref.py | 21 +++------ gramps/gui/editors/objectentries.py | 43 +++++++++---------- gramps/gui/plug/quick/_quicktable.py | 6 +-- gramps/gui/views/listview.py | 23 ++-------- gramps/gui/widgets/fanchart.py | 7 +-- gramps/gui/widgets/grampletpane.py | 15 ++----- gramps/plugins/view/relview.py | 7 +-- 14 files changed, 72 insertions(+), 178 deletions(-) diff --git a/gramps/gui/clipboard.py b/gramps/gui/clipboard.py index 4867c600e..c1d437fb3 100644 --- a/gramps/gui/clipboard.py +++ b/gramps/gui/clipboard.py @@ -890,8 +890,8 @@ class ClipboardListModel(Gtk.ListStore): class ClipboardListView: LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW' - LOCAL_DRAG_ATOM_TYPE = Gdk.atom_intern(LOCAL_DRAG_TYPE, False) - LOCAL_DRAG_TARGET = (LOCAL_DRAG_ATOM_TYPE, Gtk.TargetFlags.SAME_WIDGET, 0) + LOCAL_DRAG_TARGET = Gtk.TargetEntry.new(LOCAL_DRAG_TYPE, + Gtk.TargetFlags.SAME_WIDGET, 0) def __init__(self, dbstate, widget): @@ -948,19 +948,10 @@ class ClipboardListView: self._widget.set_enable_search(True) #self._widget.set_search_column(3) - targ_data = DdTargets.all_dtype() - tglist = Gtk.TargetList.new([]) - tglist.add(ClipboardListView.LOCAL_DRAG_TARGET[0], - ClipboardListView.LOCAL_DRAG_TARGET[1], - ClipboardListView.LOCAL_DRAG_TARGET[2]) - for _tg in targ_data: - tglist.add(_tg.atom_drag_type, _tg.target_flags, _tg.app_id) - self._widget.enable_model_drag_dest([], Gdk.DragAction.COPY) - #TODO GTK3: workaround here for bug - # https://bugzilla.gnome.org/show_bug.cgi?id=680638 - self._widget.drag_dest_set_target_list(tglist) - #self._widget.drag_dest_set(Gtk.DestDefaults.ALL, targ_data, - # Gdk.DragAction.COPY) + targ_data = ((ClipboardListView.LOCAL_DRAG_TARGET,) + + DdTargets.all_targets()) + self._widget.drag_dest_set(Gtk.DestDefaults.ALL, targ_data, + Gdk.DragAction.COPY) self._widget.connect('drag-data-get', self.object_drag_data_get) self._widget.connect('drag-begin', self.object_drag_begin) @@ -1129,8 +1120,7 @@ class ClipboardListView: tree_selection = self._widget.get_selection() model, paths = tree_selection.get_selected_rows() if len(paths) > 1: - targets = [(DdTargets.RAW_LIST.atom_drag_type, - Gtk.TargetFlags.SAME_WIDGET, 0), + targets = [DdTargets.RAW_LIST.target(), ClipboardListView.LOCAL_DRAG_TARGET] else: targets = [ClipboardListView.LOCAL_DRAG_TARGET] @@ -1138,18 +1128,12 @@ class ClipboardListView: node = model.get_iter(path) if node is not None: _ob = model.get_value(node, 1) - targets += [target.target_data_atom() + targets += [target.target() for target in _ob.__class__.DROP_TARGETS] - #TODO GTK3: workaround here for bug - # https://bugzilla.gnome.org/show_bug.cgi?id=680638 self._widget.enable_model_drag_source( - Gdk.ModifierType.BUTTON1_MASK, [], + Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY | Gdk.DragAction.MOVE) - tglist = Gtk.TargetList.new([]) - for _tg in targets: - tglist.add(_tg[0], _tg[1], _tg[2]) - self._widget.drag_source_set_target_list(tglist) def object_drag_begin(self, widget, drag_context): """ Handle the beginning of a drag operation. """ diff --git a/gramps/gui/dbman.py b/gramps/gui/dbman.py index 3c33d22bd..d5e215ebd 100644 --- a/gramps/gui/dbman.py +++ b/gramps/gui/dbman.py @@ -216,11 +216,9 @@ class DbManager(CLIDbManager, ManagedWindow): Connects the signals to the buttons on the interface. """ ddtarget = DdTargets.URI_LIST - self.top.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(ddtarget.atom_drag_type, ddtarget.target_flags, - ddtarget.app_id) - self.top.drag_dest_set_target_list(tglist) + self.top.drag_dest_set(Gtk.DestDefaults.ALL, + [DdTargets.URI_LIST.target()], + Gdk.DragAction.COPY) self.remove_btn.connect('clicked', self.__remove_db) self.new_btn.connect('clicked', self.__new_db) diff --git a/gramps/gui/editors/displaytabs/embeddedlist.py b/gramps/gui/editors/displaytabs/embeddedlist.py index e4e4323d9..06bd344b1 100644 --- a/gramps/gui/editors/displaytabs/embeddedlist.py +++ b/gramps/gui/editors/displaytabs/embeddedlist.py @@ -192,23 +192,15 @@ class EmbeddedList(ButtonTab): """ if self._DND_EXTRA: - dnd_types = [self._DND_TYPE, - self._DND_EXTRA] + dnd_types = [self._DND_TYPE.target(), + self._DND_EXTRA.target()] else: - dnd_types = [self._DND_TYPE] + dnd_types = [self._DND_TYPE.target()] - #TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638 - self.tree.enable_model_drag_dest([], Gdk.DragAction.COPY) - self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [], + self.tree.enable_model_drag_dest(dnd_types, Gdk.DragAction.COPY) + self.tree.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, + [self._DND_TYPE.target()], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - for tg in dnd_types: - tglist.add(tg.atom_drag_type, tg.target_flags, tg.app_id) - self.tree.drag_dest_set_target_list(tglist) - tglist = Gtk.TargetList.new([]) - tglist.add(self._DND_TYPE.atom_drag_type, self._DND_TYPE.target_flags, - self._DND_TYPE.app_id) - self.tree.drag_source_set_target_list(tglist) self.tree.connect('drag_data_get', self.drag_data_get) self.tree.connect_after('drag-begin', self.after_drag_begin) diff --git a/gramps/gui/editors/displaytabs/gallerytab.py b/gramps/gui/editors/displaytabs/gallerytab.py index a5c03d037..5ef44a4a5 100644 --- a/gramps/gui/editors/displaytabs/gallerytab.py +++ b/gramps/gui/editors/displaytabs/gallerytab.py @@ -404,22 +404,14 @@ class GalleryTab(ButtonTab, DbGUIElement): variable defined that points to an entry in DdTargets. """ - dnd_types = [ self._DND_TYPE, self._DND_EXTRA, DdTargets.MEDIAOBJ] + dnd_types = [self._DND_TYPE.target(), self._DND_EXTRA.target(), + DdTargets.MEDIAOBJ.target()] - #TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638 - self.iconlist.enable_model_drag_dest([], - Gdk.DragAction.MOVE|Gdk.DragAction.COPY) + self.iconlist.enable_model_drag_dest( + dnd_types, Gdk.DragAction.MOVE | Gdk.DragAction.COPY) self.iconlist.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - for tg in dnd_types: - tglist.add(tg.atom_drag_type, tg.target_flags, tg.app_id) - self.iconlist.drag_dest_set_target_list(tglist) - tglist = Gtk.TargetList.new([]) - tglist.add(self._DND_TYPE.atom_drag_type, self._DND_TYPE.target_flags, - self._DND_TYPE.app_id) - self.iconlist.drag_source_set_target_list(tglist) + [self._DND_TYPE.target()], + Gdk.DragAction.COPY) self.iconlist.connect('drag_data_get', self.drag_data_get) if not self.dbstate.db.readonly: self.iconlist.connect('drag_data_received', self.drag_data_received) diff --git a/gramps/gui/editors/editchildref.py b/gramps/gui/editors/editchildref.py index 2fe248884..f3f1acadc 100644 --- a/gramps/gui/editors/editchildref.py +++ b/gramps/gui/editors/editchildref.py @@ -107,13 +107,8 @@ class EditChildRef(EditSecondary): # Set the drag action from the label self.label_event_box = self.top.get_object('name_event_box') self.label_event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - self.label_event_box.drag_source_set_target_list(tglist) + [DdTargets.PERSON_LINK.target()], + Gdk.DragAction.COPY) self.label_event_box.drag_source_set_icon_name('gramps-person') self.label_event_box.connect('drag_data_get', self.drag_data_get) diff --git a/gramps/gui/editors/editfamily.py b/gramps/gui/editors/editfamily.py index 0eb3a2a8c..b416ab2e3 100644 --- a/gramps/gui/editors/editfamily.py +++ b/gramps/gui/editors/editfamily.py @@ -563,12 +563,8 @@ class EditFamily(EditPrimary): self.set_contexteventbox(self.top.get_object("eventboxtop")) #allow for drag of the family object from eventboxtop self.contexteventbox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.FAMILY_LINK.atom_drag_type, - DdTargets.FAMILY_LINK.target_flags, - DdTargets.FAMILY_LINK.app_id) - self.contexteventbox.drag_source_set_target_list(tglist) + [DdTargets.FAMILY_LINK.target()], + Gdk.DragAction.COPY) self.contexteventbox.drag_source_set_icon_name('gramps-family') self.contexteventbox.connect('drag_data_get', self.on_drag_data_get_family) @@ -585,13 +581,8 @@ class EditFamily(EditPrimary): # Allow drag if not event_box.drag_source_get_target_list(): event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - event_box.drag_source_set_target_list(tglist) + [DdTargets.PERSON_LINK.target()], + Gdk.DragAction.COPY) event_box.drag_source_set_icon_name('gramps-person') event_box.connect('drag_data_get', on_drag_data_get) #Disallow drop: @@ -604,14 +595,9 @@ class EditFamily(EditPrimary): #allow for drop: if not event_box.drag_dest_get_target_list(): event_box.drag_dest_set(Gtk.DestDefaults.MOTION | - Gtk.DestDefaults.DROP, - [], - Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - event_box.drag_dest_set_target_list(tglist) + Gtk.DestDefaults.DROP, + [DdTargets.PERSON_LINK.target()], + Gdk.DragAction.COPY) event_box.connect('drag_data_received', on_drag_data_received) def on_drag_fatherdata_get(self, widget, context, sel_data, info, time): diff --git a/gramps/gui/editors/editperson.py b/gramps/gui/editors/editperson.py index bbd8b55f3..205c8cb2a 100644 --- a/gramps/gui/editors/editperson.py +++ b/gramps/gui/editors/editperson.py @@ -252,14 +252,9 @@ class EditPerson(EditPrimary): # allow to initiate a drag-and-drop with this person if it has a handle if self.added: return # Avoid HandleError if dragging an objet not in db yet - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) self.contexteventbox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - self.contexteventbox.drag_source_set_target_list(tglist) + [DdTargets.PERSON_LINK.target()], + Gdk.DragAction.COPY) self.contexteventbox.drag_source_set_icon_name('gramps-person') self.contexteventbox.connect('drag_data_get', self._top_drag_data_get) diff --git a/gramps/gui/editors/editpersonref.py b/gramps/gui/editors/editpersonref.py index a3d9f6ded..ea230550f 100644 --- a/gramps/gui/editors/editpersonref.py +++ b/gramps/gui/editors/editpersonref.py @@ -97,14 +97,9 @@ class EditPersonRef(EditSecondary): #allow for drop: self.person_label.drag_dest_set(Gtk.DestDefaults.MOTION | - Gtk.DestDefaults.DROP, - [], - Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - self.person_label.drag_dest_set_target_list(tglist) + Gtk.DestDefaults.DROP, + [DdTargets.PERSON_LINK.target()], + Gdk.DragAction.COPY) self.person_label.connect('drag_data_received', self.on_drag_persondata_received) self._update_dnd_capability() @@ -112,13 +107,9 @@ class EditPersonRef(EditSecondary): self.label_event_box = self.top.get_object('person_event_box') # Set the drag action from the label if self.obj.ref: - self.label_event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - self.label_event_box.drag_source_set_target_list(tglist) + self.label_event_box.drag_source_set( + Gdk.ModifierType.BUTTON1_MASK, + [DdTargets.PERSON_LINK.target()], Gdk.DragAction.COPY) self.label_event_box.drag_source_set_icon_name('gramps-person') self.label_event_box.connect('drag_data_get', self.drag_data_get) else: diff --git a/gramps/gui/editors/objectentries.py b/gramps/gui/editors/objectentries.py index c90e69a7b..729421380 100644 --- a/gramps/gui/editors/objectentries.py +++ b/gramps/gui/editors/objectentries.py @@ -148,30 +148,27 @@ class ObjEntry: Drop is always allowed Drag only allowed when object is set """ - if self._DND_TYPE: - if not self.label.drag_dest_get_target_list(): - self.label.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(self._DND_TYPE.atom_drag_type, self._DND_TYPE.target_flags, - self._DND_TYPE.app_id) - self.label.drag_dest_set_target_list(tglist) - self.label.connect('drag_data_received', self.drag_data_received) + if not self._DND_TYPE: + return + if not self.label.drag_dest_get_target_list(): + self.label.drag_dest_set(Gtk.DestDefaults.ALL, + [self._DND_TYPE.target()], + Gdk.DragAction.COPY) + self.label.connect('drag_data_received', self.drag_data_received) # Set the drag action from this box - if self._DND_TYPE: - if self.get_val(): - if not self.label.drag_source_get_target_list(): - self.label_event_box.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(self._DND_TYPE.atom_drag_type, self._DND_TYPE.target_flags, - self._DND_TYPE.app_id) - self.label_event_box.drag_source_set_target_list(tglist) - if self._DND_ICON: - self.label_event_box.drag_source_set_icon_name(self._DND_ICON) - self.label_event_box.connect('drag_data_get', self.drag_data_get) - else: - if self.label.drag_source_get_target_list(): - self.label_event_box.drag_source_unset() + if self.get_val(): + if not self.label.drag_source_get_target_list(): + self.label_event_box.drag_source_set( + Gdk.ModifierType.BUTTON1_MASK, + [self._DND_TYPE.target()], Gdk.DragAction.COPY) + if self._DND_ICON: + self.label_event_box.drag_source_set_icon_name( + self._DND_ICON) + self.label_event_box.connect('drag_data_get', + self.drag_data_get) + else: + if self.label.drag_source_get_target_list(): + self.label_event_box.drag_source_unset() def _init_object(self): """inheriting objects can use this to set extra variables diff --git a/gramps/gui/plug/quick/_quicktable.py b/gramps/gui/plug/quick/_quicktable.py index 7270aaee6..388c9972b 100644 --- a/gramps/gui/plug/quick/_quicktable.py +++ b/gramps/gui/plug/quick/_quicktable.py @@ -352,12 +352,8 @@ class QuickTable(SimpleTable): sort_index = 0 treeview = MultiTreeView() treeview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, - [], + [DdTargets.HANDLE_LIST.target()], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.HANDLE_LIST.atom_drag_type, Gtk.TargetFlags.SAME_WIDGET, - 0) - treeview.drag_source_set_target_list(tglist) #treeview.enable_model_drag_dest(DdTargets.all_targets(), # Gdk.DragAction.DEFAULT) treeview.connect('drag_data_get', self.object_drag_data_get) diff --git a/gramps/gui/views/listview.py b/gramps/gui/views/listview.py index 0751046ee..a286838d1 100644 --- a/gramps/gui/views/listview.py +++ b/gramps/gui/views/listview.py @@ -172,11 +172,6 @@ class ListView(NavigationView): [self.drag_dest_info().target()], Gdk.DragAction.MOVE | Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(self.drag_dest_info().atom_drag_type, - self.drag_dest_info().target_flags, - self.drag_dest_info().app_id) - self.list.drag_dest_set_target_list(tglist) scrollwindow = Gtk.ScrolledWindow() scrollwindow.set_policy(Gtk.PolicyType.AUTOMATIC, @@ -729,23 +724,13 @@ class ListView(NavigationView): if len(selected_ids) == 1: if self.drag_info(): self.list.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - #TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638 - tglist = Gtk.TargetList.new([]) - dtype = self.drag_info() - tglist.add(dtype.atom_drag_type, dtype.target_flags, dtype.app_id) - self.list.drag_source_set_target_list(tglist) + [self.drag_info().target()], + Gdk.DragAction.COPY) elif len(selected_ids) > 1: if self.drag_list_info(): self.list.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], - Gdk.DragAction.COPY) - #TODO GTK3: wourkaround here for bug https://bugzilla.gnome.org/show_bug.cgi?id=680638 - tglist = Gtk.TargetList.new([]) - dtype = self.drag_list_info() - tglist.add(dtype.atom_drag_type, dtype.target_flags, dtype.app_id) - self.list.drag_source_set_target_list(tglist) + [self.drag_list_info().target()], + Gdk.DragAction.COPY) self.uistate.modify_statusbar(self.dbstate) diff --git a/gramps/gui/widgets/fanchart.py b/gramps/gui/widgets/fanchart.py index 3a55bf64a..db37e2cce 100644 --- a/gramps/gui/widgets/fanchart.py +++ b/gramps/gui/widgets/fanchart.py @@ -162,13 +162,8 @@ class FanChartBaseWidget(Gtk.DrawingArea): # Enable drop self.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.DROP, - [], + [DdTargets.PERSON_LINK.target()], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(DdTargets.PERSON_LINK.atom_drag_type, - DdTargets.PERSON_LINK.target_flags, - DdTargets.PERSON_LINK.app_id) - self.drag_dest_set_target_list(tglist) self.connect('drag_data_received', self.on_drag_data_received) self._mouse_click = False diff --git a/gramps/gui/widgets/grampletpane.py b/gramps/gui/widgets/grampletpane.py index fe2579bb2..f5640fabb 100644 --- a/gramps/gui/widgets/grampletpane.py +++ b/gramps/gui/widgets/grampletpane.py @@ -760,7 +760,8 @@ class GridGramplet(GuiGramplet): """ TARGET_TYPE_FRAME = 80 LOCAL_DRAG_TYPE = 'GRAMPLET' - LOCAL_DRAG_TARGET = (Gdk.atom_intern(LOCAL_DRAG_TYPE, False), 0, TARGET_TYPE_FRAME) + LOCAL_DRAG_TARGET = Gtk.TargetEntry.new(LOCAL_DRAG_TYPE, 0, + TARGET_TYPE_FRAME) def __init__(self, pane, dbstate, uistate, title, **kwargs): """ @@ -806,12 +807,8 @@ class GridGramplet(GuiGramplet): # source: drag = self.gvproperties drag.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], + [GridGramplet.LOCAL_DRAG_TARGET], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tg = GridGramplet.LOCAL_DRAG_TARGET - tglist.add(tg[0], tg[1], tg[2]) - drag.drag_source_set_target_list(tglist) # default tooltip msg = _("Drag Properties Button to move and click it for setup") @@ -1025,12 +1022,8 @@ class GrampletPane(Gtk.ScrolledWindow): self.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, - [], + [GridGramplet.LOCAL_DRAG_TARGET], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tg = GridGramplet.LOCAL_DRAG_TARGET - tglist.add(tg[0], tg[1], tg[2]) - self.drag_dest_set_target_list(tglist) self.connect('drag_drop', self.drop_widget) self.eventb.connect('button-press-event', self._button_press) diff --git a/gramps/plugins/view/relview.py b/gramps/plugins/view/relview.py index 3c5b5d87b..dfb3c50ca 100644 --- a/gramps/plugins/view/relview.py +++ b/gramps/plugins/view/relview.py @@ -1182,12 +1182,7 @@ class RelationshipView(NavigationView): Register the given eventbox as a drag_source with given object_h """ eventbox.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, - [], Gdk.DragAction.COPY) - tglist = Gtk.TargetList.new([]) - tglist.add(dnd_type.atom_drag_type, - dnd_type.target_flags, - dnd_type.app_id) - eventbox.drag_source_set_target_list(tglist) + [dnd_type.target()], Gdk.DragAction.COPY) eventbox.drag_source_set_icon_name(stock_icon) eventbox.connect('drag_data_get', self._make_drag_data_get_func(object_h, dnd_type))