Skip to content

Commit

Permalink
Make Virtual Library tabs lockable (no close button)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serized committed Jan 20, 2018
1 parent 8ab7330 commit 0d38679
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/calibre/gui2/__init__.py
Expand Up @@ -139,6 +139,7 @@ def create_defs():
defs['cover_grid_show_title'] = False
defs['cover_grid_texture'] = None
defs['show_vl_tabs'] = False
defs['closable_tabs'] = True
defs['show_highlight_toggle_button'] = False
defs['add_comments_to_email'] = False
defs['cb_preserve_aspect_ratio'] = False
Expand Down
23 changes: 22 additions & 1 deletion src/calibre/gui2/init.py
Expand Up @@ -396,7 +396,7 @@ def __init__(self, parent):
self.setDocumentMode(True)
self.setDrawBase(False)
self.setMovable(True)
self.setTabsClosable(True)
self.setTabsClosable(gprefs['closable_tabs'])
self.gui = parent
self.ignore_tab_changed = False
self.currentChanged.connect(self.tab_changed)
Expand Down Expand Up @@ -432,6 +432,23 @@ def disable_bar(self):
gprefs['show_vl_tabs'] = False
self.setVisible(False)

def lock_tab(self):
gprefs['closable_tabs'] = False
self.setTabsClosable(False)

def unlock_tab(self):
gprefs['closable_tabs'] = True
self.setTabsClosable(True)
try:
self.tabButton(0, self.RightSide).setVisible(False)
except AttributeError:
try:
self.tabButton(0, self.LeftSide).setVisible(False)
except AttributeError:
# On some OS X machines (using native style) the tab button is
# on the left
pass

def tab_changed(self, idx):
if self.ignore_tab_changed:
return
Expand Down Expand Up @@ -512,6 +529,10 @@ def contextMenuEvent(self, ev):
for x in hidden:
s.addAction(x, partial(self.restore, x))
m.addAction(_('Hide virtual library tabs'), self.disable_bar)
if gprefs['closable_tabs']:
m.addAction(_('Lock virtual library tabs'), self.lock_tab)
if not gprefs['closable_tabs']:
m.addAction(_('Unlock virtual library tabs'), self.unlock_tab)
i = self.tabAt(ev.pos())
if i > -1:
vl = unicode(self.tabData(i) or '')
Expand Down

0 comments on commit 0d38679

Please sign in to comment.