Index: gnome-keyring-manager.c =================================================================== RCS file: /cvs/gnome/gnome-keyring-manager/src/gnome-keyring-manager.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 gnome-keyring-manager.c --- gnome-keyring-manager.c 26 Apr 2004 11:27:00 -0000 1.1.1.1 +++ gnome-keyring-manager.c 26 Apr 2004 15:40:51 -0000 @@ -284,6 +284,18 @@ gnome_keyring_get_default_keyring (get_default_keyring_callback, tree_view, NULL); } +static void +create_keyring_callback (GnomeKeyringResult result, + GList *list, + gpointer data) +{ + if (result != GNOME_KEYRING_RESULT_OK) + { + complain_about_gnome_keyring_bad_result (GTK_WINDOW (data), result); + return; + } +} + static GtkListStore* init_tree (GtkTreeView *tree_view) { @@ -345,6 +357,66 @@ gtk_main_quit (); } +static gboolean +button_new_keyring_callback (GtkWidget *widget, + gpointer data) +{ + gint result; + GtkWidget *dialog; + GtkWidget *entry; + GtkWidget *frame; + gchar *keyring_name; + + dialog = gtk_dialog_new_with_buttons (_("Create New Keyring"), + GTK_WINDOW (data), + GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + NULL); + frame = gtk_frame_new (_("New keyring name")); + entry = gtk_entry_new (); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + frame, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (frame), + entry); + + gtk_widget_show (frame); + gtk_widget_show (entry); + + result = gtk_dialog_run (GTK_DIALOG (dialog)); + + switch (result) + { + case GTK_RESPONSE_ACCEPT: + g_printf ("accepted\n"); + break; + case GTK_RESPONSE_REJECT: + gtk_widget_destroy (dialog); + return TRUE; + break; + default: + gtk_widget_destroy (dialog); + return TRUE; + } + + keyring_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); + + if (keyring_name != NULL) + { + gnome_keyring_create (keyring_name, NULL, + create_keyring_callback, + data, + NULL); + } + + gtk_widget_destroy (dialog); + g_free (keyring_name); + return TRUE; +} + static void about_action_callback (GtkAction *action G_GNUC_UNUSED, GtkWindow *window) @@ -491,6 +563,7 @@ vbuttonbox = gtk_vbutton_box_new (); gtk_box_pack_start (GTK_BOX (vbox), vbuttonbox, TRUE, FALSE, 0); button = gtk_button_new_from_stock (GTK_STOCK_NEW); + g_signal_connect (button, "clicked", G_CALLBACK(button_new_keyring_callback), window); gtk_container_add (GTK_CONTAINER (vbuttonbox), button); init_tree (GTK_TREE_VIEW (tree_view));