Additional Find dialog boxes

svn: r853
This commit is contained in:
Don Allingham 2002-03-22 03:07:05 +00:00
parent 6b921b3d97
commit c63c61be7e
11 changed files with 280 additions and 49 deletions

View File

@ -39,6 +39,7 @@ import Utils
import Date import Date
import RelLib import RelLib
from DateEdit import DateEdit
from intl import gettext from intl import gettext
_ = gettext _ = gettext
@ -101,6 +102,8 @@ class AddressEditor:
else: else:
self.srcreflist = [] self.srcreflist = []
self.date_check = DateEdit(self.addr_start,self.top.get_widget("date_stat"))
self.top.signal_autoconnect({ self.top.signal_autoconnect({
"destroy_passed_object" : Utils.destroy_passed_object, "destroy_passed_object" : Utils.destroy_passed_object,
"on_addr_edit_ok_clicked" : self.ok_clicked, "on_addr_edit_ok_clicked" : self.ok_clicked,

View File

@ -423,7 +423,7 @@
<class>GtkTable</class> <class>GtkTable</class>
<name>table17</name> <name>table17</name>
<rows>2</rows> <rows>2</rows>
<columns>4</columns> <columns>5</columns>
<homogeneous>False</homogeneous> <homogeneous>False</homogeneous>
<row_spacing>0</row_spacing> <row_spacing>0</row_spacing>
<column_spacing>0</column_spacing> <column_spacing>0</column_spacing>
@ -556,6 +556,36 @@
</child> </child>
</widget> </widget>
<widget>
<class>GtkButton</class>
<name>button126</name>
<border_width>1</border_width>
<tooltip>Invoke death event editor</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_edit_death_clicked</handler>
<object>editPerson</object>
<last_modification_time>Tue, 02 Oct 2001 22:28:47 GMT</last_modification_time>
</signal>
<label>Edit</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<left_attach>4</left_attach>
<right_attach>5</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>3</xpad>
<ypad>3</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget> <widget>
<class>GtkCombo</class> <class>GtkCombo</class>
<name>dpcombo</name> <name>dpcombo</name>
@ -568,7 +598,7 @@
<items></items> <items></items>
<child> <child>
<left_attach>2</left_attach> <left_attach>2</left_attach>
<right_attach>4</right_attach> <right_attach>5</right_attach>
<top_attach>1</top_attach> <top_attach>1</top_attach>
<bottom_attach>2</bottom_attach> <bottom_attach>2</bottom_attach>
<xpad>3</xpad> <xpad>3</xpad>
@ -594,32 +624,21 @@
</widget> </widget>
<widget> <widget>
<class>GtkButton</class> <class>GnomePixmap</class>
<name>button126</name> <name>death_stat</name>
<border_width>1</border_width>
<tooltip>Invoke death event editor</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_edit_death_clicked</handler>
<object>editPerson</object>
<last_modification_time>Tue, 02 Oct 2001 22:28:47 GMT</last_modification_time>
</signal>
<label>Edit</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child> <child>
<left_attach>3</left_attach> <left_attach>3</left_attach>
<right_attach>4</right_attach> <right_attach>4</right_attach>
<top_attach>0</top_attach> <top_attach>0</top_attach>
<bottom_attach>1</bottom_attach> <bottom_attach>1</bottom_attach>
<xpad>3</xpad> <xpad>0</xpad>
<ypad>3</ypad> <ypad>0</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
<yexpand>False</yexpand> <yexpand>False</yexpand>
<xshrink>False</xshrink> <xshrink>False</xshrink>
<yshrink>False</yshrink> <yshrink>False</yshrink>
<xfill>True</xfill> <xfill>True</xfill>
<yfill>False</yfill> <yfill>True</yfill>
</child> </child>
</widget> </widget>
</widget> </widget>
@ -6571,6 +6590,16 @@
</child> </child>
</widget> </widget>
<widget>
<class>GnomePixmap</class>
<name>date_stat</name>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget> <widget>
<class>GtkOptionMenu</class> <class>GtkOptionMenu</class>
<name>calendar</name> <name>calendar</name>

View File

@ -607,6 +607,7 @@ class EditPerson:
self.ddate.set_text(self.death.getDate()) self.ddate.set_text(self.death.getDate())
self.dplace.set_text(self.death.getPlaceName()) self.dplace.set_text(self.death.getPlaceName())
self.bplace.set_text(prev_btext) self.bplace.set_text(prev_btext)
self.ddate_check = DateEdit(self.ddate,self.get_widget("death_stat"))
def on_add_addr_clicked(self,obj): def on_add_addr_clicked(self,obj):
"""Invokes the address editor to add a new address""" """Invokes the address editor to add a new address"""

View File

@ -39,6 +39,7 @@ import Utils
import GrampsCfg import GrampsCfg
import AutoComp import AutoComp
from DateEdit import DateEdit
from Date import compare_dates from Date import compare_dates
from RelLib import * from RelLib import *
from intl import gettext from intl import gettext
@ -121,6 +122,7 @@ class EventEditor:
else: else:
if (def_placename): if (def_placename):
self.place_field.set_text(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: if not read_only:
self.name_field.select_region(0, -1) self.name_field.select_region(0, -1)

View File

@ -31,10 +31,10 @@ import AutoComp
from intl import gettext from intl import gettext
_ = gettext _ = gettext
class Find: class FindBase:
"""Opens find person dialog for gramps""" """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 """Opens a dialog box instance that allows users to
search for a person. search for a person.
@ -42,13 +42,14 @@ class Find:
task - function to call to change the active person""" task - function to call to change the active person"""
self.clist = clist self.clist = clist
self.nlist = []
self.task = task self.task = task
title = "%s - GRAMPS" % _("Find Person") title = "%s - GRAMPS" % name
self.top = GnomeDialog(title,STOCK_BUTTON_PREV, self.top = GnomeDialog(title,STOCK_BUTTON_PREV,
STOCK_BUTTON_NEXT,STOCK_BUTTON_CLOSE) STOCK_BUTTON_NEXT,STOCK_BUTTON_CLOSE)
self.top.set_policy(0,1,0) self.top.set_policy(0,1,0)
self.top.vbox.set_spacing(5) 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.top.vbox.pack_start(gtk.GtkHSeparator(),0,0,0)
self.entry = gtk.GtkEntry() self.entry = gtk.GtkEntry()
self.top.vbox.pack_start(self.entry,0,0,25) self.top.vbox.pack_start(self.entry,0,0,25)
@ -61,13 +62,51 @@ class Find:
self.top.editable_enters(self.entry) self.top.editable_enters(self.entry)
self.entry.grab_focus() self.entry.grab_focus()
self.nlist = [] def enable_autocomp(self):
for n in plist:
self.nlist.append(n.getPrimaryName().getName())
if GrampsCfg.autocomp: if GrampsCfg.autocomp:
self.comp = AutoComp.AutoEntry(self.entry,self.nlist) 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): def advance(self,func):
try: try:
self.row = self.clist.selection[0] self.row = self.clist.selection[0]
@ -96,25 +135,135 @@ class Find:
func() func()
gtk.gdk_beep() gtk.gdk_beep()
def forward(self): class FindPlace(FindBase):
self.row = self.row + 1 """Opens a Find Place dialog for GRAMPS"""
if self.row == self.clist.rows:
self.row = 0 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)

View File

@ -83,6 +83,11 @@ class MediaView:
self.media_list.set_sort_column(self.sort_map[self.sort_col]) self.media_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(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): def set_arrow(self,column):
for a in self.sort_arrow: for a in self.sort_arrow:
a.hide() a.hide()

View File

@ -224,6 +224,11 @@ class PlaceView:
def on_add_place_clicked(self,obj): def on_add_place_clicked(self,obj):
EditPlace.EditPlace(Place(),self.db,self.new_place_after_edit) 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): def on_delete_place_clicked(self,obj):
if len(obj.selection) == 0: if len(obj.selection) == 0:
return return

View File

@ -77,6 +77,11 @@ class SourceView:
self.source_list.set_sort_column(self.sort_map[self.sort_col]) self.source_list.set_sort_column(self.sort_map[self.sort_col])
self.set_arrow(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): def set_arrow(self,column):
for a in self.sort_arrow: for a in self.sort_arrow:

View File

@ -483,6 +483,17 @@
</child> </child>
</widget> </widget>
<widget>
<class>GnomePixmap</class>
<name>date_stat</name>
<width>10</width>
<child>
<padding>5</padding>
<expand>False</expand>
<fill>True</fill>
</child>
</widget>
<widget> <widget>
<class>GtkOptionMenu</class> <class>GtkOptionMenu</class>
<name>calendar</name> <name>calendar</name>

View File

@ -3,10 +3,13 @@
import traceback import traceback
import intl import intl
import os import os
import GdkImlib
import gtk import gtk
import gnome.ui import gnome.ui
import gnome.config import gnome.config
import locale import locale
import gramps_main
import sys
if os.environ.has_key("GRAMPSI18N"): if os.environ.has_key("GRAMPSI18N"):
loc = os.environ["GRAMPSI18N"] loc = os.environ["GRAMPSI18N"]
@ -18,10 +21,6 @@ intl.bindtextdomain("gramps",loc)
locale.setlocale(locale.LC_NUMERIC,"C") locale.setlocale(locale.LC_NUMERIC,"C")
import gramps_main
import sys
import locale
if len(sys.argv) > 1: if len(sys.argv) > 1:
arg = sys.argv[1] arg = sys.argv[1]
else: else:

View File

@ -318,8 +318,18 @@ class Gramps:
def on_find_activate(self,obj): def on_find_activate(self,obj):
"""Display the find box""" """Display the find box"""
Find.Find(self.person_list,self.find_goto_to, if self.notebook.get_current_page() == 4:
self.database.getPersonMap().values()) 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): def on_findname_activate(self,obj):
"""Display the find box""" """Display the find box"""
@ -331,6 +341,18 @@ class Gramps:
self.goto_active_person() self.goto_active_person()
self.update_display(0) 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): def on_gramps_home_page_activate(self,obj):
import gnome.url import gnome.url
gnome.url.show("http://gramps.sourceforge.net") gnome.url.show("http://gramps.sourceforge.net")