GEPS008: Moved ScratchPad module (renamed as clipboard)

svn: r19772
This commit is contained in:
Nick Hall 2012-06-06 13:38:46 +00:00
parent 33f45cb087
commit 54535a83bd
9 changed files with 152 additions and 155 deletions

View File

@ -2,7 +2,6 @@
# #
# Python files # Python files
# #
src/Assistant.py
src/Bookmarks.py src/Bookmarks.py
src/const.py src/const.py
src/DateEdit.py src/DateEdit.py
@ -11,10 +10,8 @@ src/ExportOptions.py
src/gramps.py src/gramps.py
src/LdsUtils.py src/LdsUtils.py
src/PlaceUtils.py src/PlaceUtils.py
src/QuickReports.py
src/Relationship.py src/Relationship.py
src/Reorder.py src/Reorder.py
src/ScratchPad.py
src/Spell.py src/Spell.py
src/ToolTips.py src/ToolTips.py
src/TransUtils.py src/TransUtils.py
@ -330,6 +327,7 @@ src/gen/simple/_simpletable.py
# gui - GUI code # gui - GUI code
src/gui/aboutdialog.py src/gui/aboutdialog.py
src/gui/clipboard.py
src/gui/columnorder.py src/gui/columnorder.py
src/gui/configure.py src/gui/configure.py
src/gui/dbloader.py src/gui/dbloader.py

View File

@ -33,7 +33,6 @@ gdir_PYTHON = \
RecentFiles.py\ RecentFiles.py\
Relationship.py\ Relationship.py\
Reorder.py\ Reorder.py\
ScratchPad.py\
Sort.py\ Sort.py\
soundex.py\ soundex.py\
Spell.py\ Spell.py\

View File

@ -21,6 +21,7 @@ pkgpython_PYTHON = \
__init__.py \ __init__.py \
aboutdialog.py \ aboutdialog.py \
basesidebar.py \ basesidebar.py \
clipboard.py \
columnorder.py \ columnorder.py \
configure.py \ configure.py \
dbguielement.py \ dbguielement.py \

View File

