2006-03-19 12:19:03 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-05-05 00:00:36 +05:30
|
|
|
# Copyright (C) 2003-2006 Donald N. Allingham
|
2006-03-19 12:19:03 +05:30
|
|
|
#
|
|
|
|
# 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: SelectEvent.py 6155 2006-03-16 20:24:27Z rshura $
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import ListModel
|
2006-05-05 00:00:36 +05:30
|
|
|
import ManagedWindow
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SelectEvent
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-05-15 21:23:42 +05:30
|
|
|
class SelectPlace(ManagedWindow.ManagedWindow):
|
2006-03-19 12:19:03 +05:30
|
|
|
|
2006-05-05 00:00:36 +05:30
|
|
|
def __init__(self, dbstate, uistate, track, title):
|
|
|
|
self.title = title
|
|
|
|
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
2006-05-05 00:00:36 +05:30
|
|
|
self.db = dbstate.db
|
2006-03-19 12:19:03 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
2006-05-05 00:00:36 +05:30
|
|
|
window = self.glade.get_widget('select_person')
|
2006-03-19 12:19:03 +05:30
|
|
|
title_label = self.glade.get_widget('title')
|
|
|
|
self.elist = self.glade.get_widget('plist')
|
|
|
|
|
2006-05-05 00:00:36 +05:30
|
|
|
self.set_window(window,title_label,self.title)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
titles = [(_('Title'),4,350), (_('ID'),1,50), ('',0,0)]
|
|
|
|
self.ncols = len(titles)
|
|
|
|
|
|
|
|
self.model = ListModel.ListModel(self.elist,titles)
|
|
|
|
|
|
|
|
self.redraw()
|
2006-05-05 00:00:36 +05:30
|
|
|
self.show()
|
2006-03-19 12:19:03 +05:30
|
|
|
|
2006-05-05 00:00:36 +05:30
|
|
|
def build_menu_names(self,obj):
|
|
|
|
return (self.title, None)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
def redraw(self):
|
|
|
|
self.model.clear()
|
|
|
|
self.model.new_model()
|
|
|
|
|
2006-05-15 21:23:42 +05:30
|
|
|
for handle in self.db.get_place_handles():
|
|
|
|
place = self.db.get_place_from_handle(handle)
|
|
|
|
desc = place.get_title()
|
|
|
|
the_id = place.get_gramps_id()
|
2006-03-19 12:19:03 +05:30
|
|
|
self.model.add([desc,the_id,handle])
|
|
|
|
self.model.connect_model()
|
|
|
|
|
|
|
|
def run(self):
|
2006-05-05 00:00:36 +05:30
|
|
|
val = self.window.run()
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
if val == gtk.RESPONSE_OK:
|
|
|
|
store,node = self.model.get_selected()
|
|
|
|
if node:
|
|
|
|
data = self.model.get_data(node,range(self.ncols))
|
|
|
|
handle = data[2]
|
2006-05-15 21:23:42 +05:30
|
|
|
return_value = self.db.get_place_from_handle(handle)
|
2006-03-19 12:19:03 +05:30
|
|
|
else:
|
|
|
|
return_value = None
|
2006-05-05 00:00:36 +05:30
|
|
|
self.close()
|
2006-03-19 12:19:03 +05:30
|
|
|
return return_value
|
|
|
|
else:
|
2006-05-05 00:00:36 +05:30
|
|
|
self.close()
|
2006-03-19 12:19:03 +05:30
|
|
|
return None
|