The branch, build-59a18b6e3b5d3f1dd8f07f26433d37fe5984a57d has been updated via dbd4e8c2126de479b9b3d8c190ae744e78ecf51e (commit) from afce9ce43af2f911111034e243a4921cd771345c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: pyhoca/wxgui/frontend.py | 616 ++++++++++++++++++++++++++++++++++++----- pyhoca/wxgui/messages.py | 157 ++++++++++- pyhoca/wxgui/printingprefs.py | 81 +++++- 3 files changed, 775 insertions(+), 79 deletions(-) The diff of changes is: diff --git a/pyhoca/wxgui/frontend.py b/pyhoca/wxgui/frontend.py index 1c291fd..9c5276d 100644 --- a/pyhoca/wxgui/frontend.py +++ b/pyhoca/wxgui/frontend.py @@ -70,7 +70,13 @@ wx.SetDefaultPyEncoding("utf-8") wx.InitAllImageHandlers() def SetExitHandler(func): + """\ + An exit handler function for MS Windows / Unix. Currently unused. + @param func: function that shall get registered with win32api as exit handler. + @type func: C{func} + + """ if os.name == 'nt' : try : import win32api @@ -91,13 +97,52 @@ def SetExitHandler(func): class PyHocaGUI(wx.App, x2go.X2goClient): + """\ + The main application instance. + + L{PyHocaGUI} provides a system tray icon (like the GNOME network manager applet) that + provides a multi-session / multi-connection X2Go client. + + L{PyHocaGUI} has been developed with the focus of easy customization by SaaS providers. + Product branding is a wanted feature. The customizable elements are: + + - application name + - system tray icon (idle icon, while-connecting icon) + - splash screen + - window that shows the ,,About'' dialog + With L{PyHocaGUI} you can also restrict several functionalities: For example, it is possible + to disable the multi-session support completely and use L{PyHocaGUI} only or one + session in published applications mode. This turns L{PyHocaGUI} into a pseudo-startmenu that + blends in X2Go server-side application into one's desktop shell. + + L{PyHocaGUI}'s main challenge is to combine two different event handlers: + wxPython and gevent. + + """ def __init__(self, args, logger, liblogger, appname='PyHoca-GUI', vendorname='Open Source Software Foundation', version=None,): """\ - STILL UNDOCUMENTED + Initialize the application (constructor). + + The main control data structure if the C{args} object that gets passed on to L{PyHocaGUI}'s constructor. + + @param args: a class with properties representing the command-line options that are available to L{PyHocaGUI} instances. + @type args: C{argparse.ArgumentParser} (or similar) + @param logger: you can pass an L{X2goLogger} object to the + L{PyHocaCLI} constructor for logging application events + @type logger: Python X2Go C{X2goLogger} instance + @param liblogger: you can pass an L{X2goLogger} object to the + L{PyHocaCLI} constructor for logging application events, this object is forwarded to the C{X2goClient} class in Python X2Go + @type liblogger: Python X2Go C{X2goLogger} instance + @param appname: name of the application instance + @type appname: C{str} + @param vendorname: name of the company distributing this application + @type vendorname: C{str} + @param version: version of the application + @type version: C{str} """ if appname == 'pyhoca-gui': @@ -190,7 +235,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnInit(self): """\ - STILL UNDOCUMENTED + Gets called once the application (wx.App) gets initialized. + + @return: always C{True} + @rtype: C{bool} """ wx.BeginBusyCursor() @@ -205,7 +253,12 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnIdle(self, evt): """\ - STILL UNDOCUMENTED + Integration of gevent/libevent and wxPython. + + Whenever wxPython seems to be idle, inject a gevent.sleep(). + + @return: always C{True} + @rtype: C{bool} """ try: @@ -223,7 +276,7 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def startGUI(self): """\ - STILL UNDOCUMENTED + Startup method for L{PyHocaGUI}. """ # cmd line options @@ -298,7 +351,13 @@ class PyHocaGUI(wx.App, x2go.X2goClient): gevent.spawn(self._auto_connect) def _auto_connect(self): + """\ + Register all available session profiles on application start. + + The auto-registration of all session profiles will trigger the auto-connect feature + implemented in C{X2goClient} of Python X2Go. + """ # wait for splash to appear if not self.args.disable_splash: gevent.sleep(1) @@ -306,13 +365,25 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self._X2goClient__register_all_session_profiles() def session_auto_connect(self, session_uuid): + """\ + Override C{X2goClient.session_auto_connect()} to always divert authentication to L{OnSessionAuthenticate}. + + @param session_uuid: session UUID + @type session_uuid: C{str} + """ # override X2goClient method if self.auto_connect and self.get_session(session_uuid).get_session_profile_option('auto_connect'): self.HOOK_profile_auto_connect(self.get_session_profile_name(session_uuid)) def HOOK_profile_auto_connect(self, profile_name): + """\ + Override C{X2goClient.HOOK_profile_auto_connect()} to always divert authentication to L{OnSessionAuthenticate}. + @param profile_name: session profile name + @type profile_name: C{str} + + """ session_uuids = self.client_registered_sessions_of_profile_name(profile_name=profile_name) if session_uuids: session_uuid = session_uuids[0] @@ -325,7 +396,14 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self.OnSessionAuthenticate(evt, session_uuid=session_uuid) def session_auto_start_or_resume(self, session_uuid, newest=True, oldest=False, all_suspended=False): + """\ + Override C{X2goClient.session_auto_start_or_resume()} to differentiate between the application options + C{resume_newest_on_connect}, C{resume_oldest_on_connect} and C{resume_all_on_connect}. + + @param profile_name: session profile name + @type profile_name: C{str} + """ if not self.get_session(session_uuid).published_applications: if self.resume_newest_on_connect: self._X2goClient__session_auto_start_or_resume(session_uuid, newest=True, start=self.start_on_connect) @@ -335,13 +413,23 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self._X2goClient__session_auto_start_or_resume(session_uuid, newest=False, all_suspended=True, start=self.start_on_connect) def _exit_handler(self, *args): + """\ + L{PyHocaGUI}'s exit handler method. + + Currently unused. + + """ self.WakeUpIdle() self.ExitMainLoop() # wx.App's OnExit method def OnExit(self): """\ - STILL UNDOCUMENTED + Cleanly exit the application. + + - suspend all sessions + - disconnect all connected session profiles + - close all associated windows """ # close open password dialogs (or other remaining windows) @@ -361,7 +449,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): # the taskbar's OnExit method... def OnTaskbarExit(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to exit the application via the system tray icon in the taskbar. + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('exit application', loglevel=x2go.log.loglevel_INFO, ) @@ -379,7 +470,17 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self.ExitMainLoop() def _init_pubapp_session(self, session_uuid=None, profile_name=None): + """\ + Initialize a single session in published applications mode for a given profile. + + NOTE: L{PyHocaGUI} by design only supports _one_ published applications session per connected profile. + @param session_uuid: session UUID + @type session_uuid: C{str} + @param profile_name: session profile name + @type profile_name: C{str} + + """ if profile_name is None and session_uuid: profile_name = self._X2goClient__get_session_profile_name(session_uuid) @@ -461,7 +562,15 @@ class PyHocaGUI(wx.App, x2go.X2goClient): return None def _post_authenticate(self, evt, session_uuid): + """\ + Tasks that have to be done directly after authentication of a session profile. + + @param evt: event + @type evt: C{obj} + @param session_uuid: session UUID + @type session_uuid: C{str} + """ try: profile_name = self.get_session(session_uuid).get_profile_name() @@ -473,6 +582,15 @@ class PyHocaGUI(wx.App, x2go.X2goClient): pass def _do_authenticate(self, evt, session_uuid): + """\ + Perform authentication for a given session. + + @param evt: event + @type evt: C{obj} + @param session_uuid: session UUID + @type session_uuid: C{str} + + """ connect_failed = False profile_name = self.get_session(session_uuid).get_profile_name() try: @@ -589,7 +707,12 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnSessionAuthenticate(self, evt, session_uuid=None): """\ - STILL UNDOCUMENTED + Gets called if the user requests connecting to a session profile. + + @param evt: event + @type evt: C{obj} + @param session_uuid: session UUID + @type session_uuid: C{str} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -606,7 +729,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnSessionStart(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to start a new X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -618,7 +744,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnPubAppSessionStart(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to start a new X2Go session in published applications mode. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -626,26 +755,23 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnPubAppRefreshMenu(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests a reload of the published applications menu tree from the X2Go server. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] gevent.spawn(self.profile_get_published_applications, profile_name=profile_name, refresh=True, max_no_submenus=self.args.published_applications_no_submenus) - def OnApplicationStart(self, evt): + def OnPubAppExecution(self, evt): """\ - STILL UNDOCUMENTED + Gets called for sessions in published applications mode if the user requests the startup of a published application. - """ - profile_name = self._eventid_profilenames_map[evt.GetId()] - _application = self._eventid_applications_map[evt.GetId()] - _query_session = self._X2goClient__client_registered_sessions_of_profile_name(profile_name)[0] - session_uuid = self._X2goClient__register_session(profile_name=profile_name, cmd=_application, session_type="application") - if self._X2goClient__server_is_alive(session_uuid): - gevent.spawn(self._X2goClient__start_session, session_uuid) - _dummy = self._X2goClient__list_sessions(session_uuid, refresh_cache=True) + @param evt: event + @type evt: C{obj} - def OnPubAppExecution(self, evt): + """ profile_name = self._eventid_profilenames_map[evt.GetId()] _session_name = self._eventid_sessionnames_map[evt.GetId()] try: @@ -659,21 +785,75 @@ class PyHocaGUI(wx.App, x2go.X2goClient): except KeyError: pass + def OnApplicationStart(self, evt): + """\ + Gets called if the user requests the start up of a single application session. + + @param evt: event + @type evt: C{obj} + + """ + profile_name = self._eventid_profilenames_map[evt.GetId()] + _application = self._eventid_applications_map[evt.GetId()] + _query_session = self._X2goClient__client_registered_sessions_of_profile_name(profile_name)[0] + session_uuid = self._X2goClient__register_session(profile_name=profile_name, cmd=_application, session_type="application") + if self._X2goClient__server_is_alive(session_uuid): + gevent.spawn(self._X2goClient__start_session, session_uuid) + _dummy = self._X2goClient__list_sessions(session_uuid, refresh_cache=True) + def _disable_session_name(self, profile_name, session_name): + """\ + Mark a session name for a given session profile as disabled. + Disabled sessions are greyed out in the application's menu tree. + + @param profile_name: session profile name + @type profile_name: C{str} + @param session_uuid: session UUID + @type session_uuid: C{str} + + """ if profile_name not in self._temp_disabled_session_names.keys(): self._temp_disabled_session_names[profile_name] = [] self._temp_disabled_session_names[profile_name].append(session_name) def _enable_session_name(self, profile_name, session_name): + """\ + Mark a session name for a given session profile as enabled. + Disabled sessions are greyed out in the application's menu tree. + + @param profile_name: session profile name + @type profile_name: C{str} + @param session_uuid: session UUID + @type session_uuid: C{str} + + """ try: self._temp_disabled_session_names[profile_name].remove(session_name) except (KeyError, ValueError): pass def is_session_name_enabled(self, profile_name, session_name): + """\ + Test if the GUI elements for a given session name and profile name are enabled. + + @param profile_name: session profile name + @type profile_name: C{str} + @param session_uuid: session UUID + @type session_uuid: C{str} + + """ return not self.is_session_name_disabled(profile_name, session_name) def is_session_name_disabled(self, profile_name, session_name): + """\ + Test if the GUI elements for a given session name and profile name are disabled. + + @param profile_name: session profile name + @type profile_name: C{str} + @param session_uuid: session UUID + @type session_uuid: C{str} + + """ try: return session_name in self._temp_disabled_session_names[profile_name] except KeyError: @@ -681,7 +861,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnSessionResume(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to resume an available X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -695,7 +878,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnSessionSuspend(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to suspend an associated or available X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -709,7 +895,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnSessionTerminate(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to terminate an associated or available X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -723,7 +912,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnCleanSessions(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to terminate all available X2Go session for the selected session profile. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -745,7 +937,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnServerDisconnect(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user disconnects from a selected session profile (i.e. X2Go server). + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -772,7 +967,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnProfileAdd(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to add a new session profile. + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('adding new X2Go session profile', loglevel=x2go.log.loglevel_INFO, ) @@ -780,7 +978,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnProfileEdit(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to edit an existing session profile. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -793,7 +994,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnProfileCopy(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to add a new session profile by using an existing session profile as template. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -802,7 +1006,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnProfileEditWhileConnected(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to edit an existing session profile while the session profile is connected. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -811,7 +1018,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnProfileDelete(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to delete an existing session profile. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -828,7 +1038,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnShareCustomLocalFolder(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to share a non-configured local folder with the running X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -846,7 +1059,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnUnshareAllLocalFolders(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to unshare all shared local folders from the running X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -854,7 +1070,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnShareLocalFolder(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to share a previously configured local folder with the running X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -863,7 +1082,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnUnshareLocalFolder(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user chooses to unshare a previously shared local folder from the running X2Go session. + + @param evt: event + @type evt: C{obj} """ profile_name = self._eventid_profilenames_map[evt.GetId()] @@ -872,17 +1094,34 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnListSessions(self, evt): """\ - STILL UNDOCUMENTED + Not implemented, yet. + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('The ,,List Sessions\'\' information window is not implemented yet', loglevel=x2go.log.loglevel_WARN, ) def OnSessionRename(self, evt): + """\ + Gets called if the user requests to rename the title of a session window. + + @param evt: event + @type evt: C{obj} + + """ profile_name = self._eventid_profilenames_map[evt.GetId()] session_name = self._eventid_sessionnames_map[evt.GetId()] sessiontitle.PyHocaGUI_DialogBoxSessionTitle(self, profile_name, session_name) def OnSessionFocus(self, evt): + """\ + Gets called if the user requests to raise a session window and bring it to focus. + + @param evt: event + @type evt: C{obj} + + """ profile_name = self._eventid_profilenames_map[evt.GetId()] session_name = self._eventid_sessionnames_map[evt.GetId()] _s = self._X2goClient__get_session_of_session_name(session_name, return_object=True) @@ -890,7 +1129,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnAbout(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to see the application's ,,About'' window. + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('Showing the ,,About...\'\' window', loglevel=x2go.log.loglevel_INFO, ) @@ -898,14 +1140,20 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnOptions(self, evt): """\ - STILL UNDOCUMENTED + Not implemented, yet. + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('The ,,Options\'\' configuration window is not implemented yet', loglevel=x2go.log.loglevel_WARN, ) def OnPrintingPreferences(self, evt): """\ - STILL UNDOCUMENTED + Gets called if the user requests to view/modify the application's ,,Printing Preferences'' (window). + + @param evt: event + @type evt: C{obj} """ self._pyhoca_logger('opening the printing preferences window', loglevel=x2go.log.loglevel_INFO, ) @@ -913,7 +1161,10 @@ class PyHocaGUI(wx.App, x2go.X2goClient): def OnClose(self, evt): """\ - STILL UNDOCUMENTED + Introduce the clean closure of the application. + + @param evt: event + @type evt: C{obj} """ self.OnExit(evt) @@ -921,9 +1172,23 @@ class PyHocaGUI(wx.App, x2go.X2goClient): ## ## Python X2Go (X2goClient) interactive HOOK's... ## - def HOOK_check_host_dialog(self, profile_name='UNKNOWN', host='UNKNOWN', port=22, fingerprint='no fingerprint', fingerprint_type='RSA', ): + def HOOK_check_host_dialog(self, profile_name='UNKNOWN', host='UNKNOWN', port=22, fingerprint='no fingerprint', fingerprint_type='RSA', **kwargs): """\ - STILL UNDOCUMENTED + Provide a GUI-based host key check for unknown remote X2Go(=SSH) servers. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param host: SSH server name to validate + @type host: C{str} + @param port: SSH server port to validate + @type port: C{int} + @param fingerprint: the server's fingerprint + @type fingerprint: C{str} + @param fingerprint_type: finger print type (like RSA, DSA, ...) + @type fingerprint_type: C{str} + + @return: if host validity is verified, this hook method should return C{True} + @rtype: C{bool} """ _message = _(u'The authenticity of host [%s]:%s can\'t be established.\n%s key fingerprint is ,,%s\'\'.\n\nAre you sure you want to continue connecting?') % (host, port, fingerprint_type, fingerprint) @@ -947,12 +1212,38 @@ class PyHocaGUI(wx.App, x2go.X2goClient): m.Destroy() return retval + # this hook gets called from Python X2Go classes if a print job is coming in and the print action is ,,DIALOG''... + def HOOK_open_print_dialog(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Open an interactive print preferences dialog for an incoming print job. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ + _print_action = None + _pp_dialog = printingprefs.PyHocaGUI_PrintingPreferences(self, mode='print', profile_name=profile_name, session_name=session_name) + while _pp_dialog in self._sub_windows: + _print_action = _pp_dialog.get_print_action() + gevent.sleep(.2) + + return _print_action + ## ## Python X2Go (X2goClient) notification HOOK's... ## # this hook gets called from Python X2Go classes if profile_name's control session has died... - def HOOK_on_control_session_death(self, profile_name): + def HOOK_on_control_session_death(self, profile_name='UNKNOWN', **kwargs): + """\ + Notify about connection failures. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + + """ self.notifier.send(_(u'%s - channel error') % profile_name, _(u'Lost connection to server %s unexpectedly! Try to re-authenticate to the server...') % profile_name, icon='session_warning', timeout=10000) try: del self._temp_disabled_session_names[profile_name] @@ -963,13 +1254,31 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self.ExitMainLoop() - def HOOK_session_startup_failed(self, profile_name='UNKNOWN'): + def HOOK_session_startup_failed(self, profile_name='UNKNOWN', **kwargs): + """\ + Notify about session startup failures. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + + """ self.notifier.send(_(u'%s - session failure') % profile_name, _('The session startup failed.'), icon='session_error', timeout=10000) if self.exit_on_disconnect: self.WakeUpIdle() self.ExitMainLoop() - def HOOK_no_such_command(self, cmd, profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_no_such_command(self, cmd, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about commands that are not available on the remote server. + + @param cmd: the command that failed + @type cmd: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ if session_name == 'UNKNOWN': self.notifier.send(_(u'%s - session failure') % profile_name, _('The command ,,%s\'\' is not available on X2Go server.') % cmd, icon='session_error', timeout=10000) else: @@ -978,13 +1287,37 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self.WakeUpIdle() self.ExitMainLoop() - def HOOK_rforward_request_denied(self, profile_name='UNKNOWN', session_name='UNKNOWN', server_port=0): + def HOOK_rforward_request_denied(self, profile_name='UNKNOWN', session_name='UNKNOWN', server_port=0, **kwargs): + """\ + Notify about reverse port forwarding requests that get denied. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + @param server_port: remote server port (starting point of reverse forwarding tunnel) + @type server_port: C{str} + + """ self.notifier.send(_(u'%s - session warning') % profile_name, _(u'Reverse TCP port forwarding request for session %s to server port %s has been denied.') % (session_name, server_port), icon='session_warning', timeout=10000) if self.exit_on_disconnect: self.WakeUpIdle() self.ExitMainLoop() - def HOOK_forwarding_tunnel_setup_failed(self, profile_name='UNKNOWN', session_name='UNKNOWN', chain_host='UNKNOWN', chain_port=0): + def HOOK_forwarding_tunnel_setup_failed(self, profile_name='UNKNOWN', session_name='UNKNOWN', chain_host='UNKNOWN', chain_port=0, **kwargs): + """\ + Notify about port forwarding tunnel setup failures. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + @param chain_host: hostname of chain host (forwarding tunnel end point) + @type chain_host: C{str} + @param chain_port: port of chain host (forwarding tunnel end point) + @type chain_port: C{str} + + """ self.notifier.send(_(u'%s - session failure') % profile_name, _(u'Forwarding tunnel request to [%s]:%s for session %s was denied by remote X2go/SSH server. Session startup failed.') % (chain_host, chain_port, session_name), icon='session_error', timeout=10000) if not self._hide_notifications_map.has_key(profile_name): self._hide_notifications_map[profile_name] = [] @@ -999,67 +1332,195 @@ class PyHocaGUI(wx.App, x2go.X2goClient): self.WakeUpIdle() self.ExitMainLoop() - def HOOK_pulseaudio_not_supported_in_RDPsession(self): + def HOOK_pulseaudio_not_supported_in_RDPsession(self, **kwargs): + """\ + Notify that pulseaudio is not available in RDP sessions. + + """ self.notifier.send(_(u'%s - audio warning') % self.appname, _(u'The X2Go PulseAudio system is not available within Remote Desktop sessions.'), icon='audio_error', timeout=10000) - def HOOK_pulseaudio_server_startup_failed(self): + def HOOK_pulseaudio_server_startup_failed(self, **kwargs): + """\ + Notify about pulseaudio daemon startup failures. + + """ self.notifier.send(_(u'%s - audio error') % self.appname, _(u'The X2Go PulseAudio system could not be started.'), icon='audio_error', timeout=10000) - def HOOK_pulseaudio_server_died(self): + def HOOK_pulseaudio_server_died(self, **kwargs): + """\ + Notify about sudden pulseaudio crashes. + + """ self.notifier.send(_(u'%s - audio error') % self.appname, _(u'The X2Go PulseAudio system has died unexpectedly.'), icon='audio_error', timeout=10000) - def HOOK_on_sound_tunnel_failed(self, profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_sound_tunnel_failed(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about failures while setting up the audio tunnel for a session. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self.notifier.send(_(u'%s - audio problem') % profile_name, _(u'The audio connection could not be set up for this session.\n%s') % session_name, icon='session_warning', timeout=5000) - def HOOK_printing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_printing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify that client-side printing is not available for a session. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self.notifier.send(_(u'%s - client-side printing not available') % profile_name, _(u'The server denies client-side printing from within this session.\n%s') % session_name, icon='session_warning', timeout=5000) - def HOOK_mimebox_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_mimebox_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify that the MIME box feature is not available for a session. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self.notifier.send(_(u'%s - MIME box not available') % profile_name, _(u'The server does not support the X2Go MIME box.\n%s') % session_name, icon='session_warning', timeout=5000) - def HOOK_foldersharing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_foldersharing_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify that client-side folder sharing is not available for a session. + + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self.notifier.send(_(u'%s - client-side folders not sharable') % profile_name, _(u'The server denies client-side folder sharing with this session.\n%s') % session_name, icon='session_warning', timeout=5000) - def HOOK_sshfs_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN'): - self.notifier.send(_(u'%s - client resources not sharable') % profile_name, _(u'Client-side folders and printers cannot be shared with this session.\n%s') % session_name, icon='session_warning', timeout=5000) + def HOOK_sshfs_not_available(self, profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify that SSHFS support is not available on a connected X2Go server. - # this hook gets called from Python X2Go classes if a print job is coming in and the print action is ,,DIALOG''... - def HOOK_open_print_dialog(self, profile_name='UNKNOWN', session_name='UNKNOWN'): - _print_action = None - _pp_dialog = printingprefs.PyHocaGUI_PrintingPreferences(self, mode='print', profile_name=profile_name, session_name=session_name) - while _pp_dialog in self._sub_windows: - _print_action = _pp_dialog.get_print_action() - gevent.sleep(.2) + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} - return _print_action + """ + self.notifier.send(_(u'%s - client resources not sharable') % profile_name, _(u'Client-side folders and printers cannot be shared with this session.\n%s') % session_name, icon='session_warning', timeout=5000) + + def HOOK_printaction_error(self, filename, profile_name='UNKNOWN', session_name='UNKNOWN', err_msg='GENERIC_ERROR', printer=None, **kwargs): + """\ + Notify about a problem while processing a pring job. + + @param filename: file name of the print job that failed + @type filename: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + @param err_msg: if available, an appropriate error message + @type err_msg: C{str} + @param printer: if available, the printer name the print job failed on + @type printer: C{str} - def HOOK_printaction_error(self, filename, profile_name='UNKNOWN', session_name='UNKNOWN', err_msg='GENERIC_ERROR', printer=None): + """ if printer: self.notifier.send(_(u'%s - print error') % profile_name, _(u'%s\n...caused on printer %s by session\n%s') % (err_msg, printer, session_name), icon='session_error', timeout=5000) else: self.notifier.send(_(u'%s - print error') % profile_name, _(u'%s\n...caused by session\n%s') % (err_msg, session_name), icon='session_error', timeout=5000) - def HOOK_on_session_has_started_by_me(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_started_by_me(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has been started by this instance of L{PyHocaGUI}. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) self.notifier.send(_(u'%s - start') % profile_name, _(u'New X2Go session starting up...\n%s') % session_name, icon='session_start', timeout=5000) - def HOOK_on_session_has_started_by_other(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_started_by_other(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has been started by another X2Go client application. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) self.notifier.send(_(u'%s - start') % profile_name, _(u'Another client started X2Go session\n%s') % session_name, icon='session_start', timeout=5000) - def HOOK_on_session_has_resumed_by_me(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_resumed_by_me(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has been resumed by this instance of L{PyHocaGUI}. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) self.notifier.send(_(u'%s - resume') % profile_name, _(u'Resuming X2Go session...\n%s') % session_name, icon='session_resume', timeout=5000) - def HOOK_on_session_has_resumed_by_other(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_resumed_by_other(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has been resumed by another X2Go client application. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) self.notifier.send(_(u'%s - resume') % profile_name, _(u'Another client resumed X2Go session\n%s') % session_name, icon='session_resume', timeout=5000) - def HOOK_on_found_session_running_after_connect(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_found_session_running_after_connect(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about already running sessions that have been directly after the client-server connection had been established.. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) gevent.spawn_later(5, self.notifier.send, _(u'%s - running') % profile_name, _(u'Found already running session\n%s') % session_name, icon='session_resume', timeout=5000) - def HOOK_on_session_has_been_suspended(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_been_suspended(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has been suspended. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) if self._hide_notifications_map.has_key(profile_name) and session_name in self._hide_notifications_map[profile_name]: self._hide_notifications_map[profile_name].remove(session_name) @@ -1074,7 +1535,18 @@ class PyHocaGUI(wx.App, x2go.X2goClient): evt.SetId(_dummy_id) self.OnServerDisconnect(evt) - def HOOK_on_session_has_terminated(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN'): + def HOOK_on_session_has_terminated(self, session_uuid='UNKNOWN', profile_name='UNKNOWN', session_name='UNKNOWN', **kwargs): + """\ + Notify about a session that has (been) terminated. + + @param session_uuid: unique session identifier of the calling session + @type session_uuid: C{str} + @param profile_name: profile name of session that called this hook method + @type profile_name: C{str} + @param session_name: X2Go session name + @type session_name: C{str} + + """ self._enable_session_name(profile_name, session_name) # avoid notification if X2goClient.clean_sessions has been used to terminate sessions if self._hide_notifications_map.has_key(profile_name) and session_name in self._hide_notifications_map[profile_name]: diff --git a/pyhoca/wxgui/messages.py b/pyhoca/wxgui/messages.py index cc3e4a1..95a0a43 100644 --- a/pyhoca/wxgui/messages.py +++ b/pyhoca/wxgui/messages.py @@ -159,59 +159,204 @@ class PyHoca_MessageWindow(wx.Dialog): pass def OnTrue(self, evt): + """\ + Gets called if the user clicks on ,,Yes'' or ,,Ok''. + + @param evt: event + @type evt: C{obj} + + """ self.result = True self.Hide() def OnFalse(self, evt): + """\ + Gets called if the user clicks on ,,No'' or ,,Cancel''. + + @param evt: event + @type evt: C{obj} + + """ self.result = False self.Hide() def Ok(self): + """\ + Evaluate the result what the user chose in the message window. + + @return: C{True}, if ,,Ok'' had been chosen + @rtype: C{bool} + + """ return self.Yes() def Cancel(self): + """\ + Evaluate the result what the user chose in the message window. + + @return: C{True}, if ,,Cancel'' had been chosen + @rtype: C{bool} + + """ return not self.No() def Yes(self): + """\ + Evaluate the result what the user chose in the message window. + + @return: C{True}, if ,,Yes'' had been chosen + @rtype: C{bool} + + """ return self.result def No(self): + """\ + Evaluate the result what the user chose in the message window. + + @return: C{True}, if ,,No'' had been chosen + @rtype: C{bool} + + """ return not self.Yes() def Hide(self): + """\ + When hiding the message box, remove it from the list of open windows in the main application instance. + + """ try: self._PyHocaGUI._sub_windows.remove(self) except AttributeError: pass self.Show(False) - def Close(self): - wx.Dialog.Close(self) - - def Destroy(self): - wx.Dialog.Destroy(self) - class PyHoca_MessageWindow_Ok(PyHoca_MessageWindow): + """\ + A simple ,,Ok'' message window for L{PyHocaGUI}. + + """ def __init__(self, _PyHocaGUI, parent=None, title=None, shortmsg=None, custom_message=None, icon='session_warning', **kwargs): + """\ + @param _PyHocaGUI: main application instance + @type _PyHocaGUI: C{obj} + @param parent: the parent (calling) object + @type parent: C{obj} + @param title: window title + @type title: C{str} + @param shortmsg: a short string that refers to a pre-defined message (hard-coded in this class) + @type shortmsg: C{str} + @param custom_message: the message to be shown in this message box (alternative to C{shortmsg}) + @type custom_message: C{str} + @param icon: icon name for an icon to be shown left of the text in this message box + @type icon: C{str} + @param kwargs: any other optional argument (will be ignored) + @type kwargs: C{dict} + + """ PyHoca_MessageWindow.__init__(self, _PyHocaGUI, parent=parent, title=title, shortmsg=shortmsg, custom_message=custom_message, icon=icon, buttontype='ok', **kwargs) class PyHoca_MessageWindow_OkCancel(PyHoca_MessageWindow): + """\ + A simple ,,Ok+Cancel'' (default: Ok) message window for L{PyHocaGUI}. + + """ def __init__(self, _PyHocaGUI, parent=None, title=None, shortmsg=None, custom_message=None, icon='session_warning', **kwargs): + """\ + @param _PyHocaGUI: main application instance + @type _PyHocaGUI: C{obj} + @param parent: the parent (calling) object + @type parent: C{obj} + @param title: window title + @type title: C{str} + @param shortmsg: a short string that refers to a pre-defined message (hard-coded in this class) + @type shortmsg: C{str} + @param custom_message: the message to be shown in this message box (alternative to C{shortmsg}) + @type custom_message: C{str} + @param icon: icon name for an icon to be shown left of the text in this message box + @type icon: C{str} + @param kwargs: any other optional argument (will be ignored) + @type kwargs: C{dict} + + """ PyHoca_MessageWindow.__init__(self, _PyHocaGUI, parent=parent, title=title, shortmsg=shortmsg, custom_message=custom_message, icon=icon, buttontype='okcancel', **kwargs) class PyHoca_MessageWindow_CancelOk(PyHoca_MessageWindow): + """\ + A simple ,,Ok+Cancel'' (default: Cancel) message window for L{PyHocaGUI}. + + """ def __init__(self, _PyHocaGUI, parent=None, title=None, shortmsg=None, custom_message=None, icon='session_warning', **kwargs): + """\ + @param _PyHocaGUI: main application instance + @type _PyHocaGUI: C{obj} + @param parent: the parent (calling) object + @type parent: C{obj} + @param title: window title + @type title: C{str} + @param shortmsg: a short string that refers to a pre-defined message (hard-coded in this class) + @type shortmsg: C{str} + @param custom_message: the message to be shown in this message box (alternative to C{shortmsg}) + @type custom_message: C{str} + @param icon: icon name for an icon to be shown left of the text in this message box + @type icon: C{str} + @param kwargs: any other optional argument (will be ignored) + @type kwargs: C{dict} + + """ PyHoca_MessageWindow.__init__(self, _PyHocaGUI, parent=parent, title=title, shortmsg=shortmsg, custom_message=custom_message, icon=icon, buttontype='cancelok', **kwargs) class PyHoca_MessageWindow_YesNo(PyHoca_MessageWindow): + """\ + A simple ,,Yes+No'' (default: Yes) message window for L{PyHocaGUI}. + + """ def __init__(self, _PyHocaGUI, parent=None, title=None, shortmsg=None, custom_message=None, icon='session_warning', **kwargs): + """\ + @param _PyHocaGUI: main application instance + @type _PyHocaGUI: C{obj} + @param parent: the parent (calling) object + @type parent: C{obj} + @param title: window title + @type title: C{str} + @param shortmsg: a short string that refers to a pre-defined message (hard-coded in this class) + @type shortmsg: C{str} + @param custom_message: the message to be shown in this message box (alternative to C{shortmsg}) + @type custom_message: C{str} + @param icon: icon name for an icon to be shown left of the text in this message box + @type icon: C{str} + @param kwargs: any other optional argument (will be ignored) + @type kwargs: C{dict} + + """ PyHoca_MessageWindow.__init__(self, _PyHocaGUI, parent=parent, title=title, shortmsg=shortmsg, custom_message=custom_message, icon=icon, buttontype='yesno', **kwargs) class PyHoca_MessageWindow_NoYes(PyHoca_MessageWindow): + """\ + A simple ,,Yes+No'' (default: No) message window for L{PyHocaGUI}. + + """ def __init__(self, _PyHocaGUI, parent=None, title=None, shortmsg=None, custom_message=None, icon='session_warning', **kwargs): + """\ + @param _PyHocaGUI: main application instance + @type _PyHocaGUI: C{obj} + @param parent: the parent (calling) object + @type parent: C{obj} + @param title: window title + @type title: C{str} + @param shortmsg: a short string that refers to a pre-defined message (hard-coded in this class) + @type shortmsg: C{str} + @param custom_message: the message to be shown in this message box (alternative to C{shortmsg}) + @type custom_message: C{str} + @param icon: icon name for an icon to be shown left of the text in this message box + @type icon: C{str} + @param kwargs: any other optional argument (will be ignored) + @type kwargs: C{dict} + + """ PyHoca_MessageWindow.__init__(self, _PyHocaGUI, parent=parent, title=title, shortmsg=shortmsg, custom_message=custom_message, icon=icon, buttontype='noyes', **kwargs) diff --git a/pyhoca/wxgui/printingprefs.py b/pyhoca/wxgui/printingprefs.py index 3bfc35a..f18cad7 100644 --- a/pyhoca/wxgui/printingprefs.py +++ b/pyhoca/wxgui/printingprefs.py @@ -178,7 +178,7 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): def __do_layout(self): """\ - Arrange the frame's widget layout. + Arrange the frame's widget layout. """ sizer_1 = wx.BoxSizer(wx.VERTICAL) @@ -307,6 +307,10 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): return self._print_action_properties def _onPrintActionChange(self): + """\ + Helper method for L{OnPrintActionChange}. + + """ if self._print_action == 'PDFVIEW': self.PdfViewSelected() elif self._print_action == 'PDFSAVE': @@ -320,9 +324,20 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): self.__update_from_screen() def OnPrintActionChange(self, evt): + """ + Gets called whenever a print action change has been requested. + + @param evt: event + @type evt: C{obj} + + """ self._onPrintActionChange() def _disable_PrintOptions(self): + """\ + Helper method for L{PdfViewSelected}, L{PdfSaveToFolderSelected}, L{PrintPrinterSelected}, and L{PrintCmdSelected}. + + """ self.PdfViewCmdLabel.Enable(False) self.PdfViewCmd.Enable(False) self.PdfViewCmdBrowseButton.Enable(False) @@ -341,29 +356,52 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): self.OKButton.Enable(True) def PdfViewSelected(self): + """\ + Enable/disable widgets for PDFVIEW print action. + + """ self._disable_PrintOptions() self.PdfViewCmdLabel.Enable(True) self.PdfViewCmd.Enable(True) self.PdfViewCmdBrowseButton.Enable(True) def PdfSaveToFolderSelected(self): + """\ + Enable/disable widgets for PDFSAVE print action. + + """ self._disable_PrintOptions() self.PdfSaveToFolderLabel.Enable(True) self.PdfSaveToFolder.Enable(True) self.PdfSaveToFolderBrowseButton.Enable(True) def PrintPrinterSelected(self): + """\ + Enable/disable widgets for PRINT print action. + + """ self._disable_PrintOptions() if self._defaultPrinter != '#PRINTSYSTEM_UNAVAILABLE#': self.PrintPrinterLabel.Enable(True) self.PrintPrinter.Enable(True) def PrintCmdSelected(self): + """\ + Enable/disable widgets for PRINTCMD print action. + + """ self._disable_PrintOptions() self.PrintCmdLabel.Enable(True) self.PrintCmd.Enable(True) def OnPdfViewCmdBrowseButton(self, evt): + """\ + Gets called if the user requests to browse for a PDF view executable. + + @param evt: event + @type evt: C{obj} + + """ wildcard = "All files (*.*)|*" dlg = wx.FileDialog( self, message=_(u"Choose PDF viewer application"), defaultDir=_LOCAL_HOME, @@ -376,6 +414,13 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): self.PdfViewCmd.SetValue(_pdfview_cmd) def OnPdfSaveToFolderBrowseButton(self, evt): + """\ + Gets called if the user requests to set the PDFSAVE folder location. + + @param evt: event + @type evt: C{obj} + + """ _start_dir = self.PdfSaveToFolder.GetValue() if not utils.is_abs_path(_start_dir): if not _start_dir.startswith('~'): @@ -397,10 +442,18 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): self.PdfSaveToFolder.SetValue(_save_to_folder) def __validate(self): + """\ + Dummy field validation method. Always returns C{True}. + + """ validateOk = True return validateOk def _apply_changes(self): + """\ + Apply changes in the dialog to the client printing configuration. + + """ self.__update_from_screen() if self.__validate(): if self.mode == 'edit': self.client_printing.write() @@ -408,6 +461,13 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): return False def OnOKButton(self, evt): + """\ + Gets called if the user presses the ,,Ok'' button. + + @param evt: event + @type evt: C{obj} + + """ wx.BeginBusyCursor() if self._apply_changes(): try: wx.EndBusyCursor() @@ -419,17 +479,36 @@ class PyHocaGUI_PrintingPreferences(wx.Dialog): except: pass def OnApplyButton(self, evt): + """\ + Gets called if the user presses the ,,Apply'' button. + + @param evt: event + @type evt: C{obj} + + """ wx.BeginBusyCursor() self._apply_changes() try: wx.EndBusyCursor() except: pass def OnCancel(self, evt): + """\ + Gets called if the user presses the ,,Cancel'' button. + + @param evt: event + @type evt: C{obj} + + """ self.client_printing.load() self.Close() self.Destroy() def Destroy(self): + """\ + Tidy up some stuff in the main application instance before allowing desctruction of the + printing preferences window. + + """ try: self._PyHocaGUI._sub_windows.remove(self) except ValueError: hooks/post-receive -- pyhoca-gui.git (Python X2Go Client (wxPython GUI)) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "pyhoca-gui.git" (Python X2Go Client (wxPython GUI)).