@ -102,32 +102,32 @@ for (name, file) in (
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def map2class(target): def map2class(target):
d = {"person-link": ScratchPersonLink, d = {"person-link": ClipPersonLink,
"family-link": ScratchFamilyLink, "family-link": ClipFamilyLink,
'personref': ScratchPersonRef, 'personref': ClipPersonRef,
'childref': ScratchChildRef, 'childref': ClipChildRef,
'source-link': ScratchSourceLink, 'source-link': ClipSourceLink,
'citation-link': ScratchCitation, 'citation-link': ClipCitation,
'repo-link': ScratchRepositoryLink, 'repo-link': ClipRepositoryLink,
'pevent': ScratchEvent, 'pevent': ClipEvent,
'eventref': ScratchEventRef, 'eventref': ClipEventRef,
'mediaobj': ScratchMediaObj, 'mediaobj': ClipMediaObj,
'mediaref': ScratchMediaRef, 'mediaref': ClipMediaRef,
'place-link': ScratchPlace, 'place-link': ClipPlace,
'note-link': ScratchNote, 'note-link': ClipNote,
} }
return d[target] if target in d else None return d[target] if target in d else None
def obj2class(target): def obj2class(target):
d= {"Person": ScratchPersonLink, d= {"Person": ClipPersonLink,
"Family": ScratchFamilyLink, "Family": ClipFamilyLink,
'Source': ScratchSourceLink, 'Source': ClipSourceLink,
'Citation': ScratchCitation, 'Citation': ClipCitation,
'Repository': ScratchRepositoryLink, 'Repository': ClipRepositoryLink,
'Event': ScratchEvent, 'Event': ClipEvent,
'Media': ScratchMediaObj, 'Media': ClipMediaObj,
'Place': ScratchPlace, 'Place': ClipPlace,
'Note': ScratchNote, 'Note': ClipNote,
} }
return d[target] if target in d else None return d[target] if target in d else None
@ -149,7 +149,7 @@ def model_contains(model, data):
Returns True if data is a row in model. Returns True if data is a row in model.
""" """
# check type and value # check type and value
# data[0] is type of drop item, data[1] is Scratch object # data[0] is type of drop item, data[1] is Clip object
for row in model: for row in model:
if data[0] == 'TEXT': if data[0] == 'TEXT':
same = ((row[0] == data[0]) and same = ((row[0] == data[0]) and
@ -170,7 +170,7 @@ def model_contains(model, data):
# wrapper classes to provide object specific listing in the ListView # wrapper classes to provide object specific listing in the ListView
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchWrapper(object): class ClipWrapper(object):
UNAVAILABLE_ICON = gtk.STOCK_DIALOG_ERROR UNAVAILABLE_ICON = gtk.STOCK_DIALOG_ERROR
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
@ -223,10 +223,10 @@ class ScratchWrapper(object):
return True return True
class ScratchHandleWrapper(ScratchWrapper): class ClipHandleWrapper(ClipWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
super(ScratchHandleWrapper, self).__init__(dbstate, obj) super(ClipHandleWrapper, self).__init__(dbstate, obj)
#unpack object #unpack object
(drag_type, idval, data, val) = pickle.loads(obj) (drag_type, idval, data, val) = pickle.loads(obj)
if isinstance(data, dict): if isinstance(data, dict):
@ -238,10 +238,10 @@ class ScratchHandleWrapper(ScratchWrapper):
for item in data: for item in data:
setattr(self, item, data[item]) setattr(self, item, data[item])
class ScratchObjWrapper(ScratchWrapper): class ClipObjWrapper(ClipWrapper):
def __init__(self,dbstate, obj): def __init__(self,dbstate, obj):
super(ScratchObjWrapper, self).__init__(dbstate, obj) super(ClipObjWrapper, self).__init__(dbstate, obj)
#unpack object #unpack object
(drag_type, idval, self._obj, val) = pickle.loads(obj) (drag_type, idval, self._obj, val) = pickle.loads(obj)
self._pickle = obj self._pickle = obj
@ -282,14 +282,14 @@ class ScratchObjWrapper(ScratchWrapper):
return True return True
class ScratchAddress(ScratchObjWrapper): class ClipAddress(ClipObjWrapper):
DROP_TARGETS = [DdTargets.ADDRESS] DROP_TARGETS = [DdTargets.ADDRESS]
DRAG_TARGET = DdTargets.ADDRESS DRAG_TARGET = DdTargets.ADDRESS
ICON = ICONS['address'] ICON = ICONS['address']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchAddress, self).__init__(dbstate, obj) super(ClipAddress, self).__init__(dbstate, obj)
self._type = _("Address") self._type = _("Address")
self.refresh() self.refresh()
@ -302,14 +302,14 @@ class ScratchAddress(ScratchObjWrapper):
self._obj.get_country(), self._obj.get_country(),
) )
class ScratchLocation(ScratchObjWrapper): class ClipLocation(ClipObjWrapper):
DROP_TARGETS = [DdTargets.LOCATION] DROP_TARGETS = [DdTargets.LOCATION]
DRAG_TARGET = DdTargets.LOCATION DRAG_TARGET = DdTargets.LOCATION
ICON = ICONS['location'] ICON = ICONS['location']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchLocation, self).__init__(dbstate, obj) super(ClipLocation, self).__init__(dbstate, obj)
self._type = _("Location") self._type = _("Location")
self.refresh() self.refresh()
@ -319,14 +319,14 @@ class ScratchLocation(ScratchObjWrapper):
self._obj.get_country(), self._obj.get_country(),
) )
class ScratchEvent(ScratchHandleWrapper): class ClipEvent(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.EVENT] DROP_TARGETS = [DdTargets.EVENT]
DRAG_TARGET = DdTargets.EVENT DRAG_TARGET = DdTargets.EVENT
ICON = ICONS["event"] ICON = ICONS["event"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchEvent, self).__init__(dbstate, obj) super(ClipEvent, self).__init__(dbstate, obj)
self._type = _("Event") self._type = _("Event")
self._objclass = 'Event' self._objclass = 'Event'
self.refresh() self.refresh()
@ -346,14 +346,14 @@ class ScratchEvent(ScratchHandleWrapper):
return True return True
return False return False
class ScratchPlace(ScratchHandleWrapper): class ClipPlace(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.PLACE_LINK] DROP_TARGETS = [DdTargets.PLACE_LINK]
DRAG_TARGET = DdTargets.PLACE_LINK DRAG_TARGET = DdTargets.PLACE_LINK
ICON = ICONS["place"] ICON = ICONS["place"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchPlace, self).__init__(dbstate, obj) super(ClipPlace, self).__init__(dbstate, obj)
self._type = _("Place") self._type = _("Place")
self._objclass = 'Place' self._objclass = 'Place'
self.refresh() self.refresh()
@ -373,14 +373,14 @@ class ScratchPlace(ScratchHandleWrapper):
return True return True
return False return False
class ScratchNote(ScratchHandleWrapper): class ClipNote(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.NOTE_LINK] DROP_TARGETS = [DdTargets.NOTE_LINK]
DRAG_TARGET = DdTargets.NOTE_LINK DRAG_TARGET = DdTargets.NOTE_LINK
ICON = ICONS["note"] ICON = ICONS["note"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchNote, self).__init__(dbstate, obj) super(ClipNote, self).__init__(dbstate, obj)
self._type = _("Note") self._type = _("Note")
self._objclass = 'Note' self._objclass = 'Note'
self.refresh() self.refresh()
@ -406,14 +406,14 @@ class ScratchNote(ScratchHandleWrapper):
return True return True
return False return False
class ScratchFamilyEvent(ScratchObjWrapper): class ClipFamilyEvent(ClipObjWrapper):
DROP_TARGETS = [DdTargets.FAMILY_EVENT] DROP_TARGETS = [DdTargets.FAMILY_EVENT]
DRAG_TARGET = DdTargets.FAMILY_EVENT DRAG_TARGET = DdTargets.FAMILY_EVENT
ICON = ICONS['family'] ICON = ICONS['family']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchFamilyEvent, self).__init__(dbstate, obj) super(ClipFamilyEvent, self).__init__(dbstate, obj)
self._type = _("Family Event") self._type = _("Family Event")
self.refresh() self.refresh()
@ -422,14 +422,14 @@ class ScratchFamilyEvent(ScratchObjWrapper):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_description() self._value = self._obj.get_description()
class ScratchUrl(ScratchObjWrapper): class ClipUrl(ClipObjWrapper):
DROP_TARGETS = [DdTargets.URL] DROP_TARGETS = [DdTargets.URL]
DRAG_TARGET = DdTargets.URL DRAG_TARGET = DdTargets.URL
ICON = ICONS['url'] ICON = ICONS['url']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchUrl, self).__init__(dbstate, obj) super(ClipUrl, self).__init__(dbstate, obj)
self._type = _("Url") self._type = _("Url")
self.refresh() self.refresh()
@ -438,14 +438,14 @@ class ScratchUrl(ScratchObjWrapper):
self._title = self._obj.get_path() self._title = self._obj.get_path()
self._value = self._obj.get_description() self._value = self._obj.get_description()
class ScratchAttribute(ScratchObjWrapper): class ClipAttribute(ClipObjWrapper):
DROP_TARGETS = [DdTargets.ATTRIBUTE] DROP_TARGETS = [DdTargets.ATTRIBUTE]
DRAG_TARGET = DdTargets.ATTRIBUTE DRAG_TARGET = DdTargets.ATTRIBUTE
ICON = ICONS['attribute'] ICON = ICONS['attribute']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchAttribute, self).__init__(dbstate, obj) super(ClipAttribute, self).__init__(dbstate, obj)
self._type = _("Attribute") self._type = _("Attribute")
self.refresh() self.refresh()
@ -453,14 +453,14 @@ class ScratchAttribute(ScratchObjWrapper):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
class ScratchFamilyAttribute(ScratchObjWrapper): class ClipFamilyAttribute(ClipObjWrapper):
DROP_TARGETS = [DdTargets.FAMILY_ATTRIBUTE] DROP_TARGETS = [DdTargets.FAMILY_ATTRIBUTE]
DRAG_TARGET = DdTargets.FAMILY_ATTRIBUTE DRAG_TARGET = DdTargets.FAMILY_ATTRIBUTE
ICON = ICONS['attribute'] ICON = ICONS['attribute']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchFamilyAttribute, self).__init__(dbstate, obj) super(ClipFamilyAttribute, self).__init__(dbstate, obj)
self._type = _("Family Attribute") self._type = _("Family Attribute")
self.refresh() self.refresh()
@ -469,14 +469,14 @@ class ScratchFamilyAttribute(ScratchObjWrapper):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_value() self._value = self._obj.get_value()
class ScratchCitation(ScratchHandleWrapper): class ClipCitation(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.CITATION_LINK] DROP_TARGETS = [DdTargets.CITATION_LINK]
DRAG_TARGET = DdTargets.CITATION_LINK DRAG_TARGET = DdTargets.CITATION_LINK
ICON = ICONS["citation"] ICON = ICONS["citation"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchCitation, self).__init__(dbstate, obj) super(ClipCitation, self).__init__(dbstate, obj)
self._type = _("Citation") self._type = _("Citation")
self._objclass = 'Citation' self._objclass = 'Citation'
self.refresh() self.refresh()
@ -514,14 +514,14 @@ class ScratchCitation(ScratchHandleWrapper):
return True return True
return False return False
class ScratchRepoRef(ScratchObjWrapper): class ClipRepoRef(ClipObjWrapper):
DROP_TARGETS = [DdTargets.REPOREF] DROP_TARGETS = [DdTargets.REPOREF]
DRAG_TARGET = DdTargets.REPOREF DRAG_TARGET = DdTargets.REPOREF
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchRepoRef, self).__init__(dbstate, obj) super(ClipRepoRef, self).__init__(dbstate, obj)
self._type = _("Repository ref") self._type = _("Repository ref")
self.refresh() self.refresh()
@ -532,14 +532,14 @@ class ScratchRepoRef(ScratchObjWrapper):
self._title = str(base.get_type()) self._title = str(base.get_type())
self._value = base.get_name() self._value = base.get_name()
class ScratchEventRef(ScratchObjWrapper): class ClipEventRef(ClipObjWrapper):
DROP_TARGETS = [DdTargets.EVENTREF] DROP_TARGETS = [DdTargets.EVENTREF]
DRAG_TARGET = DdTargets.EVENTREF DRAG_TARGET = DdTargets.EVENTREF
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchEventRef, self).__init__(dbstate, obj) super(ClipEventRef, self).__init__(dbstate, obj)
self._type = _("Event ref") self._type = _("Event ref")
self.refresh() self.refresh()
@ -550,14 +550,14 @@ class ScratchEventRef(ScratchObjWrapper):
self._title = base.gramps_id self._title = base.gramps_id
self._value = str(base.get_type()) self._value = str(base.get_type())
class ScratchName(ScratchObjWrapper): class ClipName(ClipObjWrapper):
DROP_TARGETS = [DdTargets.NAME] DROP_TARGETS = [DdTargets.NAME]
DRAG_TARGET = DdTargets.NAME DRAG_TARGET = DdTargets.NAME
ICON = ICONS['name'] ICON = ICONS['name']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchName, self).__init__(dbstate, obj) super(ClipName, self).__init__(dbstate, obj)
self._type = _("Name") self._type = _("Name")
self.refresh() self.refresh()
@ -566,14 +566,14 @@ class ScratchName(ScratchObjWrapper):
self._title = str(self._obj.get_type()) self._title = str(self._obj.get_type())
self._value = self._obj.get_name() self._value = self._obj.get_name()
class ScratchSurname(ScratchObjWrapper): class ClipSurname(ClipObjWrapper):
DROP_TARGETS = [DdTargets.SURNAME] DROP_TARGETS = [DdTargets.SURNAME]
DRAG_TARGET = DdTargets.SURNAME DRAG_TARGET = DdTargets.SURNAME
ICON = ICONS['name'] ICON = ICONS['name']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchSurname, self).__init__(dbstate, obj) super(ClipSurname, self).__init__(dbstate, obj)
self._type = _("Surname") self._type = _("Surname")
self.refresh() self.refresh()
@ -582,14 +582,14 @@ class ScratchSurname(ScratchObjWrapper):
self._title = self._obj.get_surname() self._title = self._obj.get_surname()
self._value = self._obj.get_surname() self._value = self._obj.get_surname()
class ScratchText(ScratchWrapper): class ClipText(ClipWrapper):
DROP_TARGETS = DdTargets.all_text() DROP_TARGETS = DdTargets.all_text()
DRAG_TARGET = DdTargets.TEXT DRAG_TARGET = DdTargets.TEXT
ICON = ICONS['text'] ICON = ICONS['text']
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchText, self).__init__(dbstate, obj) super(ClipText, self).__init__(dbstate, obj)
self._type = _("Text") self._type = _("Text")
self._pickle = self._obj self._pickle = self._obj
self.refresh() self.refresh()
@ -598,14 +598,14 @@ class ScratchText(ScratchWrapper):
self._title = _("Text") self._title = _("Text")
self._value = self._obj self._value = self._obj
class ScratchMediaObj(ScratchHandleWrapper): class ClipMediaObj(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.MEDIAOBJ] DROP_TARGETS = [DdTargets.MEDIAOBJ]
DRAG_TARGET = DdTargets.MEDIAOBJ DRAG_TARGET = DdTargets.MEDIAOBJ
ICON = ICONS["media"] ICON = ICONS["media"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchMediaObj, self).__init__(dbstate, obj) super(ClipMediaObj, self).__init__(dbstate, obj)
self._type = _("Media") self._type = _("Media")
self._objclass = 'Media' self._objclass = 'Media'
self.refresh() self.refresh()
@ -625,14 +625,14 @@ class ScratchMediaObj(ScratchHandleWrapper):
return True return True
return False return False
class ScratchMediaRef(ScratchObjWrapper): class ClipMediaRef(ClipObjWrapper):
DROP_TARGETS = [DdTargets.MEDIAREF] DROP_TARGETS = [DdTargets.MEDIAREF]
DRAG_TARGET = DdTargets.MEDIAREF DRAG_TARGET = DdTargets.MEDIAREF
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchMediaRef, self).__init__(dbstate, obj) super(ClipMediaRef, self).__init__(dbstate, obj)
self._type = _("Media ref") self._type = _("Media ref")
self.refresh() self.refresh()
@ -643,14 +643,14 @@ class ScratchMediaRef(ScratchObjWrapper):
self._title = base.get_description() self._title = base.get_description()
self._value = base.get_path() self._value = base.get_path()
class ScratchPersonRef(ScratchObjWrapper): class ClipPersonRef(ClipObjWrapper):
DROP_TARGETS = [DdTargets.PERSONREF] DROP_TARGETS = [DdTargets.PERSONREF]
DRAG_TARGET = DdTargets.PERSONREF DRAG_TARGET = DdTargets.PERSONREF
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchPersonRef, self).__init__(dbstate, obj) super(ClipPersonRef, self).__init__(dbstate, obj)
self._type = _("Person ref") self._type = _("Person ref")
self.refresh() self.refresh()
@ -661,14 +661,14 @@ class ScratchPersonRef(ScratchObjWrapper):
self._title = self._obj.get_relation() self._title = self._obj.get_relation()
self._value = person.get_primary_name().get_name() self._value = person.get_primary_name().get_name()
class ScratchChildRef(ScratchObjWrapper): class ClipChildRef(ClipObjWrapper):
DROP_TARGETS = [DdTargets.CHILDREF] DROP_TARGETS = [DdTargets.CHILDREF]
DRAG_TARGET = DdTargets.CHILDREF DRAG_TARGET = DdTargets.CHILDREF
ICON = LINK_PIC ICON = LINK_PIC
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchChildRef, self).__init__(dbstate, obj) super(ClipChildRef, self).__init__(dbstate, obj)
self._type = _("Child ref") self._type = _("Child ref")
self.refresh() self.refresh()
@ -682,14 +682,14 @@ class ScratchChildRef(ScratchObjWrapper):
'mrel': mrel} 'mrel': mrel}
self._value = person.get_primary_name().get_name() self._value = person.get_primary_name().get_name()
class ScratchPersonLink(ScratchHandleWrapper): class ClipPersonLink(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.PERSON_LINK] DROP_TARGETS = [DdTargets.PERSON_LINK]
DRAG_TARGET = DdTargets.PERSON_LINK DRAG_TARGET = DdTargets.PERSON_LINK
ICON = ICONS["person"] ICON = ICONS["person"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchPersonLink, self).__init__(dbstate, obj) super(ClipPersonLink, self).__init__(dbstate, obj)
self._type = _("Person") self._type = _("Person")
self._objclass = 'Person' self._objclass = 'Person'
self.refresh() self.refresh()
@ -710,14 +710,14 @@ class ScratchPersonLink(ScratchHandleWrapper):
return False return False
class ScratchFamilyLink(ScratchHandleWrapper): class ClipFamilyLink(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.FAMILY_LINK] DROP_TARGETS = [DdTargets.FAMILY_LINK]
DRAG_TARGET = DdTargets.FAMILY_LINK DRAG_TARGET = DdTargets.FAMILY_LINK
ICON = ICONS["family"] ICON = ICONS["family"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchFamilyLink, self).__init__(dbstate, obj) super(ClipFamilyLink, self).__init__(dbstate, obj)
self._type = _("Family") self._type = _("Family")
self._objclass = 'Family' self._objclass = 'Family'
self.refresh() self.refresh()
@ -739,14 +739,14 @@ class ScratchFamilyLink(ScratchHandleWrapper):
return True return True
return False return False
class ScratchSourceLink(ScratchHandleWrapper): class ClipSourceLink(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.SOURCE_LINK] DROP_TARGETS = [DdTargets.SOURCE_LINK]
DRAG_TARGET = DdTargets.SOURCE_LINK DRAG_TARGET = DdTargets.SOURCE_LINK
ICON = ICONS["source"] ICON = ICONS["source"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchSourceLink, self).__init__(dbstate, obj) super(ClipSourceLink, self).__init__(dbstate, obj)
self._type = _("Source") self._type = _("Source")
self._objclass = 'Source' self._objclass = 'Source'
self.refresh() self.refresh()
@ -766,14 +766,14 @@ class ScratchSourceLink(ScratchHandleWrapper):
return True return True
return False return False
class ScratchRepositoryLink(ScratchHandleWrapper): class ClipRepositoryLink(ClipHandleWrapper):
DROP_TARGETS = [DdTargets.REPO_LINK] DROP_TARGETS = [DdTargets.REPO_LINK]
DRAG_TARGET = DdTargets.REPO_LINK DRAG_TARGET = DdTargets.REPO_LINK
ICON = ICONS["repository"] ICON = ICONS["repository"]
def __init__(self, dbstate, obj): def __init__(self, dbstate, obj):
super(ScratchRepositoryLink, self).__init__(dbstate, obj) super(ClipRepositoryLink, self).__init__(dbstate, obj)
self._type = _("Repository") self._type = _("Repository")
self._objclass = 'Repository' self._objclass = 'Repository'
self.refresh() self.refresh()
@ -799,7 +799,7 @@ class ScratchRepositoryLink(ScratchHandleWrapper):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchDropList(object): class ClipDropList(object):
DROP_TARGETS = [DdTargets.LINK_LIST] DROP_TARGETS = [DdTargets.LINK_LIST]
DRAG_TARGET = None DRAG_TARGET = None
@ -818,13 +818,13 @@ class ScratchDropList(object):
retval.append(obj) retval.append(obj)
return retval return retval
class ScratchDropRawList(ScratchDropList): class ClipDropRawList(ClipDropList):
DROP_TARGETS = [DdTargets.RAW_LIST] DROP_TARGETS = [DdTargets.RAW_LIST]
DRAG_TARGET = None DRAG_TARGET = None
def __init__(self, dbstate, obj_list): def __init__(self, dbstate, obj_list):
self._dbstate = dbstate self._dbstate = dbstate
# ('raw-list', id, (ScratchObject, ScratchObject, ...), 0) # ('raw-list', id, (ClipObject, ClipObject, ...), 0)
self._obj_list = pickle.loads(obj_list) self._obj_list = pickle.loads(obj_list)
def get_objects(self): def get_objects(self):
@ -840,7 +840,7 @@ class ScratchDropRawList(ScratchDropList):
retval.append(obj) retval.append(obj)
return retval return retval
class ScratchDropHandleList(ScratchDropList): class ClipDropHandleList(ClipDropList):
DROP_TARGETS = [DdTargets.HANDLE_LIST] DROP_TARGETS = [DdTargets.HANDLE_LIST]
DRAG_TARGET = None DRAG_TARGET = None
@ -867,10 +867,10 @@ class ScratchDropHandleList(ScratchDropList):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ScratchPadListModel class # ClipboardListModel class
# Now shown as 'Clipboard' #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchPadListModel(gtk.ListStore): class ClipboardListModel(gtk.ListStore):
def __init__(self): def __init__(self):
gtk.ListStore.__init__(self, gtk.ListStore.__init__(self,
@ -886,10 +886,10 @@ class ScratchPadListModel(gtk.ListStore):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ScratchPadListView class # ClipboardListView class
# Now shown as 'Clipboard' #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchPadListView(object): class ClipboardListView(object):
LOCAL_DRAG_TARGET = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0) LOCAL_DRAG_TARGET = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)
LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW' LOCAL_DRAG_TYPE = 'MY_TREE_MODEL_ROW'
@ -950,7 +950,7 @@ class ScratchPadListView(object):
#self._widget.set_search_column(3) #self._widget.set_search_column(3)
self._widget.drag_dest_set(gtk.DEST_DEFAULT_ALL, self._widget.drag_dest_set(gtk.DEST_DEFAULT_ALL,
(ScratchPadListView.LOCAL_DRAG_TARGET,) + \ (ClipboardListView.LOCAL_DRAG_TARGET,) + \
DdTargets.all_targets(), DdTargets.all_targets(),
ACTION_COPY) ACTION_COPY)
@ -1049,31 +1049,31 @@ class ScratchPadListView(object):
# Method to manage the wrapper classes. # Method to manage the wrapper classes.
def register_wrapper_classes(self): def register_wrapper_classes(self):
self.register_wrapper_class(ScratchAddress) self.register_wrapper_class(ClipAddress)
self.register_wrapper_class(ScratchLocation) self.register_wrapper_class(ClipLocation)
self.register_wrapper_class(ScratchEvent) self.register_wrapper_class(ClipEvent)
self.register_wrapper_class(ScratchPlace) self.register_wrapper_class(ClipPlace)
self.register_wrapper_class(ScratchEventRef) self.register_wrapper_class(ClipEventRef)
self.register_wrapper_class(ScratchRepoRef) self.register_wrapper_class(ClipRepoRef)
self.register_wrapper_class(ScratchFamilyEvent) self.register_wrapper_class(ClipFamilyEvent)
self.register_wrapper_class(ScratchUrl) self.register_wrapper_class(ClipUrl)
self.register_wrapper_class(ScratchAttribute) self.register_wrapper_class(ClipAttribute)
self.register_wrapper_class(ScratchFamilyAttribute) self.register_wrapper_class(ClipFamilyAttribute)
self.register_wrapper_class(ScratchName) self.register_wrapper_class(ClipName)
self.register_wrapper_class(ScratchRepositoryLink) self.register_wrapper_class(ClipRepositoryLink)
self.register_wrapper_class(ScratchMediaObj) self.register_wrapper_class(ClipMediaObj)
self.register_wrapper_class(ScratchMediaRef) self.register_wrapper_class(ClipMediaRef)
self.register_wrapper_class(ScratchSourceLink) self.register_wrapper_class(ClipSourceLink)
self.register_wrapper_class(ScratchCitation) self.register_wrapper_class(ClipCitation)
self.register_wrapper_class(ScratchPersonLink) self.register_wrapper_class(ClipPersonLink)
self.register_wrapper_class(ScratchFamilyLink) self.register_wrapper_class(ClipFamilyLink)
self.register_wrapper_class(ScratchDropList) self.register_wrapper_class(ClipDropList)
self.register_wrapper_class(ScratchDropRawList) self.register_wrapper_class(ClipDropRawList)
self.register_wrapper_class(ScratchDropHandleList) self.register_wrapper_class(ClipDropHandleList)
self.register_wrapper_class(ScratchPersonRef) self.register_wrapper_class(ClipPersonRef)
self.register_wrapper_class(ScratchChildRef) self.register_wrapper_class(ClipChildRef)
self.register_wrapper_class(ScratchText) self.register_wrapper_class(ClipText)
self.register_wrapper_class(ScratchNote) self.register_wrapper_class(ClipNote)
def register_wrapper_class(self,wrapper_class): def register_wrapper_class(self,wrapper_class):
for drop_target in wrapper_class.DROP_TARGETS: for drop_target in wrapper_class.DROP_TARGETS:
@ -1117,9 +1117,9 @@ class ScratchPadListView(object):
model, paths = tree_selection.get_selected_rows() model, paths = tree_selection.get_selected_rows()
if len(paths) > 1: if len(paths) > 1:
targets = [(DdTargets.RAW_LIST.drag_type, gtk.TARGET_SAME_WIDGET, 0), targets = [(DdTargets.RAW_LIST.drag_type, gtk.TARGET_SAME_WIDGET, 0),
ScratchPadListView.LOCAL_DRAG_TARGET] ClipboardListView.LOCAL_DRAG_TARGET]
else: else:
targets = [ScratchPadListView.LOCAL_DRAG_TARGET] targets = [ClipboardListView.LOCAL_DRAG_TARGET]
for path in paths: for path in paths:
node = model.get_iter(path) node = model.get_iter(path)
if node is not None: if node is not None:
@ -1209,10 +1209,10 @@ class ScratchPadListView(object):
if dbname: if dbname:
o._dbname = dbname o._dbname = dbname
# If the wrapper object is a subclass of ScratchDropList then # If the wrapper object is a subclass of ClipDropList then
# the drag data was a list of objects and we need to decode # the drag data was a list of objects and we need to decode
# all of them. # all of them.
if isinstance(o,ScratchDropList): if isinstance(o,ClipDropList):
o_list = o.get_objects() o_list = o.get_objects()
else: else:
o_list = [o] o_list = [o]
@ -1264,13 +1264,12 @@ class ScratchPadListView(object):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# ScratchPadWindow class # ClipboardWindow class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class ScratchPadWindow(ManagedWindow): class ClipboardWindow(ManagedWindow):
""" """
The Clipboard (was ScratchPad) provides a temporary area to hold objects The Clipboard provides a temporary area to hold objects that can
that can
be reused accross multiple Person records. The pad provides a window be reused accross multiple Person records. The pad provides a window
onto which objects can be dropped and then dragged into new Person onto which objects can be dropped and then dragged into new Person
dialogs. The objects are stored as the pickles that are built by the dialogs. The objects are stored as the pickles that are built by the
@ -1286,15 +1285,15 @@ class ScratchPadWindow(ManagedWindow):
references of objects before attempting to use them. references of objects before attempting to use them.
""" """
# Class attribute used to hold the content of the # Class attribute used to hold the content of the Clipboard.
# Clipboard (was ScratchPad). A class attribute is used so that the content # A class attribute is used so that the content
# it preserved even when the Clipboard window is closed. # it preserved even when the Clipboard window is closed.
# As there is only ever one Clipboard we do not need to # As there is only ever one Clipboard we do not need to
# maintain a list of these. # maintain a list of these.
otree = None otree = None
def __init__(self, dbstate, uistate): def __init__(self, dbstate, uistate):
"""Initialize the ScratchPad class, and displays the window""" """Initialize the ClipboardWindow class, and display the window"""
ManagedWindow.__init__(self,uistate,[],self.__class__) ManagedWindow.__init__(self,uistate,[],self.__class__)
self.dbstate = dbstate self.dbstate = dbstate
@ -1316,37 +1315,37 @@ class ScratchPadWindow(ManagedWindow):
scrolledwindow = self.top.get_object('scrolledwindow86') scrolledwindow = self.top.get_object('scrolledwindow86')
scrolledwindow.remove(objectlist) scrolledwindow.remove(objectlist)
scrolledwindow.add_with_viewport(mtv) scrolledwindow.add_with_viewport(mtv)
self.object_list = ScratchPadListView(self.dbstate, mtv) self.object_list = ClipboardListView(self.dbstate, mtv)
self.object_list.get_selection().connect('changed', self.object_list.get_selection().connect('changed',
self.set_clear_btn_sensitivity) self.set_clear_btn_sensitivity)
self.object_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.object_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.set_clear_btn_sensitivity(sel=self.object_list.get_selection()) self.set_clear_btn_sensitivity(sel=self.object_list.get_selection())
if not ScratchPadWindow.otree: if not ClipboardWindow.otree:
ScratchPadWindow.otree = ScratchPadListModel() ClipboardWindow.otree = ClipboardListModel()
self.set_clear_all_btn_sensitivity(treemodel=ScratchPadWindow.otree) self.set_clear_all_btn_sensitivity(treemodel=ClipboardWindow.otree)
ScratchPadWindow.otree.connect('row-deleted', ClipboardWindow.otree.connect('row-deleted',
self.set_clear_all_btn_sensitivity) self.set_clear_all_btn_sensitivity)
ScratchPadWindow.otree.connect('row-inserted', ClipboardWindow.otree.connect('row-inserted',
self.set_clear_all_btn_sensitivity) self.set_clear_all_btn_sensitivity)
self.object_list.set_model(ScratchPadWindow.otree) self.object_list.set_model(ClipboardWindow.otree)
#Database might have changed, objects might have been removed, #Database might have changed, objects might have been removed,
#we need to reevaluate if all data is valid #we need to reevaluate if all data is valid
self.object_list.refresh_objects() self.object_list.refresh_objects()
self.top.connect_signals({ self.top.connect_signals({
"on_close_scratchpad" : self.close, "on_close_clipboard" : self.close,
"on_clear_clicked": self.on_clear_clicked, "on_clear_clicked": self.on_clear_clicked,
"on_help_clicked": self.on_help_clicked, "on_help_clicked": self.on_help_clicked,
}) })
self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear, self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear,
ScratchPadWindow.otree) ClipboardWindow.otree)
self.db.connect('database-changed', lambda x: ScratchPadWindow.otree.clear()) self.db.connect('database-changed', lambda x: ClipboardWindow.otree.clear())
self.show() self.show()
@ -1588,5 +1587,5 @@ def gen_del_obj(func, t):
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def ScratchPad(database,person,callback,parent=None): def Clipboard(database,person,callback,parent=None):
ScratchPadWindow(database,parent) ClipboardWindow(database,parent)

