diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-10-28 16:51:52 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-10-28 16:51:52 +0100 |
| commit | a67cd9193a6ac04d34c92c1a817fb0f5e44af30f (patch) | |
| tree | 888227edebb4844efb01cd70bcbfc459b09d2a56 /UGnome.pas | |
| parent | 4234ca950044c27a1b2fcc92f45d816ef217487f (diff) | |
| download | tuxcmd-a67cd9193a6ac04d34c92c1a817fb0f5e44af30f.tar.xz | |
Password callback support from all VFS modulesv0.6.54
Cleanup, remove unused dialogs
Diffstat (limited to 'UGnome.pas')
| -rw-r--r-- | UGnome.pas | 36 |
1 files changed, 31 insertions, 5 deletions
@@ -157,6 +157,7 @@ function HandleVFSAskPasswordCallback(DialogParent: PGtkWidget; const AMessage: PChar; const default_user: PChar; const default_domain: PChar; + const default_password: PChar; flags: TVFSAskPasswordFlags; username: PPChar; password: PPChar; @@ -1234,7 +1235,7 @@ procedure HandleVFSAskQuestionCallback(DialogParent: PGtkWidget; var dialog: PGtkWidget; secondary: PChar; primary: PChar; - count, len: integer; + count, len, res: integer; begin len := 0; secondary := nil; @@ -1257,6 +1258,7 @@ begin if primary <> nil then g_free (primary); // gtk_window_set_title (PGtkWindow(dialog), 'VFS Question'); + gtk_window_set_title (PGtkWindow(dialog), ''); // First count the items in the list then add the buttons in reverse order while (TOpenPCharArray(choices)[len] <> nil) @@ -1265,7 +1267,8 @@ begin for count := len - 1 downto 0 do gtk_dialog_add_button (PGtkDialog(dialog), TOpenPCharArray(choices)[count], count); - choice^ := gtk_dialog_run(PGtkDialog(Dialog)); + res := gtk_dialog_run (PGtkDialog(Dialog)); + if choice <> nil then choice^ := res; gtk_widget_destroy (PGtkWidget(Dialog)); end; @@ -1289,7 +1292,7 @@ begin end; end; -function pw_dialog_input_is_valid (priv: PVFSAskPasswordCallbackPriv): boolean; +function pw_dialog_input_is_valid(priv: PVFSAskPasswordCallbackPriv): boolean; begin Result := entry_has_input(priv^.username_entry) and entry_has_input(priv^.domain_entry) and @@ -1313,7 +1316,7 @@ begin gtk_dialog_set_response_sensitive(GTK_DIALOG (priv^.dialog), GTK_RESPONSE_OK, is_valid); end; -procedure pw_dialog_cycle_focus (widget: PGtkWidget; priv: PVFSAskPasswordCallbackPriv); cdecl; +procedure pw_dialog_cycle_focus(widget: PGtkWidget; priv: PVFSAskPasswordCallbackPriv); cdecl; var next_widget: PGtkWidget; begin next_widget := nil; @@ -1327,6 +1330,12 @@ begin then gtk_window_activate_default(GTK_WINDOW(priv^.dialog)); end; +procedure unmask_checkbox_toggled(togglebutton: PGtkToggleButton; priv: PVFSAskPasswordCallbackPriv); cdecl; +var active: gboolean; +begin + active := gtk_toggle_button_get_active(togglebutton); + if priv^.password_entry <> nil then gtk_entry_set_visibility(priv^.password_entry, active); +end; // The following code has been stolen from gtkmountoperation.c // Copyright (C) Christian Kellner <gicmo@gnome.org> @@ -1334,6 +1343,7 @@ function HandleVFSAskPasswordCallback(DialogParent: PGtkWidget; const AMessage: PChar; const default_user: PChar; const default_domain: PChar; + const default_password: PChar; flags: TVFSAskPasswordFlags; username: PPChar; password: PPChar; @@ -1370,6 +1380,7 @@ var widget: PGtkWidget; remember_box: PGtkWidget; priv: TVFSAskPasswordCallbackPriv; s: PChar; + unmask_checkbox: PGtkWidget; begin FillChar(priv, sizeof(priv), 0); radio_forget := nil; @@ -1380,6 +1391,7 @@ begin priv.dialog := PGtkDialog(widget); window := PGtkWindow(widget); // gtk_window_set_title (window, 'VFS Question'); + gtk_window_set_title (window, ''); // Set the dialog up with HIG properties gtk_dialog_set_has_separator (priv.dialog, False); @@ -1391,9 +1403,13 @@ begin gtk_window_set_resizable (window, False); // gtk_window_set_icon_name (window, 'gtk-dialog-authentication'); + if (flags and VFS_ASK_PASSWORD_ARCHIVE_MODE) = VFS_ASK_PASSWORD_ARCHIVE_MODE + then s := GTK_STOCK_OK + else s := PChar(LANGConnMgr_ConnectButton); + gtk_dialog_add_buttons (priv.dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - PChar(LANGConnMgr_ConnectButton), GTK_RESPONSE_OK, + s, GTK_RESPONSE_OK, nil); gtk_dialog_set_default_response (priv.dialog, GTK_RESPONSE_OK); @@ -1463,10 +1479,19 @@ begin end; if (flags and VFS_ASK_PASSWORD_NEED_PASSWORD) = VFS_ASK_PASSWORD_NEED_PASSWORD then begin priv.password_entry := table_add_entry (table, rows, '_Password:', nil, @priv); + if (default_password <> nil) and (strlen(default_password) > 0) then + gtk_entry_set_text(priv.password_entry, default_password); // Inc(Rows); gtk_entry_set_visibility (GTK_ENTRY (priv.password_entry), FALSE); end; + if (flags and VFS_ASK_PASSWORD_ARCHIVE_MODE) = VFS_ASK_PASSWORD_ARCHIVE_MODE then begin + unmask_checkbox := gtk_check_button_new_with_mnemonic (PChar(LANGFSetPassword_ShowPasswordCheckButton)); + g_object_set(G_OBJECT(unmask_checkbox), 'can-focus', 0, nil); + gtk_box_pack_start (GTK_BOX (vbox), unmask_checkbox, FALSE, FALSE, 0); + g_signal_connect (unmask_checkbox, 'toggled', G_CALLBACK (@unmask_checkbox_toggled), @priv); + end; + if ((flags and VFS_ASK_PASSWORD_SAVING_SUPPORTED) = VFS_ASK_PASSWORD_SAVING_SUPPORTED) or ((flags and VFS_ASK_PASSWORD_SAVE_INTERNAL) = VFS_ASK_PASSWORD_SAVE_INTERNAL) then begin @@ -1515,6 +1540,7 @@ begin if gtk_toggle_button_get_active(PGtkToggleButton(radio_remember)) then password_save^ := VFS_PASSWORD_SAVE_PERMANENTLY; end; end; + gtk_widget_destroy (PGtkWidget(priv.dialog)); end; |
