SelectObject support

svn: r6224
This commit is contained in:
Don Allingham 2006-03-29 17:56:11 +00:00
parent 817ead70e4
commit d49a5aa8ef
5 changed files with 57 additions and 25 deletions

View File

@ -1,3 +1,9 @@
2006-03-29 Don Allingham <don@gramps-project.org>
* src/SelectObject.py: Provide images in preview
* src/DisplayTabs.py: Add support of SelectObject
* src/GenericFilter.py: check for xml file before trying to parse
* src/ListModel.py: image support in view
2006-03-28 Don Allingham <don@gramps-project.org>
* src/DataViews/_PlaceView.py: delete place properly
* src/gramps_main.py: remove 2.0.X message

View File

@ -1262,7 +1262,7 @@ class NoteTab(GrampsTab):
class GalleryTab(ButtonTab):
def __init__(self, dbstate, uistate, track, media_list):
ButtonTab.__init__(self, dbstate, uistate, track, _('Gallery'))
ButtonTab.__init__(self, dbstate, uistate, track, _('Gallery'), True)
self.media_list = media_list
self.rebuild()
self.show_all()
@ -1282,7 +1282,6 @@ class GalleryTab(ButtonTab):
return len(self.media_list)==0
def _build_icon_model(self):
# build the list model
self.iconmodel= gtk.ListStore(gtk.gdk.Pixbuf,str,object)
def _connect_icon_model(self):
@ -1345,9 +1344,13 @@ class GalleryTab(ButtonTab):
def add_button_clicked(self,obj):
from Editors import EditMediaRef
import AddMedia
am = AddMedia.AddMediaObject(self.dbstate.db)
am.run()
src = am.object
sref = RelLib.MediaRef()
src = RelLib.MediaObject()
try:
EditMediaRef(self.dbstate, self.uistate, self.track,
src, sref, self.add_callback)
@ -1355,10 +1358,28 @@ class GalleryTab(ButtonTab):
pass
def add_callback(self,media_ref, media):
media_ref.ref = media.handle
self.get_data().append(media_ref)
self.changed = True
self.rebuild()
def share_button_clicked(self,obj):
"""
Function called with the Add button is clicked. This function
should be overridden by the derived class.
"""
import SelectObject
sel = SelectObject.SelectObject(self.dbstate.db,_("Select media"))
src = sel.run()
if src:
sref = RelLib.MediaRef()
try:
EditMediaRef(self.dbstate, self.uistate, self.track,
src, sref, self.add_callback)
except Errors.WindowActiveError:
pass
def del_button_clicked(self,obj):
ref = self.get_selected()
if ref:

View File

@ -2312,9 +2312,10 @@ class GenericFilterList:
def load(self):
try:
parser = make_parser()
parser.setContentHandler(FilterParser(self))
parser.parse(self.file)
if os.path.isfile(self.file):
parser = make_parser()
parser.setContentHandler(FilterParser(self))
parser.parse(self.file)
except (IOError,OSError):
pass
except SAXParseException:

View File

@ -19,13 +19,15 @@
#
import gtk
import gtk.gdk
import pango
import const
gtk26 = gtk.pygtk_version >= (2,6,0)
TEXT = 0
TOGGLE = 1
COMBO = 2
IMAGE = 3
NOSORT = -1
#-------------------------------------------------------------------------
@ -42,8 +44,11 @@ class ListModel:
self.mylist = []
self.data_index = 0
for l in dlist:
if len(l)>3 and l[3] == TOGGLE:
self.mylist.append(bool)
if len(l)>3:
if l[3] == TOGGLE:
self.mylist.append(bool)
elif l[3] == IMAGE:
self.mylist.append(gtk.gdk.Pixbuf)
else:
self.mylist.append(str)
self.data_index += 1
@ -74,6 +79,11 @@ class ListModel:
renderer = gtk.CellRendererToggle()
column = gtk.TreeViewColumn(name[0],renderer)
column.add_attribute(renderer,'active',cnum)
elif name[0] and name[3] == IMAGE:
renderer = gtk.CellRendererPixbuf()
column = gtk.TreeViewColumn(name[0],renderer)
column.add_attribute(renderer,'pixbuf',cnum)
renderer.set_property('height',const.thumbScale)
elif gtk26 and name[3] == COMBO:
store = gtk.ListStore(str)
model = gtk.ListStore(str, object)

View File

@ -70,26 +70,21 @@ class SelectObject:
def __init__(self,db,title):
self.db = db
self.glade = gtk.glade.XML(const.gladeFile,"select_object","gramps")
self.top = self.glade.get_widget('select_object')
self.glade = gtk.glade.XML(const.gladeFile,"select_person","gramps")
self.top = self.glade.get_widget('select_person')
title_label = self.glade.get_widget('object_title')
self.object_tree = self.glade.get_widget('object_tree')
self.object_handle = self.glade.get_widget('object_id')
self.object_type = self.glade.get_widget('object_type')
self.object_desc = self.glade.get_widget('object_desc')
self.object_path = self.glade.get_widget('object_path')
self.preview = self.glade.get_widget('preview')
self.object_details = self.glade.get_widget('object_details')
self.object_tree = self.glade.get_widget('plist')
Utils.set_titles(self.top,title_label,title)
titles = [(_('Title'),0,350), (_('ID'),1,50),
(_('Type'),2,70), ('Path',3,150), ('',4,0) ]
titles = [(_('Preview'),0,100,ListModel.IMAGE),
(_('Title'),1,150), (_('ID'),2,50),
(_('Type'),3,70), ('',4,0) ]
self.ncols = len(titles)
self.object_model = ListModel.ListModel(self.object_tree,titles)
self.selection = self.object_tree.get_selection()
self.selection.connect('changed',self.on_select_row)
self.redraw()
self.top.show()
@ -102,9 +97,8 @@ class SelectObject:
obj = self.db.get_object_from_handle(key)
title = obj.get_description()
the_type = Mime.get_description(obj.get_mime_type())
path = obj.get_path()
self.object_model.add([title,obj.get_gramps_id(),the_type,path],key)
pixbuf = ImgManip.get_thumb_from_obj(obj)
self.object_model.add([pixbuf,title,obj.get_gramps_id(),the_type],key)
self.object_model.connect_model()
def on_select_row(self,obj):