2005-08-12 Richard Taylor <rjt-gramps@thegrindstone.me.uk>

* src/EditRepository.py: fixes for lack of parent window handles
	use of dbstate. Commented out code to bold labels for now as
	Utils.bold_label does not work. Renamed DelReposQuery.
	* src/EditSource.py: fixed repository ref edit code to use dbstate.
	* src/RepositoryRefEdit.py: fixes for dbstate and commented out window
	management code.
	* src/RepositoryView.py: fixes for dbstate, commented out remove repos
	code for now as it does not work. Fixes edit repository call.


svn: r5092
This commit is contained in:
Richard Taylor 2005-08-17 09:30:10 +00:00
parent e44cf47799
commit da29072138
5 changed files with 81 additions and 63 deletions

View File

@ -1,3 +1,13 @@
2005-08-12 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/EditRepository.py: fixes for lack of parent window handles
use of dbstate. Commented out code to bold labels for now as
Utils.bold_label does not work. Renamed DelReposQuery.
* src/EditSource.py: fixed repository ref edit code to use dbstate.
* src/RepositoryRefEdit.py: fixes for dbstate and commented out window
management code.
* src/RepositoryView.py: fixes for dbstate, commented out remove repos
code for now as it does not work. Fixes edit repository call.
2005-08-14 Alex Roitman <shura@gramps-project.org>
* src/PedView.py (__init__): Define database variable.
* src/ViewManager.py (__init__): Define empty pages list.

View File

@ -269,11 +269,12 @@ class ReposSrcListView:
class EditRepository:
def __init__(self,repository,dbstate,parent_window=None,readonly=False):
def __init__(self,repository,dbstate,uistate,parent_window=None,readonly=False):
if repository:
self.repository = repository
else:
self.repository = RelLib.Repository()
self.dbstate = dbstate
self.db = dbstate.db
#self.parent = parent
self.name_display = NameDisplay.displayer.display
@ -366,7 +367,9 @@ class EditRepository:
if repository.get_note():
self.notes_buffer.set_text(repository.get_note())
Utils.bold_label(self.notes_label)
# FIXME: this get a 'gtk.Label' object has no attribute 'get_children'
# from Utils.py", line 650
#Utils.bold_label(self.notes_label)
if repository.get_note_format() == 1:
self.preform.set_active(1)
else:
@ -462,7 +465,7 @@ class EditRepository:
def on_add_repos_ref_clicked(self,widget):
RepositoryRefEdit.RepositoryRefSourceEdit(RelLib.RepoRef(),
None,
self.db,
self.dbstate,
self.repos_source_model.update,
self)
@ -485,7 +488,7 @@ class EditRepository:
RepositoryRefEdit.RepositoryRefSourceEdit(repos_ref,
source,
self.db,
self.dbstate,
self.repos_source_model.update,
self)
@ -632,7 +635,7 @@ class EditRepository:
pass
class DelReposQuery:
class DelRepositoryQuery:
def __init__(self,repository,db,sources):
self.repository = repository
self.db = db

View File

