Changeset 741:429d648e23c6
- Timestamp:
- 01/02/16 12:22:28 (9 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r732 r741 279 279 else str(self._currentInteger)) 280 280 self._selfSetting = False 281 282 #------------------------------------------------------------------------------ 283 284 class CredentialsDialog(gtk.Dialog): 285 """A dialog window to ask for a user name and a password.""" 286 def __init__(self, gui, userName, password, 287 titleLabel, cancelButtonLabel, okButtonLabel, 288 userNameLabel, userNameTooltip, 289 passwordLabel, passwordTooltip, 290 infoText = None, 291 rememberPassword = None, 292 rememberLabel = None, rememberTooltip = None): 293 """Construct the dialog.""" 294 super(CredentialsDialog, self).__init__(WINDOW_TITLE_BASE + " - " + 295 titleLabel, 296 gui.mainWindow, 297 DIALOG_MODAL) 298 self.add_button(cancelButtonLabel, RESPONSETYPE_CANCEL) 299 self.add_button(okButtonLabel, RESPONSETYPE_OK) 300 301 contentArea = self.get_content_area() 302 303 contentAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 304 xscale = 0.0, yscale = 0.0) 305 contentAlignment.set_padding(padding_top = 4, padding_bottom = 16, 306 padding_left = 8, padding_right = 8) 307 308 contentArea.pack_start(contentAlignment, False, False, 0) 309 310 contentVBox = gtk.VBox() 311 contentAlignment.add(contentVBox) 312 313 if infoText is not None: 314 label = gtk.Label(infoText) 315 label.set_alignment(0.0, 0.0) 316 317 contentVBox.pack_start(label, False, False, 0) 318 319 tableAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 320 xscale = 0.0, yscale = 0.0) 321 tableAlignment.set_padding(padding_top = 24, padding_bottom = 0, 322 padding_left = 0, padding_right = 0) 323 324 table = gtk.Table(3, 2) 325 table.set_row_spacings(4) 326 table.set_col_spacings(16) 327 table.set_homogeneous(False) 328 329 tableAlignment.add(table) 330 contentVBox.pack_start(tableAlignment, True, True, 0) 331 332 label = gtk.Label(userNameLabel) 333 label.set_use_underline(True) 334 label.set_alignment(0.0, 0.5) 335 table.attach(label, 0, 1, 0, 1) 336 337 self._userName = gtk.Entry() 338 self._userName.set_width_chars(16) 339 # FIXME: enabled the OK button only when there is something in thr 340 # user name and password fields 341 #self._userName.connect("changed", 342 # lambda button: self._updateForwardButton()) 343 self._userName.set_tooltip_text(userNameTooltip) 344 self._userName.set_text(userName) 345 table.attach(self._userName, 1, 2, 0, 1) 346 label.set_mnemonic_widget(self._userName) 347 348 label = gtk.Label(passwordLabel) 349 label.set_use_underline(True) 350 label.set_alignment(0.0, 0.5) 351 table.attach(label, 0, 1, 1, 2) 352 353 self._password = gtk.Entry() 354 self._password.set_visibility(False) 355 #self._password.connect("changed", 356 # lambda button: self._updateForwardButton()) 357 self._password.set_tooltip_text(passwordTooltip) 358 self._password.set_text(password) 359 table.attach(self._password, 1, 2, 1, 2) 360 label.set_mnemonic_widget(self._password) 361 362 if rememberPassword is not None: 363 self._rememberButton = gtk.CheckButton(rememberLabel) 364 self._rememberButton.set_use_underline(True) 365 self._rememberButton.set_tooltip_text(rememberTooltip) 366 self._rememberButton.set_active(rememberPassword) 367 table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8) 368 else: 369 self._rememberButton = None 370 371 @property 372 def userName(self): 373 """Get the user name entered.""" 374 return self._userName.get_text() 375 376 @property 377 def password(self): 378 """Get the password entered.""" 379 return self._password.get_text() 380 381 @property 382 def rememberPassword(self): 383 """Get whether the password is to be remembered.""" 384 return None if self._rememberButton is None \ 385 else self._rememberButton.get_active() 386 387 def run(self): 388 """Run the dialog.""" 389 self.show_all() 390 391 response = super(CredentialsDialog, self).run() 392 393 self.hide() 394 395 return response 281 396 282 397 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.