* src/RepositoryView.py: added back in
* src/gramps_main.py: added repository view svn: r5057
This commit is contained in:
parent
a63a354c77
commit
a3ec0b3e07
@ -1,3 +1,7 @@
|
|||||||
|
2005-08-11 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/RepositoryView.py: added back in
|
||||||
|
* src/gramps_main.py: added repository view
|
||||||
|
|
||||||
2005-08-11 Alex Roitman <shura@gramps-project.org>
|
2005-08-11 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/DbState.py: Remove modeule.
|
* src/DbState.py: Remove modeule.
|
||||||
* src/DisplayState.py: Rename from DbState, kepp only DisplayState
|
* src/DisplayState.py: Rename from DbState, kepp only DisplayState
|
||||||
|
@ -70,10 +70,10 @@ class PlaceView(PageView.ListView):
|
|||||||
def __init__(self,dbstate,uistate):
|
def __init__(self,dbstate,uistate):
|
||||||
|
|
||||||
signal_map = {
|
signal_map = {
|
||||||
'event-add' : self.row_add,
|
'place-add' : self.row_add,
|
||||||
'event-update' : self.row_update,
|
'place-update' : self.row_update,
|
||||||
'event-delete' : self.row_delete,
|
'place-delete' : self.row_delete,
|
||||||
'event-rebuild' : self.build_tree,
|
'place-rebuild' : self.build_tree,
|
||||||
}
|
}
|
||||||
|
|
||||||
PageView.ListView.__init__(self,'Place View',dbstate,uistate,
|
PageView.ListView.__init__(self,'Place View',dbstate,uistate,
|
||||||
|
@ -33,6 +33,7 @@ import gtk.gdk
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import RelLib
|
import RelLib
|
||||||
|
import PageView
|
||||||
import EditRepository
|
import EditRepository
|
||||||
import DisplayModels
|
import DisplayModels
|
||||||
import const
|
import const
|
||||||
@ -46,7 +47,6 @@ from QuestionDialog import QuestionDialog, ErrorDialog
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
|
||||||
column_names = [
|
column_names = [
|
||||||
_('Name'),
|
_('Name'),
|
||||||
_('ID'),
|
_('ID'),
|
||||||
@ -61,222 +61,100 @@ column_names = [
|
|||||||
_('Search URL'),
|
_('Search URL'),
|
||||||
]
|
]
|
||||||
|
|
||||||
_HANDLE_COL = 12
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# RepositoryView
|
# RepositoryView
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class RepositoryView:
|
class RepositoryView(PageView.ListView):
|
||||||
def __init__(self,parent,db,glade):
|
def __init__(self,dbstate,uistate):
|
||||||
self.parent = parent
|
|
||||||
self.parent.connect('database-changed',self.change_db)
|
|
||||||
|
|
||||||
self.glade = glade
|
signal_map = {
|
||||||
self.list = glade.get_widget("repository_list")
|
'repository-add' : self.row_add,
|
||||||
self.list.connect('button-press-event',self.button_press)
|
'repository-update' : self.row_update,
|
||||||
self.list.connect('key-press-event',self.key_press)
|
'repository-delete' : self.row_delete,
|
||||||
self.selection = self.list.get_selection()
|
'repository-rebuild' : self.build_tree,
|
||||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
}
|
||||||
self.renderer = gtk.CellRendererText()
|
|
||||||
self.model = DisplayModels.RepositoryModel(self.parent.db,0)
|
|
||||||
self.sort_col = 0
|
|
||||||
|
|
||||||
self.list.set_model(self.model)
|
PageView.ListView.__init__(self,'Repository View',dbstate,uistate,
|
||||||
self.list.set_headers_clickable(True)
|
column_names,len(column_names),
|
||||||
self.topWindow = self.glade.get_widget("gramps")
|
DisplayModels.RepositoryModel,
|
||||||
|
signal_map)
|
||||||
|
|
||||||
self.columns = []
|
def column_order(self):
|
||||||
self.change_db(db)
|
return self.dbstate.db.get_repository_column_order()
|
||||||
|
|
||||||
def column_clicked(self,obj,data):
|
def get_stock(self):
|
||||||
if self.sort_col != data:
|
return 'gramps-repository'
|
||||||
order = gtk.SORT_ASCENDING
|
|
||||||
else:
|
def ui_definition(self):
|
||||||
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
return '''<ui>
|
||||||
or self.columns[data].get_sort_indicator() == False):
|
<menubar name="MenuBar">
|
||||||
order = gtk.SORT_ASCENDING
|
<menu action="EditMenu">
|
||||||
else:
|
<placeholder name="CommonEdit">
|
||||||
order = gtk.SORT_DESCENDING
|
<menuitem action="Add"/>
|
||||||
self.sort_col = data
|
<menuitem action="Edit"/>
|
||||||
|
<menuitem action="Remove"/>
|
||||||
|
</placeholder>
|
||||||
|
</menu>
|
||||||
|
</menubar>
|
||||||
|
<toolbar name="ToolBar">
|
||||||
|
<placeholder name="CommonEdit">
|
||||||
|
<toolitem action="Add"/>
|
||||||
|
<toolitem action="Edit"/>
|
||||||
|
<toolitem action="Remove"/>
|
||||||
|
</placeholder>
|
||||||
|
</toolbar>
|
||||||
|
<popup name="Popup">
|
||||||
|
<menuitem action="Add"/>
|
||||||
|
<menuitem action="Edit"/>
|
||||||
|
<menuitem action="Remove"/>
|
||||||
|
</popup>
|
||||||
|
</ui>'''
|
||||||
|
|
||||||
|
def on_double_click(self,obj,event):
|
||||||
handle = self.first_selected()
|
handle = self.first_selected()
|
||||||
self.model = DisplayModels.RepositoryModel(self.parent.db,
|
place = self.dbstate.db.get_place_from_handle(handle)
|
||||||
self.sort_col,order)
|
EditRepository.EditRepository(place,self.dbstate, self.uistate)
|
||||||
self.list.set_model(self.model)
|
|
||||||
colmap = self.parent.db.get_repository_column_order()
|
|
||||||
|
|
||||||
if handle:
|
def add(self,obj):
|
||||||
path = self.model.on_get_path(handle)
|
EditRepository.EditRepository(RelLib.Repository(),self.dbstate, self.uistate)
|
||||||
self.selection.select_path(path)
|
|
||||||
self.list.scroll_to_cell(path,None,1,0.5,0)
|
|
||||||
for i in range(0,len(self.columns)):
|
|
||||||
self.columns[i].set_sort_indicator(i==colmap[data][1]-1)
|
|
||||||
self.columns[self.sort_col].set_sort_order(order)
|
|
||||||
|
|
||||||
def build_columns(self):
|
def remove(self,obj):
|
||||||
for column in self.columns:
|
for event_handle in self.selected_handles():
|
||||||
self.list.remove_column(column)
|
db = self.dbstate.db
|
||||||
|
person_list = [ handle for handle in
|
||||||
|
db.get_person_handles(False)
|
||||||
|
if db.get_person_from_handle(handle).has_handle_reference('Repository',event_handle) ]
|
||||||
|
family_list = [ handle for handle in
|
||||||
|
db.get_family_handles()
|
||||||
|
if db.get_family_from_handle(handle).has_handle_reference('Repository',event_handle) ]
|
||||||
|
|
||||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
event = db.get_event_from_handle(event_handle)
|
||||||
column.set_resizable(True)
|
|
||||||
column.set_min_width(225)
|
|
||||||
column.set_clickable(True)
|
|
||||||
column.connect('clicked',self.column_clicked,0)
|
|
||||||
self.list.append_column(column)
|
|
||||||
self.columns = [column]
|
|
||||||
|
|
||||||
index = 1
|
ans = EditRepository.DelRepositoryQuery(event,db,
|
||||||
for pair in self.parent.db.get_repository_column_order():
|
person_list,family_list)
|
||||||
if not pair[0]:
|
|
||||||
continue
|
|
||||||
name = column_names[pair[1]]
|
|
||||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
|
||||||
column.connect('clicked',self.column_clicked,index)
|
|
||||||
column.set_resizable(True)
|
|
||||||
column.set_min_width(75)
|
|
||||||
column.set_clickable(True)
|
|
||||||
self.columns.append(column)
|
|
||||||
self.list.append_column(column)
|
|
||||||
index += 1
|
|
||||||
|
|
||||||
def change_db(self,db):
|
if len(person_list) + len(family_list) > 0:
|
||||||
db.connect('repository-add', self.repository_add)
|
msg = _('This place is currently being used. Deleting it '
|
||||||
db.connect('repository-update', self.repository_update)
|
|
||||||
db.connect('repository-delete', self.repository_delete)
|
|
||||||
db.connect('repository-rebuild',self.build_tree)
|
|
||||||
self.build_columns()
|
|
||||||
self.build_tree()
|
|
||||||
|
|
||||||
def build_tree(self):
|
|
||||||
self.list.set_model(None)
|
|
||||||
self.model = DisplayModels.RepositoryModel(self.parent.db,self.sort_col)
|
|
||||||
self.list.set_model(self.model)
|
|
||||||
self.selection = self.list.get_selection()
|
|
||||||
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
|
|
||||||
|
|
||||||
def button_press(self,obj,event):
|
|
||||||
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
handle = mlist[0]
|
|
||||||
repository = self.parent.db.get_repository_from_handle(handle)
|
|
||||||
EditRepository.EditRepository(repository,self.parent.db,self.parent,
|
|
||||||
self.topWindow)
|
|
||||||
return True
|
|
||||||
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
||||||
self.build_context_menu(event)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def key_press(self,obj,event):
|
|
||||||
if event.keyval == gtk.gdk.keyval_from_name("Return") \
|
|
||||||
and not event.state:
|
|
||||||
self.on_edit_clicked(obj)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def build_context_menu(self,event):
|
|
||||||
"""Builds the menu with editing operations on the repository's list"""
|
|
||||||
|
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
if mlist:
|
|
||||||
sel_sensitivity = 1
|
|
||||||
else:
|
|
||||||
sel_sensitivity = 0
|
|
||||||
|
|
||||||
entries = [
|
|
||||||
(gtk.STOCK_ADD, self.on_add_clicked,1),
|
|
||||||
(gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity),
|
|
||||||
(_("Edit"), self.on_edit_clicked,sel_sensitivity),
|
|
||||||
]
|
|
||||||
|
|
||||||
menu = gtk.Menu()
|
|
||||||
menu.set_title(_('Repository Menu'))
|
|
||||||
for stock_id,callback,sensitivity in entries:
|
|
||||||
item = gtk.ImageMenuItem(stock_id)
|
|
||||||
if callback:
|
|
||||||
item.connect("activate",callback)
|
|
||||||
item.set_sensitive(sensitivity)
|
|
||||||
item.show()
|
|
||||||
menu.append(item)
|
|
||||||
menu.popup(None,None,None,event.button,event.time)
|
|
||||||
|
|
||||||
def on_add_clicked(self,obj):
|
|
||||||
EditRepository.EditRepository(RelLib.Repository(),self.parent.db,self.parent,
|
|
||||||
self.topWindow)
|
|
||||||
|
|
||||||
def on_delete_clicked(self,obj):
|
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
|
|
||||||
for repos_handle in mlist:
|
|
||||||
|
|
||||||
source_list = [ src_handle for src_handle \
|
|
||||||
in self.parent.db.get_source_handles() \
|
|
||||||
if self.parent.db.get_source_from_handle(src_handle).has_repo_reference(repos_handle)]
|
|
||||||
|
|
||||||
repository = self.parent.db.get_repository_from_handle(repos_handle)
|
|
||||||
|
|
||||||
ans = EditRepository.DelReposQuery(repository,self.parent.db,source_list)
|
|
||||||
|
|
||||||
if len(source_list) > 0:
|
|
||||||
msg = _('This repository is currently being used. Deleting it '
|
|
||||||
'will remove it from the database and from all '
|
'will remove it from the database and from all '
|
||||||
'sources that reference it.')
|
'people and families that reference it.')
|
||||||
else:
|
else:
|
||||||
msg = _('Deleting repository will remove it from the database.')
|
msg = _('Deleting place will remove it from the database.')
|
||||||
|
|
||||||
msg = "%s %s" % (msg,Utils.data_recover_msg)
|
msg = "%s %s" % (msg,Utils.data_recover_msg)
|
||||||
QuestionDialog(_('Delete %s?') % repository.get_name(), msg,
|
descr = event.get_description()
|
||||||
_('_Delete Repository'),ans.query_response,
|
if descr == "":
|
||||||
self.topWindow)
|
descr = event.get_gramps_id()
|
||||||
|
|
||||||
def on_edit_clicked(self,obj):
|
QuestionDialog(_('Delete %s?') % descr, msg,
|
||||||
|
_('_Delete Repository'),ans.query_response)
|
||||||
|
|
||||||
|
def edit(self,obj):
|
||||||
mlist = []
|
mlist = []
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
self.selection.selected_foreach(self.blist,mlist)
|
||||||
|
|
||||||
for handle in mlist:
|
for handle in mlist:
|
||||||
repository = self.parent.db.get_repository_from_handle(handle)
|
place = self.dbstate.db.get_place_from_handle(handle)
|
||||||
EditRepository.EditRepository(repository, self.parent.db, self.parent,
|
EditRepository.EditRepository(place, self.dbstate, self.uistate)
|
||||||
self.topWindow)
|
|
||||||
|
|
||||||
def repository_add(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.add_row_by_handle(handle)
|
|
||||||
|
|
||||||
def repository_update(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.update_row_by_handle(handle)
|
|
||||||
|
|
||||||
def repository_delete(self,handle_list):
|
|
||||||
for handle in handle_list:
|
|
||||||
self.model.delete_row_by_handle(handle)
|
|
||||||
|
|
||||||
def first_selected(self):
|
|
||||||
mlist = []
|
|
||||||
self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
if mlist:
|
|
||||||
return mlist[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def blist(self,store,path,iter,sel_list):
|
|
||||||
handle = store.get_value(iter,_HANDLE_COL)
|
|
||||||
sel_list.append(handle)
|
|
||||||
|
|
||||||
## def merge(self):
|
|
||||||
## mlist = []
|
|
||||||
## self.selection.selected_foreach(self.blist,mlist)
|
|
||||||
|
|
||||||
## if len(mlist) != 2:
|
|
||||||
## msg = _("Cannot merge repositorys.")
|
|
||||||
## msg2 = _("Exactly two repositorys must be selected to perform a merge. "
|
|
||||||
## "A second repository can be selected by holding down the "
|
|
||||||
## "control key while clicking on the desired repository.")
|
|
||||||
## ErrorDialog(msg,msg2)
|
|
||||||
## else:
|
|
||||||
## import MergeData
|
|
||||||
## MergeData.MergeRepositorys(self.parent.db,mlist[0],mlist[1],
|
|
||||||
## self.build_tree)
|
|
||||||
|
@ -65,10 +65,10 @@ class SourceView(PageView.ListView):
|
|||||||
def __init__(self,dbstate,uistate):
|
def __init__(self,dbstate,uistate):
|
||||||
|
|
||||||
signal_map = {
|
signal_map = {
|
||||||
'event-add' : self.row_add,
|
'source-add' : self.row_add,
|
||||||
'event-update' : self.row_update,
|
'source-update' : self.row_update,
|
||||||
'event-delete' : self.row_delete,
|
'source-delete' : self.row_delete,
|
||||||
'event-rebuild' : self.build_tree,
|
'source-rebuild' : self.build_tree,
|
||||||
}
|
}
|
||||||
|
|
||||||
PageView.ListView.__init__(self,'Source View',dbstate,uistate,
|
PageView.ListView.__init__(self,'Source View',dbstate,uistate,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
import gtk
|
import gtk
|
||||||
import ViewManager
|
import ViewManager
|
||||||
import PersonView
|
import PersonView
|
||||||
|
import RepositoryView
|
||||||
import PedView
|
import PedView
|
||||||
import MapView
|
import MapView
|
||||||
import PlaceView
|
import PlaceView
|
||||||
@ -169,6 +170,7 @@ class Gramps:
|
|||||||
a.register_view(SourceView.SourceView)
|
a.register_view(SourceView.SourceView)
|
||||||
a.register_view(PlaceView.PlaceView)
|
a.register_view(PlaceView.PlaceView)
|
||||||
a.register_view(MapView.MapView)
|
a.register_view(MapView.MapView)
|
||||||
|
a.register_view(RepositoryView.RepositoryView)
|
||||||
a.init_interface()
|
a.init_interface()
|
||||||
|
|
||||||
if GrampsKeys.get_usetips():
|
if GrampsKeys.get_usetips():
|
||||||
|
Loading…
Reference in New Issue
Block a user