* src/EditPlace.py: use monitored widgets
* src/EditSource.py: use monitored widgets * src/EventEdit.py: use monitored widgets * src/GrampsWidgets.py: start of monitored place * src/GrampsDb/_GrampsDbBase.py: monitor place changes svn: r5975
This commit is contained in:
parent
beba25f377
commit
72d064f5b5
@ -1,3 +1,10 @@
|
|||||||
|
2006-02-22 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/EditPlace.py: use monitored widgets
|
||||||
|
* src/EditSource.py: use monitored widgets
|
||||||
|
* src/EventEdit.py: use monitored widgets
|
||||||
|
* src/GrampsWidgets.py: start of monitored place
|
||||||
|
* src/GrampsDb/_GrampsDbBase.py: monitor place changes
|
||||||
|
|
||||||
2006-02-22 Alex Roitman <shura@gramps-project.org>
|
2006-02-22 Alex Roitman <shura@gramps-project.org>
|
||||||
* src/EditSourceRef.py (__init__): Typos.
|
* src/EditSourceRef.py (__init__): Typos.
|
||||||
* src/DisplayTabs.py (GalleryTab.add_button_clicked): Typos.
|
* src/DisplayTabs.py (GalleryTab.add_button_clicked): Typos.
|
||||||
|
146
src/EditPlace.py
146
src/EditPlace.py
@ -58,8 +58,8 @@ import RelLib
|
|||||||
import ListModel
|
import ListModel
|
||||||
|
|
||||||
from DdTargets import DdTargets
|
from DdTargets import DdTargets
|
||||||
from WindowUtils import GladeIf
|
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
|
from GrampsWidgets import *
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -72,81 +72,84 @@ class EditPlace(DisplayState.ManagedWindow):
|
|||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
|
|
||||||
self.ref_not_loaded = place and place.get_handle()
|
DisplayState.ManagedWindow.__init__(self, uistate, track, place)
|
||||||
self.idle = None
|
|
||||||
self.name_display = NameDisplay.displayer.display
|
self.name_display = NameDisplay.displayer.display
|
||||||
self.place = place
|
self.place = place
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
self.path = dbstate.db.get_save_path()
|
|
||||||
self.not_loaded = True
|
|
||||||
self.model = None # becomes the model for back references.
|
|
||||||
self.lists_changed = 0
|
|
||||||
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile,"placeEditor","gramps")
|
self.top = gtk.glade.XML(const.gladeFile,"placeEditor","gramps")
|
||||||
self.gladeif = GladeIf(self.top)
|
|
||||||
|
|
||||||
self.window = self.top.get_widget("placeEditor")
|
self.window = self.top.get_widget("placeEditor")
|
||||||
title_label = self.top.get_widget('title')
|
title_label = self.top.get_widget('title')
|
||||||
|
|
||||||
Utils.set_titles(self.window,title_label,_('Place Editor'))
|
Utils.set_titles(self.window,title_label,_('Place Editor'))
|
||||||
|
|
||||||
mode = not self.dbstate.db.readonly
|
|
||||||
self.title = self.top.get_widget("place_title")
|
|
||||||
self.title.set_editable(mode)
|
|
||||||
self.city = self.top.get_widget("city")
|
|
||||||
self.city.set_editable(mode)
|
|
||||||
self.parish = self.top.get_widget("parish")
|
|
||||||
self.parish.set_editable(mode)
|
|
||||||
self.county = self.top.get_widget("county")
|
|
||||||
self.county.set_editable(mode)
|
|
||||||
self.state = self.top.get_widget("state")
|
|
||||||
self.state.set_editable(mode)
|
|
||||||
self.phone = self.top.get_widget("phone")
|
|
||||||
self.phone.set_editable(mode)
|
|
||||||
self.postal = self.top.get_widget("postal")
|
|
||||||
self.postal.set_editable(mode)
|
|
||||||
self.country = self.top.get_widget("country")
|
|
||||||
self.country.set_editable(mode)
|
|
||||||
self.longitude = self.top.get_widget("longitude")
|
|
||||||
self.longitude.set_editable(mode)
|
|
||||||
self.latitude = self.top.get_widget("latitude")
|
|
||||||
self.latitude.set_editable(mode)
|
|
||||||
|
|
||||||
self.top.get_widget('changed').set_text(place.get_change_display())
|
self.top.get_widget('changed').set_text(place.get_change_display())
|
||||||
|
|
||||||
self.title.set_text(place.get_title())
|
|
||||||
mloc = place.get_main_location()
|
|
||||||
self.city.set_text(mloc.get_city())
|
|
||||||
self.county.set_text(mloc.get_county())
|
|
||||||
self.state.set_text(mloc.get_state())
|
|
||||||
self.phone.set_text(mloc.get_phone())
|
|
||||||
self.postal.set_text(mloc.get_postal_code())
|
|
||||||
self.parish.set_text(mloc.get_parish())
|
|
||||||
self.country.set_text(mloc.get_country())
|
|
||||||
self.longitude.set_text(place.get_longitude())
|
|
||||||
self.latitude.set_text(place.get_latitude())
|
|
||||||
self.plist = self.top.get_widget("refinfo")
|
|
||||||
|
|
||||||
self.notebook = self.top.get_widget('notebook3')
|
self.notebook = self.top.get_widget('notebook3')
|
||||||
|
|
||||||
self.gladeif.connect('placeEditor', 'delete_event', self.on_delete_event)
|
|
||||||
self.gladeif.connect('button127', 'clicked', self.close)
|
|
||||||
self.gladeif.connect('ok', 'clicked', self.on_place_apply_clicked)
|
|
||||||
self.gladeif.connect('button135', 'clicked', self.on_help_clicked)
|
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, track, place)
|
|
||||||
|
|
||||||
if self.place.get_handle() == None or self.dbstate.db.readonly:
|
|
||||||
self.top.get_widget("add_photo").set_sensitive(0)
|
|
||||||
self.top.get_widget("delete_photo").set_sensitive(0)
|
|
||||||
|
|
||||||
self.top.get_widget('ok').set_sensitive(not self.db.readonly)
|
|
||||||
|
|
||||||
self._create_tabbed_pages()
|
self._create_tabbed_pages()
|
||||||
|
self._setup_fields()
|
||||||
|
self._connect_signals()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
self.pdmap = {}
|
self.pdmap = {}
|
||||||
self.build_pdmap()
|
self.build_pdmap()
|
||||||
|
|
||||||
|
def _connect_signals(self):
|
||||||
|
self.top.get_widget('placeEditor').connect('delete_event', self.delete_event)
|
||||||
|
self.top.get_widget('button127').connect('clicked', self.close)
|
||||||
|
self.top.get_widget('button135').connect('clicked', self.help_clicked)
|
||||||
|
ok = self.top.get_widget('ok')
|
||||||
|
ok.connect('clicked', self.apply_clicked)
|
||||||
|
ok.set_sensitive(not self.db.readonly)
|
||||||
|
|
||||||
|
def _setup_fields(self):
|
||||||
|
mloc = self.place.get_main_location()
|
||||||
|
|
||||||
|
self.title = MonitoredEntry(
|
||||||
|
self.top.get_widget("place_title"),
|
||||||
|
self.place.set_title, self.place.get_title,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.city = MonitoredEntry(
|
||||||
|
self.top.get_widget("city"),
|
||||||
|
mloc.set_city, mloc.get_city, self.db.readonly)
|
||||||
|
|
||||||
|
self.parish = MonitoredEntry(
|
||||||
|
self.top.get_widget("parish"),
|
||||||
|
mloc.set_parish, mloc.get_parish, self.db.readonly)
|
||||||
|
|
||||||
|
self.county = MonitoredEntry(
|
||||||
|
self.top.get_widget("county"),
|
||||||
|
mloc.set_county, mloc.get_county, self.db.readonly)
|
||||||
|
|
||||||
|
self.state = MonitoredEntry(
|
||||||
|
self.top.get_widget("state"),
|
||||||
|
mloc.set_state, mloc.get_state, self.db.readonly)
|
||||||
|
|
||||||
|
self.phone = MonitoredEntry(
|
||||||
|
self.top.get_widget("phone"),
|
||||||
|
mloc.set_phone, mloc.get_phone, self.db.readonly)
|
||||||
|
|
||||||
|
self.postal = MonitoredEntry(
|
||||||
|
self.top.get_widget("postal"),
|
||||||
|
mloc.set_postal_code, mloc.get_postal_code, self.db.readonly)
|
||||||
|
|
||||||
|
self.country = MonitoredEntry(
|
||||||
|
self.top.get_widget("country"),
|
||||||
|
mloc.set_country, mloc.get_county, self.db.readonly)
|
||||||
|
|
||||||
|
self.longitude = MonitoredEntry(
|
||||||
|
self.top.get_widget("longitude"),
|
||||||
|
self.place.set_longitude, self.place.get_longitude,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.latitude = MonitoredEntry(
|
||||||
|
self.top.get_widget("latitude"),
|
||||||
|
self.place.set_latitude, self.place.get_latitude,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
|
||||||
def build_window_key(self,place):
|
def build_window_key(self,place):
|
||||||
@ -201,18 +204,14 @@ class EditPlace(DisplayState.ManagedWindow):
|
|||||||
self.dbstate,self.uistate,self.track,
|
self.dbstate,self.uistate,self.track,
|
||||||
self.db.find_backlink_handles(self.place.handle)))
|
self.db.find_backlink_handles(self.place.handle)))
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def delete_event(self,obj,b):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def close_window(self,obj):
|
def close_window(self,obj):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
if self.idle != None:
|
|
||||||
gobject.source_remove(self.idle)
|
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
GrampsDisplay.help('adv-plc')
|
GrampsDisplay.help('adv-plc')
|
||||||
|
|
||||||
@ -225,15 +224,9 @@ class EditPlace(DisplayState.ManagedWindow):
|
|||||||
cnum = cnum + 1
|
cnum = cnum + 1
|
||||||
tree.append_column(column)
|
tree.append_column(column)
|
||||||
|
|
||||||
def set(self,field,getf,setf):
|
def apply_clicked(self,obj):
|
||||||
text = unicode(field.get_text())
|
|
||||||
if text != getf():
|
|
||||||
setf(text)
|
|
||||||
|
|
||||||
def on_place_apply_clicked(self,obj):
|
|
||||||
|
|
||||||
mloc = self.place.get_main_location()
|
title = self.place.get_title()
|
||||||
title = self.title.get_text()
|
|
||||||
if self.pdmap.has_key(title) and self.pdmap[title] != self.place.handle:
|
if self.pdmap.has_key(title) and self.pdmap[title] != self.place.handle:
|
||||||
import QuestionDialog
|
import QuestionDialog
|
||||||
QuestionDialog.ErrorDialog(
|
QuestionDialog.ErrorDialog(
|
||||||
@ -243,19 +236,6 @@ class EditPlace(DisplayState.ManagedWindow):
|
|||||||
"another place"))
|
"another place"))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.set(self.city,mloc.get_city,mloc.set_city)
|
|
||||||
self.set(self.parish,mloc.get_parish,mloc.set_parish)
|
|
||||||
self.set(self.state,mloc.get_state,mloc.set_state)
|
|
||||||
self.set(self.phone,mloc.get_phone,mloc.set_phone)
|
|
||||||
self.set(self.postal,mloc.get_postal_code,mloc.set_postal_code)
|
|
||||||
self.set(self.county,mloc.get_county,mloc.set_county)
|
|
||||||
self.set(self.country,mloc.get_country,mloc.set_country)
|
|
||||||
self.set(self.title,self.place.get_title,self.place.set_title)
|
|
||||||
self.set(self.longitude,self.place.get_longitude,
|
|
||||||
self.place.set_longitude)
|
|
||||||
self.set(self.latitude,self.place.get_latitude,
|
|
||||||
self.place.set_latitude)
|
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if self.place.get_handle():
|
if self.place.get_handle():
|
||||||
self.db.commit_place(self.place,trans)
|
self.db.commit_place(self.place,trans)
|
||||||
|
@ -56,6 +56,7 @@ import DisplayState
|
|||||||
|
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
from WindowUtils import GladeIf
|
from WindowUtils import GladeIf
|
||||||
|
from GrampsWidgets import *
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -184,83 +185,83 @@ class EditSource(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
if source:
|
if source:
|
||||||
self.source = source
|
self.source = source
|
||||||
self.ref_not_loaded = 1
|
|
||||||
else:
|
else:
|
||||||
self.source = RelLib.Source()
|
self.source = RelLib.Source()
|
||||||
self.ref_not_loaded = 0
|
|
||||||
|
|
||||||
self.path = self.db.get_save_path()
|
self.glade = gtk.glade.XML(const.gladeFile,"sourceEditor","gramps")
|
||||||
self.not_loaded = 1
|
self.window = self.glade.get_widget("sourceEditor")
|
||||||
self.lists_changed = 0
|
|
||||||
mode = not self.db.readonly
|
|
||||||
|
|
||||||
self.top_window = gtk.glade.XML(const.gladeFile,"sourceEditor","gramps")
|
Utils.set_titles(self.window,self.glade.get_widget('title'),
|
||||||
self.window = self.top_window.get_widget("sourceEditor")
|
|
||||||
self.gladeif = GladeIf(self.top_window)
|
|
||||||
|
|
||||||
Utils.set_titles(self.window,self.top_window.get_widget('title'),
|
|
||||||
_('Source Editor'))
|
_('Source Editor'))
|
||||||
|
|
||||||
self.author = self.top_window.get_widget("author")
|
self.vbox = self.glade.get_widget('vbox')
|
||||||
self.pubinfo = self.top_window.get_widget("pubinfo")
|
|
||||||
self.abbrev = self.top_window.get_widget("abbrev")
|
|
||||||
self.cancel = self.top_window.get_widget('cancel')
|
|
||||||
self.ok = self.top_window.get_widget('ok')
|
|
||||||
|
|
||||||
self.vbox = self.top_window.get_widget('vbox')
|
|
||||||
|
|
||||||
self.refinfo = self.top_window.get_widget("refinfo")
|
|
||||||
|
|
||||||
self.title = self.top_window.get_widget("source_title")
|
|
||||||
self.title.set_text(source.get_title())
|
|
||||||
self.title.set_editable(mode)
|
|
||||||
self.author.set_text(source.get_author())
|
|
||||||
self.author.set_editable(mode)
|
|
||||||
self.pubinfo.set_text(source.get_publication_info())
|
|
||||||
self.pubinfo.set_editable(mode)
|
|
||||||
self.abbrev.set_text(source.get_abbreviation())
|
|
||||||
self.abbrev.set_editable(mode)
|
|
||||||
|
|
||||||
self.ok.set_sensitive(not self.db.readonly)
|
|
||||||
self.cancel.connect('clicked', self.close_window)
|
|
||||||
self.ok.connect('clicked', self.apply_clicked)
|
|
||||||
|
|
||||||
self.notebook = gtk.Notebook()
|
self.notebook = gtk.Notebook()
|
||||||
self.notebook.show()
|
self.notebook.show()
|
||||||
self.vbox.pack_start(self.notebook,True)
|
self.vbox.pack_start(self.notebook,True)
|
||||||
|
|
||||||
self.load_data()
|
self._create_tabbed_pages()
|
||||||
|
self._setup_fields()
|
||||||
|
self._connect_signals()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def load_data(self):
|
def _connect_signals(self):
|
||||||
self.note_tab = NoteTab(
|
self.glade.get_widget('cancel').connect('clicked', self.close_window)
|
||||||
self.dbstate, self.uistate, self.track, self.source.get_note_object())
|
|
||||||
self.gallery_tab = GalleryTab(
|
ok = self.glade.get_widget('ok')
|
||||||
self.dbstate, self.uistate, self.track, self.source.get_media_list())
|
ok.set_sensitive(not self.db.readonly)
|
||||||
self.data_tab = DataEmbedList(
|
ok.connect('clicked', self.apply_clicked)
|
||||||
self.dbstate, self.uistate, self.track, self.source)
|
|
||||||
self.repo_tab = RepoEmbedList(
|
def _setup_fields(self):
|
||||||
self.dbstate, self.uistate, self.track, self.source.get_reporef_list())
|
self.author = MonitoredEntry(
|
||||||
self.backref_tab = SourceBackRefList(
|
self.glade.get_widget("author"),
|
||||||
|
self.source.set_author,
|
||||||
|
self.source.get_author,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.pubinfo = MonitoredEntry(
|
||||||
|
self.glade.get_widget("pubinfo"),
|
||||||
|
self.source.set_publication_info,
|
||||||
|
self.source.get_publication_info,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.abbrev = MonitoredEntry(
|
||||||
|
self.glade.get_widget("abbrev"),
|
||||||
|
self.source.set_abbreviation,
|
||||||
|
self.source.get_abbreviation,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
self.title = MonitoredEntry(
|
||||||
|
self.glade.get_widget("source_title"),
|
||||||
|
self.source.set_title,
|
||||||
|
self.source.get_title,
|
||||||
|
self.db.readonly)
|
||||||
|
|
||||||
|
def _add_page(self,page):
|
||||||
|
self.notebook.insert_page(page)
|
||||||
|
self.notebook.set_tab_label(page,page.get_tab_widget())
|
||||||
|
return page
|
||||||
|
|
||||||
|
def _create_tabbed_pages(self):
|
||||||
|
self.note_tab = self._add_page(NoteTab(
|
||||||
self.dbstate, self.uistate, self.track,
|
self.dbstate, self.uistate, self.track,
|
||||||
self.db.find_backlink_handles(self.source.handle))
|
self.source.get_note_object()))
|
||||||
|
|
||||||
|
self.gallery_tab = self._add_page(GalleryTab(
|
||||||
|
self.dbstate, self.uistate, self.track,
|
||||||
|
self.source.get_media_list()))
|
||||||
|
|
||||||
|
self.data_tab = self._add_page(DataEmbedList(
|
||||||
|
self.dbstate, self.uistate, self.track, self.source))
|
||||||
|
|
||||||
|
self.repo_tab = self._add_page(RepoEmbedList(
|
||||||
|
self.dbstate, self.uistate, self.track,
|
||||||
|
self.source.get_reporef_list()))
|
||||||
|
|
||||||
|
self.backref_tab = self._add_page(SourceBackRefList(
|
||||||
|
self.dbstate, self.uistate, self.track,
|
||||||
|
self.db.find_backlink_handles(self.source.handle)))
|
||||||
|
|
||||||
self.notebook.insert_page(self.note_tab)
|
|
||||||
self.notebook.set_tab_label(self.note_tab,self.note_tab.get_tab_widget())
|
|
||||||
|
|
||||||
self.notebook.insert_page(self.data_tab)
|
|
||||||
self.notebook.set_tab_label(self.data_tab,self.data_tab.get_tab_widget())
|
|
||||||
|
|
||||||
self.notebook.insert_page(self.gallery_tab)
|
|
||||||
self.notebook.set_tab_label(self.gallery_tab,self.gallery_tab.get_tab_widget())
|
|
||||||
|
|
||||||
self.notebook.insert_page(self.repo_tab)
|
|
||||||
self.notebook.set_tab_label(self.repo_tab,self.repo_tab.get_tab_widget())
|
|
||||||
|
|
||||||
self.notebook.insert_page(self.backref_tab)
|
|
||||||
self.notebook.set_tab_label(self.backref_tab,self.backref_tab.get_tab_widget())
|
|
||||||
|
|
||||||
self.notebook.show_all()
|
self.notebook.show_all()
|
||||||
|
|
||||||
def build_window_key(self,source):
|
def build_window_key(self,source):
|
||||||
@ -278,7 +279,6 @@ class EditSource(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def on_delete_event(self,obj,b):
|
||||||
self.backref_tab.close()
|
self.backref_tab.close()
|
||||||
self.gladeif.close()
|
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def on_help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
@ -286,28 +286,10 @@ class EditSource(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
def close_window(self,obj):
|
def close_window(self,obj):
|
||||||
self.backref_tab.close()
|
self.backref_tab.close()
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def apply_clicked(self,obj):
|
def apply_clicked(self,obj):
|
||||||
|
|
||||||
title = unicode(self.title.get_text())
|
|
||||||
author = unicode(self.author.get_text())
|
|
||||||
pubinfo = unicode(self.pubinfo.get_text())
|
|
||||||
abbrev = unicode(self.abbrev.get_text())
|
|
||||||
|
|
||||||
if author != self.source.get_author():
|
|
||||||
self.source.set_author(author)
|
|
||||||
|
|
||||||
if title != self.source.get_title():
|
|
||||||
self.source.set_title(title)
|
|
||||||
|
|
||||||
if pubinfo != self.source.get_publication_info():
|
|
||||||
self.source.set_publication_info(pubinfo)
|
|
||||||
|
|
||||||
if abbrev != self.source.get_abbreviation():
|
|
||||||
self.source.set_abbreviation(abbrev)
|
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if self.source.get_handle() == None:
|
if self.source.get_handle() == None:
|
||||||
self.db.add_source(self.source,trans)
|
self.db.add_source(self.source,trans)
|
||||||
|
131
src/EventEdit.py
131
src/EventEdit.py
@ -45,19 +45,15 @@ import gtk.glade
|
|||||||
# gramps modules
|
# gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import Sources
|
|
||||||
import Witness
|
|
||||||
import const
|
import const
|
||||||
import Utils
|
import Utils
|
||||||
import AutoComp
|
import AutoComp
|
||||||
import RelLib
|
import RelLib
|
||||||
from DateHandler import parser as _dp, displayer as _dd
|
|
||||||
import DateEdit
|
import DateEdit
|
||||||
import GrampsDisplay
|
import GrampsDisplay
|
||||||
import DisplayState
|
import DisplayState
|
||||||
|
|
||||||
from QuestionDialog import WarningDialog, ErrorDialog
|
from QuestionDialog import WarningDialog, ErrorDialog
|
||||||
from WindowUtils import GladeIf
|
|
||||||
from DisplayTabs import *
|
from DisplayTabs import *
|
||||||
from GrampsWidgets import *
|
from GrampsWidgets import *
|
||||||
|
|
||||||
@ -105,16 +101,11 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
self.track = track
|
self.track = track
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
|
|
||||||
read_only = self.db.readonly
|
|
||||||
noedit = self.db.readonly
|
|
||||||
self.event = event
|
self.event = event
|
||||||
self.path = self.db.get_save_path()
|
self.path = self.db.get_save_path()
|
||||||
self.plist = []
|
self.plist = []
|
||||||
self.pmap = {}
|
self.pmap = {}
|
||||||
|
|
||||||
self.dp = _dp
|
|
||||||
self.dd = _dd
|
|
||||||
|
|
||||||
DisplayState.ManagedWindow.__init__(self, uistate, self.track, event)
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, event)
|
||||||
if self.already_exist:
|
if self.already_exist:
|
||||||
return
|
return
|
||||||
@ -123,15 +114,10 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
title = self.db.get_place_from_handle(key).get_title()
|
title = self.db.get_place_from_handle(key).get_title()
|
||||||
self.pmap[title] = key
|
self.pmap[title] = key
|
||||||
|
|
||||||
if event:
|
if not event:
|
||||||
self.srcreflist = self.event.get_source_references()
|
self.event = RelLib.Event()
|
||||||
self.date = RelLib.Date(self.event.get_date_object())
|
|
||||||
else:
|
|
||||||
self.srcreflist = []
|
|
||||||
self.date = RelLib.Date(None)
|
|
||||||
|
|
||||||
self.top = gtk.glade.XML(const.gladeFile, "event_edit","gramps")
|
self.top = gtk.glade.XML(const.gladeFile, "event_edit","gramps")
|
||||||
self.gladeif = GladeIf(self.top)
|
|
||||||
|
|
||||||
self.window = self.top.get_widget("event_edit")
|
self.window = self.top.get_widget("event_edit")
|
||||||
title_label = self.top.get_widget('title')
|
title_label = self.top.get_widget('title')
|
||||||
@ -141,64 +127,57 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
_('Event Editor'))
|
_('Event Editor'))
|
||||||
|
|
||||||
self.place_field = self.top.get_widget("eventPlace")
|
self.place_field = self.top.get_widget("eventPlace")
|
||||||
self.place_field.set_editable(not noedit)
|
self.place_field.set_editable(not self.db.readonly)
|
||||||
self.cause_field = self.top.get_widget("eventCause")
|
|
||||||
self.cause_monitor = MonitoredEntry(self.cause_field,self.event.set_cause,
|
|
||||||
self.event.get_cause, noedit)
|
|
||||||
self.date_field = self.top.get_widget("eventDate")
|
|
||||||
self.date_field.set_editable(not noedit)
|
|
||||||
self.descr_field = MonitoredEntry(self.top.get_widget("event_description"),
|
|
||||||
self.event.set_description,
|
|
||||||
self.event.get_description, noedit)
|
|
||||||
self.event_menu = self.top.get_widget("personal_events")
|
|
||||||
self.priv = PrivacyButton(self.top.get_widget("private"),self.event)
|
|
||||||
self.priv.set_sensitive(not noedit)
|
|
||||||
self.ok = self.top.get_widget('ok')
|
|
||||||
|
|
||||||
self.ok.set_sensitive(not noedit)
|
|
||||||
|
|
||||||
if read_only or noedit:
|
|
||||||
self.event_menu.set_sensitive(False)
|
|
||||||
self.date_field.grab_focus()
|
|
||||||
|
|
||||||
if event:
|
place_handle = event.get_place_handle()
|
||||||
defval = event.get_type()[0]
|
if not place_handle:
|
||||||
|
place_name = u""
|
||||||
else:
|
else:
|
||||||
defval = None
|
place_name = self.db.get_place_from_handle(place_handle).get_title()
|
||||||
|
self.place_field.set_text(place_name)
|
||||||
self.type_selector = AutoComp.StandardCustomSelector(
|
|
||||||
total_events, self.event_menu,
|
|
||||||
RelLib.Event.CUSTOM, defval)
|
|
||||||
|
|
||||||
AutoComp.fill_entry(self.place_field,self.pmap.keys())
|
|
||||||
|
|
||||||
if event != None:
|
|
||||||
place_handle = event.get_place_handle()
|
|
||||||
if not place_handle:
|
|
||||||
place_name = u""
|
|
||||||
else:
|
|
||||||
place_name = self.db.get_place_from_handle(place_handle).get_title()
|
|
||||||
self.place_field.set_text(place_name)
|
|
||||||
|
|
||||||
self.date_field.set_text(_dd.display(self.date))
|
|
||||||
|
|
||||||
else:
|
|
||||||
event = RelLib.Event()
|
|
||||||
date_stat = self.top.get_widget("date_stat")
|
|
||||||
date_stat.set_sensitive(not self.db.readonly)
|
|
||||||
self.date_check = DateEdit.DateEdit(self.date,
|
|
||||||
self.date_field,
|
|
||||||
date_stat,
|
|
||||||
self.window)
|
|
||||||
|
|
||||||
self.gladeif.connect('button111','clicked',self.close_window)
|
|
||||||
self.gladeif.connect('ok','clicked',self.on_event_edit_ok_clicked)
|
|
||||||
self.gladeif.connect('button126','clicked',self.on_help_clicked)
|
|
||||||
|
|
||||||
self._create_tabbed_pages()
|
self._create_tabbed_pages()
|
||||||
|
self._setup_fields()
|
||||||
|
self._connect_signals()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
def _connect_signals(self):
|
||||||
|
self.top.get_widget('button111').connect('clicked',self.close_window)
|
||||||
|
self.top.get_widget('button126').connect('clicked',self.on_help_clicked)
|
||||||
|
|
||||||
|
ok = self.top.get_widget('ok')
|
||||||
|
ok.set_sensitive(not self.db.readonly)
|
||||||
|
ok.connect('clicked',self.on_event_edit_ok_clicked)
|
||||||
|
|
||||||
|
def _setup_fields(self):
|
||||||
|
self.cause_monitor = MonitoredEntry(
|
||||||
|
self.top.get_widget("eventCause"),
|
||||||
|
self.event.set_cause,
|
||||||
|
self.event.get_cause, self.db.readonly)
|
||||||
|
|
||||||
|
self.descr_field = MonitoredEntry(
|
||||||
|
self.top.get_widget("event_description"),
|
||||||
|
self.event.set_description,
|
||||||
|
self.event.get_description, self.db.readonly)
|
||||||
|
|
||||||
|
|
||||||
|
self.priv = PrivacyButton(
|
||||||
|
self.top.get_widget("private"),
|
||||||
|
self.event, self.db.readonly)
|
||||||
|
|
||||||
|
self.event_menu = MonitoredType(
|
||||||
|
self.top.get_widget("personal_events"),
|
||||||
|
self.event.set_type,
|
||||||
|
self.event.get_type,
|
||||||
|
dict(total_events),
|
||||||
|
RelLib.Event.CUSTOM)
|
||||||
|
|
||||||
|
self.date_field = MonitoredDate(
|
||||||
|
self.top.get_widget("eventDate"),
|
||||||
|
self.top.get_widget("date_stat"),
|
||||||
|
self.event.get_date_object(),
|
||||||
|
self.window, self.db.readonly)
|
||||||
|
|
||||||
def _add_page(self,page):
|
def _add_page(self,page):
|
||||||
self.notebook.insert_page(page)
|
self.notebook.insert_page(page)
|
||||||
self.notebook.set_tab_label(page,page.get_tab_widget())
|
self.notebook.set_tab_label(page,page.get_tab_widget())
|
||||||
@ -246,11 +225,9 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
return id(self)
|
return id(self)
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def on_delete_event(self,obj,b):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def close_window(self,obj):
|
def close_window(self,obj):
|
||||||
self.gladeif.close()
|
|
||||||
self.close()
|
self.close()
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
@ -260,12 +237,9 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
|
|
||||||
def on_event_edit_ok_clicked(self,obj):
|
def on_event_edit_ok_clicked(self,obj):
|
||||||
|
|
||||||
event_data = self.type_selector.get_values()
|
|
||||||
eplace_obj = get_place(self.place_field,self.pmap,self.db)
|
eplace_obj = get_place(self.place_field,self.pmap,self.db)
|
||||||
|
|
||||||
self.update_event(event_data,self.date,eplace_obj)
|
self.update_event(eplace_obj)
|
||||||
|
|
||||||
print self.event, self.event.handle
|
|
||||||
|
|
||||||
if self.event.handle == None:
|
if self.event.handle == None:
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
@ -282,7 +256,7 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
self.callback(self.event)
|
self.callback(self.event)
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
|
|
||||||
def update_event(self,the_type,date,place):
|
def update_event(self,place):
|
||||||
# FIXME: commented because we no longer have parent
|
# FIXME: commented because we no longer have parent
|
||||||
if place:
|
if place:
|
||||||
if self.event.get_place_handle() != place.get_handle():
|
if self.event.get_place_handle() != place.get_handle():
|
||||||
@ -291,13 +265,6 @@ class EventEditor(DisplayState.ManagedWindow):
|
|||||||
if self.event.get_place_handle():
|
if self.event.get_place_handle():
|
||||||
self.event.set_place_handle("")
|
self.event.set_place_handle("")
|
||||||
|
|
||||||
if self.event.get_type() != the_type:
|
|
||||||
self.event.set_type(the_type)
|
|
||||||
|
|
||||||
dobj = self.event.get_date_object()
|
|
||||||
if not dobj.is_equal(date):
|
|
||||||
self.event.set_date_object(date)
|
|
||||||
|
|
||||||
def commit(self,event,trans):
|
def commit(self,event,trans):
|
||||||
self.db.commit_event(event,trans)
|
self.db.commit_event(event,trans)
|
||||||
|
|
||||||
|
@ -1991,6 +1991,28 @@ class DbState(GrampsDBCallback):
|
|||||||
self.db = GrampsDbBase()
|
self.db = GrampsDbBase()
|
||||||
self.open = False
|
self.open = False
|
||||||
self.active = None
|
self.active = None
|
||||||
|
self.places = {}
|
||||||
|
|
||||||
|
def _place_rebuild(self):
|
||||||
|
self.places.clear()
|
||||||
|
cursor = self.db.get_place_cursor()
|
||||||
|
data = cursor.next()
|
||||||
|
while data:
|
||||||
|
if data[1][2]:
|
||||||
|
self.places[data[1][2]] = data[0]
|
||||||
|
data = cursor.next()
|
||||||
|
cursor.close()
|
||||||
|
|
||||||
|
def _place_add(self,handle):
|
||||||
|
place = self.db.get_place_from_handle(handle)
|
||||||
|
self.places[place.get_title()] = handle
|
||||||
|
|
||||||
|
def _place_update(self,handle):
|
||||||
|
place = self.db.get_place_from_handle(handle)
|
||||||
|
self.places[handle] = place.get_title()
|
||||||
|
|
||||||
|
def _place_delete(self,handle):
|
||||||
|
del self.places[handle]
|
||||||
|
|
||||||
def change_active_person(self,person):
|
def change_active_person(self,person):
|
||||||
self.active = person
|
self.active = person
|
||||||
@ -2009,6 +2031,10 @@ class DbState(GrampsDBCallback):
|
|||||||
def change_database(self,db):
|
def change_database(self,db):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
self.db = db
|
self.db = db
|
||||||
|
self.db.connect('place-add',self._place_add)
|
||||||
|
self.db.connect('place-update',self._place_update)
|
||||||
|
self.db.connect('place-delete',self._place_delete)
|
||||||
|
self.db.connect('place-rebuild',self._place_rebuild)
|
||||||
self.active = None
|
self.active = None
|
||||||
self.open = True
|
self.open = True
|
||||||
self.emit('database-changed',(self.db,))
|
self.emit('database-changed',(self.db,))
|
||||||
|
@ -334,3 +334,25 @@ class MonitoredDate:
|
|||||||
|
|
||||||
field.set_text(DateHandler.displayer.display(self.date))
|
field.set_text(DateHandler.displayer.display(self.date))
|
||||||
|
|
||||||
|
class MonitoredPlace:
|
||||||
|
|
||||||
|
def __init__(self,obj,set_val,get_val,mapping,custom):
|
||||||
|
self.set_val = set_val
|
||||||
|
self.get_val = get_val
|
||||||
|
|
||||||
|
self.obj = obj
|
||||||
|
|
||||||
|
val = get_val()
|
||||||
|
if val:
|
||||||
|
default = val[0]
|
||||||
|
else:
|
||||||
|
default = None
|
||||||
|
|
||||||
|
self.sel = AutoComp.StandardCustomSelector(
|
||||||
|
mapping, obj, custom, default)
|
||||||
|
|
||||||
|
self.obj.connect('changed', self.on_change)
|
||||||
|
|
||||||
|
def on_change(self, obj):
|
||||||
|
self.set_val(self.sel.get_values())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user