View File

@ -3,7 +3,7 @@ in glade.
Assuming you are in the root svn directory do: Assuming you are in the root svn directory do:
GLADE_CATALOG_PATH=src/glade/catalog glade GLADE_CATALOG_PATH=src/gui/glade/catalog glade
As project settings: As project settings:

View File

@ -2,7 +2,7 @@
<interface> <interface>
<!-- interface-requires gtk+ 2.12 --> <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual --> <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="scratchpad"> <object class="GtkDialog" id="clipboard">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Clipboard</property> <property name="title" translatable="yes">Clipboard</property>
<property name="default_width">500</property> <property name="default_width">500</property>
@ -89,7 +89,7 @@
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<signal name="clicked" handler="on_close_scratchpad"/> <signal name="clicked" handler="on_close_clipboard"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -39,6 +39,7 @@ import cPickle as pickle
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
from gtk.gdk import ACTION_COPY
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -50,7 +51,6 @@ from gen.simple import SimpleTable
from TransUtils import trans_objclass from TransUtils import trans_objclass
import Errors import Errors
from gui.widgets.multitreeview import MultiTreeView from gui.widgets.multitreeview import MultiTreeView
from ScratchPad import ScratchPadListView, ACTION_COPY
from DdTargets import DdTargets from DdTargets import DdTargets
from gui.plug.quick import run_quick_report_by_name from gui.plug.quick import run_quick_report_by_name
from gui.editors import (EditPerson, EditEvent, EditFamily, EditCitation, from gui.editors import (EditPerson, EditEvent, EditFamily, EditCitation,

View File

@ -138,7 +138,7 @@ UIDEFAULT = '''<ui>
<separator/> <separator/>
<placeholder name="TagMenu"/> <placeholder name="TagMenu"/>
<separator/> <separator/>
<menuitem action="ScratchPad"/> <menuitem action="Clipboard"/>
<separator/> <separator/>
<menuitem action="Preferences"/> <menuitem action="Preferences"/>
</menu> </menu>
@ -186,7 +186,7 @@ UIDEFAULT = '''<ui>
<toolbar name="ToolBar"> <toolbar name="ToolBar">
<placeholder name="CommonNavigation"/> <placeholder name="CommonNavigation"/>
<separator/> <separator/>
<toolitem action="ScratchPad"/> <toolitem action="Clipboard"/>
<toolitem action="Reports"/> <toolitem action="Reports"/>
<toolitem action="Tools"/> <toolitem action="Tools"/>
<separator/> <separator/>
@ -819,8 +819,8 @@ class ViewManager(CLIManager):
] ]
self._action_action_list = [ self._action_action_list = [
('ScratchPad', gtk.STOCK_PASTE, _('Clip_board'), "<control>b", ('Clipboard', gtk.STOCK_PASTE, _('Clip_board'), "<control>b",
_("Open the Clipboard dialog"), self.scratchpad), _("Open the Clipboard dialog"), self.clipboard),
('Import', 'gramps-import', _('_Import...'), "<control>i", None, ('Import', 'gramps-import', _('_Import...'), "<control>i", None,
self.import_data), self.import_data),
('Tools', 'gramps-tools', _('_Tools'), None, ('Tools', 'gramps-tools', _('_Tools'), None,
@ -1662,13 +1662,13 @@ class ViewManager(CLIManager):
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return
def scratchpad(self, obj): def clipboard(self, obj):
""" """
Displays the Clipboard (was scratchpad) Displays the Clipboard
""" """
import ScratchPad from gui.clipboard import ClipboardWindow
try: try:
ScratchPad.ScratchPadWindow(self.dbstate, self.uistate) ClipboardWindow(self.dbstate, self.uistate)
except Errors.WindowActiveError: except Errors.WindowActiveError:
return return

View File

@ -231,17 +231,17 @@ class PageView(DbGUIElement):
system. system.
""" """
import cPickle as pickle import cPickle as pickle
from ScratchPad import ScratchPadWindow, obj2target from gui.clipboard import ClipboardWindow, obj2target
handled = False handled = False
for handle in handles: for handle in handles:
if handle is None: if handle is None:
continue continue
clipboard = None clipboard = None
for widget in self.uistate.gwm.window_tree: for widget in self.uistate.gwm.window_tree:
if isinstance(widget, ScratchPadWindow): if isinstance(widget, ClipboardWindow):
clipboard = widget clipboard = widget
if clipboard is None: if clipboard is None:
clipboard = ScratchPadWindow(self.dbstate, self.uistate) clipboard = ClipboardWindow(self.dbstate, self.uistate)
# Construct a drop: # Construct a drop:
drag_type = obj2target(objclass) drag_type = obj2target(objclass)
if drag_type: if drag_type:
@ -270,13 +270,13 @@ 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 ScratchPad import ScratchPadWindow, obj2target from gui.clipboard import ClipboardWindow, obj2target
clipboard = None clipboard = None
for widget in self.uistate.gwm.window_tree: for widget in self.uistate.gwm.window_tree:
if isinstance(widget, ScratchPadWindow): if isinstance(widget, ClipboardWindow):
clipboard = widget clipboard = widget
if clipboard is None: if clipboard is None:
clipboard = ScratchPadWindow(self.dbstate, self.uistate) clipboard = ClipboardWindow(self.dbstate, self.uistate)
return True return True
return False return False