|
GnuCash 2.4.99
|
00001 /********************************************************************\ 00002 * dialog-userpass.c -- dialog for username/password entry * 00003 * Copyright (C) 2001 Gnumatic, Inc. * 00004 * Author: Dave Peticolas <dave@krondo.com> * 00005 * * 00006 * This program is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU General Public License as * 00008 * published by the Free Software Foundation; either version 2 of * 00009 * the License, or (at your option) any later version. * 00010 * * 00011 * This program is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License* 00017 * along with this program; if not, contact: * 00018 * * 00019 * Free Software Foundation Voice: +1-617-542-5942 * 00020 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00021 * Boston, MA 02110-1301, USA gnu@gnu.org * 00022 \********************************************************************/ 00023 00024 #include "config.h" 00025 #include <gtk/gtk.h> 00026 00027 #include "dialog-utils.h" 00028 #include "gnc-ui.h" 00029 00030 00031 gboolean 00032 gnc_get_username_password (GtkWidget *parent, 00033 const char *heading, 00034 const char *initial_username, 00035 const char *initial_password, 00036 char **username, 00037 char **password) 00038 { 00039 GtkWidget *dialog; 00040 GtkWidget *heading_label; 00041 GtkWidget *username_entry; 00042 GtkWidget *password_entry; 00043 GtkBuilder *builder; 00044 gint result; 00045 00046 g_return_val_if_fail (username != NULL, FALSE); 00047 g_return_val_if_fail (password != NULL, FALSE); 00048 00049 builder = gtk_builder_new(); 00050 gnc_builder_add_from_file (builder, "dialog-userpass.glade", "Username Password Dialog"); 00051 00052 dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Username Password Dialog")); 00053 00054 if (parent) 00055 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); 00056 00057 heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label")); 00058 username_entry = GTK_WIDGET(gtk_builder_get_object (builder, "username_entry")); 00059 password_entry = GTK_WIDGET(gtk_builder_get_object (builder, "password_entry")); 00060 00061 if (heading) 00062 gtk_label_set_text (GTK_LABEL (heading_label), heading); 00063 00064 if (initial_username) 00065 gtk_entry_set_text (GTK_ENTRY (username_entry), initial_username); 00066 gtk_editable_select_region (GTK_EDITABLE (username_entry), 0, -1); 00067 00068 if (initial_password) 00069 gtk_entry_set_text (GTK_ENTRY (password_entry), initial_password); 00070 00071 result = gtk_dialog_run(GTK_DIALOG (dialog)); 00072 gtk_widget_hide(dialog); 00073 00074 if (result == GTK_RESPONSE_OK) 00075 { 00076 *username = gtk_editable_get_chars (GTK_EDITABLE (username_entry), 0, -1); 00077 *password = gtk_editable_get_chars (GTK_EDITABLE (password_entry), 0, -1); 00078 00079 gtk_widget_destroy(dialog); 00080 return TRUE; 00081 } 00082 00083 *username = NULL; 00084 *password = NULL; 00085 00086 g_object_unref(G_OBJECT(builder)); 00087 00088 gtk_widget_destroy(dialog); 00089 return FALSE; 00090 }
1.7.4