2 Unix SMB/CIFS implementation.
4 Copyright (C) Jelmer Vernooij 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "gtk/common/gtk-smb.h"
24 static const char *gtk_get_userpassword(struct cli_credentials *credentials)
29 GtkWidget *dialog_vbox1;
32 GtkWidget *entry_password;
33 GtkWidget *dialog_action_area1;
34 GtkWidget *cancelbutton1;
37 dialog = gtk_dialog_new ();
38 gtk_window_set_title (GTK_WINDOW (dialog), "Enter Password");
39 gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
40 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
42 dialog_vbox1 = GTK_DIALOG (dialog)->vbox;
44 hbox = gtk_hbox_new (FALSE, 0);
45 gtk_box_pack_start (GTK_BOX (dialog_vbox1), hbox, TRUE, TRUE, 0);
47 prompt = talloc_asprintf(NULL, "Password for [%s\\%s]:",
48 cli_credentials_get_domain(credentials),
49 cli_credentials_get_username(credentials));
51 label = gtk_label_new (prompt);
53 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
55 entry_password = gtk_entry_new ();
56 gtk_box_pack_start (GTK_BOX (hbox), entry_password, TRUE, TRUE, 0);
57 gtk_entry_set_visibility (GTK_ENTRY (entry_password), FALSE);
58 gtk_entry_set_activates_default (GTK_ENTRY (entry_password), TRUE);
60 dialog_action_area1 = GTK_DIALOG (dialog)->action_area;
61 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
63 cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
64 gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancelbutton1, GTK_RESPONSE_CANCEL);
65 GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
67 okbutton1 = gtk_button_new_from_stock ("gtk-ok");
68 gtk_dialog_add_action_widget (GTK_DIALOG (dialog), okbutton1, GTK_RESPONSE_OK);
69 GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
71 gtk_widget_show_all (dialog);
73 switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
75 ret = talloc_strdup(credentials, gtk_entry_get_text(GTK_ENTRY(entry_password)));
82 gtk_widget_destroy (dialog);
89 void cli_credentials_set_gtk_callbacks(struct cli_credentials *cred)
91 if (cred->password_obtained <= CRED_CALLBACK) {
92 cred->password_cb = gtk_get_userpassword;
93 cred->password_obtained = CRED_CALLBACK;