From ab55a25674d64426fa06877ec6b9c6a1bb87b8a9 Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 21 May 2011 21:17:27 -0400 Subject: [PATCH] Store: add missed files. Add more quick functions for listing stores and which ones are enabled. --- src/calibre/customize/ui.py | 23 ++- src/calibre/gui2/store/config/__init__.py | 0 .../gui2/store/config/search_widget.py | 45 +++++ .../gui2/store/config/search_widget.ui | 162 ++++++++++++++++++ src/calibre/gui2/store/config/store.py | 14 ++ src/calibre/gui2/ui.py | 4 +- 6 files changed, 243 insertions(+), 5 deletions(-) create mode 100644 src/calibre/gui2/store/config/__init__.py create mode 100644 src/calibre/gui2/store/config/search_widget.py create mode 100644 src/calibre/gui2/store/config/search_widget.ui create mode 100644 src/calibre/gui2/store/config/store.py diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py index e955336d3f..0a21b0b42e 100644 --- a/src/calibre/customize/ui.py +++ b/src/calibre/customize/ui.py @@ -216,9 +216,26 @@ def store_plugins(): customization = config['plugin_customization'] for plugin in _initialized_plugins: if isinstance(plugin, Store): - if not is_disabled(plugin): - plugin.site_customization = customization.get(plugin.name, '') - yield plugin + plugin.site_customization = customization.get(plugin.name, '') + yield plugin + +def available_store_plugins(): + for plugin in store_plugins(): + if not is_disabled(plugin): + yield plugin + +def stores(): + stores = set([]) + for plugin in store_plugins(): + stores.add(plugin.name) + return stores + +def available_stores(): + stores = set([]) + for plugin in available_store_plugins(): + stores.add(plugin.name) + return stores + # }}} # Metadata read/write {{{ diff --git a/src/calibre/gui2/store/config/__init__.py b/src/calibre/gui2/store/config/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/calibre/gui2/store/config/search_widget.py b/src/calibre/gui2/store/config/search_widget.py new file mode 100644 index 0000000000..43e911a432 --- /dev/null +++ b/src/calibre/gui2/store/config/search_widget.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +from __future__ import (unicode_literals, division, absolute_import, print_function) + +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + +from PyQt4.Qt import QWidget + +from calibre.gui2 import JSONConfig +from calibre.gui2.store.config.search_widget_ui import Ui_Form + +class StoreConfigWidget(QWidget, Ui_Form): + + def __init__(self, config=None): + QWidget.__init__(self) + self.setupUi(self) + + self.config = JSONConfig('store/search') if not config else config + + # These default values should be the same as in + # calibre.gui2.store.search.search:SearchDialog.load_settings + # Seconds + self.opt_timeout.setValue(self.config.get('timeout', 75)) + self.opt_hang_time.setValue(self.config.get('hang_time', 75)) + + self.opt_max_results.setValue(self.config.get('max_results', 10)) + self.opt_open_external.setChecked(self.config.get('open_external', True)) + + # Number of threads to run for each type of operation + self.opt_search_thread_count.setValue(self.config.get('search_thread_count', 4)) + self.opt_cache_thread_count.setValue(self.config.get('cache_thread_count', 2)) + self.opt_cover_thread_count.setValue(self.config.get('cover_thread_count', 2)) + self.opt_details_thread_count.setValue(self.config.get('details_thread_count', 4)) + + def save_settings(self): + self.config['timeout'] = self.opt_timeout.value() + self.config['hang_time'] = self.opt_hang_time.value() + self.config['max_results'] = self.opt_max_results.value() + self.config['open_external'] = self.opt_open_external.isChecked() + self.config['search_thread_count'] = self.opt_search_thread_count.value() + self.config['cache_thread_count'] = self.opt_cache_thread_count.value() + self.config['cover_thread_count'] = self.opt_cover_thread_count.value() + self.config['details_thread_count'] = self.opt_details_thread_count.value() diff --git a/src/calibre/gui2/store/config/search_widget.ui b/src/calibre/gui2/store/config/search_widget.ui new file mode 100644 index 0000000000..a73aae3ea5 --- /dev/null +++ b/src/calibre/gui2/store/config/search_widget.ui @@ -0,0 +1,162 @@ + + + Form + + + + 0 + 0 + 465 + 396 + + + + Form + + + + + + Time + + + + + + Number of seconds to wait for a store to respond + + + + + + + 1 + + + + + + + Number of seconds to let a store process results + + + + + + + 1 + + + 99 + + + 1 + + + 1 + + + + + + + + + + Display + + + + + + Maximum number of results to show per store + + + + + + + 1 + + + + + + + Open search result in system browser + + + + + + + + + + Threads + + + + + + Number of search threads to use + + + + + + + 1 + + + + + + + Number of cache update threads to use + + + + + + + 1 + + + + + + + Number of conver download threads to use + + + + + + + 1 + + + + + + + Number of details threads to use + + + + + + + 1 + + + + + + + + + + + diff --git a/src/calibre/gui2/store/config/store.py b/src/calibre/gui2/store/config/store.py new file mode 100644 index 0000000000..0e05514867 --- /dev/null +++ b/src/calibre/gui2/store/config/store.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +from __future__ import (unicode_literals, division, absolute_import, print_function) + +__license__ = 'GPL 3' +__copyright__ = '2011, John Schember ' +__docformat__ = 'restructuredtext en' + +def config_widget(): + from calibre.gui2.store.config.search_widget import StoreConfigWidget + return StoreConfigWidget() + +def save_settings(config_widget): + config_widget.save_settings() diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index 122bfc81b4..df0e20e1bc 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -23,7 +23,7 @@ from calibre.constants import __appname__, isosx from calibre.utils.config import prefs, dynamic from calibre.utils.ipc.server import Server from calibre.library.database2 import LibraryDatabase2 -from calibre.customize.ui import interface_actions, store_plugins +from calibre.customize.ui import interface_actions, enabled_store_plugins from calibre.gui2 import error_dialog, GetMetadata, open_url, \ gprefs, max_available_height, config, info_dialog, Dispatcher, \ question_dialog @@ -144,7 +144,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ def load_store_plugins(self): self.istores = OrderedDict() - for store in store_plugins(): + for store in enabled_store_plugins(): if self.opts.ignore_plugins and store.plugin_path is not None: continue try: