3376: RFE: please add 'Open directory' to context menu of media objects

svn: r13693
This commit is contained in:
Doug Blank 2009-12-01 02:56:03 +00:00
parent b6f8cd5ee6
commit 216a5d6e0a
2 changed files with 27 additions and 2 deletions

View File

@ -128,10 +128,18 @@ class GalleryTab(ButtonTab, DbGUIElement):
ref_obj = self.dbstate.db.get_object_from_handle(obj.ref)
media_path = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
if media_path:
item = gtk.MenuItem(_('View'))
item = gtk.ImageMenuItem(_('View'))
img = gtk.Image()
img.set_from_stock("gramps-viewmedia", gtk.ICON_SIZE_MENU)
item.set_image(img)
item.connect('activate', make_launcher(media_path))
item.show()
menu.append(item)
mfolder, mfile = os.path.split(media_path)
item = gtk.MenuItem(_('Open Containing _Folder'))
item.connect('activate', make_launcher(mfolder))
item.show()
menu.append(item)
item = gtk.SeparatorMenuItem()
item.show()
menu.append(item)

View File

@ -221,6 +221,10 @@ class MediaView(ListView):
self._add_action('OpenMedia', 'gramps-viewmedia', _('View'),
tip=_("View in the default viewer"),
callback=self.view_media)
self._add_action('OpenContainingFolder', None,
_('Open Containing _Folder'),
tip=_("Open the folder containing the media file"),
callback=self.open_containing_folder)
def view_media(self, obj):
"""
@ -231,6 +235,17 @@ class MediaView(ListView):
mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
open_file_with_default_application(mpath)
def open_containing_folder(self, obj):
"""
Launch external viewers for the selected objects.
"""
for handle in self.selected_handles():
ref_obj = self.dbstate.db.get_object_from_handle(handle)
mpath = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
if mpath:
mfolder, mfile = os.path.split(mpath)
open_file_with_default_application(mfolder)
def _column_editor(self, obj):
"""
Start the column editor dialog
@ -351,9 +366,11 @@ class MediaView(ListView):
<toolitem action="OpenMedia"/>
</toolbar>
<popup name="Popup">
<menuitem action="OpenMedia"/>
<menuitem action="OpenContainingFolder"/>
<separator/>
<menuitem action="Add"/>
<menuitem action="Edit"/>
<menuitem action="OpenMedia"/>
<menuitem action="Remove"/>
</popup>
</ui>'''