From f2cf13f469b288ccbdcf07efafe3b4423c5507b4 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 7 Jun 2005 05:08:50 +0000 Subject: [PATCH] * src/DisplayModels.py: Support for event view. * src/EventEdit.py: Commit event on OK. * src/GrampsDbBase.py: Event column order and event cursor. * src/GrampsInMemDB.py: Event cursor. * src/gramps.glade: Event View, rework buttons. * src/gramps_main.py: Event View support. * src/EventView.py: Add to CVS. * src/Makefile.am: Ship EventView. svn: r4797 --- gramps2/ChangeLog | 9 + gramps2/src/DisplayModels.py | 69 ++++ gramps2/src/EventEdit.py | 42 +-- gramps2/src/EventView.py | 282 ++++++++++++++++ gramps2/src/GrampsDbBase.py | 12 + gramps2/src/GrampsInMemDB.py | 3 + gramps2/src/Makefile.am | 3 +- gramps2/src/gramps.glade | 612 +++++++++++++++++++++++++++-------- gramps2/src/gramps_main.py | 30 ++ 9 files changed, 904 insertions(+), 158 deletions(-) create mode 100644 gramps2/src/EventView.py diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3e52a3e3a..cd64bf3a5 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -10,6 +10,15 @@ * src/edit_person.glade: Add select button to the event tab. * src/gramps.glade: Add new editor for both events and refs. + * src/DisplayModels.py: Support for event view. + * src/EventEdit.py: Commit event on OK. + * src/GrampsDbBase.py: Event column order and event cursor. + * src/GrampsInMemDB.py: Event cursor. + * src/gramps.glade: Event View, rework buttons. + * src/gramps_main.py: Event View support. + * src/EventView.py: Add to CVS. + * src/Makefile.am: Ship EventView. + 2005-06-05 Alex Roitman * src/DateHandler.py: Fix typo caught in gramps20 branch. diff --git a/gramps2/src/DisplayModels.py b/gramps2/src/DisplayModels.py index dcdd6196a..e8d21bea0 100644 --- a/gramps2/src/DisplayModels.py +++ b/gramps2/src/DisplayModels.py @@ -489,6 +489,75 @@ class MediaModel(BaseModel): return unicode(time.strftime(_date_format,time.localtime(data[8])), _codeset) +#------------------------------------------------------------------------- +# +# EventModel +# +#------------------------------------------------------------------------- +class EventModel(BaseModel): + + def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING): + self.gen_cursor = db.get_event_cursor + self.map = db.event_map + + self.fmap = [ + self.column_description, + self.column_id, + self.column_type, + self.column_change, + self.column_date, + self.column_place, + self.column_cause, + self.column_handle, + ] + self.smap = [ + self.column_description, + self.column_id, + self.column_type, + self.sort_change, + self.column_date, + self.column_place, + self.column_cause, + self.column_handle, + ] + BaseModel.__init__(self,db,scol,order) + + def on_get_n_columns(self): + return len(self.fmap)+1 + + def column_description(self,data): + return unicode(data[4]) + + def column_cause(self,data): + return unicode(data[6]) + + def column_place(self,data): + if data[5]: + return unicode(self.db.get_place_from_handle(data[5]).get_title()) + else: + return u'' + + def column_type(self,data): + return unicode(data[2][1]) + + def column_id(self,data): + return unicode(data[1]) + + def column_date(self,data): + if data[3]: + return unicode(DateHandler.displayer.display(data[3])) + return u'' + + def column_handle(self,data): + return unicode(data[0]) + + def sort_change(self,data): + return time.localtime(data[11]) + + def column_change(self,data): + return unicode(time.strftime(_date_format,time.localtime(data[11])), + _codeset) + #------------------------------------------------------------------------- # diff --git a/gramps2/src/EventEdit.py b/gramps2/src/EventEdit.py index faab31eae..3ae085a18 100644 --- a/gramps2/src/EventEdit.py +++ b/gramps2/src/EventEdit.py @@ -80,10 +80,12 @@ def get_place(field,pmap,db): #------------------------------------------------------------------------- class EventEditor: - def __init__(self,parent,name,etypes,event,def_placename, - read_only, cb, def_event=None, noedit=False): + def __init__(self,event,db,parent,parent_window): + #read_only, cb, def_event=None, noedit=False): self.parent = parent - self.db = self.parent.db + self.db = db + read_only = self.db.readonly + noedit = self.db.readonly if event: if self.parent.child_windows.has_key(event.get_handle()): self.parent.child_windows[event.get_handle()].present(None) @@ -94,7 +96,6 @@ class EventEditor: self.win_key = self self.event = event self.child_windows = {} - self.callback = cb self.path = self.db.get_save_path() self.plist = [] self.pmap = {} @@ -115,10 +116,10 @@ class EventEditor: self.window = self.top.get_widget("event_edit") title_label = self.top.get_widget('title') - if name == ", ": - etitle = _('Event Editor') - else: - etitle = _('Event Editor for %s') % name + #if name == ", ": + etitle = _('Event Editor') + #else: + # etitle = _('Event Editor for %s') % name Utils.set_titles(self.window,title_label, etitle, _('Event Editor')) @@ -188,16 +189,16 @@ class EventEditor: AutoComp.fill_entry(self.place_field,self.pmap.keys()) if event != None: -# self.event_menu.child.set_text(transname) - if def_placename: - self.place_field.set_text(def_placename) + # self.event_menu.child.set_text(transname) + # if def_placename: + # self.place_field.set_text(def_placename) + # else: + place_handle = event.get_place_handle() + if not place_handle: + place_name = u"" else: - 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) + 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)) self.cause_field.set_text(event.get_cause()) @@ -345,9 +346,12 @@ class EventEditor: self.update_event(event_data,self.date,eplace_obj,edesc,enote,eformat, epriv,ecause) + if self.parent.lists_changed: + trans = self.db.transaction_begin() + self.db.commit_event(self.event,trans) + self.db.transaction_commit(trans,_("Edit Event")) + self.close(obj) - if self.callback: - self.callback(self.event) def update_event(self,the_type,date,place,desc,note,format,priv,cause): if place: diff --git a/gramps2/src/EventView.py b/gramps2/src/EventView.py new file mode 100644 index 000000000..74f642504 --- /dev/null +++ b/gramps2/src/EventView.py @@ -0,0 +1,282 @@ +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2001-2005 Donald N. Allingham +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +import gtk +import gtk.gdk + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import RelLib +import EventEdit +import DisplayModels +import const +import Utils +from QuestionDialog import QuestionDialog, ErrorDialog + +#------------------------------------------------------------------------- +# +# internationalization +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + + +column_names = [ + _('Description'), + _('ID'), + _('Type'), + _('Date'), + _('Place'), + _('Cause'), + ] + +_HANDLE_COL = 7 + +#------------------------------------------------------------------------- +# +# EventView +# +#------------------------------------------------------------------------- +class EventView: + def __init__(self,parent,db,glade): + self.parent = parent + self.parent.connect('database-changed',self.change_db) + + self.glade = glade + self.list = glade.get_widget("event_list") + self.list.connect('button-press-event',self.button_press) + self.list.connect('key-press-event',self.key_press) + self.selection = self.list.get_selection() + self.selection.set_mode(gtk.SELECTION_MULTIPLE) + self.renderer = gtk.CellRendererText() + self.model = DisplayModels.EventModel(self.parent.db,0) + self.sort_col = 0 + + self.list.set_model(self.model) + self.list.set_headers_clickable(True) + self.topWindow = self.glade.get_widget("gramps") + + self.columns = [] + self.change_db(db) + + def column_clicked(self,obj,data): + if self.sort_col != data: + order = gtk.SORT_ASCENDING + else: + if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING + or self.columns[data].get_sort_indicator() == False): + order = gtk.SORT_ASCENDING + else: + order = gtk.SORT_DESCENDING + self.sort_col = data + handle = self.first_selected() + self.model = DisplayModels.EventModel(self.parent.db, + self.sort_col,order) + self.list.set_model(self.model) + colmap = self.parent.db.get_repository_column_order() + + if handle: + path = self.model.on_get_path(handle) + 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): + for column in self.columns: + self.list.remove_column(column) + + column = gtk.TreeViewColumn(_('Type'), self.renderer,text=0) + 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 + for pair in self.parent.db.get_event_column_order(): + if not pair[0]: + continue + print pair + 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): + db.connect('event-add', self.event_add) + db.connect('event-update', self.event_update) + db.connect('event-delete', self.event_delete) + db.connect('event-rebuild',self.build_tree) + self.build_columns() + self.build_tree() + + def build_tree(self): + self.list.set_model(None) + self.model = DisplayModels.EventModel(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] + the_event = self.parent.db.get_event_from_handle(handle) + EventEdit.EventEditor(the_event,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(_('Event 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): + EventEdit.EventEditor(RelLib.Event(),self.parent.db,self.parent, + self.topWindow) + + def on_delete_clicked(self,obj): + mlist = [] + self.selection.selected_foreach(self.blist,mlist) + + for event_handle in mlist: + + person_list = [ handle for handle in + self.parent.db.get_person_handles(False) + if self.parent.db.get_person_from_handle(handle).has_handle_reference('Event',event_handle) ] + family_list = [ handle for handle in + self.parent.db.get_family_handles() + if self.parent.db.get_family_from_handle(handle).has_handle_reference('Event',event_handle) ] + + event = self.parent.db.get_event_from_handle(event_handle) + + ans = EventEdit.DelReposQuery(event,self.parent.db, + person_list+family_list) + + if len(person_list+family_list) > 0: + msg = _('This event is currently being used. Deleting it ' + 'will remove it from the database and from all ' + 'people and families that reference it.') + else: + msg = _('Deleting event will remove it from the database.') + + msg = "%s %s" % (msg,Utils.data_recover_msg) + QuestionDialog(_('Delete %s?') % event.get_gramps_id(), msg, + _('_Delete Event'),ans.query_response, + self.topWindow) + + def on_edit_clicked(self,obj): + mlist = [] + self.selection.selected_foreach(self.blist,mlist) + + for handle in mlist: + event = self.parent.db.get_event_from_handle(handle) + EventEdit.EventEditor(event, self.parent.db, self.parent, + self.topWindow) + + def event_add(self,handle_list): + for handle in handle_list: + self.model.add_row_by_handle(handle) + + def event_update(self,handle_list): + for handle in handle_list: + self.model.update_row_by_handle(handle) + + def event_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) diff --git a/gramps2/src/GrampsDbBase.py b/gramps2/src/GrampsDbBase.py index 6f9d24031..f1a1ae3f4 100644 --- a/gramps2/src/GrampsDbBase.py +++ b/gramps2/src/GrampsDbBase.py @@ -69,6 +69,7 @@ PLACE_COL_KEY = 'place_columns' SOURCE_COL_KEY = 'source_columns' MEDIA_COL_KEY = 'media_columns' REPOSITORY_COL_KEY = 'repository_columns' +EVENT_COL_KEY = 'event_columns' _sigbase = ('person', 'family', 'source', 'event', 'media', 'place', 'repository') @@ -235,6 +236,9 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): def get_family_cursor(self): assert False, "Needs to be overridden in the derived class" + def get_event_cursor(self): + assert False, "Needs to be overridden in the derived class" + def get_place_cursor(self): assert False, "Needs to be overridden in the derived class" @@ -1355,6 +1359,14 @@ class GrampsDbBase(GrampsDBCallback.GrampsDBCallback): default = [(1,1),(0,5),(0,6),(1,2),(1,3),(0,4)] return self._get_column_order(MEDIA_COL_KEY,default) + def get_event_column_order(self): + """ + Returns the Event display common information stored in the + database's metadata. + """ + default = [(1,0),(1,1),(1,2),(0,3),(1,4),(1,5),(0,6)] + return self._get_column_order(EVENT_COL_KEY,default) + def get_repository_column_order(self): """ Returns the Repository display common information stored in the diff --git a/gramps2/src/GrampsInMemDB.py b/gramps2/src/GrampsInMemDB.py index 09ea9182c..97fdbe3a0 100644 --- a/gramps2/src/GrampsInMemDB.py +++ b/gramps2/src/GrampsInMemDB.py @@ -104,6 +104,9 @@ class GrampsInMemDB(GrampsDbBase): def get_family_cursor(self): return GrampsInMemCursor(self.family_map) + def get_event_cursor(self): + return GrampsInMemCursor(self.event_map) + def get_place_cursor(self): return GrampsInMemCursor(self.place_map) diff --git a/gramps2/src/Makefile.am b/gramps2/src/Makefile.am index 54176d94c..3d5e723ca 100644 --- a/gramps2/src/Makefile.am +++ b/gramps2/src/Makefile.am @@ -120,7 +120,8 @@ gdir_PYTHON = \ RecentFiles.py\ ReportOptions.py\ ReadGrdb.py\ - WriteGrdb.py + WriteGrdb.py\ + EventView.py # Could use GNU make's ':=' syntax for nice wildcard use. # If not using GNU make, then list all files individually diff --git a/gramps2/src/gramps.glade b/gramps2/src/gramps.glade index a96012de9..39db8b473 100644 --- a/gramps2/src/gramps.glade +++ b/gramps2/src/gramps.glade @@ -1005,13 +1005,47 @@ - + True - people48.png - 0.5 - 0.5 - 0 - 0 + False + 2 + + + + True + people48.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>People</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + @@ -1022,28 +1056,6 @@ - - - True - <b>People</b> - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views - - - 0 - False - False - - - True @@ -1053,13 +1065,61 @@ - + True - family48.png 0.5 0.5 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + family48.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Family</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + @@ -1070,28 +1130,6 @@ - - - True - <b>Family</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views - - - 0 - False - False - - - True @@ -1101,13 +1139,61 @@ - + True - gramps.png 0.5 0.5 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gramps.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Pedigree</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + @@ -1118,28 +1204,6 @@ - - - True - <b>Pedigree</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views - - - 0 - False - False - - - True @@ -1149,13 +1213,61 @@ - + True - sources.png 0.5 0.5 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + sources.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Sources</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + @@ -1167,19 +1279,72 @@ - + True - <b>Sources</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views + True + GTK_RELIEF_NONE + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + sources.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Reposi- +tories</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -1197,13 +1362,61 @@ - + True - place.png 0.5 0.5 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + place.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Places</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + @@ -1214,28 +1427,6 @@ - - - True - <b>Places</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views - - - 0 - False - False - - - True @@ -1245,13 +1436,61 @@ - + True - media.png 0.5 0.5 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + media.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Media</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + @@ -1263,19 +1502,71 @@ - + True - <b>Media</b> - True - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - views + True + GTK_RELIEF_NONE + True + + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + media.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + <b>Events</b> + True + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -3611,6 +3902,51 @@ tab + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + True + False + True + + + + + False + True + + + + + + True + <b>Events</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + 0 diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index fa700e2e7..ee05c6ec0 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -58,6 +58,7 @@ import PedView import MediaView import PlaceView import FamilyView +import EventView import SourceView import RepositoryView import PeopleView @@ -102,6 +103,7 @@ SOURCE_VIEW = 4 REPOSITORY_VIEW = 5 PLACE_VIEW = 6 MEDIA_VIEW = 7 +EVENT_VIEW = 8 #------------------------------------------------------------------------- # @@ -383,6 +385,7 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.repository_view = RepositoryView.RepositoryView(self,self.db,self.gtop) self.media_view = MediaView.MediaView(self,self.db,self.gtop, self.update_display) + self.event_view = EventView.EventView(self,self.db,self.gtop) self.add_button = self.gtop.get_widget('addbtn') self.add_item = self.gtop.get_widget('add_item') @@ -471,6 +474,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): "on_gramps_report_bug_activate" : self.report_bug_activate, "on_gramps_mailing_lists_activate" : self.mailing_lists_activate, "on_open_example" : self.open_example, + "on_events_activate" : self.on_events_activate, + "on_repos_activate" : self.on_repos_activate, }) self.filter_btn.set_active(GrampsKeys.get_filter()) @@ -597,6 +602,10 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.db.set_media_column_order(list) self.media_view.build_columns() + def set_event_column_order(self,list): + self.db.set_event_column_order(list) + self.event_view.build_columns() + def column_order(self,obj): import ColumnOrder @@ -621,6 +630,10 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): ColumnOrder.ColumnOrder(self.db.get_media_column_order(), MediaView.column_names, self.set_media_column_order) + elif cpage == EVENT_VIEW: + ColumnOrder.ColumnOrder(self.db.get_event_column_order(), + EventView.column_names, + self.set_event_column_order) def clear_history(self): self.history = [] @@ -860,6 +873,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.place_view.on_edit_clicked(obj) elif cpage == MEDIA_VIEW: self.media_view.on_edit_clicked(obj) + elif cpage == EVENT_VIEW: + self.event_view.on_edit_clicked(obj) def add_button_clicked(self,obj): cpage = self.views.get_current_page() @@ -873,6 +888,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.place_view.on_add_place_clicked(obj) elif cpage == MEDIA_VIEW: self.media_view.on_add_clicked(obj) + elif cpage == EVENT_VIEW: + self.event_view.on_add_clicked(obj) def remove_button_clicked(self,obj): cpage = self.views.get_current_page() @@ -886,6 +903,8 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): self.place_view.on_delete_clicked(obj) elif cpage == MEDIA_VIEW: self.media_view.on_delete_clicked(obj) + elif cpage == EVENT_VIEW: + self.event_view.on_delete_clicked(obj) def enable_buttons(self,val): if self.db.readonly: @@ -1675,6 +1694,14 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): """Switches to the media view""" self.views.set_current_page(MEDIA_VIEW) + def on_events_activate(self,obj): + """Switches to the event view""" + self.views.set_current_page(EVENT_VIEW) + + def on_repos_activate(self,obj): + """Switches to the repository view""" + self.views.set_current_page(REPOSITORY_VIEW) + def on_views_switch_page(self,obj,junk,page): """Load the appropriate page after a notebook switch""" if page == PERSON_VIEW: @@ -1697,6 +1724,9 @@ class Gramps(GrampsDBCallback.GrampsDBCallback): elif page == MEDIA_VIEW: self.enable_buttons(1) self.merge_button.set_sensitive(0) + elif page == EVENT_VIEW: + self.enable_buttons(1) + self.merge_button.set_sensitive(0) def on_apply_filter_clicked(self,obj): self.people_view.apply_filter_clicked()