Change the way we "launch" files using their default application. Instead of trying to find the application ourselves, use the OS built in functions to open a file with its default application. We no longer show the name of the application that we will open the file with because we don't know.
svn: r11781
This commit is contained in:
@ -206,11 +206,9 @@ class EditMedia(EditPrimary):
|
||||
ref_obj = self.dbstate.db.get_object_from_handle(self.obj.handle)
|
||||
|
||||
if ref_obj:
|
||||
mime_type = ref_obj.get_mime_type()
|
||||
app = Mime.get_application(mime_type)
|
||||
if app:
|
||||
Utils.launch(app[0], Utils.media_path_full(self.dbstate.db,
|
||||
ref_obj.get_path()))
|
||||
media_path = Utils.media_path_full(self.dbstate.db,
|
||||
ref_obj.get_path())
|
||||
Utils.open_file_with_default_application(media_path)
|
||||
|
||||
def select_file(self, val):
|
||||
self.determine_mime()
|
||||
|
@ -44,7 +44,7 @@ import const
|
||||
import Config
|
||||
import Mime
|
||||
import ThumbNails
|
||||
from Utils import media_path_full
|
||||
import Utils
|
||||
from gen.lib import NoteType
|
||||
|
||||
from DisplayTabs import (SourceEmbedList, AttrEmbedList, MediaBackRefList,
|
||||
@ -102,7 +102,7 @@ class EditMediaRef(EditReference):
|
||||
the path.
|
||||
"""
|
||||
self.mtype = self.source.get_mime_type()
|
||||
fullpath = media_path_full(self.db, self.source.get_path())
|
||||
fullpath = Utils.media_path_full(self.db, self.source.get_path())
|
||||
self.pix = ThumbNails.get_thumbnail_image(fullpath,
|
||||
self.mtype)
|
||||
self.pixmap.set_from_pixbuf(self.pix)
|
||||
@ -350,7 +350,7 @@ class EditMediaRef(EditReference):
|
||||
self.subpixmap.hide()
|
||||
else:
|
||||
try:
|
||||
fullpath = media_path_full(self.db, path)
|
||||
fullpath = Utils.media_path_full(self.db, path)
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(fullpath)
|
||||
width = pixbuf.get_width()
|
||||
height = pixbuf.get_height()
|
||||
@ -389,7 +389,8 @@ class EditMediaRef(EditReference):
|
||||
|
||||
def button_press_event(self, obj, event):
|
||||
if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS:
|
||||
self.view_media(obj)
|
||||
photo_path = Utils.media_path_full(self.db, self.source.get_path())
|
||||
Utils.open_file_with_default_application(photo_path)
|
||||
|
||||
def button_press_event_ref(self, widget, event):
|
||||
"""
|
||||
@ -489,13 +490,6 @@ class EditMediaRef(EditReference):
|
||||
obj.update()
|
||||
self.draw_preview()
|
||||
|
||||
def view_media(self, obj):
|
||||
mime_type = self.source.get_mime_type()
|
||||
app = Mime.get_application(mime_type)
|
||||
if app:
|
||||
from Utils import launch
|
||||
launch(app[0], media_path_full(self.db, self.source.get_path()))
|
||||
|
||||
def _connect_signals(self):
|
||||
self.define_cancel_button(self.top.get_widget('button84'))
|
||||
self.define_ok_button(self.top.get_widget('button82'),self.save)
|
||||
|
@ -470,12 +470,8 @@ class EditPerson(EditPrimary):
|
||||
menu = gtk.Menu()
|
||||
menu.set_title(_("Media Object"))
|
||||
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
||||
mtype = obj.get_mime_type()
|
||||
progname = Mime.get_application(mtype)
|
||||
|
||||
if progname and len(progname) > 1:
|
||||
Utils.add_menuitem(menu, _("Open in %s") % progname[1],
|
||||
photo, self._popup_view_photo)
|
||||
if obj:
|
||||
Utils.add_menuitem(menu, _("View"), photo, self._popup_view_photo)
|
||||
Utils.add_menuitem(menu, _("Edit Object Properties"), photo,
|
||||
self._popup_change_description)
|
||||
menu.popup(None, None, None, event.button, event.time)
|
||||
@ -488,8 +484,9 @@ class EditPerson(EditPrimary):
|
||||
if media_list:
|
||||
photo = media_list[0]
|
||||
object_handle = photo.get_reference_handle()
|
||||
Utils.view_photo(self.db.get_object_from_handle(object_handle),
|
||||
self.db)
|
||||
ref_obj = self.db.get_object_from_handle(object_handle)
|
||||
photo_path = Utils.media_path_full(self.db, ref_obj.get_path())
|
||||
Utils.open_file_with_default_application(photo_path)
|
||||
|
||||
def _popup_change_description(self, obj):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user