2006-11-05 Don Allingham <don@gramps-project.org>
* src/DataViews/_PlaceView.py: drag-n-drop support * src/GrampsWidgets.py: drag-n-drop support for place selector widget * src/ScratchPad.py: drag-n-drop support for places * src/DdTargets.py: drag-n-drop support for places svn: r7555
This commit is contained in:
parent
7b89307797
commit
a1c363e4bd
@ -1,3 +1,9 @@
|
|||||||
|
2006-11-05 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/DataViews/_PlaceView.py: drag-n-drop support
|
||||||
|
* src/GrampsWidgets.py: drag-n-drop support for place selector widget
|
||||||
|
* src/ScratchPad.py: drag-n-drop support for places
|
||||||
|
* src/DdTargets.py: drag-n-drop support for places
|
||||||
|
|
||||||
2006-11-05 Alex Roitman <shura@gramps-project.org>
|
2006-11-05 Alex Roitman <shura@gramps-project.org>
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
* configure.in (ALL_LINGUAS): Add Turkish language.
|
* configure.in (ALL_LINGUAS): Add Turkish language.
|
||||||
|
@ -39,6 +39,7 @@ import Errors
|
|||||||
import Bookmarks
|
import Bookmarks
|
||||||
import const
|
import const
|
||||||
import Config
|
import Config
|
||||||
|
from DdTargets import DdTargets
|
||||||
from Editors import EditPlace, DeletePlaceQuery
|
from Editors import EditPlace, DeletePlaceQuery
|
||||||
from QuestionDialog import QuestionDialog, ErrorDialog
|
from QuestionDialog import QuestionDialog, ErrorDialog
|
||||||
from Filters.SideBar import PlaceSidebarFilter
|
from Filters.SideBar import PlaceSidebarFilter
|
||||||
@ -111,6 +112,9 @@ class PlaceView(PageView.ListView):
|
|||||||
self.add_action('FilterEdit', None, _('Place Filter Editor'),
|
self.add_action('FilterEdit', None, _('Place Filter Editor'),
|
||||||
callback=self.filter_editor,)
|
callback=self.filter_editor,)
|
||||||
|
|
||||||
|
def drag_info(self):
|
||||||
|
return DdTargets.PLACE_LINK
|
||||||
|
|
||||||
def filter_toggle(self, client, cnxn_id, etnry, data):
|
def filter_toggle(self, client, cnxn_id, etnry, data):
|
||||||
if Config.get(Config.FILTER):
|
if Config.get(Config.FILTER):
|
||||||
self.search_bar.hide()
|
self.search_bar.hide()
|
||||||
|
@ -115,6 +115,7 @@ class _DdTargets(object):
|
|||||||
self.SOURCEREF = _DdType(self,'srcref')
|
self.SOURCEREF = _DdType(self,'srcref')
|
||||||
self.REPOREF = _DdType(self,'reporef')
|
self.REPOREF = _DdType(self,'reporef')
|
||||||
self.REPO_LINK = _DdType(self,'repo-link')
|
self.REPO_LINK = _DdType(self,'repo-link')
|
||||||
|
self.PLACE_LINK= _DdType(self,'place-link')
|
||||||
self.NAME = _DdType(self,'name')
|
self.NAME = _DdType(self,'name')
|
||||||
self.MEDIAOBJ = _DdType(self,'mediaobj')
|
self.MEDIAOBJ = _DdType(self,'mediaobj')
|
||||||
self.MEDIAREF = _DdType(self,'mediaref')
|
self.MEDIAREF = _DdType(self,'mediaref')
|
||||||
@ -143,6 +144,7 @@ class _DdTargets(object):
|
|||||||
self.MEDIAOBJ,
|
self.MEDIAOBJ,
|
||||||
self.MEDIAREF,
|
self.MEDIAREF,
|
||||||
self.REPO_LINK,
|
self.REPO_LINK,
|
||||||
|
self.PLACE_LINK,
|
||||||
self.SOURCE_LINK,
|
self.SOURCE_LINK,
|
||||||
self.PERSON_LINK,
|
self.PERSON_LINK,
|
||||||
self.PERSON_LINK_LIST]
|
self.PERSON_LINK_LIST]
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
import cgi
|
import cgi
|
||||||
import os
|
import os
|
||||||
|
import cPickle as pickle
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -38,6 +39,7 @@ import DateHandler
|
|||||||
import DateEdit
|
import DateEdit
|
||||||
import const
|
import const
|
||||||
import Errors
|
import Errors
|
||||||
|
from DdTargets import DdTargets
|
||||||
|
|
||||||
_lock_path = os.path.join(const.image_dir, 'stock_lock.png')
|
_lock_path = os.path.join(const.image_dir, 'stock_lock.png')
|
||||||
_lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png')
|
_lock_open_path = os.path.join(const.image_dir, 'stock_lock-open.png')
|
||||||
@ -531,6 +533,10 @@ class PlaceEntry:
|
|||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
self.track = track
|
self.track = track
|
||||||
|
|
||||||
|
self.obj.drag_dest_set(gtk.DEST_DEFAULT_ALL, [DdTargets.PLACE_LINK.target()],
|
||||||
|
gtk.gdk.ACTION_COPY)
|
||||||
|
self.obj.connect('drag_data_received', self.drag_data_received)
|
||||||
|
|
||||||
if get_val():
|
if get_val():
|
||||||
self.set_button(True)
|
self.set_button(True)
|
||||||
p = self.db.get_place_from_handle(self.get_val())
|
p = self.db.get_place_from_handle(self.get_val())
|
||||||
@ -571,6 +577,12 @@ class PlaceEntry:
|
|||||||
except Errors.WindowActiveError:
|
except Errors.WindowActiveError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def drag_data_received(self, widget, context, x, y, selection, info, time):
|
||||||
|
(drag_type, idval, obj, val) = pickle.loads(selection.data)
|
||||||
|
|
||||||
|
data = self.db.get_place_from_handle(obj)
|
||||||
|
self.place_added(data)
|
||||||
|
|
||||||
def place_added(self, data):
|
def place_added(self, data):
|
||||||
self.set_val(data.handle)
|
self.set_val(data.handle)
|
||||||
self.obj.set_text("%s [%s]" % (data.get_title(),data.gramps_id))
|
self.obj.set_text("%s [%s]" % (data.get_title(),data.gramps_id))
|
||||||
|
@ -256,6 +256,35 @@ class ScratchPadEvent(ScratchPadWrapper):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class ScratchPadPlace(ScratchPadWrapper):
|
||||||
|
|
||||||
|
DROP_TARGETS = [DdTargets.PLACE_LINK]
|
||||||
|
DRAG_TARGET = DdTargets.PLACE_LINK
|
||||||
|
ICON = LINK_PIC
|
||||||
|
|
||||||
|
def __init__(self,dbstate,obj):
|
||||||
|
ScratchPadWrapper.__init__(self,dbstate,obj)
|
||||||
|
self._type = _("Place")
|
||||||
|
|
||||||
|
(drag_type, idval, handle, val) = pickle.loads(obj)
|
||||||
|
|
||||||
|
value = self._db.get_place_from_handle(handle)
|
||||||
|
|
||||||
|
self._title = value.get_title()
|
||||||
|
self._value = "" #value.get_description()
|
||||||
|
|
||||||
|
def tooltip(self):
|
||||||
|
global escape
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def is_valid(self):
|
||||||
|
data = pickle.loads(self._obj)
|
||||||
|
handle = data[2]
|
||||||
|
obj = self._db.get_place_from_handle(handle)
|
||||||
|
if obj:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
|
class ScratchPadFamilyEvent(ScratchPadGrampsTypeWrapper):
|
||||||
|
|
||||||
DROP_TARGETS = [DdTargets.FAMILY_EVENT]
|
DROP_TARGETS = [DdTargets.FAMILY_EVENT]
|
||||||
@ -786,7 +815,6 @@ class ScratchPadListView:
|
|||||||
'family-delete',
|
'family-delete',
|
||||||
'family-rebuild',
|
'family-rebuild',
|
||||||
'source-update',
|
'source-update',
|
||||||
'source-delete',
|
|
||||||
'source-rebuild',
|
'source-rebuild',
|
||||||
'place-update',
|
'place-update',
|
||||||
'place-delete',
|
'place-delete',
|
||||||
@ -795,16 +823,18 @@ class ScratchPadListView:
|
|||||||
'media-delete',
|
'media-delete',
|
||||||
'media-rebuild',
|
'media-rebuild',
|
||||||
'event-update',
|
'event-update',
|
||||||
'event-delete',
|
|
||||||
'event-rebuild',
|
'event-rebuild',
|
||||||
'repository-update',
|
'repository-update',
|
||||||
'repository-delete',
|
|
||||||
'repository-rebuild'
|
'repository-rebuild'
|
||||||
)
|
)
|
||||||
|
|
||||||
for signal in db_signals:
|
for signal in db_signals:
|
||||||
self._db.connect(signal,self.remove_invalid_objects)
|
self._db.connect(signal,self.remove_invalid_objects)
|
||||||
self._db.connect('person-delete', self.person_delete)
|
|
||||||
|
self._db.connect('person-delete', gen_del_obj(self.delete_object, 'person-link'))
|
||||||
|
self._db.connect('source-delete', gen_del_obj(self.delete_object, 'source-link'))
|
||||||
|
self._db.connect('repository-delete', gen_del_obj(self.delete_object, 'repo-link'))
|
||||||
|
self._db.connect('event-delete', gen_del_obj(self.delete_object, 'pevent'))
|
||||||
|
|
||||||
self.remove_invalid_objects()
|
self.remove_invalid_objects()
|
||||||
|
|
||||||
@ -816,13 +846,12 @@ class ScratchPadListView:
|
|||||||
if not o[1].is_valid():
|
if not o[1].is_valid():
|
||||||
model.remove(o.iter)
|
model.remove(o.iter)
|
||||||
|
|
||||||
def person_delete(self, handle_list):
|
def delete_object(self, handle_list, link_type):
|
||||||
|
|
||||||
model = self._widget.get_model()
|
model = self._widget.get_model()
|
||||||
|
|
||||||
if model:
|
if model:
|
||||||
for o in model:
|
for o in model:
|
||||||
if o[0] == 'person-link':
|
if o[0] == link_type:
|
||||||
data = pickle.loads(o[1]._obj)
|
data = pickle.loads(o[1]._obj)
|
||||||
if data[2] in handle_list:
|
if data[2] in handle_list:
|
||||||
model.remove(o.iter)
|
model.remove(o.iter)
|
||||||
@ -833,6 +862,7 @@ class ScratchPadListView:
|
|||||||
self.register_wrapper_class(ScratchPadAddress)
|
self.register_wrapper_class(ScratchPadAddress)
|
||||||
self.register_wrapper_class(ScratchPadLocation)
|
self.register_wrapper_class(ScratchPadLocation)
|
||||||
self.register_wrapper_class(ScratchPadEvent)
|
self.register_wrapper_class(ScratchPadEvent)
|
||||||
|
self.register_wrapper_class(ScratchPadPlace)
|
||||||
self.register_wrapper_class(ScratchPadEventRef)
|
self.register_wrapper_class(ScratchPadEventRef)
|
||||||
self.register_wrapper_class(ScratchPadSourceRef)
|
self.register_wrapper_class(ScratchPadSourceRef)
|
||||||
self.register_wrapper_class(ScratchPadRepoRef)
|
self.register_wrapper_class(ScratchPadRepoRef)
|
||||||
@ -853,7 +883,6 @@ class ScratchPadListView:
|
|||||||
for drop_target in wrapper_class.DROP_TARGETS:
|
for drop_target in wrapper_class.DROP_TARGETS:
|
||||||
self._target_type_to_wrapper_class_map[drop_target.drag_type] = wrapper_class
|
self._target_type_to_wrapper_class_map[drop_target.drag_type] = wrapper_class
|
||||||
|
|
||||||
|
|
||||||
# Methods for rendering the cells.
|
# Methods for rendering the cells.
|
||||||
|
|
||||||
def object_pixbuf(self, column, cell, model, node, user_data=None):
|
def object_pixbuf(self, column, cell, model, node, user_data=None):
|
||||||
@ -867,7 +896,6 @@ class ScratchPadListView:
|
|||||||
def object_title(self, column, cell, model, node, user_data=None):
|
def object_title(self, column, cell, model, node, user_data=None):
|
||||||
o = model.get_value(node, 1)
|
o = model.get_value(node, 1)
|
||||||
cell.set_property('text', o.get_title())
|
cell.set_property('text', o.get_title())
|
||||||
|
|
||||||
|
|
||||||
def object_value(self, column, cell, model, node, user_data=None):
|
def object_value(self, column, cell, model, node, user_data=None):
|
||||||
o = model.get_value(node, 1)
|
o = model.get_value(node, 1)
|
||||||
@ -918,7 +946,7 @@ class ScratchPadListView:
|
|||||||
# the time values are the same so we can drop all but the first.
|
# the time values are the same so we can drop all but the first.
|
||||||
if realTime == self._previous_drop_time:
|
if realTime == self._previous_drop_time:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Find a wrapper class
|
# Find a wrapper class
|
||||||
possible_wrappers = [target for target in context.targets \
|
possible_wrappers = [target for target in context.targets \
|
||||||
if target in self._target_type_to_wrapper_class_map.keys()]
|
if target in self._target_type_to_wrapper_class_map.keys()]
|
||||||
@ -1100,6 +1128,9 @@ def place_title(db,event):
|
|||||||
else:
|
else:
|
||||||
return u''
|
return u''
|
||||||
|
|
||||||
|
def gen_del_obj(func, t):
|
||||||
|
return lambda l : func(l, t)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user