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
1=== modified file 'GTG/plugins/export/export.py'
2--- GTG/plugins/export/export.py 2012-07-13 17:24:28 +0000
3+++ GTG/plugins/export/export.py 2012-08-11 12:29:19 +0000
4@@ -87,6 +87,7 @@
5 DEFAULT_PREFERENCES = {
6 "menu_entry": True,
7 "toolbar_entry": True,
8+ "last_template": None,
9 }
10
11 def __init__(self):
12@@ -263,8 +264,12 @@
13 model.clear()
14
15 templates = get_templates_paths()
16- for path in templates:
17+ active_entry = None
18+ for i, path in enumerate(templates):
19 template = Template(path)
20+ if path == self.preferences["last_template"]:
21+ active_entry = i
22+
23 model.append((path,
24 template.get_title(),
25 template.get_description(),
26@@ -273,7 +278,10 @@
27 # wrap the combo-box if it's too long
28 if len(templates) > 15:
29 self.combo.set_wrap_width(5)
30- self.combo.set_active(0)
31+
32+ if active_entry is None:
33+ active_entry = 0
34+ self.combo.set_active(active_entry)
35
36 def on_combo_changed(self, combo):
37 """ Display details about the selected template """
38@@ -293,6 +301,10 @@
39 self.export_image.clear()
40 self.description_label.set_markup("<i>%s</i>" % description)
41
42+ # Remember the last selected path
43+ self.preferences["last_template"] = model[active][0]
44+ self._preferences_store()
45+
46 def show_error_dialog(self, message):
47 """ Display an error """
48 dialog = gtk.MessageDialog(
49
50=== modified file 'GTG/plugins/export/export.ui'
51--- GTG/plugins/export/export.ui 2012-05-23 08:55:31 +0000
52+++ GTG/plugins/export/export.ui 2012-08-11 12:29:19 +0000
53@@ -92,6 +92,7 @@
54 </object>
55 <packing>
56 <property name="position">0</property>
57+ <property name="expand">False</property>
58 </packing>
59 </child>
60 <child>
61
62=== modified file 'GTG/plugins/export/export_templates/script_pocketmod' (properties changed: +x to -x)
63--- GTG/plugins/export/export_templates/script_pocketmod 2012-05-03 18:56:54 +0000
64+++ GTG/plugins/export/export_templates/script_pocketmod 2012-08-11 12:29:19 +0000
65@@ -1,4 +1,4 @@
66-#/bin/sh
67+#!/bin/sh
68 #
69 # Copyright (c) 2009 - Jan Girlich <vollkorn@freenet.de>, Luca Invernizzi <invernizzi.l@gmail.com>
70 #
71@@ -31,5 +31,5 @@
72 pdf90 $TMPFOLDER/seite5432-r.pdf --outfile $TMPFOLDER/seite5432-r2.pdf 1>&2
73 pdftk $TMPFOLDER/seite6781.pdf $TMPFOLDER/seite5432-r2.pdf cat output $TMPFOLDER/gesamt.pdf 1>&2
74 pdfnup $TMPFOLDER/gesamt.pdf --nup 4x2 --landscape --outfile $OUTFILE 1>&2
75-#rm -rf $TMPFOLDER 1>&2
76+rm -rf $TMPFOLDER 1>&2
77 echo -n $OUTFILE
78
79=== modified file 'GTG/plugins/export/templates.py'
80--- GTG/plugins/export/templates.py 2012-07-13 17:24:28 +0000
81+++ GTG/plugins/export/templates.py 2012-08-11 12:29:19 +0000
82@@ -135,21 +135,29 @@
83 document_ready = threading.Event()
84
85 def script():
86- """ Run script using /bin/sh.
87+ """ Run script using the shebang of the script
88
89 The script gets path to a document as it only argument and
90 this thread expects resulting file as the only output of
91 the script. """
92
93- cmd = self._script_path + " " + self._document_path
94+ with open(self._script_path, 'r') as script_file:
95+ first_line = script_file.readline().strip()
96+ if first_line.startswith('#!'):
97+ cmd = [first_line[2:], self._script_path,
98+ self._document_path]
99+ else:
100+ cmd = None
101+
102 self._document_path = None
103- try:
104- self._document_path = subprocess.Popen(
105- args = ['/bin/sh', '-c', cmd],
106- shell = False, stdout = subprocess.PIPE)\
107- .communicate()[0]
108- except Exception: # pylint: disable-msg=W0703
109- pass
110+
111+ if cmd is not None:
112+ try:
113+ self._document_path = subprocess.Popen(
114+ args = cmd, shell = False,
115+ stdout = subprocess.PIPE).communicate()[0]
116+ except Exception: # pylint: disable-msg=W0703
117+ pass
118
119 if self._document_path and not os.path.exists(self._document_path):
120 self._document_path = None

Subscribers

People subscribed via source and target branches

to status/vote changes: