diff --git a/src/calibre/gui2/catalog/catalog_csv_xml.py b/src/calibre/gui2/catalog/catalog_csv_xml.py index 6bd5d2c082..69eda732da 100644 --- a/src/calibre/gui2/catalog/catalog_csv_xml.py +++ b/src/calibre/gui2/catalog/catalog_csv_xml.py @@ -16,6 +16,7 @@ class PluginWidget(QWidget, Ui_Form): TITLE = _('CSV/XML Output') HELP = _('Options specific to')+' CSV/XML '+_('output') sync_enabled = False + formats = set(['csv', 'xml']) def __init__(self, parent=None): QWidget.__init__(self, parent) diff --git a/src/calibre/gui2/dialogs/catalog.py b/src/calibre/gui2/dialogs/catalog.py index 2e81042467..d792707670 100644 --- a/src/calibre/gui2/dialogs/catalog.py +++ b/src/calibre/gui2/dialogs/catalog.py @@ -100,8 +100,6 @@ class Catalog(QDialog, Ui_Dialog): info("No dynamic tab resources found for %s" % name) self.widgets = sorted(self.widgets, cmp=lambda x,y:cmp(x.TITLE, y.TITLE)) - for pw in self.widgets: - self.tabs.addTab(pw, pw.TITLE) # Generate a sorted list of installed catalog formats/sync_enabled pairs fmts = sorted([x[0] for x in self.fmts]) @@ -125,6 +123,19 @@ class Catalog(QDialog, Ui_Dialog): if self.sync.isEnabled(): self.sync.setChecked(dynamic.get('catalog_sync_to_device', True)) + self.format.currentIndexChanged.connect(self.format_changed) + self.show_plugin_tab(None) + + + def show_plugin_tab(self, idx): + cf = unicode(self.format.currentText()).lower() + while self.tabs.count() > 1: + self.tabs.remove(1) + for pw in self.widgets: + if cf in pw.formats: + self.tabs.addTab(pw, pw.TITLE) + break + def format_changed(self, idx): cf = unicode(self.format.currentText()) if cf in self.sync_enabled_formats: @@ -133,6 +144,14 @@ class Catalog(QDialog, Ui_Dialog): self.sync.setDisabled(True) self.sync.setChecked(False) + @property + def fmt_options(self): + ans = {} + if self.tabs.count() > 1: + w = self.tabs.widget(1) + ans = w.options() + return ans + def accept(self): self.catalog_format = unicode(self.format.currentText()) dynamic.set('catalog_preferred_format', self.catalog_format) diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py index b23e0b6259..7dc83baf32 100644 --- a/src/calibre/gui2/tools.py +++ b/src/calibre/gui2/tools.py @@ -238,7 +238,7 @@ def fetch_scheduled_recipe(arg): def generate_catalog(parent, dbspec, ids): from calibre.gui2.dialogs.catalog import Catalog - + # Build the Catalog dialog in gui2.dialogs.catalog d = Catalog(parent, dbspec, ids) @@ -248,22 +248,13 @@ def generate_catalog(parent, dbspec, ids): # Create the output file out = PersistentTemporaryFile(suffix='_catalog_out.'+d.catalog_format.lower()) - # Retrieve plugin options - fmt_options = {} - for x in range(d.tabs.count()): - if str(d.tabs.tabText(x)).find(str(d.catalog_format)) > -1: - for fmt in d.fmts: - if fmt[0] == d.catalog_format: - fmt_options = fmt[2].options() - # print "gui2.tools:generate_catalog(): options for %s: %s" % (fmt[0], fmt_options) - args = [ d.catalog_format, d.catalog_title, dbspec, ids, out.name, - fmt_options + d.fmt_options ] out.close()