[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue gnue-common/src/GConnections.py gnuef/src/...
From: |
James Thompson |
Subject: |
gnue gnue-common/src/GConnections.py gnuef/src/... |
Date: |
Wed, 07 Nov 2001 21:47:16 -0500 |
CVSROOT: /cvs
Module name: gnue
Changes by: James Thompson <address@hidden> 01/11/07 21:47:16
Modified files:
gnue-common/src: GConnections.py
gnuef/src : UIwxpython.py
Log message:
Kludge to support modal logins properly on win32
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GConnections.py.diff?cvsroot=OldCVS&tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/UIwxpython.py.diff?cvsroot=OldCVS&tr1=1.116&tr2=1.117&r1=text&r2=text
Patches:
Index: gnue/gnue-common/src/GConnections.py
diff -u gnue/gnue-common/src/GConnections.py:1.23
gnue/gnue-common/src/GConnections.py:1.24
--- gnue/gnue-common/src/GConnections.py:1.23 Mon Nov 5 14:32:53 2001
+++ gnue/gnue-common/src/GConnections.py Wed Nov 7 21:47:15 2001
@@ -193,7 +193,8 @@
# We're done!
attempts = 0
-
+ self._loginHandler.destroyLoginDialog()
+
except GDataObjects.LoginError, error:
# Oops, they must have entered an invalid user/password.
# Those silly users.
@@ -201,11 +202,13 @@
if not attempts:
# Four times is plenty...
+ self._loginHandler.destroyLoginHandler()
raise GDataObjects.LoginError, \
"Unable to log in after 4 attempts.\n\nError: %s" % error
except GLoginHandler.UserCanceledLogin:
# Guess they changed their minds. Treat as a login error.
+ self._loginHandler.destroyLoginHandler()
raise GDataObjects.LoginError, "User canceled the login request."
Index: gnue/gnuef/src/UIwxpython.py
diff -u gnue/gnuef/src/UIwxpython.py:1.116 gnue/gnuef/src/UIwxpython.py:1.117
--- gnue/gnuef/src/UIwxpython.py:1.116 Sun Nov 4 17:04:48 2001
+++ gnue/gnuef/src/UIwxpython.py Wed Nov 7 21:47:15 2001
@@ -42,8 +42,6 @@
_NOTEBOOK = None
_LOOPTRAP = 0
-
-
##
## Only create one instance of wxApp
## Use getWxApp() to get or create the
@@ -929,120 +927,120 @@
class UILoginHandler(GLoginHandler.LoginHandler):
def __init__(self):
self._wxapp = getWxApp()
-
- def getLogin(self, loginData):
-
- if len(loginData[1]):
-# loginMesg = 'Login required for "%s" (%s)' % (loginData[1],
loginData[0])
- loginMesg = 'Login required for "%s"' % (loginData[1])
- else:
- loginMesg = 'Login required for %s' % (loginData[0])
-
- self.dlg = wxDialog(NULL, -1, "GNU Enterprise: Login")
-# self.dlg.SetBackgroundColour(wxWHITE)
- self.dlg.SetAutoLayout(true)
+ self.dlg = None
- bmp = wxImage(GConfig.get('smallPNG'), wxBITMAP_TYPE_PNG).ConvertToBitmap()
-
-
- self.textctrlList = []
- messageField = wxStaticText(self.dlg, 1010, str(loginMesg))
- labelList = []
-
- dlgWidth = getLargest(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
-
- dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
-
- xSpacing = 0
- ySpacing = 0
- fieldLabelWidth = 0
-
- for prompt in loginData[2]:
- s = wxStaticText(self.dlg, 1010, '%s:' % prompt[1])
- labelList.append(s)
- if prompt[2]:
- t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PASSWORD|wxTE_PROCESS_ENTER)
+ def getLogin(self, loginData):
+ if not self.dlg:
+ if len(loginData[1]):
+ loginMesg = 'Login required for "%s"' % (loginData[1])
else:
- t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PROCESS_ENTER)
- myID = len(self.textctrlList)
- self.textctrlList.append(t)
- EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
-
- fieldLabelWidth = getLargest(fieldLabelWidth, \
- s.GetSize().GetWidth() + t.GetSize().GetWidth() + 10)
-
- dlgWidth = getLargest(dlgWidth, \
- s.GetSize().GetWidth() + t.GetSize().GetWidth() + 10)
-
- xSpacing = getLargest(xSpacing, s.GetSize().GetWidth())
- ySpacing = getLargest(ySpacing, s.GetSize().GetHeight())
- ySpacing = getLargest(ySpacing, t.GetSize().GetHeight())
-
-
- loginButton = wxButton(self.dlg,19998,'Login')
- cancelButton = wxButton(self.dlg,19999,'Cancel')
-
- EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
- EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
- dlgWidth = getLargest(dlgWidth, loginButton.GetSize().GetWidth() +
- cancelButton.GetSize().GetWidth() + 6) + 20
+ loginMesg = 'Login required for %s' % (loginData[0])
- dlgHeight = dlgHeight + \
- getLargest(loginButton.GetSize().GetHeight(),
- cancelButton.GetSize().GetHeight()) - 6
-
- firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
- lastY = firstY
- xSpacing = xSpacing + 10 # Add whitespace between widgets
- ySpacing = ySpacing + 6 # Add whitespace between widgets
- xPos = dlgWidth/2 - fieldLabelWidth/2
-
-
- # Move the fields and labels into position
- for i in range(0, len(self.textctrlList)):
- dlgHeight = dlgHeight + ySpacing
- labelList[i].SetPosition(wxPoint(xPos, lastY))
- self.textctrlList[i].SetPosition(wxPoint(xPos + xSpacing, lastY))
- lastY = lastY + ySpacing
+ self.dlg = wxDialog(NULL, -1, "GNU Enterprise: Login")
+ self.dlg.SetAutoLayout(true)
+
+ bmp = wxImage(GConfig.get('smallPNG'),
wxBITMAP_TYPE_PNG).ConvertToBitmap()
+ self.textctrlList = []
+ messageField = wxStaticText(self.dlg, 1010, str(loginMesg))
+ labelList = []
+
+ dlgWidth = getLargest(bmp.GetWidth(),
messageField.GetSize().GetWidth()+20)
+
+ dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
+
+ xSpacing = 0
+ ySpacing = 0
+ fieldLabelWidth = 0
+
+ for prompt in loginData[2]:
+ s = wxStaticText(self.dlg, 1010, '%s:' % prompt[1])
+ labelList.append(s)
+ if prompt[2]:
+ t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PASSWORD|wxTE_PROCESS_ENTER)
+ else:
+ t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20),
style=wxTE_PROCESS_ENTER)
+
+ myID = len(self.textctrlList)
+ self.textctrlList.append(t)
+ EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
+
+ fieldLabelWidth = getLargest(fieldLabelWidth, \
+ s.GetSize().GetWidth() +
t.GetSize().GetWidth() + 10)
+
+ dlgWidth = getLargest(dlgWidth, \
+ s.GetSize().GetWidth() + t.GetSize().GetWidth()
+ 10)
+
+ xSpacing = getLargest(xSpacing, s.GetSize().GetWidth())
+ ySpacing = getLargest(ySpacing, s.GetSize().GetHeight())
+ ySpacing = getLargest(ySpacing, t.GetSize().GetHeight())
+
+
+ loginButton = wxButton(self.dlg,19998,'Login')
+ cancelButton = wxButton(self.dlg,19999,'Cancel')
+
+ EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
+ EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
+ dlgWidth = getLargest(dlgWidth, loginButton.GetSize().GetWidth() +
+ cancelButton.GetSize().GetWidth() + 6) + 20
+
+ dlgHeight = dlgHeight + \
+ getLargest(loginButton.GetSize().GetHeight(),
+ cancelButton.GetSize().GetHeight()) - 6
+
+ firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
+ lastY = firstY
+ xSpacing = xSpacing + 10 # Add whitespace between widgets
+ ySpacing = ySpacing + 6 # Add whitespace between widgets
+ xPos = dlgWidth/2 - fieldLabelWidth/2
+
- # Create and position the logo
- wxStaticBitmap(self.dlg,-1, bmp,
- wxPoint((dlgWidth-bmp.GetWidth())/2, 12),
- wxSize(bmp.GetWidth(), bmp.GetHeight()))
+ # Move the fields and labels into position
+ for i in range(0, len(self.textctrlList)):
+ dlgHeight = dlgHeight + ySpacing
+ labelList[i].SetPosition(wxPoint(xPos, lastY))
+ self.textctrlList[i].SetPosition(wxPoint(xPos + xSpacing, lastY))
+ lastY = lastY + ySpacing
- # Move the various widgets into position
- messageField.SetPosition(
+ # Create and position the logo
+ wxStaticBitmap(self.dlg,-1, bmp,
+ wxPoint((dlgWidth-bmp.GetWidth())/2, 12),
+ wxSize(bmp.GetWidth(), bmp.GetHeight()))
+
+ # Move the various widgets into position
+ messageField.SetPosition(
wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2,
30 + bmp.GetHeight()))
-
-
- cancelButton.SetPosition(
+
+ cancelButton.SetPosition(
wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
- cancelButton.GetSize().GetHeight())))
-
- loginButton.SetPosition(
+
cancelButton.GetSize().GetHeight())))
+ loginButton.SetPosition(
wxPoint(dlgWidth - 16 - cancelButton.GetSize().GetWidth() - \
loginButton.GetSize().GetWidth(),
dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
- cancelButton.GetSize().GetHeight())))
+
cancelButton.GetSize().GetHeight())))
+ self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
- self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
- self.dlg.Refresh()
-
+ self.dlg.Refresh()
+ self.dlg.Fit()
+ self.dlg.Raise()
+ self.dlg.CenterOnScreen()
+
# If user cancels, this will be set to 0
self._completed = 0
-
- self.dlg.Fit()
- self.dlg.Raise()
- self.dlg.CenterOnScreen()
self.dlg.ShowModal()
- self.dlg.Destroy()
+ #if sys.platform == 'win32':
+ # import time
+ # time.sleep(3)
+ #self.dlg.Destroy()
+ #self.dlg = None
+
if not self._completed:
raise GLoginHandler.UserCanceledLogin
@@ -1070,6 +1068,13 @@
#
def loginCancelEventTrap(self, event):
self.loginCompleted(0)
+
+ #
+ # TODO: This is a hack required because windows
+ # TODO: seems to have issues with wxWindows dialogs
+ #
+ def destroyLoginDialog(self):
+ self.dlg.Destroy()
WIDGETS = {'GFLabel' : UILabel,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue gnue-common/src/GConnections.py gnuef/src/...,
James Thompson <=