From 66aefc1897da33b92e5c50a708201873fa476676 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 31 Dec 2011 09:06:21 +0530 Subject: [PATCH] Allow user to set the number of recently viewed books shown in the dropdown menu of the view button, via a tweak in Preferences->Tweaks. Fixes #910292 (More entries for the view button) --- resources/default_tweaks.py | 5 +++++ src/calibre/gui2/actions/view.py | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/default_tweaks.py b/resources/default_tweaks.py index b2863107c1..c77bcf5228 100644 --- a/resources/default_tweaks.py +++ b/resources/default_tweaks.py @@ -471,3 +471,8 @@ unified_title_toolbar_on_osx = False # this to False you can prevent calibre from saving the original file. save_original_format = True +#: Number of recently viewed books to show +# Right-clicking the View button shows a list of recently viewed books. Control +# how many should be shown, here. +gui_view_history_size = 15 + diff --git a/src/calibre/gui2/actions/view.py b/src/calibre/gui2/actions/view.py index 84060de786..43e9dad5c4 100644 --- a/src/calibre/gui2/actions/view.py +++ b/src/calibre/gui2/actions/view.py @@ -14,7 +14,7 @@ from calibre.constants import isosx from calibre.gui2 import error_dialog, Dispatcher, question_dialog, config, \ open_local_file, info_dialog from calibre.gui2.dialogs.choose_format import ChooseFormatDialog -from calibre.utils.config import prefs +from calibre.utils.config import prefs, tweaks from calibre.ptempfile import PersistentTemporaryFile from calibre.gui2.actions import InterfaceAction @@ -239,6 +239,7 @@ class ViewAction(InterfaceAction): def update_history(self, views, remove=frozenset()): db = self.gui.current_db + vh = tweaks['gui_view_history_size'] if views: seen = set() history = [] @@ -247,12 +248,12 @@ class ViewAction(InterfaceAction): seen.add(title) history.append((id_, title)) - db.prefs['gui_view_history'] = history[:10] + db.prefs['gui_view_history'] = history[:vh] self.build_menus(db) if remove: history = db.prefs.get('gui_view_history', []) history = [x for x in history if x[0] not in remove] - db.prefs['gui_view_history'] = history[:10] + db.prefs['gui_view_history'] = history[:vh] self.build_menus(db) def _view_books(self, rows):