gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #03595
[Merge] lp:~izidor/gtg/export_bugs into lp:gtg
Izidor Matušov has proposed merging lp:~izidor/gtg/export_bugs into lp:gtg.
Requested reviews:
Gtg developers (gtg)
Related bugs:
Bug #1026400 in Getting Things GNOME!: "script_pocketmod doesn't have execute permission"
https://bugs.launchpad.net/gtg/+bug/1026400
Bug #1027817 in Getting Things GNOME!: "Export plugin: changing output format moves widgets up and down"
https://bugs.launchpad.net/gtg/+bug/1027817
For more details, see:
https://code.launchpad.net/~izidor/gtg/export_bugs/+merge/119244
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
--
https://code.launchpad.net/~izidor/gtg/export_bugs/+merge/119244
Your team Gtg developers is requested to review the proposed merge of lp:~izidor/gtg/export_bugs into lp:gtg.
=== 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 @@
DEFAULT_PREFERENCES = {
"menu_entry": True,
"toolbar_entry": True,
+ "last_template": None,
}
def __init__(self):
@@ -263,8 +264,12 @@
model.clear()
templates = get_templates_paths()
- for path in templates:
+ active_entry = None
+ for i, path in enumerate(templates):
template = Template(path)
+ if path == self.preferences["last_template"]:
+ active_entry = i
+
model.append((path,
template.get_title(),
template.get_description(),
@@ -273,7 +278,10 @@
# wrap the combo-box if it's too long
if len(templates) > 15:
self.combo.set_wrap_width(5)
- self.combo.set_active(0)
+
+ if active_entry is None:
+ active_entry = 0
+ self.combo.set_active(active_entry)
def on_combo_changed(self, combo):
""" Display details about the selected template """
@@ -293,6 +301,10 @@
self.export_image.clear()
self.description_label.set_markup("<i>%s</i>" % description)
+ # Remember the last selected path
+ self.preferences["last_template"] = model[active][0]
+ self._preferences_store()
+
def show_error_dialog(self, message):
""" Display an error """
dialog = gtk.MessageDialog(
=== 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 @@
</object>
<packing>
<property name="position">0</property>
+ <property name="expand">False</property>
</packing>
</child>
<child>
=== 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 @@
-#/bin/sh
+#!/bin/sh
#
# Copyright (c) 2009 - Jan Girlich <vollkorn@xxxxxxxxxx>, Luca Invernizzi <invernizzi.l@xxxxxxxxx>
#
@@ -31,5 +31,5 @@
pdf90 $TMPFOLDER/seite5432-r.pdf --outfile $TMPFOLDER/seite5432-r2.pdf 1>&2
pdftk $TMPFOLDER/seite6781.pdf $TMPFOLDER/seite5432-r2.pdf cat output $TMPFOLDER/gesamt.pdf 1>&2
pdfnup $TMPFOLDER/gesamt.pdf --nup 4x2 --landscape --outfile $OUTFILE 1>&2
-#rm -rf $TMPFOLDER 1>&2
+rm -rf $TMPFOLDER 1>&2
echo -n $OUTFILE
=== 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 @@
document_ready = threading.Event()
def script():
- """ Run script using /bin/sh.
+ """ Run script using the shebang of the script
The script gets path to a document as it only argument and
this thread expects resulting file as the only output of
the script. """
- cmd = self._script_path + " " + self._document_path
+ with open(self._script_path, 'r') as script_file:
+ first_line = script_file.readline().strip()
+ if first_line.startswith('#!'):
+ cmd = [first_line[2:], self._script_path,
+ self._document_path]
+ else:
+ cmd = None
+
self._document_path = None
- try:
- self._document_path = subprocess.Popen(
- args = ['/bin/sh', '-c', cmd],
- shell = False, stdout = subprocess.PIPE)\
- .communicate()[0]
- except Exception: # pylint: disable-msg=W0703
- pass
+
+ if cmd is not None:
+ try:
+ self._document_path = subprocess.Popen(
+ args = cmd, shell = False,
+ stdout = subprocess.PIPE).communicate()[0]
+ except Exception: # pylint: disable-msg=W0703
+ pass
if self._document_path and not os.path.exists(self._document_path):
self._document_path = None