1#!/usr/local/bin/python3.8
2# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
3
4
5__license__   = 'GPL v3'
6__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
7__docformat__ = 'restructuredtext en'
8
9
10from calibre.gui2.actions import InterfaceAction
11
12
13class OpenFolderAction(InterfaceAction):
14
15    name = 'Open Folder'
16    action_spec = (_('Open containing folder'), 'document_open.png',
17                   _('Open the folder containing the current book\'s files'), _('O'))
18    dont_add_to = frozenset(('context-menu-device',))
19    action_type = 'current'
20
21    def genesis(self):
22        self.qaction.triggered.connect(self.gui.iactions['View'].view_folder)
23
24    def location_selected(self, loc):
25        enabled = loc == 'library'
26        self.qaction.setEnabled(enabled)
27        self.menuless_qaction.setEnabled(enabled)
28