diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-07-11 10:46:54 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-07-11 10:46:54 +0000 |
commit | ba0e6fd383b6a527059aa90e4402187c1fc2bef0 (patch) | |
tree | 144347443879fecf1829adf247742edbaf511ac4 /test | |
parent | 8ad7134e8c130567d3331162302ab1c70d56cd5f (diff) | |
download | nautilus-ba0e6fd383b6a527059aa90e4402187c1fc2bef0.tar.gz |
Many cleanups and improvements. Use the GnomeDialog run_and_close call
* libnautilus-extensions/nautilus-password-dialog.c:
(nautilus_password_dialog_initialize_class),
(nautilus_password_dialog_initialize),
(nautilus_password_dialog_destroy), (dialog_show_callback),
(dialog_close_callback), (caption_table_activate_callback),
(nautilus_password_dialog_new),
(nautilus_password_dialog_run_and_block),
(nautilus_password_dialog_set_username),
(nautilus_password_dialog_set_password),
(nautilus_password_dialog_set_readonly_username),
(nautilus_password_dialog_get_username),
(nautilus_password_dialog_get_password),
(nautilus_password_dialog_get_remember),
(nautilus_password_dialog_set_remember),
(nautilus_password_dialog_set_remember_label_text):
* libnautilus-extensions/nautilus-password-dialog.h:
Many cleanups and improvements. Use the GnomeDialog run_and_close
call instead of our own event loop hack. Removed many unneeded
callbacks and details member variables. Add checks for all
callbacks. Add support for remembering the password.
* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-password-dialog.c:
(authenticate_boink_callback), (exit_callback), (main):
Add a new test for the password dialog.
* test/test-nautilus-widgets.c: (main),
(text_caption_changed_callback):
Removed the old password dialog test.
Diffstat (limited to 'test')
-rw-r--r-- | test/.cvsignore | 6 | ||||
-rw-r--r-- | test/test-nautilus-password-dialog.c | 97 | ||||
-rw-r--r-- | test/test-nautilus-widgets.c | 57 |
3 files changed, 100 insertions, 60 deletions
diff --git a/test/.cvsignore b/test/.cvsignore index f662c0ba1..a24254cf0 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -4,9 +4,9 @@ *.lo Makefile Makefile.in +test-nautilus-graphic test-nautilus-mime-actions test-nautilus-mime-actions-set -test-nautilus-widgets +test-nautilus-password-dialog test-nautilus-preferences -test-nautilus-graphic - +test-nautilus-widgets diff --git a/test/test-nautilus-password-dialog.c b/test/test-nautilus-password-dialog.c new file mode 100644 index 000000000..0ff5c83c2 --- /dev/null +++ b/test/test-nautilus-password-dialog.c @@ -0,0 +1,97 @@ + +#include <config.h> + +#include <libnautilus-extensions/nautilus-password-dialog.h> +#include <gnome.h> + +static GtkWidget *password_dialog = NULL; + +static void +authenticate_boink_callback (GtkWidget *button, gpointer user_data) +{ + gboolean result; + char *username; + char *password; + gboolean remember; + + if (password_dialog == NULL) { + password_dialog = nautilus_password_dialog_new ("Authenticate Me", + "foouser", + "sekret", + TRUE); + + nautilus_password_dialog_set_remember_label_text (NAUTILUS_PASSWORD_DIALOG (password_dialog), + "Remember foouser's password"); + } + + result = nautilus_password_dialog_run_and_block (NAUTILUS_PASSWORD_DIALOG (password_dialog)); + + username = nautilus_password_dialog_get_username (NAUTILUS_PASSWORD_DIALOG (password_dialog)); + password = nautilus_password_dialog_get_password (NAUTILUS_PASSWORD_DIALOG (password_dialog)); + remember = nautilus_password_dialog_get_remember (NAUTILUS_PASSWORD_DIALOG (password_dialog)); + + g_assert (username != NULL); + g_assert (password != NULL); + + if (result) { + g_print ("authentication submitted: username='%s' , password='%s' , remember=%s\n", + username, + password, + remember ? "TRUE" : "FALSE"); + } + else { + g_print ("authentication cancelled:\n"); + } + + g_free (username); + g_free (password); +} + +static void +exit_callback (GtkWidget *button, gpointer user_data) +{ + if (password_dialog != NULL) { + gtk_widget_destroy (password_dialog); + } + + gtk_main_quit (); +} + +int +main (int argc, char * argv[]) +{ + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *authenticate_button; + GtkWidget *exit_button; + + gnome_init ("foo", "bar", argc, argv); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width (GTK_CONTAINER (window), 4); + + vbox = gtk_vbox_new (TRUE, 0); + gtk_container_add (GTK_CONTAINER (window), vbox); + + authenticate_button = gtk_button_new_with_label ("Boink me to authenticate"); + exit_button = gtk_button_new_with_label ("Exit"); + + gtk_signal_connect (GTK_OBJECT (authenticate_button), + "clicked", + GTK_SIGNAL_FUNC (authenticate_boink_callback), + (gpointer) NULL); + + gtk_signal_connect (GTK_OBJECT (exit_button), + "clicked", + GTK_SIGNAL_FUNC (exit_callback), + (gpointer) NULL); + + gtk_box_pack_start (GTK_BOX (vbox), authenticate_button, TRUE, TRUE, 4); + gtk_box_pack_end (GTK_BOX (vbox), exit_button, TRUE, TRUE, 0); + + gtk_widget_show_all (window); + + gtk_main (); + + return 0; +} diff --git a/test/test-nautilus-widgets.c b/test/test-nautilus-widgets.c index 9b462390a..6f5ed6b23 100644 --- a/test/test-nautilus-widgets.c +++ b/test/test-nautilus-widgets.c @@ -2,7 +2,6 @@ #include <config.h> #include <libnautilus-extensions/nautilus-caption-table.h> -#include <libnautilus-extensions/nautilus-password-dialog.h> #include <libnautilus-extensions/nautilus-radio-button-group.h> #include <libnautilus-extensions/nautilus-string-picker.h> #include <libnautilus-extensions/nautilus-text-caption.h> @@ -11,15 +10,12 @@ static void test_radio_group (void); static void test_caption_table (void); -static void test_password_dialog (void); static void test_string_picker (void); static void test_text_caption (void); /* Callbacks */ static void test_radio_changed_callback (GtkWidget *button_group, gpointer user_data); -static void test_authenticate_boink_callback (GtkWidget *button, - gpointer user_data); static void string_picker_changed_callback (GtkWidget *string_picker, gpointer user_data); static void text_caption_changed_callback (GtkWidget *text_caption, @@ -35,7 +31,6 @@ main (int argc, char * argv[]) test_radio_group (); test_caption_table (); - test_password_dialog (); test_string_picker (); test_text_caption (); @@ -183,36 +178,6 @@ test_text_caption (void) } static void -test_authenticate_boink_callback (GtkWidget *button, gpointer user_data) -{ - GtkWidget *dialog; - gboolean rv; - char *username; - char *password; - - dialog = nautilus_password_dialog_new ("Authenticate Me", - "foouser", - "sekret", - FALSE); - - rv = nautilus_password_dialog_run_and_block (NAUTILUS_PASSWORD_DIALOG (dialog)); - - username = nautilus_password_dialog_get_username (NAUTILUS_PASSWORD_DIALOG (dialog)); - password = nautilus_password_dialog_get_password (NAUTILUS_PASSWORD_DIALOG (dialog)); - - g_assert (username != NULL); - g_assert (password != NULL); - - g_print ("test_authenticate_boink_callback (rv=%d , username='%s' , password='%s')\n", - rv, - username, - password); - - g_free (username); - g_free (password); -} - -static void string_picker_changed_callback (GtkWidget *string_picker, gpointer user_data) { char *text; @@ -243,28 +208,6 @@ text_caption_changed_callback (GtkWidget *text_caption, gpointer user_data) } static void -test_password_dialog (void) -{ - GtkWidget * window; - GtkWidget * button; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - button = gtk_button_new_with_label ("Boink me to authenticate"); - - gtk_signal_connect (GTK_OBJECT (button), - "clicked", - GTK_SIGNAL_FUNC (test_authenticate_boink_callback), - (gpointer) NULL); - - gtk_container_add (GTK_CONTAINER (window), button); - - gtk_widget_show (button); - - gtk_widget_show (window); -} - -static void test_radio_changed_callback (GtkWidget *buttons, gpointer user_data) { gint i; |