GTK3 port, reenable ctrl+C copy behavior on listvie

svn: r20089
This commit is contained in:
Benny Malengier 2012-07-26 15:57:05 +00:00
parent e44e69b0dc
commit 28a20116b5
2 changed files with 20 additions and 14 deletions

View File

@ -133,18 +133,18 @@ def obj2class(target):
} }
return d[target] if target in d else None return d[target] if target in d else None
def obj2target(target): OBJ2TARGET = {"Person": Gdk.atom_intern('person-link', False),
d = {"Person": 'person-link', "Family": Gdk.atom_intern('family-link', False),
"Family": 'family-link', 'Source': Gdk.atom_intern('source-link', False),
'Source': 'source-link', 'Citation': Gdk.atom_intern('citation-link', False),
'Citation': 'citation-link', 'Repository': Gdk.atom_intern('repo-link', False),
'Repository': 'repo-link', 'Event': Gdk.atom_intern('pevent', False),
'Event': 'pevent', 'Media': Gdk.atom_intern('mediaobj', False),
'Media': 'mediaobj', 'Place': Gdk.atom_intern('place-link', False),
'Place': 'place-link', 'Note': Gdk.atom_intern('note-link', False),
'Note': 'note-link',
} }
return d[target] if target in d else None def obj2target(target):
return OBJ2TARGET[target] if target in OBJ2TARGET else None
def model_contains(model, data): def model_contains(model, data):
""" """
@ -857,7 +857,7 @@ class ClipDropHandleList(ClipDropList):
retval = [] retval = []
for (objclass, handle) in self._obj_list: for (objclass, handle) in self._obj_list:
_class = obj2class(objclass) _class = obj2class(objclass)
target = obj2target(objclass) target = obj2target(objclass).name()
# outgoing: # outgoing:
# (drag_type, idval, self._handle, val) = pickle.loads(self._obj) # (drag_type, idval, self._handle, val) = pickle.loads(self._obj)
data = (target, id(self), handle, 0) data = (target, id(self), handle, 0)

View File

@ -249,11 +249,17 @@ class PageView(DbGUIElement):
class Selection(object): class Selection(object):
def __init__(self, data): def __init__(self, data):
self.data = data self.data = data
def get_data(self):
return self.data
class Context(object): class Context(object):
targets = [drag_type] targets = [drag_type]
action = 1 action = 1
def list_targets(self):
return Context.targets
def get_actions(self):
return Context.action
# eg: ('person-link', 23767, '27365123671', 0) # eg: ('person-link', 23767, '27365123671', 0)
data = (drag_type, id(self), handle, 0) data = (drag_type.name(), id(self), handle, 0)
clipboard.object_list.object_drag_data_received( clipboard.object_list.object_drag_data_received(
clipboard.object_list._widget, # widget clipboard.object_list._widget, # widget
Context(), # drag type and action Context(), # drag type and action
@ -271,7 +277,7 @@ class PageView(DbGUIElement):
The code creates the Clipboard if it does not already exist. The code creates the Clipboard if it does not already exist.
""" """
from gui.clipboard import ClipboardWindow, obj2target from gui.clipboard import ClipboardWindow
clipboard = None clipboard = None
for widget in self.uistate.gwm.window_tree: for widget in self.uistate.gwm.window_tree:
if isinstance(widget, ClipboardWindow): if isinstance(widget, ClipboardWindow):