From 95054dbfb0584744f14e4c7af89dea90fc9ffa5e Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 24 Aug 2005 06:59:23 +0000 Subject: [PATCH] Added --main option. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/injector/injector-gui@480 9f8c893c-44ee-0310-b757-c8ca8341c71e --- 0launch-gui | 4 +++- download_box.py | 7 +++++-- gui.py | 6 ++++-- mainwindow.py | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/0launch-gui b/0launch-gui index b2f3af4..c3bb1e0 100755 --- a/0launch-gui +++ b/0launch-gui @@ -7,6 +7,7 @@ __builtins__._ = lambda x: x parser = OptionParser(usage="usage: %prog [options] interface [args]") parser.add_option("-d", "--download-only", help="fetch but don't run", action='store_true') +parser.add_option("-m", "--main", help="name of the file to execute") parser.add_option("-n", "--no-self-update", help="don't check for updates to the GUI itself", action='store_true') parser.add_option("-r", "--refresh", help="check for updates of all interfaces", action='store_true') parser.add_option("-v", "--verbose", help="more verbose output", action='count') @@ -61,5 +62,6 @@ if options.no_self_update is not True: policy = gui.GUIPolicy(interface_uri, prog_args, download_only = bool(options.download_only), - refresh = bool(options.refresh)) + refresh = bool(options.refresh), + main = options.main) policy.main() diff --git a/download_box.py b/download_box.py index 14ed17d..60d8c2a 100644 --- a/download_box.py +++ b/download_box.py @@ -9,7 +9,7 @@ from dialog import Dialog import warnings warnings.filterwarnings('ignore', category = DeprecationWarning, module='download_box') -def download_with_gui(mainwindow, prog_args, run_afterwards): +def download_with_gui(mainwindow, prog_args, run_afterwards, main = None): """If all downloads are ready, runs the program. Otherwise, hides mainwindow, shows the download progress box and then runs it. On error, mainwindow is re-shown.""" @@ -29,7 +29,10 @@ def download_with_gui(mainwindow, prog_args, run_afterwards): mainwindow.destroy() return try: - run.execute(policy, prog_args) + if main is None: + run.execute(policy, prog_args) # Don't break older versions + else: + run.execute(policy, prog_args, main = main) mainwindow.destroy() except SafeException, ex: box = gtk.MessageDialog(None, gtk.DIALOG_MODAL, diff --git a/gui.py b/gui.py index dcc8f16..e988053 100644 --- a/gui.py +++ b/gui.py @@ -20,12 +20,14 @@ class GUIPolicy(Policy): original_implementation = None download_only = None prog_args = None + main_exec = None - def __init__(self, interface, prog_args, download_only, refresh): + def __init__(self, interface, prog_args, download_only, refresh, main): Policy.__init__(self, interface) global policy assert policy is None policy = self + self.main_exec = main self.prog_args = prog_args self.download_only = download_only self.monitored_downloads = [] @@ -128,7 +130,7 @@ class GUIPolicy(Policy): self.window.show() else: import download_box - download_box.download_with_gui(self.window, self.prog_args, + download_box.download_with_gui(self.window, self.prog_args, main = self.main_exec, run_afterwards = not self.download_only) else: self.window.show() diff --git a/mainwindow.py b/mainwindow.py index d18cf1a..e28f8d7 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -118,7 +118,7 @@ class MainWindow(Dialog): self.destroy() sys.exit(1) elif resp == gtk.RESPONSE_OK: - download_box.download_with_gui(self, prog_args, + download_box.download_with_gui(self, prog_args, main = policy.main_exec, run_afterwards = not download_only) elif resp == gtk.RESPONSE_HELP: gui_help.display() -- 2.11.4.GIT