From c63c61be7e818151b39a1cdb98048046e7c6a0b4 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 22 Mar 2002 03:07:05 +0000 Subject: [PATCH] Additional Find dialog boxes svn: r853 --- gramps/src/AddrEdit.py | 3 + gramps/src/EditPerson.glade | 65 ++++++++---- gramps/src/EditPerson.py | 1 + gramps/src/EventEdit.py | 2 + gramps/src/Find.py | 199 +++++++++++++++++++++++++++++++----- gramps/src/MediaView.py | 5 + gramps/src/PlaceView.py | 5 + gramps/src/SourceView.py | 5 + gramps/src/dialog.glade | 11 ++ gramps/src/gramps.py | 7 +- gramps/src/gramps_main.py | 26 ++++- 11 files changed, 280 insertions(+), 49 deletions(-) diff --git a/gramps/src/AddrEdit.py b/gramps/src/AddrEdit.py index 1fc6f5faa..405bf449a 100644 --- a/gramps/src/AddrEdit.py +++ b/gramps/src/AddrEdit.py @@ -39,6 +39,7 @@ import Utils import Date import RelLib +from DateEdit import DateEdit from intl import gettext _ = gettext @@ -101,6 +102,8 @@ class AddressEditor: else: self.srcreflist = [] + self.date_check = DateEdit(self.addr_start,self.top.get_widget("date_stat")) + self.top.signal_autoconnect({ "destroy_passed_object" : Utils.destroy_passed_object, "on_addr_edit_ok_clicked" : self.ok_clicked, diff --git a/gramps/src/EditPerson.glade b/gramps/src/EditPerson.glade index 0304901b3..6b2ae486e 100644 --- a/gramps/src/EditPerson.glade +++ b/gramps/src/EditPerson.glade @@ -423,7 +423,7 @@ GtkTable table17 2 - 4 + 5 False 0 0 @@ -556,6 +556,36 @@ + + GtkButton + button126 + 1 + Invoke death event editor + True + + clicked + on_edit_death_clicked + editPerson + Tue, 02 Oct 2001 22:28:47 GMT + + + GTK_RELIEF_NORMAL + + 4 + 5 + 0 + 1 + 3 + 3 + False + False + False + False + True + False + + + GtkCombo dpcombo @@ -568,7 +598,7 @@ 2 - 4 + 5 1 2 3 @@ -594,32 +624,21 @@ - GtkButton - button126 - 1 - Invoke death event editor - True - - clicked - on_edit_death_clicked - editPerson - Tue, 02 Oct 2001 22:28:47 GMT - - - GTK_RELIEF_NORMAL + GnomePixmap + death_stat 3 4 0 1 - 3 - 3 + 0 + 0 False False False False True - False + True @@ -6571,6 +6590,16 @@ + + GnomePixmap + date_stat + + 5 + False + True + + + GtkOptionMenu calendar diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index 816886a3f..c80080a9a 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -607,6 +607,7 @@ class EditPerson: self.ddate.set_text(self.death.getDate()) self.dplace.set_text(self.death.getPlaceName()) self.bplace.set_text(prev_btext) + self.ddate_check = DateEdit(self.ddate,self.get_widget("death_stat")) def on_add_addr_clicked(self,obj): """Invokes the address editor to add a new address""" diff --git a/gramps/src/EventEdit.py b/gramps/src/EventEdit.py index bf6559c93..c579a341a 100644 --- a/gramps/src/EventEdit.py +++ b/gramps/src/EventEdit.py @@ -39,6 +39,7 @@ import Utils import GrampsCfg import AutoComp +from DateEdit import DateEdit from Date import compare_dates from RelLib import * from intl import gettext @@ -121,6 +122,7 @@ class EventEditor: else: if (def_placename): self.place_field.set_text(def_placename) + self.date_check = DateEdit(self.date_field,self.top.get_widget("date_stat")) if not read_only: self.name_field.select_region(0, -1) diff --git a/gramps/src/Find.py b/gramps/src/Find.py index 25b25f6c9..62a60d48c 100644 --- a/gramps/src/Find.py +++ b/gramps/src/Find.py @@ -31,10 +31,10 @@ import AutoComp from intl import gettext _ = gettext -class Find: +class FindBase: """Opens find person dialog for gramps""" - def __init__(self,clist,task,plist): + def __init__(self,clist,task,name): """Opens a dialog box instance that allows users to search for a person. @@ -42,13 +42,14 @@ class Find: task - function to call to change the active person""" self.clist = clist + self.nlist = [] self.task = task - title = "%s - GRAMPS" % _("Find Person") + title = "%s - GRAMPS" % name self.top = GnomeDialog(title,STOCK_BUTTON_PREV, STOCK_BUTTON_NEXT,STOCK_BUTTON_CLOSE) self.top.set_policy(0,1,0) self.top.vbox.set_spacing(5) - self.top.vbox.pack_start(gtk.GtkLabel(_("Find Person")),0,0,5) + self.top.vbox.pack_start(gtk.GtkLabel(name),0,0,5) self.top.vbox.pack_start(gtk.GtkHSeparator(),0,0,0) self.entry = gtk.GtkEntry() self.top.vbox.pack_start(self.entry,0,0,25) @@ -60,14 +61,52 @@ class Find: self.top.show_all() self.top.editable_enters(self.entry) self.entry.grab_focus() - - self.nlist = [] - for n in plist: - self.nlist.append(n.getPrimaryName().getName()) - + + def enable_autocomp(self): if GrampsCfg.autocomp: self.comp = AutoComp.AutoEntry(self.entry,self.nlist) + + def advance(self,func): + pass + def forward(self): + self.row = self.row + 1 + if self.row == self.clist.rows: + self.row = 0 + + def backward(self): + self.row = self.row - 1 + if self.row < 0: + self.row = self.clist.rows + + def on_close_clicked(self,obj): + self.top.destroy() + + def on_next_clicked(self,obj): + """Advances to the next person that matches the dialog text""" + self.advance(self.forward) + + def on_prev_clicked(self,obj): + """Advances to the previous person that matches the dialog text""" + self.advance(self.backward) + + + +class FindPerson(FindBase): + """Opens a Find Person dialog for GRAMPS""" + + def __init__(self,clist,task,plist): + """Opens a dialog box instance that allows users to + search for a person. + + clist - GtkCList containing the people information + task - function to call to change the active person""" + + FindBase.__init__(self,clist,task,_("Find Person")) + for n in plist: + self.nlist.append(n.getPrimaryName().getName()) + self.enable_autocomp() + def advance(self,func): try: self.row = self.clist.selection[0] @@ -96,25 +135,135 @@ class Find: func() gtk.gdk_beep() - def forward(self): - self.row = self.row + 1 - if self.row == self.clist.rows: - self.row = 0 +class FindPlace(FindBase): + """Opens a Find Place dialog for GRAMPS""" + + def __init__(self,clist,task,plist): + """Opens a dialog box instance that allows users to + search for a place. + + clist - GtkCList containing the people information + task - function to call to change the active person""" + + FindBase.__init__(self,clist,task,_("Find Place")) + for n in plist: + self.nlist.append(n.get_title()) + self.enable_autocomp() + + def advance(self,func): + try: + self.row = self.clist.selection[0] + except IndexError: + gtk.gdk_beep() + return + + text = self.entry.get_text() + if self.row == None or text == "": + gtk.gdk_beep() + return + orow = self.row + func() + place = None + while self.row != orow: + value = self.clist.get_row_data(self.row) + if value == None: + func() + continue + name = value.get_title() + if string.find(string.upper(name),string.upper(text)) >= 0: + self.task(self.row) + return + func() + gtk.gdk_beep() + +class FindSource(FindBase): + """Opens a Find Place dialog for GRAMPS""" + + def __init__(self,clist,task,plist): + """Opens a dialog box instance that allows users to + search for a place. + + clist - GtkCList containing the people information + task - function to call to change the active person""" + + FindBase.__init__(self,clist,task,_("Find Source")) + for n in plist: + self.nlist.append(n.getTitle()) + self.enable_autocomp() + + def advance(self,func): + try: + self.row = self.clist.selection[0] + except IndexError: + gtk.gdk_beep() + return + + text = self.entry.get_text() + if self.row == None or text == "": + gtk.gdk_beep() + return + orow = self.row + func() + place = None + while self.row != orow: + value = self.clist.get_row_data(self.row) + if value == None: + func() + continue + name = value.getTitle() + if string.find(string.upper(name),string.upper(text)) >= 0: + self.task(self.row) + return + func() + gtk.gdk_beep() + +class FindMedia(FindBase): + """Opens a Find Media Object dialog for GRAMPS""" + + def __init__(self,clist,task,plist): + """Opens a dialog box instance that allows users to + search for a place. + + clist - GtkCList containing the people information + task - function to call to change the active person""" + + FindBase.__init__(self,clist,task,_("Find Media Object")) + for n in plist: + self.nlist.append(n.getDescription()) + self.enable_autocomp() + + def advance(self,func): + try: + self.row = self.clist.selection[0] + except IndexError: + gtk.gdk_beep() + return + + text = self.entry.get_text() + if self.row == None or text == "": + gtk.gdk_beep() + return + orow = self.row + func() + place = None + while self.row != orow: + value = self.clist.get_row_data(self.row) + if value == None: + func() + continue + name = value.getDescription() + if string.find(string.upper(name),string.upper(text)) >= 0: + self.task(self.row) + return + func() + gtk.gdk_beep() + + + + - def backward(self): - self.row = self.row - 1 - if self.row < 0: - self.row = self.clist.rows - def on_close_clicked(self,obj): - self.top.destroy() - def on_next_clicked(self,obj): - """Advances to the next person that matches the dialog text""" - self.advance(self.forward) - def on_prev_clicked(self,obj): - """Advances to the previous person that matches the dialog text""" - self.advance(self.backward) diff --git a/gramps/src/MediaView.py b/gramps/src/MediaView.py index 7b6d1a082..a50b95a3f 100644 --- a/gramps/src/MediaView.py +++ b/gramps/src/MediaView.py @@ -83,6 +83,11 @@ class MediaView: self.media_list.set_sort_column(self.sort_map[self.sort_col]) self.set_arrow(self.sort_col) + def moveto(self,row): + self.media_list.unselect_all() + self.media_list.select_row(row,0) + self.media_list.moveto(row) + def set_arrow(self,column): for a in self.sort_arrow: a.hide() diff --git a/gramps/src/PlaceView.py b/gramps/src/PlaceView.py index 4b88376a7..36667176a 100644 --- a/gramps/src/PlaceView.py +++ b/gramps/src/PlaceView.py @@ -224,6 +224,11 @@ class PlaceView: def on_add_place_clicked(self,obj): EditPlace.EditPlace(Place(),self.db,self.new_place_after_edit) + def moveto(self,row): + self.place_list.unselect_all() + self.place_list.select_row(row,0) + self.place_list.moveto(row) + def on_delete_place_clicked(self,obj): if len(obj.selection) == 0: return diff --git a/gramps/src/SourceView.py b/gramps/src/SourceView.py index 951eeb723..7bff79840 100644 --- a/gramps/src/SourceView.py +++ b/gramps/src/SourceView.py @@ -77,6 +77,11 @@ class SourceView: self.source_list.set_sort_column(self.sort_map[self.sort_col]) self.set_arrow(self.sort_col) + def moveto(self,row): + self.source_list.unselect_all() + self.source_list.select_row(row,0) + self.source_list.moveto(row) + def set_arrow(self,column): for a in self.sort_arrow: diff --git a/gramps/src/dialog.glade b/gramps/src/dialog.glade index 8f1157f06..6d09568dd 100644 --- a/gramps/src/dialog.glade +++ b/gramps/src/dialog.glade @@ -483,6 +483,17 @@ + + GnomePixmap + date_stat + 10 + + 5 + False + True + + + GtkOptionMenu calendar diff --git a/gramps/src/gramps.py b/gramps/src/gramps.py index 9e0d587a0..eeabc0350 100755 --- a/gramps/src/gramps.py +++ b/gramps/src/gramps.py @@ -3,10 +3,13 @@ import traceback import intl import os +import GdkImlib import gtk import gnome.ui import gnome.config import locale +import gramps_main +import sys if os.environ.has_key("GRAMPSI18N"): loc = os.environ["GRAMPSI18N"] @@ -18,10 +21,6 @@ intl.bindtextdomain("gramps",loc) locale.setlocale(locale.LC_NUMERIC,"C") -import gramps_main -import sys -import locale - if len(sys.argv) > 1: arg = sys.argv[1] else: diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 2c9c82851..4519760a9 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -318,8 +318,18 @@ class Gramps: def on_find_activate(self,obj): """Display the find box""" - Find.Find(self.person_list,self.find_goto_to, - self.database.getPersonMap().values()) + if self.notebook.get_current_page() == 4: + Find.FindPlace(self.place_view.place_list,self.find_goto_place, + self.database.getPlaceMap().values()) + elif self.notebook.get_current_page() == 3: + Find.FindSource(self.source_view.source_list,self.find_goto_source, + self.database.getSourceMap().values()) + elif self.notebook.get_current_page() == 5: + Find.FindMedia(self.media_view.media_list,self.find_goto_media, + self.database.getObjectMap().values()) + else: + Find.FindPerson(self.person_list,self.find_goto_to, + self.database.getPersonMap().values()) def on_findname_activate(self,obj): """Display the find box""" @@ -331,6 +341,18 @@ class Gramps: self.goto_active_person() self.update_display(0) + def find_goto_place(self,row): + """Find callback to jump to the selected place""" + self.place_view.moveto(row) + + def find_goto_source(self,row): + """Find callback to jump to the selected source""" + self.source_view.moveto(row) + + def find_goto_media(self,row): + """Find callback to jump to the selected media""" + self.media_view.moveto(row) + def on_gramps_home_page_activate(self,obj): import gnome.url gnome.url.show("http://gramps.sourceforge.net")