From 80546c39057c36dab0eef289879b79d8a76f0f53 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 17 May 2006 06:13:37 +0000 Subject: [PATCH] * src/glade/gramps.glade (select_person): Name the box. * src/DataViews/_MediaView.py (row_change): Collect garbage on the row change. * src/Selectors/_BaseSelector.py: Use DisplaModel models; (_local_init): Add selector-specific hook. (_local_init): Set up preview; (_row_change): Show preview; collect garbage. svn: r6690 --- gramps2/ChangeLog | 8 ++++++- gramps2/src/DataViews/_MediaView.py | 16 +++++++------ gramps2/src/Selectors/_BaseSelector.py | 5 ++++ gramps2/src/Selectors/_SelectObject.py | 32 ++++++++++++++++++++++++-- gramps2/src/glade/gramps.glade | 2 +- 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index da0f54447..c1c2cf615 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,15 +1,21 @@ 2006-05-16 Alex Roitman + * src/glade/gramps.glade (select_person): Name the box. + * src/DataViews/_MediaView.py (row_change): Collect garbage on the + row change. * src/Editors/_EditLdsOrd.py: Adapt to new selector. * src/DisplayTabs/_SourceEmbedList.py: Adapt to new selector. * src/DisplayTabs/_EventEmbedList.py: Adapt to new selector. * src/DisplayTabs/_GalleryTab.py: Adapt to new selector. - * src/Selectors/_BaseSelector.py: Use DisplaModel models. + * src/Selectors/_BaseSelector.py: Use DisplaModel models; + (_local_init): Add selector-specific hook. * src/Selectors/_SelectRepository.py: Use DisplaModel models. * src/Selectors/_SelectSource.py: Use DisplaModel models. * src/Selectors/_SelectEvent.py: Use DisplaModel models. * src/Selectors/_SelectFamily.py: Use DisplaModel models. * src/Selectors/_SelectPlace.py: Use DisplaModel models. * src/Selectors/_SelectObject.py: Use DisplaModel models. + (_local_init): Set up preview; + (_row_change): Show preview; collect garbage. 2006-05-16 Don Allingham * src/Editors/_EditEvent.py: start of SelectPlace integration diff --git a/gramps2/src/DataViews/_MediaView.py b/gramps2/src/DataViews/_MediaView.py index 8e0e21786..fef9eb2f1 100644 --- a/gramps2/src/DataViews/_MediaView.py +++ b/gramps2/src/DataViews/_MediaView.py @@ -19,6 +19,14 @@ # $Id$ +#------------------------------------------------------------------------- +# +# Python modules +# +#------------------------------------------------------------------------- +import gc +from gettext import gettext as _ + #------------------------------------------------------------------------- # # GTK/Gnome modules @@ -42,13 +50,6 @@ from Editors import EditMedia import Errors from QuestionDialog import QuestionDialog, ErrorDialog -#------------------------------------------------------------------------- -# -# internationalization -# -#------------------------------------------------------------------------- -from gettext import gettext as _ - column_names = [ _('Title'), _('ID'), @@ -135,6 +136,7 @@ class MediaView(PageView.ListView): obj = self.dbstate.db.get_object_from_handle(handle) pix = ImgManip.get_thumbnail_image(obj.get_path()) self.image.set_from_pixbuf(pix) + gc.collect() def ui_definition(self): return ''' diff --git a/gramps2/src/Selectors/_BaseSelector.py b/gramps2/src/Selectors/_BaseSelector.py index df6bcda81..b8c97e457 100644 --- a/gramps2/src/Selectors/_BaseSelector.py +++ b/gramps2/src/Selectors/_BaseSelector.py @@ -69,6 +69,7 @@ class BaseSelector(ManagedWindow.ManagedWindow): self.tree.set_model(self.model) self.add_columns(self.tree) + self._local_init() self.show() def add_columns(self,tree): @@ -112,6 +113,10 @@ class BaseSelector(ManagedWindow.ManagedWindow): self.close() return None + def _local_init(self): + # define selector-specific init routine + pass + def get_window_title(self): # return _("Select something") assert False, "Must be defined in the subclass" diff --git a/gramps2/src/Selectors/_SelectObject.py b/gramps2/src/Selectors/_SelectObject.py index 321162222..10ac4fd40 100644 --- a/gramps2/src/Selectors/_SelectObject.py +++ b/gramps2/src/Selectors/_SelectObject.py @@ -20,23 +20,31 @@ # $Id$ -# # Written by Alex Roitman, # largely based on the MediaView and SelectPerson by Don Allingham -# #------------------------------------------------------------------------- # # internationalization # #------------------------------------------------------------------------- +import gc from gettext import gettext as _ +#------------------------------------------------------------------------- +# +# GTK+ +# +#------------------------------------------------------------------------- +import gtk + #------------------------------------------------------------------------- # # gramps modules # #------------------------------------------------------------------------- +import const +import ImgManip from DisplayModels import MediaModel from _BaseSelector import BaseSelector @@ -65,3 +73,23 @@ class SelectObject(BaseSelector): (_('ID'), 75, BaseSelector.TEXT), (_('Type'), 75, BaseSelector.TEXT), ] + + def _local_init(self): + self.preview = gtk.Image() + self.preview.set_size_request(int(const.thumbScale), + int(const.thumbScale)) + vbox = self.glade.get_widget('select_person_vbox') + vbox.pack_start(self.preview,False) + vbox.reorder_child(self.preview,1) + self.preview.show() + self.selection.connect('changed',self._row_change) + + def _row_change(self,obj): + id_list = self.get_selected_ids() + if not (id_list and id_list[0]): + return + handle = id_list[0] + obj = self.get_from_handle_func()(handle) + pix = ImgManip.get_thumbnail_image(obj.get_path()) + self.preview.set_from_pixbuf(pix) + gc.collect() diff --git a/gramps2/src/glade/gramps.glade b/gramps2/src/glade/gramps.glade index 2f6211f49..1ff47ca6e 100644 --- a/gramps2/src/glade/gramps.glade +++ b/gramps2/src/glade/gramps.glade @@ -4101,7 +4101,7 @@ Text Beside Icons - + 6 True False