0001483: Cannot display media files within GRAMPS (running on MS Vista)
svn: r9898
This commit is contained in:
parent
2b7534d55d
commit
6873e9823b
@ -1,3 +1,7 @@
|
|||||||
|
2008-01-20 Brian Matherly <brian@gramps-project.org>
|
||||||
|
* src/Mime/_WinMime.py:
|
||||||
|
0001483: Cannot display media files within GRAMPS (running on MS Vista)
|
||||||
|
|
||||||
2008-01-20 Brian Matherly <brian@gramps-project.org>
|
2008-01-20 Brian Matherly <brian@gramps-project.org>
|
||||||
* src/plugins/Makefile.am:
|
* src/plugins/Makefile.am:
|
||||||
* po/POTFILES.in:
|
* po/POTFILES.in:
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
# $Id:
|
# $Id$
|
||||||
|
|
||||||
|
"""
|
||||||
|
Mime utility functions for the MS Windows platform
|
||||||
|
"""
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -29,40 +33,32 @@ import os
|
|||||||
from _winreg import *
|
from _winreg import *
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# GNOME/GTK
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
import gtk
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Gramps modules
|
# Gramps modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import const
|
|
||||||
import _PythonMime
|
import _PythonMime
|
||||||
|
|
||||||
|
|
||||||
def get_application(type):
|
def get_application(mime_type):
|
||||||
"""Returns the application command and application name of the
|
"""Returns the application command and application name of the
|
||||||
specified mime type"""
|
specified mime type"""
|
||||||
extension = _get_extension(type)
|
extension = _get_extension(mime_type)
|
||||||
progId = _get_prog_id(extension)
|
progid = _get_prog_id(extension)
|
||||||
|
|
||||||
if not progId:
|
if not progid:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Find the application associated with this program ID
|
# Find the application associated with this program ID
|
||||||
aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT)
|
hcr = ConnectRegistry(None, HKEY_CLASSES_ROOT)
|
||||||
subkey = OpenKey(aReg, "%s\shell\open\command" % progId)
|
subkey = OpenKey(hcr, "%s\shell\open\command" % progid)
|
||||||
if subkey:
|
if subkey:
|
||||||
n,command,type = EnumValue(subkey, 0)
|
name, command, data_type = EnumValue(subkey, 0)
|
||||||
if type == REG_EXPAND_SZ:
|
if data_type == REG_EXPAND_SZ:
|
||||||
command = command.replace( '%SystemRoot%',
|
command = command.replace( '%SystemRoot%',
|
||||||
os.getenv('SystemRoot') )
|
os.getenv('SystemRoot') )
|
||||||
CloseKey(aReg)
|
CloseKey(hcr)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
CloseKey(subkey)
|
CloseKey(subkey)
|
||||||
@ -76,32 +72,36 @@ def get_application(type):
|
|||||||
else:
|
else:
|
||||||
app = command.split()[0]
|
app = command.split()[0]
|
||||||
|
|
||||||
hcu = ConnectRegistry(None,HKEY_CURRENT_USER)
|
hcu = ConnectRegistry(None, HKEY_CURRENT_USER)
|
||||||
subkey = OpenKey(hcu, "Software\Microsoft\Windows\ShellNoRoam\MUICache")
|
try:
|
||||||
|
subkey = OpenKey(hcu, "Software\Microsoft\Windows\ShellNoRoam\MUICache")
|
||||||
|
except WindowsError:
|
||||||
|
subkey = None
|
||||||
|
|
||||||
desc = None
|
desc = None
|
||||||
if subkey:
|
if subkey:
|
||||||
try:
|
try:
|
||||||
desc,ValType = QueryValueEx(subkey, app)
|
desc, data_type = QueryValueEx(subkey, app)
|
||||||
except:
|
except WindowsError:
|
||||||
# No friendly name exists. Use progId
|
# No friendly name exists. Use progid
|
||||||
desc = progId
|
desc = progid
|
||||||
CloseKey(subkey)
|
CloseKey(subkey)
|
||||||
else:
|
else:
|
||||||
desc = progId
|
desc = progid
|
||||||
CloseKey(hcu)
|
CloseKey(hcu)
|
||||||
|
|
||||||
return (command,desc)
|
return (command, desc)
|
||||||
|
|
||||||
def get_description(mime_type):
|
def get_description(mime_type):
|
||||||
"""Returns the description of the specfied mime type"""
|
"""Returns the description of the specfied mime type"""
|
||||||
desc = None
|
desc = None
|
||||||
extension = _get_extension(mime_type)
|
extension = _get_extension(mime_type)
|
||||||
progId = _get_prog_id(extension)
|
progid = _get_prog_id(extension)
|
||||||
|
|
||||||
if progId:
|
if progid:
|
||||||
aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT)
|
hcr = ConnectRegistry(None, HKEY_CLASSES_ROOT)
|
||||||
desc = QueryValue(aReg, progId)
|
desc = QueryValue(hcr, progid)
|
||||||
CloseKey(aReg)
|
CloseKey(hcr)
|
||||||
|
|
||||||
if not desc:
|
if not desc:
|
||||||
desc = _("unknown")
|
desc = _("unknown")
|
||||||
@ -121,8 +121,6 @@ def mime_type_is_defined(mime_type):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return _PythonMime.mime_type_is_defined(mime_type)
|
return _PythonMime.mime_type_is_defined(mime_type)
|
||||||
|
|
||||||
_icon_theme = gtk.icon_theme_get_default()
|
|
||||||
|
|
||||||
def find_mime_type_pixbuf(mime_type):
|
def find_mime_type_pixbuf(mime_type):
|
||||||
return _PythonMime.find_mime_type_pixbuf(mime_type)
|
return _PythonMime.find_mime_type_pixbuf(mime_type)
|
||||||
@ -139,14 +137,14 @@ def _get_extension(mime_type):
|
|||||||
"""
|
"""
|
||||||
extension = None
|
extension = None
|
||||||
try:
|
try:
|
||||||
aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT)
|
hcr = ConnectRegistry(None, HKEY_CLASSES_ROOT)
|
||||||
subkey = OpenKey(aReg, "MIME\DataBase\Content Type")
|
subkey = OpenKey(hcr, "MIME\DataBase\Content Type")
|
||||||
mimekey = OpenKey(subkey, mime_type)
|
mimekey = OpenKey(subkey, mime_type)
|
||||||
extension,type = QueryValueEx(mimekey, "Extension")
|
extension, value_type = QueryValueEx(mimekey, "Extension")
|
||||||
CloseKey(mimekey)
|
CloseKey(mimekey)
|
||||||
CloseKey(subkey)
|
CloseKey(subkey)
|
||||||
CloseKey(aReg)
|
CloseKey(hcr)
|
||||||
except:
|
except WindowsError:
|
||||||
extension = None
|
extension = None
|
||||||
|
|
||||||
if not extension:
|
if not extension:
|
||||||
@ -160,7 +158,6 @@ def _get_extension(mime_type):
|
|||||||
|
|
||||||
return extension
|
return extension
|
||||||
|
|
||||||
|
|
||||||
def _get_prog_id(extension):
|
def _get_prog_id(extension):
|
||||||
"""
|
"""
|
||||||
Return the program ID associated with this extension
|
Return the program ID associated with this extension
|
||||||
@ -170,10 +167,10 @@ def _get_prog_id(extension):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT)
|
hcr = ConnectRegistry(None, HKEY_CLASSES_ROOT)
|
||||||
progId = QueryValue(aReg, extension)
|
progid = QueryValue(hcr, extension)
|
||||||
CloseKey(aReg)
|
CloseKey(hcr)
|
||||||
return progId
|
return progid
|
||||||
except:
|
except WindowsError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user