def _process_startup_complete(self, packet): log("all the existing windows and system trays have been received") XpraClientBase._process_startup_complete(self, packet) gui_ready() if self.tray: self.tray.ready() self.send_info_request()
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() app = StartNewCommand() app.close = app.quit def app_signal(signum, frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() app = StartNewCommand() app.hide = app.quit def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def show_pass_dialog(argv): from xpra.platform.gui import ready as gui_ready, init as gui_init, set_default_icon set_default_icon("authentication.png") gui_init() log("show_pass_dialog(%s)", argv) def arg(n): if len(argv) <= n: return "" return argv[n].replace("\\n\\r", "\\n").replace("\\n", "\n") title = arg(0) or "Enter Password" prompt = arg(1) icon = arg(2) app = PasswordInputDialogWindow(title, prompt, icon) register_os_signals(app.quit, "Password Dialog") gui_ready() app.show() p = app.run() if p is not None: sys.stdout.write(p) sys.stdout.flush() return 0 return 1
def main(argv=()): from xpra.os_util import POSIX, OSX from xpra.platform import program_context with program_context("Xpra-Bug-Report", "Xpra Bug Report"): from xpra.log import enable_color enable_color() if POSIX and not OSX: from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source init_gdk_display_source() from xpra.log import enable_debug_for #logging init: if "-v" in argv: enable_debug_for("util") from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport from xpra.gtk_common.gobject_compat import register_os_signals app = BugReport() app.close = app.quit app.init(True) register_os_signals(app.quit) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import init as gui_init, ready as gui_ready gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("util") from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() app = OpenRequestsWindow() def cb(accept): print("callback: %s" % (accept, )) app.add_request(cb, "1", "file", "someimage.png", 16384, False, True, 10) app.add_request(cb, "2", "file", "otherimage.png", 16384, False, True, 100) app.add_request(cb, "3", "file", "document.pdf", 32768, True, False, 200) app.add_request(cb, "4", "url", "https://xpra.org/", 0, False, True, 300) app.hide = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import init as platform_init from xpra.platform.gui import ready as gui_ready platform_init("Xpra-Launcher", "Xpra Connection Launcher") gui_init() #logging init: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() gobject.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) gobject.timeout_add(1000, app.set_info_color, True) #call from UI thread: gobject.idle_add(show_signal) signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) try: app.update_gui_from_config() if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): gobject.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() client = AdHocStruct() client.server_last_info_time = monotonic_time() commands_info = { 0: {'returncode': None, 'name': 'xterm', 'pid': 542, 'dead': False, 'ignore': True, 'command': ('xterm',), 'forget': False}, 'start-child' : (), 'start-new' : True, 'start-after-connect-done' : True, 'start' : ('xterm',), 'start-after-connect' : (), 'start-child-on-connect' : (), 'exit-with-children' : False, 'start-child-after-connect': (), 'start-on-connect' : (), } client.server_last_info = {"commands" : commands_info} client.server_start_new_commands = True client.server_commands_signals = ("SIGINT", "SIGTERM", "SIGUSR1") def noop(*_args): pass client.send_info_request = noop client.send = noop window1 = AdHocStruct() window1._metadata = {"pid" : 542} client._id_to_window = { 1 : window1 } def show_start_new_command(*_args): from xpra.client.gtk_base.start_new_command import getStartNewCommand getStartNewCommand(None).show() client.show_start_new_command = show_start_new_command app = ServerCommandsWindow(client) app.hide = app.quit def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): if sys.platform.startswith("win"): from xpra.platform.win32 import set_log_filename set_log_filename("Xpra-Launcher.log") set_prgname("Xpra-Launcher") platform_init() gui_init() #logging init: from xpra.scripts.main import parse_cmdline _, options, args = parse_cmdline(sys.argv) import logging logging.basicConfig(format="%(asctime)s %(message)s") if options.debug: logging.root.setLevel(logging.DEBUG) else: logging.root.setLevel(logging.INFO) app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() gobject.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) gobject.timeout_add(1000, app.set_info_color, True) #call from UI thread: gobject.idle_add(show_signal) signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) if app.config.debug: logging.root.setLevel(logging.DEBUG) app.create_window() try: app.update_gui_from_config() if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): gobject.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import init as platform_init from xpra.platform.gui import init as gui_init, ready as gui_ready platform_init("Xpra-Launcher", "Xpra Connection Launcher") gui_init() #logging init: from xpra.scripts.main import parse_cmdline _, options, args = parse_cmdline(sys.argv) if options.debug: from xpra.log import enable_debug_for enable_debug_for("all") app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() gobject.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) gobject.timeout_add(1000, app.set_info_color, True) #call from UI thread: gobject.idle_add(show_signal) signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) if app.config.debug: enable_debug_for("all") app.create_window() try: app.update_gui_from_config() if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): gobject.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0
def show_confirm_dialog(argv): from xpra.os_util import SIGNAMES from xpra.platform.gui import ready as gui_ready from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable from xpra.platform.gui import init as gui_init gui_init() gtk_main_quit_on_fatal_exceptions_enable() log("show_confirm_dialog(%s)", argv) def arg(n): if len(argv) <= n: return "" return argv[n].replace("\\n\\r", "\\n").replace("\\n", "\n") title = arg(0) or "Confirm Key" prompt = arg(1) info = arg(2) icon = arg(3) buttons = [] n = 4 while len(argv) > (n + 1): label = arg(n) try: code = int(arg(n + 1)) except ValueError as e: log.error("Error: confirm dialog cannot parse code '%s': %s", arg(n + 1), e) return 1 buttons.append((label, code)) n += 2 app = ConfirmDialogWindow(title, prompt, info, icon, buttons) def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) gui_ready() app.show() return app.run()
def main(): # pragma: no cover from xpra.platform.gui import init as gui_init, ready as gui_ready from xpra.platform import program_context gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") app = StartNewCommand() app.hide = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: from xpra.log import enable_debug_for enable_debug_for("util") from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() app = OpenRequestsWindow() def cb(accept): print("callback: %s" % (accept, )) app.add_request(cb, "1", "file", "someimage.png", 16384, False, True, 10) app.add_request(cb, "2", "file", "otherimage.png", 16384, False, True, 100) app.add_request(cb, "3", "file", "document.pdf", 32768, True, False, 200) app.add_request(cb, "4", "url", "https://xpra.org/", 0, False, True, 300) app.hide = app.quit def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def _process_startup_complete(self, packet): log("all the existing windows and system trays have been received") XpraClientBase._process_startup_complete(self, packet) gui_ready() if self.tray: self.tray.ready() self.send_info_request() msg = "running" try: windows = tuple(self._id_to_window.values()) except AttributeError: pass else: trays = sum(1 for w in windows if w.is_tray()) wins = sum(1 for w in windows if not w.is_tray()) if wins: msg += ", %i window%s" % (wins, engs(wins)) if trays: msg += ", %i tray%s" % (trays, engs(trays)) log.info(msg)
def main(): from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready with program_context("Xpra-Version-Check", "Xpra Version Check"): #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import register_os_signals app = UpdateStatusWindow() app.close = app.quit register_os_signals(app.quit, "Version Check") try: gui_ready() app.show() app.check() app.run() except KeyboardInterrupt: pass return 0
def show_pass_dialog(argv): from xpra.platform.gui import ready as gui_ready from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable from xpra.platform.gui import init as gui_init gui_init() gtk_main_quit_on_fatal_exceptions_enable() log("show_pass_dialog(%s)", argv) def arg(n): if len(argv)<=n: return "" return argv[n].replace("\\n\\r", "\\n").replace("\\n", "\n") title = arg(0) or "Enter Password" prompt = arg(1) icon = arg(2) app = PasswordInputDialogWindow(title, prompt, icon) register_os_signals(app.quit) gui_ready() app.show() return app.run()
def main(argv=[]): from xpra.platform import program_context with program_context("Xpra-Bug-Report", "Xpra Bug Report"): from xpra.log import enable_color enable_color() from xpra.log import Logger, enable_debug_for log = Logger("util") #logging init: if "-v" in argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() gobject.threads_init() from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport app = BugReport() app.close = app.quit app.init(True) def app_signal(signum, _frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def show_confirm_dialog(argv): from xpra.platform.gui import ready as gui_ready from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable from xpra.platform.gui import init as gui_init, set_default_icon set_default_icon("information.png") gui_init() gtk_main_quit_on_fatal_exceptions_enable() log("show_confirm_dialog(%s)", argv) def arg(n): if len(argv) <= n: return "" return argv[n].replace("\\n\\r", "\\n").replace("\\n", "\n") title = arg(0) or "Confirm Key" prompt = arg(1) info = arg(2) icon = arg(3) buttons = [] n = 4 while len(argv) > (n + 1): label = arg(n) try: code = int(arg(n + 1)) except ValueError as e: log.error("Error: confirm dialog cannot parse code '%s': %s", arg(n + 1), e) return 1 buttons.append((label, code)) n += 2 app = ConfirmDialogWindow(title, prompt, info, icon, buttons) register_os_signals(app.quit, "Dialog") gui_ready() force_focus() app.show_all() app.present() return app.run()
def main(): from xpra.platform import init as platform_init platform_init("Xpra-Bug-Report", "Xpra Bug Report") from xpra.log import enable_color enable_color() from xpra.log import Logger, enable_debug_for log = Logger("util") #logging init: if "-v" in sys.argv: enable_debug_for("util") from xpra.gtk_common.gobject_compat import import_gobject gobject = import_gobject() gobject.threads_init() from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.client.gtk_base.bug_report import BugReport app = BugReport() app.close = app.quit app.init(True) def app_signal(signum, frame): print("") log.info("got signal %s", SIGNAMES.get(signum, signum)) app.quit() signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) try: from xpra.platform.gui import ready as gui_ready gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def main(): # pragma: no cover from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready, init as gui_init gui_init() with program_context("Start-New-Command", "Start New Command"): #logging init: if "-v" in sys.argv: enable_debug_for("util") client = AdHocStruct() client.server_last_info_time = monotonic_time() commands_info = { 0: { 'returncode': None, 'name': 'xterm', 'pid': 542, 'dead': False, 'ignore': True, 'command': ('xterm', ), 'forget': False }, 'start-child': (), 'start-new': True, 'start-after-connect-done': True, 'start': ('xterm', ), 'start-after-connect': (), 'start-child-on-connect': (), 'exit-with-children': False, 'start-child-after-connect': (), 'start-on-connect': (), } client.server_last_info = {"commands": commands_info} client.server_start_new_commands = True client.server_commands_signals = ("SIGINT", "SIGTERM", "SIGUSR1") def noop(*_args): pass client.send_info_request = noop client.send = noop window1 = AdHocStruct() window1._metadata = {"pid": 542} #pylint: disable=protected-access client._id_to_window = { #pylint: disable=protected-access 1: window1 } def show_start_new_command(*_args): from xpra.client.gtk_base.start_new_command import getStartNewCommand getStartNewCommand(None).show() client.show_start_new_command = show_start_new_command app = ServerCommandsWindow(client) app.close = app.quit register_os_signals(app.quit) try: gui_ready() app.show() app.run() except KeyboardInterrupt: pass return 0
def do_main(): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform.gui import ready as gui_ready gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def app_signal(signum, _frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: #FIXME: this is ugly as hell #We have to wait for the main loop to be running #to get the NSApplicationOpneFile signal, #so we end up duplicating some of the logic from just above #maybe we should always run this code from the main loop instead if OSX: def force_show(): from xpra.platform.darwin.gui import enable_focus_workaround, disable_focus_workaround enable_focus_workaround() app.show() glib.timeout_add(500, disable_focus_workaround) #wait a little bit for the "openFile" signal app.__osx_open_signal = False def do_open_file(filename): log.info("do_open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect) else: force_show() def open_file(_, filename): log.info("open_file(%s)", filename) glib.idle_add(do_open_file, filename) def do_open_URL(url): log.info("do_open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() glib.idle_add(app.do_connect) def open_URL(url): log.info("open_URL(%s)", url) glib.idle_add(do_open_URL, url) from xpra.platform.darwin.gui import get_OSXApplication, register_URL_handler register_URL_handler(open_URL) try: get_OSXApplication().connect("NSApplicationOpenFile", open_file) except Exception as e: log.error("Error: cannot handle file associations:") log.error(" %s", e) def may_show(): log("may_show() osx open signal=%s", app.__osx_open_signal) if not app.__osx_open_signal: force_show() glib.timeout_add(500, may_show) else: app.show() app.run() except KeyboardInterrupt: pass return 0
def ready(self): gui_ready()
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import program_context from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color with program_context("Xpra-Launcher", "Xpra Connection Launcher"): enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: #FIXME: this is ugly as hell #We have to wait for the main loop to be running #to get the NSApplicationOpneFile signal, #so we end up duplicating some of the logic from just above #maybe we should always run this code from the main loop instead if sys.platform.startswith("darwin"): #wait a little bit for the "openFile" signal app.__osx_open_file = False def do_open_file(filename): app.__osx_open_file = True app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: glib.idle_add(app.do_connect) def open_file(_, filename): log("open_file(%s)", filename) glib.idle_add(do_open_file, filename) from xpra.platform.darwin.gui import get_OSXApplication get_OSXApplication().connect("NSApplicationOpenFile", open_file) def may_show(): log("may_show() osx open file=%s", app.__osx_open_file) if not app.__osx_open_file: app.show() glib.timeout_add(500, may_show) else: app.show() app.run() except KeyboardInterrupt: pass return 0
def do_main(argv): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.platform.gui import init as gui_init, ready as gui_ready if POSIX and not OSX: from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source init_gdk_display_source() gui_init() try: from xpra.scripts.parsing import parse_cmdline, fixup_debug_option options, args = parse_cmdline(argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def handle_signal(signum): app.show() client = app.client if client: client.cleanup() else: Gtk.main_quit() GLib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) GLib.timeout_add(1000, app.set_info_color, True) register_os_signals(handle_signal, "Client Launcher") has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) app.create_window_with_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): GLib.idle_add(app.do_connect) if not has_file: app.reset_errors() if not app.config.autoconnect or app.config.debug: if OSX: from xpra.platform.darwin.gui import wait_for_open_handlers, force_focus if has_file: force_focus() app.show() else: def open_file(filename): log("open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True GLib.idle_add(app.do_connect) else: force_focus() app.show() def open_URL(url): log("open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() GLib.idle_add(app.do_connect) wait_for_open_handlers(app.show, open_file, open_URL) else: app.show() gui_ready() app.run() except KeyboardInterrupt: pass return 0
def do_main(argv): from xpra.os_util import SIGNAMES from xpra.scripts.main import InitExit, InitInfo from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform.gui import ready as gui_ready gui_init() try: from xpra.scripts.parsing import parse_cmdline, fixup_debug_option options, args = parse_cmdline(argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except InitInfo as e: print(str(e)) return 0 except InitExit as e: return e.status except Exception: exception_dialog("Error parsing command line") return 1 #allow config to be debugged: from xpra.scripts import config config.debug = log.debug try: app = ApplicationWindow() def app_signal(signum, _frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add( 1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0] < 3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) app.create_window_with_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() if not app.config.autoconnect or app.config.debug: if OSX and not has_file: from xpra.platform.darwin.gui import wait_for_open_handlers, show_with_focus_workaround def open_file(filename): log("open_file(%s)", filename) app.update_options_from_file(filename) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() if app.config.autoconnect: app.__osx_open_signal = True glib.idle_add(app.do_connect) else: show_with_focus_workaround(app.show) def open_URL(url): log("open_URL(%s)", url) app.__osx_open_signal = True app.update_options_from_URL(url) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) app.update_gui_from_config() glib.idle_add(app.do_connect) wait_for_open_handlers(app.show, open_file, open_URL) else: app.show() gui_ready() app.run() except KeyboardInterrupt: pass return 0
def main(): from xpra.os_util import SIGNAMES from xpra.gtk_common.quit import gtk_main_quit_on_fatal_exceptions_enable gtk_main_quit_on_fatal_exceptions_enable() from xpra.platform import init as platform_init, clean as platform_clean from xpra.platform.gui import ready as gui_ready from xpra.log import enable_color try: platform_init("Xpra-Launcher", "Xpra Connection Launcher") enable_color() gui_init() try: from xpra.scripts.main import parse_cmdline, fixup_debug_option options, args = parse_cmdline(sys.argv) debug = fixup_debug_option(options.debug) if debug: for x in debug.split(","): enable_debug_for(x) except Exception: exception_dialog("Error parsing command line") return 1 try: app = ApplicationWindow() def app_signal(signum, frame): print("") log("got signal %s" % SIGNAMES.get(signum, signum)) def show_signal(): app.show() app.client.cleanup() glib.timeout_add(1000, app.set_info_text, "got signal %s" % SIGNAMES.get(signum, signum)) glib.timeout_add(1000, app.set_info_color, True) #call from UI thread: glib.idle_add(show_signal) if sys.version_info[0]<3: #breaks GTK3.. signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) has_file = len(args) == 1 if has_file: app.update_options_from_file(args[0]) #the compressors and packet encoders cannot be changed from the UI #so apply them now: configure_network(app.config) debug = fixup_debug_option(app.config.debug) if debug: for x in debug.split(","): enable_debug_for(x) #suspend tray workaround for our window widgets: try: set_use_tray_workaround(False) app.create_window() finally: set_use_tray_workaround(True) app.update_gui_from_config() except Exception: exception_dialog("Error creating launcher form") return 1 try: if app.config.autoconnect: #file says we should connect, #do that only (not showing UI unless something goes wrong): glib.idle_add(app.do_connect) if not has_file: app.reset_errors() gui_ready() if not app.config.autoconnect or app.config.debug: app.show() app.run() except KeyboardInterrupt: pass return 0 finally: platform_clean()