2003-09-08 06:54:40 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
* src/RelLib.py (Transaction.__len__): Redefine length.
* src/ChooseParents.py, src/EditPerson.py, src/EditSource.py,
src/EventEdit.py, src/FamilyView.py, src/gramps_main.py,
src/ImageSelect.py, src/Marriage.py, src/MediaView.py,
src/PedView.py, src/PeopleModel.py, src/PlaceView.py,
src/SelectChild.py, src/SelectObject.py, src/Sources.py,
src/SourceView.py, src/Utils.py, src/Witness.py,
src/WriteXML.py: Switch from find_* to try_to_find_* methods.
svn: r3193
2004-05-26 08:56:18 +05:30
|
|
|
# Copyright (C) 2003-2004 Donald N. Allingham
|
2003-09-08 06:54:40 +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
|
|
|
|
#
|
|
|
|
|
* src/RelLib.py (Transaction.__len__): Redefine length.
* src/ChooseParents.py, src/EditPerson.py, src/EditSource.py,
src/EventEdit.py, src/FamilyView.py, src/gramps_main.py,
src/ImageSelect.py, src/Marriage.py, src/MediaView.py,
src/PedView.py, src/PeopleModel.py, src/PlaceView.py,
src/SelectChild.py, src/SelectObject.py, src/Sources.py,
src/SourceView.py, src/Utils.py, src/Witness.py,
src/WriteXML.py: Switch from find_* to try_to_find_* methods.
svn: r3193
2004-05-26 08:56:18 +05:30
|
|
|
# $Id$
|
|
|
|
|
2003-09-08 06:54:40 +05:30
|
|
|
#
|
|
|
|
# Written by Alex Roitman,
|
|
|
|
# largely based on the MediaView and SelectPerson by Don Allingham
|
|
|
|
#
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# general modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
import gc
|
2003-09-08 06:54:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-17 01:54:27 +05:30
|
|
|
from TransUtils import sgettext as _
|
2003-09-08 06:54:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
import gtk.gdk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import ListModel
|
2005-01-09 07:48:49 +05:30
|
|
|
import ImgManip
|
2006-03-03 05:53:04 +05:30
|
|
|
import Mime
|
2003-09-08 06:54:40 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# SelectPerson
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class SelectObject:
|
|
|
|
|
|
|
|
def __init__(self,db,title):
|
|
|
|
|
|
|
|
self.db = db
|
2006-03-29 23:26:11 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
|
|
|
|
self.top = self.glade.get_widget('select_person')
|
2003-09-08 06:54:40 +05:30
|
|
|
title_label = self.glade.get_widget('object_title')
|
2006-03-29 23:26:11 +05:30
|
|
|
self.object_tree = self.glade.get_widget('plist')
|
2003-09-08 06:54:40 +05:30
|
|
|
|
|
|
|
Utils.set_titles(self.top,title_label,title)
|
|
|
|
|
2006-03-29 23:26:11 +05:30
|
|
|
titles = [(_('Preview'),0,100,ListModel.IMAGE),
|
|
|
|
(_('Title'),1,150), (_('ID'),2,50),
|
|
|
|
(_('Type'),3,70), ('',4,0) ]
|
|
|
|
|
2003-09-08 06:54:40 +05:30
|
|
|
self.ncols = len(titles)
|
|
|
|
|
|
|
|
self.object_model = ListModel.ListModel(self.object_tree,titles)
|
|
|
|
self.selection = self.object_tree.get_selection()
|
|
|
|
|
|
|
|
self.redraw()
|
|
|
|
self.top.show()
|
|
|
|
|
|
|
|
def redraw(self):
|
|
|
|
self.object_model.clear()
|
|
|
|
self.object_model.new_model()
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
for key in self.db.get_media_object_handles():
|
2004-08-23 04:46:57 +05:30
|
|
|
obj = self.db.get_object_from_handle(key)
|
|
|
|
title = obj.get_description()
|
2006-03-03 05:53:04 +05:30
|
|
|
the_type = Mime.get_description(obj.get_mime_type())
|
2006-03-29 23:26:11 +05:30
|
|
|
pixbuf = ImgManip.get_thumb_from_obj(obj)
|
|
|
|
self.object_model.add([pixbuf,title,obj.get_gramps_id(),the_type],key)
|
2003-09-08 06:54:40 +05:30
|
|
|
self.object_model.connect_model()
|
|
|
|
|
|
|
|
def on_select_row(self,obj):
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.object_model.get_selected()
|
|
|
|
if not node:
|
2003-09-08 06:54:40 +05:30
|
|
|
return
|
2004-08-23 04:46:57 +05:30
|
|
|
data = self.object_model.get_data(node,range(self.ncols))
|
|
|
|
handle = data[4]
|
|
|
|
obj = self.db.get_object_from_handle(handle)
|
2005-05-24 18:38:06 +05:30
|
|
|
the_type = obj.get_mime_type()
|
2004-08-23 04:46:57 +05:30
|
|
|
path = obj.get_path()
|
2003-09-08 06:54:40 +05:30
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
if the_type and the_type[0:5] == "image":
|
2005-12-06 12:08:09 +05:30
|
|
|
image = ImgManip.get_thumbnail_image(path,the_type)
|
2003-09-08 06:54:40 +05:30
|
|
|
else:
|
2006-03-03 05:53:04 +05:30
|
|
|
image = Mime.find_mime_type_pixbuf(the_type)
|
2005-05-24 18:38:06 +05:30
|
|
|
self.preview.set_from_pixbuf(image)
|
2003-09-08 06:54:40 +05:30
|
|
|
|
2004-11-06 09:01:34 +05:30
|
|
|
self.object_handle.set_text(obj.get_gramps_id())
|
2005-08-18 11:28:28 +05:30
|
|
|
if the_type:
|
|
|
|
self.object_type.set_text(the_type)
|
|
|
|
else:
|
|
|
|
self.object_type.set_text("")
|
2004-08-23 04:46:57 +05:30
|
|
|
self.object_desc.set_text(obj.get_description())
|
2005-01-09 07:48:49 +05:30
|
|
|
if len(path) == 0:
|
2003-09-08 06:54:40 +05:30
|
|
|
self.object_path.set_text(_("The file no longer exists"))
|
|
|
|
elif path[0] == "/":
|
|
|
|
self.object_path.set_text(path)
|
|
|
|
else:
|
|
|
|
self.object_path.set_text("<local>")
|
2004-08-23 04:46:57 +05:30
|
|
|
self.object_details.set_text(Utils.get_detail_text(obj,0))
|
2003-09-08 06:54:40 +05:30
|
|
|
|
|
|
|
def run(self):
|
|
|
|
val = self.top.run()
|
|
|
|
|
|
|
|
if val == gtk.RESPONSE_OK:
|
2004-08-23 04:46:57 +05:30
|
|
|
store,node = self.object_model.get_selected()
|
|
|
|
if node:
|
|
|
|
data = self.object_model.get_data(node,range(self.ncols))
|
|
|
|
handle = data[4]
|
|
|
|
return_value = self.db.get_object_from_handle(handle)
|
2003-09-08 06:54:40 +05:30
|
|
|
else:
|
|
|
|
return_value = None
|
|
|
|
self.top.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2003-09-08 06:54:40 +05:30
|
|
|
return return_value
|
|
|
|
else:
|
|
|
|
self.top.destroy()
|
2005-12-06 12:08:09 +05:30
|
|
|
gc.collect()
|
2003-09-08 06:54:40 +05:30
|
|
|
return None
|