From 308f2616ba2e2dc9e7da439bf8c32101eb5d4330 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 6 Jun 2012 17:48:55 +0000 Subject: [PATCH] GEPS008: Moved ThumbNails module svn: r19775 --- po/POTFILES.skip | 2 +- src/Makefile.am | 1 - src/gui/Makefile.am | 1 + src/gui/editors/addmedia.py | 4 ++-- src/gui/editors/displaytabs/gallerytab.py | 4 ++-- src/gui/editors/editmedia.py | 6 +++--- src/gui/editors/editmediaref.py | 8 ++++---- src/gui/editors/editperson.py | 4 ++-- src/gui/selectors/selectobject.py | 5 ++--- src/{ThumbNails.py => gui/thumbnails.py} | 0 src/gui/widgets/photo.py | 12 +++++------- src/plugins/graph/GVFamilyLines.py | 4 ++-- src/plugins/graph/GVRelGraph.py | 4 ++-- src/plugins/view/mediaview.py | 1 - src/plugins/view/pedigreeview.py | 4 ++-- src/plugins/view/relview.py | 4 ++-- src/plugins/webreport/NarrativeWeb.py | 10 +++++----- 17 files changed, 35 insertions(+), 39 deletions(-) rename src/{ThumbNails.py => gui/thumbnails.py} (100%) diff --git a/po/POTFILES.skip b/po/POTFILES.skip index cb941a725..c6979f3b4 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -10,7 +10,6 @@ src/ImgManip.py src/RecentFiles.py src/Sort.py src/soundex.py -src/ThumbNails.py src/TreeTips.py # cli @@ -233,6 +232,7 @@ src/gui/listmodel.py src/gui/managedwindow.py src/gui/navigator.py src/gui/pluginmanager.py +src/gui/thumbnails.py src/gui/user.py # gui/editors - the GUI editors package diff --git a/src/Makefile.am b/src/Makefile.am index e433e1ea4..644d656fa 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,7 +34,6 @@ gdir_PYTHON = \ Sort.py\ soundex.py\ Spell.py\ - ThumbNails.py\ ToolTips.py\ TransUtils.py\ TreeTips.py\ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index ca685ea33..ac7dadf2a 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -40,6 +40,7 @@ pkgpython_PYTHON = \ managedwindow.py \ navigator.py \ pluginmanager.py \ + thumbnails.py \ tipofday.py \ undohistory.py \ user.py \ diff --git a/src/gui/editors/addmedia.py b/src/gui/editors/addmedia.py index ade6bf8cd..c96e85c63 100644 --- a/src/gui/editors/addmedia.py +++ b/src/gui/editors/addmedia.py @@ -54,7 +54,7 @@ import const import config import Utils import gen.mime -import ThumbNails +from gui.thumbnails import find_mime_type_pixbuf from gui.display import display_help from gui.managedwindow import ManagedWindow from gui.dialog import ErrorDialog, WarningDialog @@ -201,7 +201,7 @@ class AddMediaObject(ManagedWindow): if mtype and mtype.startswith("image"): image = scale_image(filename, const.THUMBSCALE) else: - image = ThumbNails.find_mime_type_pixbuf(mtype) + image = find_mime_type_pixbuf(mtype) self.image.set_from_pixbuf(image) def _cleanup_on_exit(self): diff --git a/src/gui/editors/displaytabs/gallerytab.py b/src/gui/editors/displaytabs/gallerytab.py index 8ec6f4c6f..e2ffa94ba 100644 --- a/src/gui/editors/displaytabs/gallerytab.py +++ b/src/gui/editors/displaytabs/gallerytab.py @@ -53,7 +53,7 @@ from gui.selectors import SelectorFactory import gen.lib from gen.db import DbTxn import Utils -import ThumbNails +from gui.thumbnails import get_thumbnail_image import Errors import gen.mime from gui.ddtargets import DdTargets @@ -250,7 +250,7 @@ class GalleryTab(ButtonTab, DbGUIElement): RunDatabaseRepair( _('Non existing media found in the Gallery')) else : - pixbuf = ThumbNails.get_thumbnail_image( + pixbuf = get_thumbnail_image( Utils.media_path_full(self.dbstate.db, obj.get_path()), obj.get_mime_type(), diff --git a/src/gui/editors/editmedia.py b/src/gui/editors/editmedia.py index 0523434b5..77f76109d 100644 --- a/src/gui/editors/editmedia.py +++ b/src/gui/editors/editmedia.py @@ -46,7 +46,7 @@ from gui.utils import open_file_with_default_application import gen.lib from gen.db import DbTxn import gen.mime -import ThumbNails +from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf import Utils from editprimary import EditPrimary from gui.widgets import (MonitoredDate, MonitoredEntry, PrivacyButton, @@ -173,12 +173,12 @@ class EditMedia(EditPrimary): def draw_preview(self): mtype = self.obj.get_mime_type() if mtype: - pb = ThumbNails.get_thumbnail_image( + pb = get_thumbnail_image( Utils.media_path_full(self.db, self.obj.get_path()), mtype) self.pixmap.set_from_pixbuf(pb) else: - pb = ThumbNails.find_mime_type_pixbuf('text/plain') + pb = find_mime_type_pixbuf('text/plain') self.pixmap.set_from_pixbuf(pb) def setup_filepath(self): diff --git a/src/gui/editors/editmediaref.py b/src/gui/editors/editmediaref.py index 7f841f088..c4d69b6da 100644 --- a/src/gui/editors/editmediaref.py +++ b/src/gui/editors/editmediaref.py @@ -46,7 +46,7 @@ import gtk from gui.utils import open_file_with_default_application import const import gen.mime -import ThumbNails +from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf import Utils from gen.lib import NoteType from gen.db import DbTxn @@ -140,13 +140,13 @@ class EditMediaRef(EditReference): mtype = self.source.get_mime_type() if mtype: fullpath = Utils.media_path_full(self.db, self.source.get_path()) - pb = ThumbNails.get_thumbnail_image(fullpath, mtype) + pb = get_thumbnail_image(fullpath, mtype) self.pixmap.set_from_pixbuf(pb) - subpix = ThumbNails.get_thumbnail_image(fullpath, mtype, + subpix = get_thumbnail_image(fullpath, mtype, self.rectangle) self.subpixmap.set_from_pixbuf(subpix) else: - pb = ThumbNails.find_mime_type_pixbuf('text/plain') + pb = find_mime_type_pixbuf('text/plain') self.pixmap.set_from_pixbuf(pb) self.subpixmap.set_from_pixbuf(pb) diff --git a/src/gui/editors/editperson.py b/src/gui/editors/editperson.py index f67825ed1..9f76cf924 100644 --- a/src/gui/editors/editperson.py +++ b/src/gui/editors/editperson.py @@ -50,7 +50,7 @@ import pango # #------------------------------------------------------------------------- import Utils -import ThumbNails +from gui.thumbnails import get_thumbnail_image import gui.utils from gen.utils import get_birth_or_fallback import gen.lib @@ -939,7 +939,7 @@ class EditPerson(EditPrimary): """ Load the person's main photo using the Thumbnailer. """ - pixbuf = ThumbNails.get_thumbnail_image( + pixbuf = get_thumbnail_image( Utils.media_path_full(self.dbstate.db, obj.get_path()), obj.get_mime_type(), diff --git a/src/gui/selectors/selectobject.py b/src/gui/selectors/selectobject.py index e7df2517c..eacefb128 100644 --- a/src/gui/selectors/selectobject.py +++ b/src/gui/selectors/selectobject.py @@ -46,7 +46,7 @@ import gtk #------------------------------------------------------------------------- import const from Utils import media_path_full -import ThumbNails +from gui.thumbnails import get_thumbnail_image from gui.views.treemodels import MediaModel from baseselector import BaseSelector @@ -97,7 +97,6 @@ class SelectObject(BaseSelector): return handle = id_list[0] obj = self.get_from_handle_func()(handle) - pix = ThumbNails.get_thumbnail_image(media_path_full(self.db, - obj.get_path())) + pix = get_thumbnail_image(media_path_full(self.db, obj.get_path())) self.preview.set_from_pixbuf(pix) gc.collect() diff --git a/src/ThumbNails.py b/src/gui/thumbnails.py similarity index 100% rename from src/ThumbNails.py rename to src/gui/thumbnails.py diff --git a/src/gui/widgets/photo.py b/src/gui/widgets/photo.py index 4d27267df..e7379395d 100644 --- a/src/gui/widgets/photo.py +++ b/src/gui/widgets/photo.py @@ -31,7 +31,7 @@ import gtk # Gramps modules # #------------------------------------------------------------------------- -import ThumbNails +from gui.thumbnails import get_thumbnail_image, SIZE_NORMAL, SIZE_LARGE from gui.utils import open_file_with_default_application from gen.ggettext import gettext as _ @@ -53,9 +53,9 @@ class Photo(gtk.EventBox): tip = _('Double-click on the picture to view it in the default image ' 'viewer application.') self.set_tooltip_text(tip) - self.__size = ThumbNails.SIZE_LARGE + self.__size = SIZE_LARGE if use_small_size: - self.__size = ThumbNails.SIZE_NORMAL + self.__size = SIZE_NORMAL def set_image(self, full_path, mime_type=None, rectangle=None): """ @@ -63,10 +63,8 @@ class Photo(gtk.EventBox): """ self.full_path = full_path if full_path: - pixbuf = ThumbNails.get_thumbnail_image(full_path, - mime_type, - rectangle, - self.__size) + pixbuf = get_thumbnail_image(full_path, mime_type, rectangle, + self.__size) self.photo.set_from_pixbuf(pixbuf) self.photo.show() else: diff --git a/src/plugins/graph/GVFamilyLines.py b/src/plugins/graph/GVFamilyLines.py index 188ce427b..b2fd473c7 100644 --- a/src/plugins/graph/GVFamilyLines.py +++ b/src/plugins/graph/GVFamilyLines.py @@ -52,7 +52,7 @@ log = logging.getLogger(".FamilyLines") #------------------------------------------------------------------------ import gen.lib import Utils -import ThumbNails +from gui.thumbnails import get_thumbnail_path from gen.datehandler import displayer as _dd from gen.plug.report import Report from gen.plug.report import utils as ReportUtils @@ -796,7 +796,7 @@ class FamilyLinesReport(Report): media = self._db.get_object_from_handle(mediaHandle) mediaMimeType = media.get_mime_type() if mediaMimeType[0:5] == "image": - imagePath = ThumbNails.get_thumbnail_path( + imagePath = get_thumbnail_path( Utils.media_path_full(self._db, media.get_path()), rectangle=mediaList[0].get_rectangle()) diff --git a/src/plugins/graph/GVRelGraph.py b/src/plugins/graph/GVRelGraph.py index c2b850010..e41cb839d 100644 --- a/src/plugins/graph/GVRelGraph.py +++ b/src/plugins/graph/GVRelGraph.py @@ -56,7 +56,7 @@ from gen.display.name import displayer as name_displayer import gen.datehandler import gen.lib import Utils -import ThumbNails +from gui.thumbnails import get_thumbnail_path from gen.utils import get_birth_or_fallback, get_death_or_fallback #------------------------------------------------------------------------ @@ -354,7 +354,7 @@ class RelGraphReport(Report): media = self.database.get_object_from_handle(mediaHandle) mediaMimeType = media.get_mime_type() if mediaMimeType[0:5] == "image": - imagePath = ThumbNails.get_thumbnail_path( + imagePath = get_thumbnail_path( Utils.media_path_full(self.database, media.get_path()), rectangle=mediaList[0].get_rectangle()) diff --git a/src/plugins/view/mediaview.py b/src/plugins/view/mediaview.py index bf642cb7f..e67514876 100644 --- a/src/plugins/view/mediaview.py +++ b/src/plugins/view/mediaview.py @@ -52,7 +52,6 @@ import gtk from gui.utils import open_file_with_default_application from gui.views.listview import ListView from gui.views.treemodels import MediaModel -import ThumbNails import const import constfunc import config diff --git a/src/plugins/view/pedigreeview.py b/src/plugins/view/pedigreeview.py index c1af24d21..6995c6bb5 100644 --- a/src/plugins/view/pedigreeview.py +++ b/src/plugins/view/pedigreeview.py @@ -54,7 +54,7 @@ from gen.display.name import displayer as name_displayer from Utils import (media_path_full, probably_alive, find_children, find_parents, find_witnessed_people) from libformatting import FormattingHelper -import ThumbNails +from gui.thumbnails import get_thumbnail_path import Errors from gui.editors import EditPerson, EditFamily from gui.ddtargets import DdTargets @@ -152,7 +152,7 @@ class _PersonWidgetBase(gtk.DrawingArea): if obj: mtype = obj.get_mime_type() if mtype and mtype[0:5] == "image": - image_path = ThumbNails.get_thumbnail_path( + image_path = get_thumbnail_path( media_path_full( dbstate.db, obj.get_path()), diff --git a/src/plugins/view/relview.py b/src/plugins/view/relview.py index e77e6978a..7fe6445c8 100644 --- a/src/plugins/view/relview.py +++ b/src/plugins/view/relview.py @@ -55,7 +55,7 @@ from gen.display.name import displayer as name_displayer from Utils import media_path_full, probably_alive from gui.utils import open_file_with_default_application import gen.datehandler -import ThumbNails +from gui.thumbnails import get_thumbnail_image import config from gui import widgets from gui.selectors import SelectorFactory @@ -668,7 +668,7 @@ class RelationshipView(NavigationView): if image_list: mobj = self.dbstate.db.get_object_from_handle(image_list[0].ref) if mobj and mobj.get_mime_type()[0:5] == "image": - pixbuf = ThumbNails.get_thumbnail_image( + pixbuf = get_thumbnail_image( media_path_full(self.dbstate.db, mobj.get_path()), rectangle=image_list[0].get_rectangle()) diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index 697eedb27..03d8d65fb 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -90,7 +90,7 @@ from gen.plug.report import MenuReportOptions import Utils import constfunc -import ThumbNails +from gui.thumbnails import get_thumbnail_path, run_thumbnailer import ImgManip import gen.mime from gen.display.name import displayer as _nd @@ -496,7 +496,7 @@ def copy_thumbnail(report, handle, photo, region=None): ) if photo.get_mime_type(): - from_path = ThumbNails.get_thumbnail_path(Utils.media_path_full( + from_path = get_thumbnail_path(Utils.media_path_full( report.database, photo.get_path()), photo.get_mime_type(), @@ -4005,9 +4005,9 @@ class MediaPage(BasePage): else: dirname = tempfile.mkdtemp() thmb_path = os.path.join(dirname, "document.png") - if ThumbNails.run_thumbnailer(mime_type, - Utils.media_path_full(self.dbase_, media.get_path()), - thmb_path, 320): + if run_thumbnailer(mime_type, + Utils.media_path_full(self.dbase_, media.get_path()), + thmb_path, 320): try: path = self.report.build_path("preview", media.get_handle()) npath = os.path.join(path, media.get_handle()) + ".png"