[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/forms/src/uidrivers/win32 UILoginHandler.py
From: |
Bajusz Tamás |
Subject: |
gnue/forms/src/uidrivers/win32 UILoginHandler.py |
Date: |
Sat, 22 Mar 2003 12:34:39 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Bajusz Tamás <address@hidden> 03/03/22 12:34:38
Modified files:
forms/src/uidrivers/win32: UILoginHandler.py
Log message:
far from perfect LoginHandler
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/uidrivers/win32/UILoginHandler.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/forms/src/uidrivers/win32/UILoginHandler.py
diff -c gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.1
gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.2
*** gnue/forms/src/uidrivers/win32/UILoginHandler.py:1.1 Sun Feb 23
18:43:32 2003
--- gnue/forms/src/uidrivers/win32/UILoginHandler.py Sat Mar 22 12:34:38 2003
***************
*** 27,39 ****
# NOTES:
#
! import string
!
! import win32gui
from gnue.common.datasources import GLoginHandler
from gnue.common.apps import GConfig
! from GFwin32App import *
# Shortcut
images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
--- 27,40 ----
# NOTES:
#
! import win32api, win32gui, win32con, commctrl
! import struct
from gnue.common.datasources import GLoginHandler
from gnue.common.apps import GConfig
! from gnue.forms.uidrivers.win32.common import getNextId
!
! g_registeredClass = 0
# Shortcut
images_dir = GConfig.getInstalledBase('forms_images','common_images') + '/'
***************
*** 53,60 ****
#
class UILoginHandler(GLoginHandler.LoginHandler):
def __init__(self):
! self._win32app = getWin32App()
! self.dlg = None
def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
! pass
\ No newline at end of file
--- 54,178 ----
#
class UILoginHandler(GLoginHandler.LoginHandler):
def __init__(self):
! win32gui.InitCommonControls()
! self.hinst = win32api.GetModuleHandle(None)
def getLogin(self, loginData, errortext=None):#"Invalid username/password"):
! if 1: # TODO: This is left here to prevent me from having to unindent
this code
! # TODO: Since the UI stuff is currently being gutted I'm not
wasting the time
! # TODO: to do the right thingData.Items()
! self._loginData = loginData
!
! if len(loginData[1]):
! loginMesg = _('Login required for\n"%s"') % (loginData[1])
! else:
! loginMesg = _('Login required for %s') % (loginData[0])
!
! message_map = {
! win32con.WM_COMMAND: self.OnCommand,
! win32con.WM_INITDIALOG: self.OnInitDialog,
! win32con.WM_CLOSE: self.OnClose,
! win32con.WM_DESTROY: self.OnDestroy,
! }
! dlgClassName = self._RegisterWndClass()
!
! style = win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION |
win32con.DS_SETFONT | win32con.WS_SYSMENU
! cs = win32con.WS_CHILD | win32con.WS_VISIBLE
! title = _("GNU Enterprise: Login to %s") % loginData[0]
!
! dlg = [ [title, (0, 0, 200, 160), style, None, (8, "MS Sans Serif"),
None, dlgClassName], ]
!
! Y=20
! dlg.append([130, str(loginMesg), -1, (5, Y, 195, 100), cs |
win32con.SS_CENTER])
!
! self.textctrlList = []
!
! Y += 20
! for prompt in loginData[2]:
! Y += 20
! dlg.append([130, '%s:' % prompt[1], -1, (5, Y, 200, 12), cs |
win32con.SS_LEFT])
!
! s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
! ID = getNextId()
! if prompt[2]:
! dlg.append([129, None, ID, (55, Y, 100, 12), s |
win32con.ES_PASSWORD])
! else:
! dlg.append([129, None, ID, (55, Y, 100, 12), s])
! self.textctrlList.append(ID)
!
! if errortext:
! Y += 20
! dlg.append([130, str(errortext), -1, (5, Y, 190, 100), cs |
win32con.SS_CENTER])
! #errorField.SetForegroundColour(wxColour(223,0,0))
!
! # Buttons
! Y += 40
! s = cs | win32con.WS_TABSTOP
! self.ID_Login = getNextId()
! dlg.append([128, _('Login'), self.ID_Login, (35, Y, 50, 14), s |
win32con.BS_DEFPUSHBUTTON])
! s = s | win32con.BS_PUSHBUTTON
! self.ID_Cancel = getNextId()
! dlg.append([128, _('Cancel'), self.ID_Cancel, (115, Y, 50, 14), s])
!
! # If user cancels, this will be set to 0
! self._completed = 0
! self._rv = {}
! win32gui.DialogBoxIndirect(self.hinst, dlg, 0, message_map)
!
! if not self._completed:
! raise GLoginHandler.UserCanceledLogin
!
! return self._rv
!
!
! def _RegisterWndClass(self):
! className = "GNUe login"
! global g_registeredClass
! if not g_registeredClass:
! message_map = {}
! wc = win32gui.WNDCLASS()
! wc.SetDialogProc() # Make it a dialog class.
! self.hinst = wc.hInstance = win32api.GetModuleHandle(None)
! wc.lpszClassName = className
! wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW
! wc.hCursor = win32gui.LoadCursor( 0, win32con.IDC_ARROW )
! wc.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION)
! wc.hbrBackground = win32con.COLOR_WINDOW
! wc.lpfnWndProc = message_map # could also specify a wndproc.
! wc.cbWndExtra = win32con.DLGWINDOWEXTRA + struct.calcsize("Pi")
! classAtom = win32gui.RegisterClass(wc)
! g_registeredClass = 1
! return className
!
!
! def OnInitDialog(self, hwnd, msg, wparam, lparam):
! # TODO: calculate and reposition the dialog items
! # TODO: and resize the dialog window
! self.hwnd = hwnd
! # centre the dialog
! desktop = win32gui.GetDesktopWindow()
! l,t,r,b = win32gui.GetWindowRect(hwnd)
! dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
! centre_x, centre_y = win32gui.ClientToScreen( desktop, (
(dt_r-dt_l)/2, (dt_b-dt_t)/2) )
! win32gui.MoveWindow(hwnd, centre_x-(r/2), centre_y-(b/2), r-l, b-t, 0)
!
! def OnClose(self, hwnd, msg, wparam, lparam):
! win32gui.EndDialog(hwnd, 0)
!
! def OnDestroy(self, hwnd, msg, wparam, lparam):
! print "OnDestroy"
! #win32gui.PostQuitMessage(0) # Terminate the app.
!
!
! def OnCommand(self, hwnd, msg, wparam, lparam):
! id = win32api.LOWORD(wparam)
! if id == self.ID_Login:
! for i in range(0, len(self._loginData[2])):
! self._rv[self._loginData[2][i][0]] =
win32gui.GetWindowText(win32gui.GetDlgItem(self.hwnd, self.textctrlList[i]))
! self._completed = 1
! win32gui.EndDialog(hwnd, 0)
! elif id == self.ID_Cancel:
! self._completed = 0
! win32gui.EndDialog(hwnd, 0)
!
!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/forms/src/uidrivers/win32 UILoginHandler.py,
Bajusz Tamás <=