2008-01-01 Gary Burton <gary.burton@zen.co.uk>

* src/Selectors/_SelectPerson.py: the select person dialog now allows a
	person to be selected by using the keyboard. This dialog really needs an
	overhaul so that it can use the BaseSelector class as SelectFamily does.
	However a PeopleModel based on BaseModel is required for this as the
	existing PeopleModel is a custom built class. bug #1456



svn: r9695
This commit is contained in:
Gary Burton 2008-01-03 13:39:57 +00:00
parent d54e05c41e
commit 424665ee39
2 changed files with 42 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2008-01-01 Gary Burton <gary.burton@zen.co.uk>
* src/Selectors/_SelectPerson.py: the select person dialog now allows a
person to be selected by using the keyboard. This dialog really needs an
overhaul so that it can use the BaseSelector class as SelectFamily does.
However a PeopleModel based on BaseModel is required for this as the
existing PeopleModel is a custom built class. bug #1456
2008-01-03 Jérôme Rapinat <romjerome@yahoo.fr> 2008-01-03 Jérôme Rapinat <romjerome@yahoo.fr>
* src/configure.in : add bulgarian * src/configure.in : add bulgarian

View File

@ -79,16 +79,20 @@ class SelectPerson(ManagedWindow.ManagedWindow):
self.plist = self.glade.get_widget('plist') self.plist = self.glade.get_widget('plist')
self.showall = self.glade.get_widget('showall') self.showall = self.glade.get_widget('showall')
self.notebook = self.glade.get_widget('notebook') self.notebook = self.glade.get_widget('notebook')
self.plist.connect('row-activated', self._on_row_activated)
self.plist.connect('key-press-event', self._key_press)
self.selection = self.plist.get_selection()
self.selection.set_mode(gtk.SELECTION_SINGLE)
window = self.glade.get_widget('select_person') window = self.glade.get_widget('select_person')
title_label = self.glade.get_widget('title') title_label = self.glade.get_widget('title')
self.set_window(window,title_label,self.title) self.set_window(window,title_label,self.title)
self.filter = filter self.filter = filter
if self.filter: if self.filter:
self.showall.show() self.showall.show()
self.skip = skip self.skip = skip
self.model = PeopleModel(self.dbstate.db, self.model = PeopleModel(self.dbstate.db,
(PeopleModel.FAST, filter), (PeopleModel.FAST, filter),
@ -100,15 +104,15 @@ class SelectPerson(ManagedWindow.ManagedWindow):
self.show() self.show()
def show_toggle(self, obj): def show_toggle(self, obj):
if obj.get_active(): if obj.get_active():
filt = None filt = None
else: else:
filt = self.filter filt = self.filter
self.model = PeopleModel(self.dbstate.db, self.model = PeopleModel(self.dbstate.db,
(PeopleModel.FAST, filt), (PeopleModel.FAST, filt),
skip=self.skip) skip=self.skip)
self.plist.set_model(self.model) self.plist.set_model(self.model)
def build_menu_names(self, obj): def build_menu_names(self, obj):
return (self.title, None) return (self.title, None)
@ -164,7 +168,25 @@ class SelectPerson(ManagedWindow.ManagedWindow):
return_value = self.dbstate.db.get_person_from_handle(idlist[0]) return_value = self.dbstate.db.get_person_from_handle(idlist[0])
else: else:
return_value = None return_value = None
return return_value return return_value
elif val != gtk.RESPONSE_DELETE_EVENT: elif val != gtk.RESPONSE_DELETE_EVENT:
self.close() self.close()
return None return None
def _key_press(self, obj, event):
if not event.state or event.state in (gtk.gdk.MOD2_MASK, ):
if event.keyval in (gtk.keysyms.Return, gtk.keysyms.KP_Enter):
store, paths = self.selection.get_selected_rows()
if paths and len(paths[0]) == 1 :
if self.plist.row_expanded(paths[0]):
self.plist.collapse_row(paths[0])
else:
self.plist.expand_row(paths[0], 0)
return True
else:
self.window.response(gtk.RESPONSE_OK)
return True
return False
def _on_row_activated(self, treeview, path, view_col):
self.window.response(gtk.RESPONSE_OK)