From 92d5ba8dfda9231a2d5d82c113e83c66d78f5aed Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 20 May 2008 03:19:58 +0000 Subject: [PATCH] Remove the "tables" parameter for text and book document generators. All generators support tables, and if one didn't, it doesn't look like the code would work. svn: r10745 --- src/PluginUtils/_PluginMgr.py | 8 ++++---- src/ReportBase/_BookFormatComboBox.py | 18 ++++++++---------- src/ReportBase/_TextFormatComboBox.py | 20 +++++++++----------- src/ReportBase/_TextReportDialog.py | 14 +------------- src/docgen/AsciiDoc.py | 4 ++-- src/docgen/GtkPrint.py | 4 ++-- src/docgen/HtmlDoc.py | 4 ++-- src/docgen/LaTeXDoc.py | 2 +- src/docgen/ODFDoc.py | 4 ++-- src/docgen/PdfDoc.py | 4 ++-- src/docgen/RTFDoc.py | 4 ++-- src/plugins/BookReport.py | 6 +----- 12 files changed, 36 insertions(+), 56 deletions(-) diff --git a/src/PluginUtils/_PluginMgr.py b/src/PluginUtils/_PluginMgr.py index 32eacb98b..1338cda8a 100644 --- a/src/PluginUtils/_PluginMgr.py +++ b/src/PluginUtils/_PluginMgr.py @@ -447,7 +447,7 @@ class PluginManager(gen.utils.Callback): self.__cl_list.append( (name, category, report_class, options_class, translated_name, unsupported, require_active) ) - def register_text_doc(self, name, classref, table, paper, style, ext, + def register_text_doc(self, name, classref, paper, style, ext, print_report_label=None, clname=''): """ Register a text document generator. @@ -463,11 +463,11 @@ class PluginManager(gen.utils.Callback): if not clname: clname = ext[1:] - self.__textdoc_list.append( (name, classref, table, paper, style, + self.__textdoc_list.append( (name, classref, paper, style, ext, print_report_label, clname) ) self.__mod2text[classref.__module__] = name - def register_book_doc(self, name, classref, table, paper, style, ext, + def register_book_doc(self, name, classref, paper, style, ext, print_report_label=None, clname=''): """ Register a text document generator. @@ -482,7 +482,7 @@ class PluginManager(gen.utils.Callback): if not clname: clname = ext[1:] - self.__bookdoc_list.append( (name, classref, table, paper, style, ext, + self.__bookdoc_list.append( (name, classref, paper, style, ext, print_report_label, clname) ) def register_draw_doc(self, name, classref, paper, style, ext, diff --git a/src/ReportBase/_BookFormatComboBox.py b/src/ReportBase/_BookFormatComboBox.py index 70dbbee7c..cdc06da4f 100644 --- a/src/ReportBase/_BookFormatComboBox.py +++ b/src/ReportBase/_BookFormatComboBox.py @@ -50,24 +50,22 @@ class BookFormatComboBox(gtk.ComboBox): self.__book_doc_list.sort() gtk.ComboBox.__init__(self) - def set(self,tables,callback, obj=None,active=None): + def set(self, callback, obj=None, active=None): self.store = gtk.ListStore(gobject.TYPE_STRING) self.set_model(self.store) cell = gtk.CellRendererText() - self.pack_start(cell,True) - self.add_attribute(cell,'text',0) + self.pack_start(cell, True) + self.add_attribute(cell, 'text', 0) out_pref = Config.get(Config.OUTPUT_PREFERENCE) index = 0 active_index = 0 self.data = [] for item in self.__book_doc_list: - if tables and item[2] == 0: - continue self.data.append(item) name = item[0] self.store.append(row=[name]) - if item[7] == active: + if item[6] == active: active_index = index elif not active and name == out_pref: active_index = index @@ -81,13 +79,13 @@ class BookFormatComboBox(gtk.ComboBox): return self.data[self.get_active()][0] def get_paper(self): - return self.data[self.get_active()][3] + return self.data[self.get_active()][2] def get_ext(self): - return self.data[self.get_active()][5] + return self.data[self.get_active()][4] def get_printable(self): - return self.data[self.get_active()][6] + return self.data[self.get_active()][5] def get_clname(self): - return self.data[self.get_active()][7] + return self.data[self.get_active()][6] diff --git a/src/ReportBase/_TextFormatComboBox.py b/src/ReportBase/_TextFormatComboBox.py index 9e29276fb..f5d674568 100644 --- a/src/ReportBase/_TextFormatComboBox.py +++ b/src/ReportBase/_TextFormatComboBox.py @@ -39,22 +39,20 @@ class TextFormatComboBox(gtk.ComboBox): self.__text_doc_list.sort() gtk.ComboBox.__init__(self) - def set(self,tables,callback, obj=None,active=None): + def set(self, callback, obj=None, active=None): self.store = gtk.ListStore(gobject.TYPE_STRING) self.set_model(self.store) cell = gtk.CellRendererText() - self.pack_start(cell,True) - self.add_attribute(cell,'text',0) + self.pack_start(cell, True) + self.add_attribute(cell, 'text', 0) out_pref = Config.get(Config.OUTPUT_PREFERENCE) index = 0 active_index = 0 for item in self.__text_doc_list: - if tables and item[2] == 0: - continue name = item[0] self.store.append(row=[name]) - if item[7] == active: + if item[6] == active: active_index = index elif not active and name == out_pref: active_index = index @@ -68,16 +66,16 @@ class TextFormatComboBox(gtk.ComboBox): return self.__text_doc_list[self.get_active()][1] def get_paper(self): - return self.__text_doc_list[self.get_active()][3] + return self.__text_doc_list[self.get_active()][2] def get_styles(self): - return self.__text_doc_list[self.get_active()][4] + return self.__text_doc_list[self.get_active()][3] def get_ext(self): - return self.__text_doc_list[self.get_active()][5] + return self.__text_doc_list[self.get_active()][4] def get_printable(self): - return self.__text_doc_list[self.get_active()][6] + return self.__text_doc_list[self.get_active()][5] def get_clname(self): - return self.__text_doc_list[self.get_active()][7] + return self.__text_doc_list[self.get_active()][6] diff --git a/src/ReportBase/_TextReportDialog.py b/src/ReportBase/_TextReportDialog.py index e835f084e..bb27724b4 100644 --- a/src/ReportBase/_TextReportDialog.py +++ b/src/ReportBase/_TextReportDialog.py @@ -40,17 +40,6 @@ class TextReportDialog(DocReportDialog): DocReportDialog.__init__(self, dbstate, uistate, options, name, translated_name) - #------------------------------------------------------------------------ - # - # Customization hooks for subclasses - # - #------------------------------------------------------------------------ - def doc_uses_tables(self): - """Does this report require the ability to generate tables in - the file format. Override this for documents that do need - table support.""" - return 0 - #------------------------------------------------------------------------ # # Functions related to selecting/changing the current file format. @@ -61,5 +50,4 @@ class TextReportDialog(DocReportDialog): this text report. This menu will be generated based upon whether the document requires table support, etc.""" self.format_menu = TextFormatComboBox() - self.format_menu.set(self.doc_uses_tables(), - self.doc_type_changed, None, active) + self.format_menu.set(self.doc_type_changed, None, active) diff --git a/src/docgen/AsciiDoc.py b/src/docgen/AsciiDoc.py index 5cdee7f57..5c0fc68f7 100644 --- a/src/docgen/AsciiDoc.py +++ b/src/docgen/AsciiDoc.py @@ -384,7 +384,7 @@ try: else: print_label=None - pmgr.register_text_doc(mtype, AsciiDoc, 1, 1, 1, ".txt", print_label) + pmgr.register_text_doc(mtype, AsciiDoc, 1, 1, ".txt", print_label) except: - pmgr.register_text_doc(_("Plain Text"), AsciiDoc, 1, 1, 1, ".txt", None) + pmgr.register_text_doc(_("Plain Text"), AsciiDoc, 1, 1, ".txt", None) diff --git a/src/docgen/GtkPrint.py b/src/docgen/GtkPrint.py index 4f692048e..e803d5b16 100644 --- a/src/docgen/GtkPrint.py +++ b/src/docgen/GtkPrint.py @@ -620,6 +620,6 @@ class GtkPrint(CairoDoc): # #------------------------------------------------------------------------ pmgr = PluginManager.get_instance() -pmgr.register_text_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) +pmgr.register_text_doc(_('Print...'), GtkPrint, 1, 1, "", None) pmgr.register_draw_doc(_('Print...'), GtkPrint, 1, 1, "", None) -pmgr.register_book_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) +pmgr.register_book_doc(_('Print...'), GtkPrint, 1, 1, "", None) diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index 41263dc6f..2d1569986 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -494,6 +494,6 @@ try: if mtype == _("unknown"): mtype = _('HTML') - pmgr.register_text_doc(mtype, HtmlDoc, 1, 0, 1, ".html", print_label) + pmgr.register_text_doc(mtype, HtmlDoc, 0, 1, ".html", print_label) except: - pmgr.register_text_doc(_('HTML'), HtmlDoc, 1, 0, 1, ".html", None) + pmgr.register_text_doc(_('HTML'), HtmlDoc, 0, 1, ".html", None) diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index 2a1402ddf..8547c9870 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -534,4 +534,4 @@ try: except: print_label = None -pmgr.register_text_doc(_('LaTex'), LaTeXDoc, 1, 1, 0, ".tex", print_label) +pmgr.register_text_doc(_('LaTex'), LaTeXDoc, 1, 0, ".tex", print_label) diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index f0f1d0ef0..5a72dceb3 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -1158,8 +1158,8 @@ except: print_label = None pmgr.register_text_doc(_('Open Document Text'), - ODFDoc, 1, 1, 1, ".odt", print_label) + ODFDoc, 1, 1, ".odt", print_label) pmgr.register_book_doc(_("Open Document Text"), - ODFDoc, 1, 1, 1, ".odt", print_label) + ODFDoc, 1, 1, ".odt", print_label) pmgr.register_draw_doc(_("Open Document Text"), ODFDoc, 1, 1, ".odt", print_label); diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index 5923afc07..153d9e59d 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -150,8 +150,8 @@ def register_docgen(): print_label = None pmgr = PluginManager.get_instance() - pmgr.register_text_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) + pmgr.register_text_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label) pmgr.register_draw_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label) - pmgr.register_book_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) + pmgr.register_book_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label) register_docgen() \ No newline at end of file diff --git a/src/docgen/RTFDoc.py b/src/docgen/RTFDoc.py index 9ce73667d..af6764938 100644 --- a/src/docgen/RTFDoc.py +++ b/src/docgen/RTFDoc.py @@ -449,6 +449,6 @@ try: print_label=_("Open in %s") % mprog[1] else: print_label=None - pmgr.register_text_doc(mtype, RTFDoc, 1, 1, 1, ".rtf", print_label) + pmgr.register_text_doc(mtype, RTFDoc, 1, 1, ".rtf", print_label) except: - pmgr.register_text_doc(_('RTF document'), RTFDoc, 1, 1, 1, ".rtf", None) + pmgr.register_text_doc(_('RTF document'), RTFDoc, 1, 1, ".rtf", None) diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index b34d3f4c1..50e3d5c3e 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -1103,9 +1103,6 @@ class BookReportDialog(DocReportDialog): def setup_other_frames(self): pass def parse_style_frame(self): pass - def doc_uses_tables(self): - return 1 - def get_title(self): return _("Book Report") @@ -1121,8 +1118,7 @@ class BookReportDialog(DocReportDialog): this text report. This menu will be generated based upon whether the document requires table support, etc.""" self.format_menu = BookFormatComboBox() - self.format_menu.set(self.doc_uses_tables(), - self.doc_type_changed, None, active) + self.format_menu.set(self.doc_type_changed, None, active) def make_document(self): """Create a document of the type requested by the user."""