@ -90,11 +90,10 @@ class ReposRefListModel(gtk.ListStore):
class ReposRefListView:
def __init__(self, model, widget):
self._gramps_model = model
self.database_changed(self._gramps_model.db)
self._gramps_model.connect('database-changed', self.database_changed)
def __init__(self, dbstate, widget):
self._dbstate = dbstate
self.database_changed(self._dbstate.db)
self._db.connect('database-changed', self.database_changed)
self._widget = widget
@ -236,10 +235,10 @@ class EditSource:
self.top_window.get_widget('sel_photo').set_sensitive(mode)
self.top_window.get_widget('delete_photo').set_sensitive(mode)
# self.repos_ref_view = ReposRefListView(self.parent,
# self.top_window.get_widget('repository_ref_list'))
# self.repos_ref_model = ReposRefListModel(self.source)
# self.repos_ref_view.set_model(self.repos_ref_model)
self.repos_ref_view = ReposRefListView(self.dbstate,
self.top_window.get_widget('repository_ref_list'))
self.repos_ref_model = ReposRefListModel(self.source)
self.repos_ref_view.set_model(self.repos_ref_model)
self.top_window.get_widget('add_repos_ref').set_sensitive(mode)
self.top_window.get_widget('edit_repos_ref').set_sensitive(mode)
@ -347,7 +346,7 @@ class EditSource:
model.remove(node)
def on_add_repos_ref_clicked(self,widget):
RepositoryRefEdit.RepositoryRefEdit(RelLib.RepoRef(),self.db,
RepositoryRefEdit.RepositoryRefEdit(RelLib.RepoRef(),self.dbstate,
self.repos_ref_model.update,self)
def on_delete_repos_ref_clicked(self,widget):
@ -365,7 +364,7 @@ class EditSource:
if iter:
repos_ref = model.get_value(iter,0)
RepositoryRefEdit.RepositoryRefEdit(repos_ref,self.db,
RepositoryRefEdit.RepositoryRefEdit(repos_ref,self.dbstate,
self.repos_ref_model.update,self)

View File

@ -66,22 +66,24 @@ import AutoComp
class RepositoryRefEditBase:
def __init__(self, reposref, database, update, parent):
def __init__(self, reposref, dbstate, update, parent):
self.db = database
self.dbstate = dbstate
self.db = dbstate.db
self.parent = parent
if self.parent.__dict__.has_key('child_windows'):
self.win_parent = self.parent
else:
self.win_parent = self.parent.parent
if reposref:
if self.win_parent.child_windows.has_key(reposref):
self.win_parent.child_windows[reposref].present(None)
return
else:
self.win_key = reposref
else:
self.win_key = self
# FIXME: window manangement
# if self.parent.__dict__.has_key('child_windows'):
# self.win_parent = self.parent
# else:
# self.win_parent = self.parent.parent
# if reposref:
# if self.win_parent.child_windows.has_key(reposref):
# self.win_parent.child_windows[reposref].present(None)
# return
# else:
# self.win_key = reposref
# else:
# self.win_key = self
self.update = update
self.repos_ref = reposref
self.child_windows = {}
@ -132,6 +134,8 @@ class RepositoryRefEditBase:
self.child_windows = {}
def add_itself_to_menu(self):
# FIXME
return
self.win_parent.child_windows[self.win_key] = self
label = _('Repository Reference')
self.parent_menu_item = gtk.MenuItem(label)
@ -145,6 +149,8 @@ class RepositoryRefEditBase:
self.winsmenu.append(self.menu_item)
def remove_itself_from_menu(self):
#FIXME
return
del self.win_parent.child_windows[self.win_key]
self.menu_item.destroy()
self.winsmenu.destroy()
@ -168,9 +174,9 @@ class RepositoryRefEditBase:
class RepositoryRefEdit(RepositoryRefEditBase):
def __init__(self, reposref, database, update, parent):
def __init__(self, reposref, dbstate, update, parent):
RepositoryRefEditBase.__init__(self, reposref,
database, update,
dbstate, update,
parent)
self.top_window = gtk.glade.XML(const.gladeFile,"repositoryRefEditor","gramps")
@ -301,16 +307,16 @@ class RepositoryRefEdit(RepositoryRefEditBase):
def add_repos_clicked(self,obj):
import EditRepository
EditRepository.EditRepository(RelLib.Repository(),self.db, self)
EditRepository.EditRepository(RelLib.Repository(),self.dbstate, self)
class RepositoryRefSourceEdit(RepositoryRefEditBase):
"""Edit a Repository Reference from the perspective of the Repository."""
def __init__(self, reposref, source, database, update, parent):
def __init__(self, reposref, source, dbstate, update, parent):
RepositoryRefEditBase.__init__(self, reposref,
database, update,
dbstate, update,
parent)
self.top_window = gtk.glade.XML(const.gladeFile,"repositoryRefSourceEditor","gramps")
@ -431,4 +437,4 @@ class RepositoryRefSourceEdit(RepositoryRefEditBase):
def add_source_clicked(self,obj):
import EditSource
EditSource.EditSource(RelLib.Source(),self.db, self.parent)
EditSource.EditSource(RelLib.Source(),self.dbstate, self.parent)

View File

@ -114,47 +114,47 @@ class RepositoryView(PageView.ListView):
def on_double_click(self,obj,event):
handle = self.first_selected()
place = self.dbstate.db.get_place_from_handle(handle)
EditRepository.EditRepository(place,self.dbstate, self.uistate)
repos = self.dbstate.db.get_repository_from_handle(handle)
EditRepository.EditRepository(repos,self.dbstate, self.uistate)
def add(self,obj):
EditRepository.EditRepository(RelLib.Repository(),self.dbstate, self.uistate)
def remove(self,obj):
for event_handle in self.selected_handles():
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) ]
db = self.dbstate.db
# for event_handle in self.selected_handles():
# 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) ]
event = db.get_event_from_handle(event_handle)
# event = db.get_event_from_handle(event_handle)
ans = EditRepository.DelRepositoryQuery(event,db,
person_list,family_list)
# ans = EditRepository.DelRepositoryQuery(event,db,
# person_list,family_list)
if len(person_list) + len(family_list) > 0:
msg = _('This place is currently being used. Deleting it '
'will remove it from the database and from all '
'people and families that reference it.')
else:
msg = _('Deleting place will remove it from the database.')
# if len(person_list) + len(family_list) > 0:
# msg = _('This place is currently being used. Deleting it '
# 'will remove it from the database and from all '
# 'people and families that reference it.')
# else:
# msg = _('Deleting place will remove it from the database.')
msg = "%s %s" % (msg,Utils.data_recover_msg)
descr = event.get_description()
if descr == "":
descr = event.get_gramps_id()
# msg = "%s %s" % (msg,Utils.data_recover_msg)
# descr = event.get_description()
# if descr == "":
# descr = event.get_gramps_id()
QuestionDialog(_('Delete %s?') % descr, msg,
_('_Delete Repository'),ans.query_response)
# QuestionDialog(_('Delete %s?') % descr, msg,
# _('_Delete Repository'),ans.query_response)
def edit(self,obj):
mlist = []
self.selection.selected_foreach(self.blist,mlist)
for handle in mlist:
place = self.dbstate.db.get_place_from_handle(handle)
EditRepository.EditRepository(place, self.dbstate, self.uistate)
repos = self.dbstate.db.get_repository_from_handle(handle)
EditRepository.EditRepository(repos, self.dbstate, self.uistate)