From 43c775b975eee655490871511562077298d4d8bd Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 19 Mar 2006 03:50:47 +0000 Subject: [PATCH] removed RelImage svn: r6176 --- ChangeLog | 2 ++ src/AddMedia.py | 35 ++++++++++++++++++--- src/Makefile.am | 1 - src/RelImage.py | 83 ------------------------------------------------- 4 files changed, 32 insertions(+), 89 deletions(-) delete mode 100644 src/RelImage.py diff --git a/ChangeLog b/ChangeLog index 06ae24e87..8afc06269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2006-03-18 Don Allingham + * src/RelImage.py: removed + * src/AddMedia.py: added scale_image function from RelImage * src/DataViews/_PersonView.py: use fixed width/height mode to prevent unnecessary reads during initialization. Prevent double loading of data from filter. diff --git a/src/AddMedia.py b/src/AddMedia.py index 669bbba8f..fe459d933 100644 --- a/src/AddMedia.py +++ b/src/AddMedia.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2000-2003 Donald N. Allingham +# Copyright (C) 2000-2006 Donald N. Allingham # # 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 @@ -36,7 +36,6 @@ import os # internationalization # #------------------------------------------------------------------------- - from TransUtils import sgettext as _ #------------------------------------------------------------------------- @@ -44,7 +43,7 @@ from TransUtils import sgettext as _ # GTK/Gnome modules # #------------------------------------------------------------------------- -from QuestionDialog import ErrorDialog +from QuestionDialog import ErrorDialog, WarningDialog import gtk.glade #------------------------------------------------------------------------- @@ -54,7 +53,6 @@ import gtk.glade #------------------------------------------------------------------------- import const import Utils -import RelImage import RelLib import Mime import GrampsDisplay @@ -164,7 +162,7 @@ class AddMediaObject: if filename: mtype = Mime.get_type(filename) if mtype and mtype.startswith("image"): - image = RelImage.scale_image(filename,const.thumbScale) + image = scale_image(filename,const.thumbScale) else: image = Mime.find_mime_type_pixbuf(mtype) self.image.set_from_pixbuf(image) @@ -183,3 +181,30 @@ class AddMediaObject: self.window.destroy() return None return None + +#------------------------------------------------------------------------- +# +# scale_image +# +#------------------------------------------------------------------------- +def scale_image(path,size): + try: + image1 = gtk.gdk.pixbuf_new_from_file(path) + except: + WarningDialog(_("Cannot display %s") % path, + _('GRAMPS is not able to display the image file. ' + 'This may be caused by a corrupt file.')) + return gtk.gdk.pixbuf_new_from_file(const.icon) + + width = image1.get_width() + height = image1.get_height() + + scale = size / float(max(width,height)) + try: + return image1.scale_simple(int(scale*width), int(scale*height), + gtk.gdk.INTERP_BILINEAR) + except: + WarningDialog(_("Cannot display %s") % path, + _('GRAMPS is not able to display the image file. ' + 'This may be caused by a corrupt file.')) + return gtk.gdk.pixbuf_new_from_file(const.icon) diff --git a/src/Makefile.am b/src/Makefile.am index 56e6b42fa..c919a50f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,7 +76,6 @@ gdir_PYTHON = \ QuestionDialog.py\ RecentFiles.py\ Relationship.py\ - RelImage.py\ ScratchPad.py\ SelectEvent.py\ SelectObject.py\ diff --git a/src/RelImage.py b/src/RelImage.py deleted file mode 100644 index e87474c32..000000000 --- a/src/RelImage.py +++ /dev/null @@ -1,83 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2000-2003 Donald N. Allingham -# -# 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 -# - -#------------------------------------------------------------------------- -# -# Standard python modules -# -#------------------------------------------------------------------------- -import os - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gtk -from QuestionDialog import ErrorDialog, WarningDialog - -#------------------------------------------------------------------------- -# -# Gramps modules -# -#------------------------------------------------------------------------- -import const -from TransUtils import sgettext as _ - -#------------------------------------------------------------------------- -# -# import_media_object -# -#------------------------------------------------------------------------- -def import_media_object(filename,path,base): - if not os.path.exists(filename): - ErrorDialog(_("Could not import %s") % filename, - _("The file has been moved or deleted")) - return "" - return filename - -#------------------------------------------------------------------------- -# -# scale_image -# -#------------------------------------------------------------------------- -def scale_image(path,size): - try: - image1 = gtk.gdk.pixbuf_new_from_file(path) - except: - WarningDialog(_("Cannot display %s") % path, - _('GRAMPS is not able to display the image file. ' - 'This may be caused by a corrupt file.')) - return gtk.gdk.pixbuf_new_from_file(const.icon) - - width = image1.get_width() - height = image1.get_height() - - scale = size / float(max(width,height)) - try: - return image1.scale_simple(int(scale*width), int(scale*height), - gtk.gdk.INTERP_BILINEAR) - except: - WarningDialog(_("Cannot display %s") % path, - _('GRAMPS is not able to display the image file. ' - 'This may be caused by a corrupt file.')) - return gtk.gdk.pixbuf_new_from_file(const.icon) - -