Add Mime package

svn: r6047
This commit is contained in:
Alex Roitman 2006-03-03 00:23:04 +00:00
parent 4efbaaa16c
commit 7286845b75
26 changed files with 73 additions and 70 deletions

View File

@ -10,6 +10,9 @@
* src/plugins/NavWebPage.py: update to new install paths
2006-03-02 Alex Roitman <shura@gramps-project.org>
* 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).

View File

@ -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):

View File

@ -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<len(options)-1 \
and options[opt_ix+1][0] in ( '-f', '--format'):
@ -149,7 +149,7 @@ class ArgHandler:
self.open = (fname,format)
elif o in ( '-i', '--import'):
fname = v
ftype = GrampsMime.get_type(
ftype = Mime.get_type(
os.path.abspath(os.path.expanduser(fname)))
if opt_ix<len(options)-1 \
and options[opt_ix+1][0] in ( '-f', '--format'):
@ -227,7 +227,7 @@ class ArgHandler:
#-------------------------------------------------------------------------
def auto_save_load(self,filename):
filename = os.path.normpath(os.path.abspath(filename))
filetype = GrampsMime.get_type(filename)
filetype = Mime.get_type(filename)
if filetype in (const.app_gramps,
const.app_gramps_xml,
const.app_gedcom):
@ -253,7 +253,7 @@ class ArgHandler:
# the rest of given arguments.
success = False
filename = os.path.abspath(os.path.expanduser(self.open_gui))
filetype = GrampsMime.get_type(filename)
filetype = Mime.get_type(filename)
if filetype in (const.app_gramps,const.app_gedcom,
const.app_gramps_xml):
# Say the type outloud

View File

@ -43,7 +43,7 @@ import gtk
import GrampsDb
import Config
import NameDisplay
import GrampsMime
import Mime
import const
import Errors
@ -395,7 +395,7 @@ class RecentDocsMenu:
for item in rfiles:
try:
filename = os.path.basename(item.get_path()).replace('_','__')
filetype = GrampsMime.get_type(item.get_path())
filetype = Mime.get_type(item.get_path())
action_id = "RecentMenu%d" % count
f.write('<menuitem action="%s"/>' % action_id)
actions.append((action_id,None,filename,None,None,

View File

@ -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)

View File

@ -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:

View File

@ -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],

View File

@ -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:

View File

@ -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)

View File

@ -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

View File

@ -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())

View File

@ -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

View File

@ -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,

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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':

View File

@ -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")

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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)