The branch, master has been updated via 40cf50288c994d3e9b899d52fa09890283dc11dc (commit) from a49b9792b2e97c5eca68d87aed401520ccf8153a (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 ----------------------------------------------------------------- commit 40cf50288c994d3e9b899d52fa09890283dc11dc Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Jan 20 16:01:20 2013 +0100 add forgotten file: listdesktops.py ----------------------------------------------------------------------- Summary of changes: pyhoca/wxgui/{sessiontitle.py => listdesktops.py} | 151 ++++++++++++++++++--- 1 file changed, 129 insertions(+), 22 deletions(-) copy pyhoca/wxgui/{sessiontitle.py => listdesktops.py} (50%) The diff of changes is: diff --git a/pyhoca/wxgui/sessiontitle.py b/pyhoca/wxgui/listdesktops.py similarity index 50% copy from pyhoca/wxgui/sessiontitle.py copy to pyhoca/wxgui/listdesktops.py index ef69ece..0e54a38 100644 --- a/pyhoca/wxgui/sessiontitle.py +++ b/pyhoca/wxgui/listdesktops.py @@ -40,6 +40,7 @@ gevent.monkey.patch_all() import wx import os +import wx.lib.mixins.listctrl as listmix # PyHoca-GUI modules # ... NONE ... @@ -49,12 +50,12 @@ if os.environ.has_key('DESKTOP_SESSION'): else: WINDOW_MANAGER = 'generic' -class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): +class PyHocaGUI_DialogBoxListDesktops(wx.Dialog): """\ Simple dialog box for selecting a session title string. """ - def __init__(self, _PyHocaGUI, profile_name, session_name): + def __init__(self, _PyHocaGUI, profile_name): """\ Session title renaming dialog box (constructor). @@ -62,46 +63,69 @@ class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): @type _PyHocaGUI: C{obj} @param profile_name: session profile name @type profile_name: C{str} - @param session_name: the X2Go session name of the Window that we intend to modify the name of - @type session_name C{str} """ self._PyHocaGUI = _PyHocaGUI self._pyhoca_logger = self._PyHocaGUI._pyhoca_logger - self._pyhoca_logger('session title query box started', loglevel=x2go.loglevel_INFO, ) + self._pyhoca_logger('desktop list selection box started', loglevel=x2go.loglevel_INFO, ) + + self.connect = False + self.cancel = False self.current_profile_name = profile_name - self.current_session_name = session_name + self.list_index = 0 + self.listed_desktops = {} wx.Dialog.__init__(self, None, id=-1, title=profile_name, style=wx.DEFAULT_FRAME_STYLE, ) self._PyHocaGUI._sub_windows.append(self) - self.SetTitle(_(u'Session Title - %s') % profile_name) + self.SetTitle(_(u'Share Desktop Session - %s') % profile_name) + + self.titleLbl = wx.StaticText(self, wx.ID_ANY, _(u'Select one of the available desktop sessions on this server')+':', size=(-1, -1)) + self.desktopList = wx.ListCtrl(self, size=(420,140), + style=wx.LC_REPORT|wx.BORDER_SUNKEN|wx.LC_SINGLE_SEL) + self.desktopList.InsertColumn(0, 'Display') + self.desktopList.InsertColumn(1, 'User') + + self.shareMode0 = wx.RadioButton(self, -1, _(u"View session only"), style=wx.RB_GROUP) + self.shareMode1 = wx.RadioButton(self, -1, _(u"Gain full access")) + self.share_mode = 0 - self.titleLbl = wx.StaticText(self, wx.ID_ANY, _(u'Change session title to')+':', size=(-1, -1)) - self.titleTxt = wx.TextCtrl(self, wx.ID_ANY, '', style=wx.TE_PROCESS_ENTER, size=(120, -1)) - self.okBtn = wx.Button(self, wx.ID_OK, _(u'OK'), ) + ID_REFRESH = wx.NewId() + self.okBtn = wx.Button(self, wx.ID_OK, _(u'Share Desktop'), ) self.okBtn.SetDefault() + self.okBtn.Enable(False) + self.refreshBtn = wx.Button(self, ID_REFRESH, _(u'Refresh list'), ) self.cancelBtn = wx.Button(self, wx.ID_CANCEL, _(u'Cancel'), ) + self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnListClick, self.desktopList) self.Bind(wx.EVT_BUTTON, self.OnOk, self.okBtn) - self.Bind(wx.EVT_TEXT_ENTER, self.OnOk, self.titleTxt) + self.Bind(wx.EVT_BUTTON, self.OnRefreshDesktopList, self.refreshBtn) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.cancelBtn) titleSizer = wx.BoxSizer(wx.HORIZONTAL) + listSizer = wx.BoxSizer(wx.HORIZONTAL) + modeSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer = wx.BoxSizer(wx.VERTICAL) titleSizer.Add(self.titleLbl, 0, wx.ALL, 5) - titleSizer.Add(self.titleTxt, 0, wx.ALL, 5) + + listSizer.Add(self.desktopList, 0, wx.ALL|wx.EXPAND, 5) + + modeSizer.Add(self.shareMode0, 0, wx.ALL, 5) + modeSizer.Add(self.shareMode1, 0, wx.ALL, 5) btnSizer.Add(self.okBtn, 0, wx.ALL, 5) + btnSizer.Add(self.refreshBtn, 0, wx.ALL, 5) btnSizer.Add(self.cancelBtn, 0, wx.ALL, 5) mainSizer.Add(titleSizer, 0, wx.ALL, 5) + mainSizer.Add(listSizer, 0, wx.ALL|wx.EXPAND, 5) + mainSizer.Add(modeSizer, 0, wx.ALL, 5) mainSizer.Add(btnSizer, 0, wx.ALL|wx.ALIGN_RIGHT, 5) - self.SetSizerAndFit(mainSizer) + self.SetSizerAndFit(mainSizer) self.Layout() maxX, maxY = wx.GetDisplaySize() @@ -132,7 +156,55 @@ class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): move_y = maxY - (self.GetSize().GetHeight() + 70) self.Move((move_x, move_y)) - self.Show() + self._refreshDesktopList() + + def ShowModal(self, **kwargs): + self._PyHocaGUI._sub_windows.append(self) + wx.Dialog.ShowModal(self, **kwargs) + + def add_item(self, display, user): + self.listed_desktops.update({ self.list_index: '%s@%s' % (user, display) }) + self.desktopList.InsertStringItem(self.list_index, display) + self.desktopList.SetStringItem(self.list_index, 1, user) + self.list_index += 1 + + def _refreshDesktopList(self): + """\ + Gets called if the Refresh button gets pressed. + + @param evt: event + @type evt: C{obj} + + """ + self.desktopList.DeleteAllItems() + self.listed_desktops = {} + self.list_index = 0 + desktops = self._PyHocaGUI._X2GoClient__list_desktops(profile_name=self.current_profile_name) + for desktop in desktops: + if len(desktop.split('@')) >= 2: + display = desktop.split('@')[0] + user = desktop.split('@')[1] + self.add_item(user, display) + + def OnListClick(self, evt): + """\ + Enable the Connect button only if a list item got clicked. + + @param evt: event + @type evt: C{obj} + + """ + self.okBtn.Enable(True) + + def OnRefreshDesktopList(self, evt): + """\ + Gets called if the Refresh button gets pressed. + + @param evt: event + @type evt: C{obj} + + """ + self._refreshDesktopList() def OnOk(self, evt): """\ @@ -142,13 +214,16 @@ class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): @type evt: C{obj} """ - title = self.titleTxt.GetValue() + self.Hide() + self.connect = True + self.share_mode = self.shareMode1.GetValue() and 1 or 0 - _session = self._PyHocaGUI._X2GoClient__get_session_of_session_name(session_name=self.current_session_name, return_object=True) - _session.set_session_window_title(title=title) + def GetResult(self): + """\ + Retrieve the result of the selection in the list box. - self.Close() - self.Destroy() + """ + return self.desktopList.GetValue() def OnCancel(self, evt): """\ @@ -158,10 +233,21 @@ class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): @type evt: C{obj} """ - self.Close() - self.Destroy() + self.Hide() + self.cancel = True + + def Hide(self): + """\ + When hiding the list desktops box, remove it from the list of open windows in the main application instance. + + """ + try: + self._PyHocaGUI._sub_windows.remove(self) + except (AttributeError, ValueError): + pass + self.Show(False) - def Destroy(self): + def Close(self): """\ Do some PyHocaGUI specific cleanup if this window gets destroyed. @@ -174,4 +260,25 @@ class PyHocaGUI_DialogBoxSessionTitle(wx.Dialog): self._PyHocaGUI._temp_disabled_profile_names.remove(self.current_profile_name) except ValueError: pass + wx.Dialog.Close(self) wx.Dialog.Destroy(self) + + def GetSelectedItems(self): + """\ + Gets the selected items for the list control. + Selection is returned as a list of selected indices, + low to high. + + """ + selection = [] + idx = self.desktopList.GetFirstSelected() + selection.append(idx) + while len(selection) != self.desktopList.GetSelectedItemCount(): + idx = self.desktopList.GetNextSelected(idx) + selection.append(idx) + + return selection + + def GetSelectedDesktop(self): + idx = self.GetSelectedItems()[0] + return self.listed_desktops[idx] 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)).