GTG

Merge lp:~izidor/gtg/export_bugs into lp:~gtg/gtg/old-trunk

Proposed by Izidor Matušov
Status: Merged
Merged at revision: 1225
Proposed branch: lp:~izidor/gtg/export_bugs
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 120 lines (+34/-13)
4 files modified
GTG/plugins/export/export.py (+14/-2)
GTG/plugins/export/export.ui (+1/-0)
GTG/plugins/export/export_templates/script_pocketmod (+2/-2)
GTG/plugins/export/templates.py (+17/-9)
To merge this branch: bzr merge lp:~izidor/gtg/export_bugs
Reviewer Review Type Date Requested Status
Bertrand Rousseau (community) code, running Approve
Review via email: mp+119244@code.launchpad.net

Description of the change

Few smaller changes in export plugin:

  * Widgets in export dialog are no longer jumping up and down when switching between templates
  * Template script is no longer required to have execute permission -- its shebang is parsed and that is executed
  * Remember the last selected template

To post a comment you must log in.
Revision history for this message
Bertrand Rousseau (bertrand-rousseau) wrote :

I don't have anything to say about the code, and I could manage to produce a foldable pdf on my computer (Ubuntu 12.04) with this branch. I also noticed that the widgets are no longer moving and that the last template selected was remembered. So I approve this patch.

review: Approve (code, running)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'GTG/plugins/export/export.py'
--- GTG/plugins/export/export.py 2012-07-13 17:24:28 +0000
+++ GTG/plugins/export/export.py 2012-08-11 12:29:19 +0000
@@ -87,6 +87,7 @@
87 DEFAULT_PREFERENCES = {87 DEFAULT_PREFERENCES = {
88 "menu_entry": True,88 "menu_entry": True,
89 "toolbar_entry": True,89 "toolbar_entry": True,
90 "last_template": None,
90 }91 }
9192
92 def __init__(self):93 def __init__(self):
@@ -263,8 +264,12 @@
263 model.clear()264 model.clear()
264265
265 templates = get_templates_paths()266 templates = get_templates_paths()
266 for path in templates:267 active_entry = None
268 for i, path in enumerate(templates):
267 template = Template(path)269 template = Template(path)
270 if path == self.preferences["last_template"]:
271 active_entry = i
272
268 model.append((path,273 model.append((path,
269 template.get_title(),274 template.get_title(),
270 template.get_description(),275 template.get_description(),
@@ -273,7 +278,10 @@
273 # wrap the combo-box if it's too long278 # wrap the combo-box if it's too long
274 if len(templates) > 15:279 if len(templates) > 15:
275 self.combo.set_wrap_width(5)280 self.combo.set_wrap_width(5)
276 self.combo.set_active(0)281
282 if active_entry is None:
283 active_entry = 0
284 self.combo.set_active(active_entry)
277285
278 def on_combo_changed(self, combo):286 def on_combo_changed(self, combo):
279 """ Display details about the selected template """287 """ Display details about the selected template """
@@ -293,6 +301,10 @@
293 self.export_image.clear()301 self.export_image.clear()
294 self.description_label.set_markup("<i>%s</i>" % description)302 self.description_label.set_markup("<i>%s</i>" % description)
295303
304 # Remember the last selected path
305 self.preferences["last_template"] = model[active][0]
306 self._preferences_store()
307
296 def show_error_dialog(self, message):308 def show_error_dialog(self, message):
297 """ Display an error """309 """ Display an error """
298 dialog = gtk.MessageDialog(310 dialog = gtk.MessageDialog(
299311
=== modified file 'GTG/plugins/export/export.ui'
--- GTG/plugins/export/export.ui 2012-05-23 08:55:31 +0000
+++ GTG/plugins/export/export.ui 2012-08-11 12:29:19 +0000
@@ -92,6 +92,7 @@
92 </object>92 </object>
93 <packing>93 <packing>
94 <property name="position">0</property>94 <property name="position">0</property>
95 <property name="expand">False</property>
95 </packing>96 </packing>
96 </child>97 </child>
97 <child>98 <child>
9899
=== modified file 'GTG/plugins/export/export_templates/script_pocketmod' (properties changed: +x to -x)
--- GTG/plugins/export/export_templates/script_pocketmod 2012-05-03 18:56:54 +0000
+++ GTG/plugins/export/export_templates/script_pocketmod 2012-08-11 12:29:19 +0000
@@ -1,4 +1,4 @@
1#/bin/sh1#!/bin/sh
2#2#
3# Copyright (c) 2009 - Jan Girlich <vollkorn@freenet.de>, Luca Invernizzi <invernizzi.l@gmail.com>3# Copyright (c) 2009 - Jan Girlich <vollkorn@freenet.de>, Luca Invernizzi <invernizzi.l@gmail.com>
4#4#
@@ -31,5 +31,5 @@
31pdf90 $TMPFOLDER/seite5432-r.pdf --outfile $TMPFOLDER/seite5432-r2.pdf 1>&231pdf90 $TMPFOLDER/seite5432-r.pdf --outfile $TMPFOLDER/seite5432-r2.pdf 1>&2
32pdftk $TMPFOLDER/seite6781.pdf $TMPFOLDER/seite5432-r2.pdf cat output $TMPFOLDER/gesamt.pdf 1>&232pdftk $TMPFOLDER/seite6781.pdf $TMPFOLDER/seite5432-r2.pdf cat output $TMPFOLDER/gesamt.pdf 1>&2
33pdfnup $TMPFOLDER/gesamt.pdf --nup 4x2 --landscape --outfile $OUTFILE 1>&233pdfnup $TMPFOLDER/gesamt.pdf --nup 4x2 --landscape --outfile $OUTFILE 1>&2
34#rm -rf $TMPFOLDER 1>&234rm -rf $TMPFOLDER 1>&2
35echo -n $OUTFILE35echo -n $OUTFILE
3636
=== modified file 'GTG/plugins/export/templates.py'
--- GTG/plugins/export/templates.py 2012-07-13 17:24:28 +0000
+++ GTG/plugins/export/templates.py 2012-08-11 12:29:19 +0000
@@ -135,21 +135,29 @@
135 document_ready = threading.Event()135 document_ready = threading.Event()
136136
137 def script():137 def script():
138 """ Run script using /bin/sh.138 """ Run script using the shebang of the script
139139
140 The script gets path to a document as it only argument and140 The script gets path to a document as it only argument and
141 this thread expects resulting file as the only output of141 this thread expects resulting file as the only output of
142 the script. """142 the script. """
143143
144 cmd = self._script_path + " " + self._document_path144 with open(self._script_path, 'r') as script_file:
145 first_line = script_file.readline().strip()
146 if first_line.startswith('#!'):
147 cmd = [first_line[2:], self._script_path,
148 self._document_path]
149 else:
150 cmd = None
151
145 self._document_path = None152 self._document_path = None
146 try:153
147 self._document_path = subprocess.Popen(154 if cmd is not None:
148 args = ['/bin/sh', '-c', cmd],155 try:
149 shell = False, stdout = subprocess.PIPE)\156 self._document_path = subprocess.Popen(
150 .communicate()[0]157 args = cmd, shell = False,
151 except Exception: # pylint: disable-msg=W0703158 stdout = subprocess.PIPE).communicate()[0]
152 pass159 except Exception: # pylint: disable-msg=W0703
160 pass
153161
154 if self._document_path and not os.path.exists(self._document_path):162 if self._document_path and not os.path.exists(self._document_path):
155 self._document_path = None163 self._document_path = None

Subscribers

People subscribed via source and target branches

to status/vote changes: