2 # -*- coding: UTF-8 -*-
5 # graphical user interface for pdf2swf
7 # Part of the swftools package.
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 from wx.lib.pubsub import Publisher
29 from subprocess import Popen, PIPE
32 one_page_per_file = False
34 def before_render(self):
37 def before_save(self, page):
40 def after_save(self, page):
43 def _swap_extension(self, filename, newext, flashversion=""):
44 name, ext = os.path.splitext(filename)
45 return u"%s%s.%s" % (name, flashversion, newext)
47 def __find_swfcombine(self):
49 if "wxMSW" in wx.PlatformInfo:
50 prog = "swfcombine.exe"
53 #basedir = os.path.dirname(__file__)
54 basedir = GPDF2SWF_BASEDIR
55 #print 'basedir', basedir
58 locations = [os.path.normpath(opj(basedir, '..', prog))]
59 if "wxMSW" in wx.PlatformInfo:
61 opj("c:", "swftools", prog),
62 opj("c:", "Program Files", "SWFTools", prog)
66 opj("/usr", "local", "bin", prog),
67 opj("/usr", "bin", prog),
68 opj(basedir, '..', 'src', prog),
82 def swfcombine(self, *args):
84 self.__swfcombine(*args)
86 wx.CallAfter(Publisher.sendMessage,
87 "SWF_COMBINE_ERROR", unicode(e))
90 def __swfcombine(self, *args):
91 exe, found = self.__find_swfcombine()
92 # uncoment to test a failed swfcombine find
96 raise Exception(u"Could not execute %s: %s not found" % (exe, exe))
98 # Create a command line
102 if "wxMSW" in wx.PlatformInfo:
105 # To avoid an ugly "DOS Window" to show up
106 flags = win32process.CREATE_NO_WINDOW
111 output = Popen(cmd, stdin=PIPE, stdout=PIPE,
112 stderr=PIPE, creationflags=flags).communicate()[0]
114 # Check the process output
116 raise Exception(u"Error executing %s:%s%s" %
117 (u" ".join(cmd), os.linesep, output))