From 7e34b525614f693f3b3b7c07400dfbc9a55b25d0 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski Date: Mon, 12 Jul 2021 17:52:28 +0200 Subject: [PATCH 1/3] Hardcode maximum columns in PDF exports --- .../import_export/pdf_plugin/pdf_exporter.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py index caefba95..5f6efdbf 100644 --- a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py +++ b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py @@ -863,13 +863,23 @@ class PdfPrefGetter: _('Index Cards (4x6)'), _('Index Cards (A7)')] layouts = {_('Plain'): ('column', 1), + _('2 Columns'): ('column', 2), + _('3 Columns'): ('column', 3), + _('4 Columns'): ('column', 4), + _('5 Columns'): ('column', 5), _('Index Cards (3.5x5)'): ('index_cards', (5 * inch, 3.5 * inch)), _('Index Cards (4x6)'): ('index_cards', (6 * inch, 4 * inch)), _('Index Cards (A7)'): ('index_cards', (105 * mm, 74 * mm))} + for n in range(2, 5): + layouts[ngettext('%s Column', '%s Columns', n) % n] = ('column', n) # These two dictionaries are here to be able to store the preferences in the persistent toml file. # This allows us to have a locale-agnostic GUI. _layouts_to_settings = {_('Plain'): 'plain', + _('2 Columns'): '2_columns', + _('3 Columns'): '3_columns', + _('4 Columns'): '4_columns', + _('5 Columns'): '5_columns', _('Index Cards (3.5x5)'): 'index_cards_35_5', _('Index Cards (4x6)'): 'index_cards_4_6', _('Index Cards (A7)'): 'a7'} @@ -884,9 +894,6 @@ class PdfPrefGetter: def __init__(self): self.size_strings = list(self.page_sizes.keys()) self.size_strings.sort() - for n in range(2,5): - self.layouts[ngettext('%s Column','%s Columns',n)%n]=('column',n) - self.page_sizes_r = {v: k for k, v in self.page_sizes.items()} self.layouts_r = {v: k for k, v in self.layouts.items()} self.page_modes_r = {v: k for k, v in self.page_modes.items()} @@ -920,7 +927,6 @@ def __init__(self): default_layout = defaults.get('page_layout', PDF_PREF_DEFAULT['page_layout']) default_layout = self._settings_to_layout[default_layout] - # default_layout = self.layouts_r[default_layout] layout = [_('Page _Layout'), (default_layout, self.layout_strings)] From 778c4d7b87d0ea3ff8e3e02ea98f75a0f13bd6a6 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski Date: Mon, 12 Jul 2021 17:52:48 +0200 Subject: [PATCH 2/3] Remove deprecated Gtk.ComboText.remove_text call --- src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py index 5f6efdbf..1fabf221 100644 --- a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py +++ b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py @@ -1018,10 +1018,6 @@ def change_cb(self, option_table, *args,**kwargs): if n in [i[0] for i in self.index_card_layouts_to_put_back]: default_pos = self.layout_strings.index(_('Plain')) cb.set_active(default_pos) - self.index_card_layouts_to_put_back.reverse() - for pos,txt in self.index_card_layouts_to_put_back: - cb.remove_text(pos) - self.index_card_layouts_to_put_back.reverse() elif pagesize not in self.INDEX_CARDS and last_pagesize in self.INDEX_CARDS: changed = True option_table.set_option(self.OPT_PO,_('Portrait')) From 0133f983afabcbb7af4b2e2acfe887380c953606 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski Date: Mon, 12 Jul 2021 17:53:34 +0200 Subject: [PATCH 3/3] Only apply scaling of attribute if attribute available for reportlab style --- .../plugins/import_export/pdf_plugin/pdf_exporter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py index 1fabf221..822554e2 100644 --- a/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py +++ b/src/gourmet/plugins/import_export/pdf_plugin/pdf_exporter.py @@ -269,14 +269,15 @@ def setup_frames(self, f'not {mode}') return frames - def scale_stylesheet (self, perc): - for name,sty in list(self.styleSheet.byName.items()): + def scale_stylesheet(self, perc: float): + for name, sty in list(self.styleSheet.byName.items()): for attr in ['firstLineIndent', 'fontSize', 'leftIndent', 'rightIndent', 'leading']: - setattr(sty,attr,int(perc*getattr(sty,attr))) + if hasattr(sty, attr): + setattr(sty, attr, int(perc * getattr(sty, attr))) def setup_column_frames (self, n): COLUMN_SEPARATOR = 0.5 * inch