diff --git a/ChangeLog b/ChangeLog index 1ca93676f..e636f2667 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ * src/plugins/NavWebPage.py: update to new install paths 2006-03-02 Alex Roitman + * src/Mime/__init__.py: Add new package. + * src/GrampsMime.py, src/GnomeMime.py, src/PythonMimie.py: Remove + (placed under Mime now). * src/Config/__init__.py: Add new package. * src/GrampsGconfKeys.py, src/GrampsIniKeys.py, src/GrampsKeys.py: Remove (placed under Config now). diff --git a/src/AddMedia.py b/src/AddMedia.py index b6a14f930..0a6e992dc 100644 --- a/src/AddMedia.py +++ b/src/AddMedia.py @@ -58,7 +58,7 @@ import const import Utils import RelImage import RelLib -import GrampsMime +import Mime import GrampsDisplay #------------------------------------------------------------------------- @@ -132,7 +132,7 @@ class AddMediaObject: ErrorDialog(msgstr % filename, msgstr2) return - mtype = GrampsMime.get_type(filename) + mtype = Mime.get_type(filename) if description == "": description = os.path.basename(filename) @@ -165,11 +165,11 @@ class AddMediaObject: filename = Utils.find_file( filename) if filename: - mtype = GrampsMime.get_type(filename) + mtype = Mime.get_type(filename) if mtype and mtype.startswith("image"): image = RelImage.scale_image(filename,const.thumbScale) else: - image = GrampsMime.find_mime_type_pixbuf(mtype) + image = Mime.find_mime_type_pixbuf(mtype) self.image.set_from_pixbuf(image) def run(self): diff --git a/src/ArgHandler.py b/src/ArgHandler.py index f09e350a0..cd67a2007 100644 --- a/src/ArgHandler.py +++ b/src/ArgHandler.py @@ -42,7 +42,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------- import const import GrampsDb -import GrampsMime +import Mime import QuestionDialog import Config import RecentFiles @@ -127,7 +127,7 @@ class ArgHandler: o,v = options[opt_ix] if o in ( '-O', '--open'): fname = v - ftype = GrampsMime.get_type( + ftype = Mime.get_type( os.path.abspath(os.path.expanduser(fname))) if opt_ix' % action_id) actions.append((action_id,None,filename,None,None, diff --git a/src/EditMedia.py b/src/EditMedia.py index 96c68e84e..295e32172 100644 --- a/src/EditMedia.py +++ b/src/EditMedia.py @@ -45,7 +45,7 @@ import gtk.glade import const import Utils import RelLib -import GrampsMime +import Mime import ImgManip import EditPrimary @@ -104,11 +104,11 @@ class EditMedia(EditPrimary.EditPrimary): if mtype: pb = ImgManip.get_thumbnail_image(self.obj.get_path(),mtype) pixmap.set_from_pixbuf(pb) - descr = GrampsMime.get_description(mtype) + descr = Mime.get_description(mtype) if descr: self.glade.get_widget("type").set_text(descr) else: - pb = GrampsMime.find_mime_type_pixbuf('text/plain') + pb = Mime.find_mime_type_pixbuf('text/plain') pixmap.set_from_pixbuf(pb) self.glade.get_widget("type").set_text(_('Note')) @@ -196,7 +196,7 @@ class EditMedia(EditPrimary.EditPrimary): path = self.glade.get_widget('path').get_text() if path != self.obj.get_path(): - mime = GrampsMime.get_type(path) + mime = Mime.get_type(path) self.obj.set_mime_type(mime) self.obj.set_path(path) diff --git a/src/EditMediaRef.py b/src/EditMediaRef.py index 58c9debe7..b4b08da2a 100644 --- a/src/EditMediaRef.py +++ b/src/EditMediaRef.py @@ -44,7 +44,7 @@ import gtk.glade import const import Utils import RelLib -import GrampsMime +import Mime import ImgManip import DisplayState import GrampsDisplay @@ -115,7 +115,7 @@ class EditMediaRef(DisplayState.ManagedWindow): self.media.get_path, self.db.readonly) - mt = GrampsMime.get_description(mtype) + mt = Mime.get_description(mtype) if mt: self.change_dialog.get_widget("type").set_text(mt) else: diff --git a/src/EditPerson.py b/src/EditPerson.py index 4db24ca42..7ad121765 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -47,7 +47,7 @@ import gtk.gdk import const import Utils import Config -import GrampsMime +import Mime import RelLib import DateHandler import NameDisplay @@ -297,7 +297,7 @@ class EditPerson(EditPrimary.EditPrimary): menu.set_title(_("Media Object")) obj = self.db.get_object_from_handle(photo.get_reference_handle()) mtype = obj.get_mime_type() - progname = GrampsMime.get_application(mtype) + progname = Mime.get_application(mtype) if progname and len(progname) > 1: Utils.add_menuitem(menu,_("Open in %s") % progname[1], diff --git a/src/GrampsDb/_ReadGedcom.py b/src/GrampsDb/_ReadGedcom.py index 449b2cb71..476c580ce 100644 --- a/src/GrampsDb/_ReadGedcom.py +++ b/src/GrampsDb/_ReadGedcom.py @@ -63,7 +63,7 @@ import NameDisplay import DisplayTrace from ansel_utf8 import ansel_to_utf8 import Utils -import GrampsMime +import Mime from bsddb import db from _GedcomInfo import * from _GedTokens import * @@ -1283,7 +1283,7 @@ class GedcomParser: photo = RelLib.MediaObject() photo.set_path(path) photo.set_description(title) - photo.set_mime_type(GrampsMime.get_type(os.path.abspath(path))) + photo.set_mime_type(Mime.get_type(os.path.abspath(path))) self.db.add_object(photo, self.trans) self.media_map[path] = photo.handle else: @@ -1324,7 +1324,7 @@ class GedcomParser: photo = RelLib.MediaObject() photo.set_path(path) photo.set_description(title) - photo.set_mime_type(GrampsMime.get_type(os.path.abspath(path))) + photo.set_mime_type(Mime.get_type(os.path.abspath(path))) self.db.add_object(photo, self.trans) self.media_map[path] = photo.handle else: diff --git a/src/GrampsDb/_ReadXML.py b/src/GrampsDb/_ReadXML.py index aa05870b3..d0acfb64c 100644 --- a/src/GrampsDb/_ReadXML.py +++ b/src/GrampsDb/_ReadXML.py @@ -45,7 +45,7 @@ import gtk # #------------------------------------------------------------------------- from QuestionDialog import ErrorDialog, WarningDialog, MissingMediaDialog -import GrampsMime +import Mime import RelLib import const import Utils @@ -1088,7 +1088,7 @@ class GrampsParser: a.set_type(key) a.set_value(attrs[key]) self.photo.add_attribute(a) - self.photo.set_mime_type(GrampsMime.get_type(self.photo.get_path())) + self.photo.set_mime_type(Mime.get_type(self.photo.get_path())) self.db.add_object(self.photo) if self.family: self.family.add_media_reference(self.pref) diff --git a/src/ImgManip.py b/src/ImgManip.py index 930b03a63..7cd472a35 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -25,7 +25,7 @@ import md5 import gtk import gobject -import GrampsMime +import Mime import Config import Utils @@ -153,7 +153,7 @@ def get_thumbnail_image(path,mtype=None): return gtk.gdk.pixbuf_new_from_file(filename) except (gobject.GError, OSError): if mtype: - return GrampsMime.find_mime_type_pixbuf(mtype) + return Mime.find_mime_type_pixbuf(mtype) else: return gtk.gdk.pixbuf_new_from_file(os.path.join( const.data_dir,"document.png")) @@ -169,7 +169,7 @@ def get_thumb_from_obj(obj): if mtype[0:5] == "image": image = get_thumbnail_image(obj.get_path()) else: - image = GrampsMime.find_mime_type_pixbuf(mtype) + image = Mime.find_mime_type_pixbuf(mtype) if not image: image = gtk.gdk.pixbuf_new_from_file(const.icon) return image diff --git a/src/GnomeMime.py b/src/Mime/_GnomeMime.py similarity index 100% rename from src/GnomeMime.py rename to src/Mime/_GnomeMime.py diff --git a/src/PythonMime.py b/src/Mime/_PythonMime.py similarity index 100% rename from src/PythonMime.py rename to src/Mime/_PythonMime.py diff --git a/src/GrampsMime.py b/src/Mime/__init__.py similarity index 100% rename from src/GrampsMime.py rename to src/Mime/__init__.py diff --git a/src/SelectObject.py b/src/SelectObject.py index 6ff8e2dfe..f06a0da29 100644 --- a/src/SelectObject.py +++ b/src/SelectObject.py @@ -58,7 +58,7 @@ import const import Utils import ListModel import ImgManip -import GrampsMime +import Mime #------------------------------------------------------------------------- # @@ -101,7 +101,7 @@ class SelectObject: for key in self.db.get_media_object_handles(): obj = self.db.get_object_from_handle(key) title = obj.get_description() - the_type = GramspMime.get_description(obj.get_mime_type()) + 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) @@ -120,7 +120,7 @@ class SelectObject: if the_type and the_type[0:5] == "image": image = ImgManip.get_thumbnail_image(path,the_type) else: - image = GrampsMime.find_mime_type_pixbuf(the_type) + image = Mime.find_mime_type_pixbuf(the_type) self.preview.set_from_pixbuf(image) self.object_handle.set_text(obj.get_gramps_id()) diff --git a/src/Utils.py b/src/Utils.py index 2a3da3ed5..aa93c6efb 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -45,7 +45,7 @@ import gtk.gdk # #------------------------------------------------------------------------- import const -import GrampsMime +import Mime import NameDisplay import RelLib import Errors @@ -503,7 +503,7 @@ def add_menuitem(menu,msg,obj,func): def view_photo(photo): mime_type = photo.get_mime_type() try: - data = GrampsMime.get_application(mime_type) + data = Mime.get_application(mime_type) prog = data[0] except: return diff --git a/src/ViewManager.py b/src/ViewManager.py index 875a76e6d..e61bae83d 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -62,7 +62,7 @@ import RecentFiles import NameDisplay import Tool import Report -import GrampsMime +import Mime import Config import GrampsWidgets @@ -570,7 +570,7 @@ class ViewManager: return False filetype = type_selector.get_value() if filetype == 'auto': - filetype = GrampsMime.get_type(filename) + filetype = Mime.get_type(filename) (the_path,the_file) = os.path.split(filename) choose.destroy() if filetype in [const.app_gramps,const.app_gramps_xml, @@ -916,7 +916,7 @@ class ViewManager: filetype = type_selector.get_value() if filetype == 'auto': try: - filetype = GrampsMime.get_type(filename) + filetype = Mime.get_type(filename) except RuntimeError,msg: QuestionDialog.ErrorDialog( _("Could not open file: %s") % filename, diff --git a/src/docgen/AbiWord2Doc.py b/src/docgen/AbiWord2Doc.py index 89b44ad76..47350b91e 100644 --- a/src/docgen/AbiWord2Doc.py +++ b/src/docgen/AbiWord2Doc.py @@ -36,7 +36,7 @@ import BaseDoc import Errors import PluginMgr import ImgManip -import GrampsMime +import Mime import Utils from gettext import gettext as _ @@ -179,7 +179,7 @@ class AbiWordDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'application/x-abiword' try: - app = GrampsMime.get_application(apptype)[0] + app = Mime.get_application(apptype)[0] os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app) except: @@ -326,8 +326,8 @@ class AbiWordDoc(BaseDoc.BaseDoc): #-------------------------------------------------------------------------- try: - prog = GrampsMime.get_application("application/x-abiword") - mtype = GrampsMime.get_description('application/x-abiword') + prog = Mime.get_application("application/x-abiword") + mtype = Mime.get_description('application/x-abiword') if Utils.search_for(prog[0]): print_label=_("Open in %s") % prog[1] diff --git a/src/docgen/AsciiDoc.py b/src/docgen/AsciiDoc.py index 93b6a61f9..b62fdf45a 100644 --- a/src/docgen/AsciiDoc.py +++ b/src/docgen/AsciiDoc.py @@ -36,7 +36,7 @@ from gettext import gettext as _ import BaseDoc import PluginMgr import Errors -import GrampsMime +import Mime #------------------------------------------------------------------------ # @@ -153,7 +153,7 @@ class AsciiDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'text/plain' - prog = GrampsMime.get_application(apptype) + prog = Mime.get_application(apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % prog[0]) @@ -383,8 +383,8 @@ print_label = None try: import Utils - mprog = GrampsMime.get_application("text/plain") - mtype = GrampsMime.get_description('text/plain') + mprog = Mime.get_application("text/plain") + mtype = Mime.get_description('text/plain') if Utils.search_for(mprog[0]): print_label=_("Open in %s") % mprog[1] diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index d5219dd89..355200ee5 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -42,7 +42,7 @@ import const import Errors import BaseDoc import QuestionDialog -import GrampsMime +import Mime #------------------------------------------------------------------------ # @@ -356,7 +356,7 @@ class HtmlDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'text/html' - app = GrampsMime.get_application(apptype) + app = Mime.get_application(apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app[0]) @@ -499,8 +499,8 @@ class HtmlDoc(BaseDoc.BaseDoc): try: import Utils - prog = GrampsMime.get_application("text/html") - mtype = GrampsMime.get_description("text/html") + prog = Mime.get_application("text/html") + mtype = Mime.get_description("text/html") if Utils.search_for(prog[0]): print_label=_("Open in %s") % prog[1] diff --git a/src/docgen/KwordDoc.py b/src/docgen/KwordDoc.py index 1c099fbb2..6148961a7 100644 --- a/src/docgen/KwordDoc.py +++ b/src/docgen/KwordDoc.py @@ -31,7 +31,7 @@ import Errors from TarFile import TarFile import PluginMgr import ImgManip -import GrampsMime +import Mime from gettext import gettext as _ @@ -263,7 +263,7 @@ class KwordDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'application/x-kword' - app = GrampsMime.get_application(apptype) + app = Mime.get_application(apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app[0]) @@ -488,8 +488,8 @@ class KwordDoc(BaseDoc.BaseDoc): try: import Utils - prog = GrampsMime.get_application("application/x-kword") - mtype = GrampsMime.get_description("application/x-kword") + prog = Mime.get_application("application/x-kword") + mtype = Mime.get_description("application/x-kword") if prog and Utils.search_for(prog[0]): print_label=_("Open in %s") % prog[1] diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index 599cce098..ececa5687 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -44,7 +44,7 @@ import const import PluginMgr import ImgManip import FontScale -import GrampsMime +import Mime from ReportUtils import pt2cm #------------------------------------------------------------------------- @@ -417,7 +417,7 @@ class ODFDoc(BaseDoc.BaseDoc): self._write_mimetype_file() self._write_zip() if self.print_req: - app = GrampsMime.get_application(_apptype) + app = Mime.get_application(_apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app[0]) @@ -1132,8 +1132,8 @@ print_label = None try: import Utils - mprog = GrampsMime.get_application(_apptype) - mtype = GrampsMime.get_description(_apptype) + mprog = Mime.get_application(_apptype) + mtype = Mime.get_description(_apptype) if Utils.search_for(mprog[0]): print_label = _("Open in %(program_name)s") % { 'program_name': diff --git a/src/docgen/OpenOfficeDoc.py b/src/docgen/OpenOfficeDoc.py index ff3e6998d..b61184eb2 100644 --- a/src/docgen/OpenOfficeDoc.py +++ b/src/docgen/OpenOfficeDoc.py @@ -43,7 +43,7 @@ import const import PluginMgr import ImgManip import FontScale -import GrampsMime +import Mime import Utils from ReportUtils import pt2cm @@ -381,7 +381,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): self._write_meta_file() self._write_zip() if self.print_req: - app = GrampsMime.get_application(_apptype) + app = Mime.get_application(_apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app[0]) @@ -995,8 +995,8 @@ class OpenOfficeDoc(BaseDoc.BaseDoc): print_label = None try: - mprog = GrampsMime.get_application(_apptype) - mtype = GrampsMime.get_description(_apptype) + mprog = Mime.get_application(_apptype) + mtype = Mime.get_description(_apptype) if Utils.search_for(mprog[0]): print_label = _("Open in OpenOffice.org") diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index 4bf574502..7b8152c6b 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -36,7 +36,7 @@ import BaseDoc import PluginMgr import Errors import ImgManip -import GrampsMime +import Mime _H = 'Helvetica' _HB = 'Helvetica-Bold' @@ -189,7 +189,7 @@ class PdfDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'application/pdf' - app = GrampsMime.get_application(apptype) + app = Mime.get_application(apptype) os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app[0]) @@ -631,8 +631,8 @@ print_label = None try: import Utils - mprog = GrampsMime.get_application("application/pdf") - mtype = GrampsMime.get_description("application/pdf") + mprog = Mime.get_application("application/pdf") + mtype = Mime.get_description("application/pdf") if Utils.search_for(mprog[0]): print_label=_("Open in %s") % mprog[1] diff --git a/src/docgen/RTFDoc.py b/src/docgen/RTFDoc.py index fb408ca51..f6ec1d78e 100644 --- a/src/docgen/RTFDoc.py +++ b/src/docgen/RTFDoc.py @@ -37,7 +37,7 @@ import BaseDoc import PluginMgr import ImgManip import Errors -import GrampsMime +import Mime #------------------------------------------------------------------------ # @@ -127,7 +127,7 @@ class RTFDoc(BaseDoc.BaseDoc): if self.print_req: apptype = 'application/rtf' try: - app = GrampsMime.get_application(apptype)[0] + app = Mime.get_application(apptype)[0] os.environ["FILE"] = self.filename os.system ('%s "$FILE" &' % app) except: @@ -420,8 +420,8 @@ class RTFDoc(BaseDoc.BaseDoc): try: import Utils - mprog = GrampsMime.get_application("application/rtf") - mtype = GrampsMime.get_description("application/rtf") + mprog = Mime.get_application("application/rtf") + mtype = Mime.get_description("application/rtf") if Utils.search_for(mprog[0]): print_label=_("Open in %s") % mprog[1] diff --git a/src/gramps_main.py b/src/gramps_main.py index 66256ba28..f0e783b55 100644 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -57,7 +57,7 @@ import Errors import PluginMgr import TipOfDay -from GrampsMime import mime_type_is_defined +from Mime import mime_type_is_defined from QuestionDialog import ErrorDialog iconpaths = [".",const.image_dir] diff --git a/src/plugins/WriteCD.py b/src/plugins/WriteCD.py index 477fca88b..950032a53 100644 --- a/src/plugins/WriteCD.py +++ b/src/plugins/WriteCD.py @@ -52,7 +52,7 @@ except: #------------------------------------------------------------------------- import WriteXML import Utils -import GrampsMime +import Mime import const import QuestionDialog import ImgManip @@ -226,7 +226,7 @@ class PackageWriter: newfile = fs_top.get_filename() if os.path.isfile(newfile): self.copy_file(newfile,'burn:///%s/%s' % (base,obase)) - ntype = GrampsMime.get_type(newfile) + ntype = Mime.get_type(newfile) if ntype and ntype.startswith("image"): self.make_thumbnail(base,obase,newfile)