Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F36622873
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
50 KB
Subscribers
None
View Options
diff --git a/src/Makefile.am b/src/Makefile.am
index 8033dee..726900d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,111 +1,110 @@
## Process this file with automake to produce Makefile.in
logo = gpa_logo.ppm
pkgdata_DATA = $(logo)
EXTRA_DIST = $(logo) gpa.ico gpa-resource.rc
if HAVE_W32_SYSTEM
.rc.o:
$(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@
gpa_res_ldflag = -Wl,gpa-resource.o
gpa_deps = gpa-resource.o
gpa_w32_sources = w32reg.h w32reg.c w32-afunix.h w32-afunix.c
else
gpa_res_ldflag =
gpa_deps =
gpa_w32_sources =
endif
bin_PROGRAMS = gpa
noinst_PROGRAMS = dndtest
AM_CPPFLAGS = -I$(top_srcdir)/intl -I$(top_srcdir)/pixmaps
AM_CFLAGS = $(GPGME_CFLAGS) $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) \
$(GTK_CFLAGS)
LDADD = $(GPGME_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(GTK_LIBS) $(LIBINTL) $(NETLIBS)
gpa_LDFLAGS = $(gpa_res_ldflag)
gpa_DEPENDENCIES = $(gpa_deps)
gpa_SOURCES = get-path.h get-path.c \
gpa.c gpa.h i18n.h options.h \
gpawindowkeeper.c gpawindowkeeper.h \
gtktools.c gtktools.h \
helpmenu.c helpmenu.h \
icons.c icons.h \
gpawidgets.c gpawidgets.h \
fileman.c fileman.h \
clipboard.h clipboard.c \
filesigndlg.c filesigndlg.h \
encryptdlg.c encryptdlg.h \
verifydlg.c verifydlg.h \
recipientdlg.c recipientdlg.h \
selectkeydlg.c selectkeydlg.h \
keyring.c keyring.h \
ownertrustdlg.c ownertrustdlg.h \
keysigndlg.c keysigndlg.h \
keygendlg.c keygendlg.h \
keygenwizard.c keygenwizard.h \
qdchkpwd.c qdchkpwd.h \
keyeditdlg.c keyeditdlg.h \
expirydlg.c expirydlg.h \
keydeletedlg.c keydeletedlg.h \
keylist.c keylist.h \
siglist.c siglist.h \
gpasubkeylist.c gpasubkeylist.h \
- gpawizard.c gpawizard.h \
gpapastrings.c gpapastrings.h\
gpl-text.c gpl-text.h \
keyserver.c keyserver.h \
hidewnd.c hidewnd.h \
keytable.c keytable.h \
gpgmetools.h gpgmetools.c \
gpgmeedit.h gpgmeedit.c \
server_access.h server_access.c \
settingsdlg.h settingsdlg.c \
passwddlg.h passwddlg.c \
gpacontext.h gpacontext.c \
gpaprogressdlg.h gpaprogressdlg.c \
gpaprogressbar.h gpaprogressbar.c \
gparecvkeydlg.h gparecvkeydlg.c \
gpaoperation.h gpaoperation.c \
gpastreamop.h gpastreamop.c \
gpastreamencryptop.h gpastreamencryptop.c \
gpastreamsignop.h gpastreamsignop.c \
gpafileop.h gpafileop.c \
gpafiledecryptop.h gpafiledecryptop.c \
gpafileencryptop.h gpafileencryptop.c \
gpafilesignop.h gpafilesignop.c \
gpafileverifyop.h gpafileverifyop.c \
gpakeyop.h gpakeyop.c \
gpakeydeleteop.h gpakeydeleteop.c \
gpakeysignop.h gpakeysignop.c \
gpakeytrustop.h gpakeytrustop.c \
gpakeyexpireop.h gpakeyexpireop.c \
gpakeypasswdop.h gpakeypasswdop.c \
gpaexportop.h gpaexportop.c \
gpaexportfileop.h gpaexportfileop.c \
gpaexportclipop.h gpaexportclipop.c \
gpaexportserverop.h gpaexportserverop.c \
gpaimportop.h gpaimportop.c \
gpaimportfileop.h gpaimportfileop.c \
gpaimportclipop.h gpaimportclipop.c \
gpaimportserverop.h gpaimportserverop.c \
gpagenkeyop.h gpagenkeyop.c \
gpagenkeyadvop.h gpagenkeyadvop.c \
gpagenkeysimpleop.h gpagenkeysimpleop.c \
gpabackupop.h gpabackupop.c \
gpakeyselector.h gpakeyselector.c \
server.c \
options.c \
confdialog.h confdialog.c \
utils.c $(gpa_w32_sources)
dndtest_SOURCES = dndtest.c
diff --git a/src/gpawizard.c b/src/gpawizard.c
deleted file mode 100644
index 2b7a60e..0000000
--- a/src/gpawizard.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* keygendlg.c - The GNU Privacy Assistant
- Copyright (C) 2001 G-N-U GmbH.
- Copyright (C) 2008 g10 Code GmbH.
- This file is part of GPA
-
- GPA is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- GPA is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-
-/*
- * A simple general purpose Wizard implementation
- */
-
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
-#include "gpa.h"
-#include "gtktools.h"
-#include "gpawizard.h"
-
-typedef struct
-{
- GtkWidget *notebook;
- GtkWidget *prev_button;
- GtkWidget *next_button;
- GtkWidget *finish_button;
- GtkWidget *cancel_button;
- GtkWidget *close_button;
- GtkAccelGroup *accel_group;
- GPAWizardPageSwitchedFunc page_switched;
- gpointer page_switched_data;
-}
-GPAWizard;
-
-typedef struct
-{
- gboolean is_last;
- GPAWizardAction action;
- gpointer user_data;
-}
-GPAWizardPage;
-
-/* Return the page data associated with the current page of the wizard */
-static GPAWizardPage *
-gpa_wizard_get_current_page (GPAWizard * wizard)
-{
- GtkWidget * page_widget;
- int page_number;
-
- page_number = gtk_notebook_get_current_page (GTK_NOTEBOOK(wizard->notebook));
- if (page_number < 0)
- page_number = 0;
- page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK(wizard->notebook),
- page_number);
- return g_object_get_data (G_OBJECT (page_widget), "gpa_wizard_page");
-}
-
-/* Update the buttons of the wizard depending on the current page */
-void
-gpa_wizard_update_buttons (GtkWidget * widget)
-{
- GPAWizard * wizard = g_object_get_data (G_OBJECT (widget), "user_data");
- GPAWizardPage * page;
- int page_number;
-
- page_number = gtk_notebook_get_current_page (GTK_NOTEBOOK(wizard->notebook));
- if (page_number < 0)
- page_number = 0;
-
- page = gpa_wizard_get_current_page (wizard);
-
- /* Choose whether to show "Next" or "Finish" button based on the data
- * provided */
- if (page->is_last)
- {
- gtk_widget_hide (wizard->next_button);
- gtk_widget_show (wizard->finish_button);
- }
- else
- {
- gtk_widget_show (wizard->next_button);
- gtk_widget_hide (wizard->finish_button);
- }
-
- /* if we're at the last page, assume that whatever the wizard was
- * supposed to do has been achieved. Therefore make both prev and next
- * button insensitive, hide the cancel button and show the close one.
- */
- /* There doesn't seem to be a simple way to get the number of pages in
- * a notebook, so try to get the next page and if that is NULL, we're
- * at the last page.
- */
- if (!gtk_notebook_get_nth_page (GTK_NOTEBOOK (wizard->notebook),
- page_number + 1))
- {
- gtk_widget_set_sensitive (wizard->prev_button, FALSE);
- gtk_widget_set_sensitive (wizard->next_button, FALSE);
- gtk_widget_set_sensitive (wizard->finish_button, FALSE);
- gtk_widget_set_sensitive (wizard->close_button, TRUE);
- gtk_widget_set_sensitive (wizard->cancel_button, TRUE);
- gtk_widget_show (wizard->close_button);
- gtk_widget_hide (wizard->cancel_button);
- }
- else
- {
- gtk_widget_set_sensitive (wizard->prev_button, TRUE);
- gtk_widget_set_sensitive (wizard->next_button, TRUE);
- gtk_widget_set_sensitive (wizard->finish_button, TRUE);
- gtk_widget_set_sensitive (wizard->close_button, TRUE);
- gtk_widget_set_sensitive (wizard->cancel_button, TRUE);
- gtk_widget_hide (wizard->close_button);
- gtk_widget_show (wizard->cancel_button);
- }
-
- /* if we're at the first page, make the prev-button insensitive. */
- if (page_number == 0)
- {
- gtk_widget_set_sensitive (wizard->prev_button, FALSE);
- }
-
- /* FIXME: If we are on the "wait" page, disable all buttons.
- */
- if (gtk_notebook_get_nth_page (GTK_NOTEBOOK (wizard->notebook),
- page_number + 1) &&
- !gtk_notebook_get_nth_page (GTK_NOTEBOOK (wizard->notebook),
- page_number + 2))
- {
- gtk_widget_set_sensitive (wizard->prev_button, FALSE);
- gtk_widget_set_sensitive (wizard->next_button, FALSE);
- gtk_widget_set_sensitive (wizard->finish_button, FALSE);
- gtk_widget_set_sensitive (wizard->close_button, FALSE);
- gtk_widget_set_sensitive (wizard->cancel_button, FALSE);
- }
-}
-
-static void
-gpa_wizard_prev (GtkWidget * button, gpointer data)
-{
- GPAWizard * wizard = data;
- gtk_notebook_prev_page (GTK_NOTEBOOK (wizard->notebook));
-}
-
-static void
-gpa_wizard_next (GtkWidget * button, gpointer data)
-{
- gpa_wizard_next_page ((GtkWidget *)data);
-}
-
-static void
-gpa_wizard_page_switched (GtkWidget *notebook, GtkNotebookPage *page,
- gint page_num, gpointer user_data)
-{
- GtkWidget * page_widget;
- int page_number;
- GtkWidget * focus;
- GtkWidget * main_widget = user_data;
- GPAWizard * wizard = g_object_get_data (G_OBJECT (main_widget), "user_data");
-
- /* Switch-page is emitted also when pages are added to the notebook,
- even when it's not even displayed yet. In that case the page
- number is < 0, so we simply ignore that case and only try to set
- the focus if the page number is >= 0. */
- page_number = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
- if (page_number >= 0)
- {
- gpa_wizard_update_buttons ((GtkWidget *)user_data);
- page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK(notebook),
- page_number);
- focus = g_object_get_data (G_OBJECT (page_widget),
- "gpa_wizard_focus_child");
- if (focus)
- {
- gtk_widget_grab_focus (focus);
- }
-
- /* Call the page switched callback */
- /* FIXME: this should really be a proper GTK signal */
- if (wizard->page_switched)
- {
- wizard->page_switched (page_widget, wizard->page_switched_data);
- }
- }
-}
-
-
-/* Handler for the notebook's destroy signal. Remove the page_switch
- * callback. For whatever reason, the notebook would emit page_switch
- * signals during the destroy which could cause segfaults in the
- * callback */
-static void
-gpa_wizard_notebook_destroy (GtkWidget * widget, gpointer param)
-{
- GPAWizard * wizard = param;
-
- wizard->page_switched = NULL;
- wizard->page_switched_data = NULL;
-}
-
-
-/* Create a new GPA Wizard. */
-GtkWidget *
-gpa_wizard_new (GtkAccelGroup *accel_group,
- GtkSignalFunc close_func, gpointer close_data)
-{
- GtkWidget *vbox;
- GtkWidget *notebook;
- GtkWidget *hbox;
- GtkWidget *button_box;
- GtkWidget *button;
-
- GPAWizard *wizard = g_malloc (sizeof (*wizard));
- wizard->accel_group = accel_group;
- wizard->page_switched = NULL;
- wizard->page_switched_data = NULL;
-
- vbox = gtk_vbox_new (FALSE, 3);
- g_object_set_data_full (G_OBJECT (vbox), "user_data", wizard, g_free);
-
- notebook = gtk_notebook_new ();
- wizard->notebook = notebook;
- gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
- /* use *_connect_after so that the callback is called after the
- current page number has been updated so that
- gpa_wizard_update_buttons uses the new page. */
- g_signal_connect_after (G_OBJECT (notebook), "switch-page",
- G_CALLBACK (gpa_wizard_page_switched), vbox);
- g_signal_connect (G_OBJECT (notebook), "destroy",
- G_CALLBACK (gpa_wizard_notebook_destroy), wizard);
-
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-
- button_box = gtk_hbutton_box_new ();
- gtk_box_pack_start (GTK_BOX (hbox), button_box, TRUE, TRUE, 5);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END);
- gtk_box_set_spacing (GTK_BOX (button_box), 10);
-
- button = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
- wizard->prev_button = button;
- gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (gpa_wizard_prev), wizard);
-
- button = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
- wizard->next_button = button;
- gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (gpa_wizard_next), vbox);
-
- button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- wizard->finish_button = button;
- gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (gpa_wizard_next), vbox);
-
- button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
- wizard->close_button = button;
- gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 5);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (close_func), close_data);
- gtk_widget_add_accelerator (button, "clicked", accel_group, GDK_Escape,
- 0, 0);
-
- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- wizard->cancel_button = button;
- gtk_box_pack_start (GTK_BOX (button_box), button, FALSE, FALSE, 5);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (close_func), close_data);
- gtk_widget_add_accelerator (button, "clicked", accel_group, GDK_Escape,
- 0, 0);
-
- return vbox;
-}
-
-/* Append page_widget as a new page to the wizard. prev_label and
- * next_label are the labels to be used for the prev- and next button.
- * If they're NULL, the default values "Prev" and "Next" will be used.
- * action is a callback to be called when the user clicks the next
- * button. user_data is passed through to the callback. If the callback
- * returns FALSE, the wizard does not switch to the next page, other
- * wise it does. If action is NULL, assume a noop action that returns
- * TRUE.
- */
-void
-gpa_wizard_append_page (GtkWidget * widget, GtkWidget * page_widget,
- gboolean is_last,
- GPAWizardAction action, gpointer user_data)
-{
- GPAWizard * wizard = g_object_get_data (G_OBJECT (widget), "user_data");
- GPAWizardPage * page = g_malloc (sizeof (*page));
-
- page->is_last = is_last;
- page->action = action;
- page->user_data = user_data;
-
- g_object_set_data_full (G_OBJECT (page_widget), "gpa_wizard_page",
- page, g_free);
- gtk_notebook_append_page (GTK_NOTEBOOK (wizard->notebook), page_widget,
- NULL);
-}
-
-
-/* Turn to the next page of the wizard and run the page action.
- */
-void
-gpa_wizard_next_page (GtkWidget * widget)
-{
- GPAWizard *wizard = g_object_get_data (G_OBJECT (widget), "user_data");
- GPAWizardPage *page;
-
- page = gpa_wizard_get_current_page (wizard);
- if (page->action)
- {
- if (!page->action(page->user_data))
- return;
- }
- gtk_notebook_next_page (GTK_NOTEBOOK (wizard->notebook));
-}
-
-
-/* Turn to the next page of the wizard and don't run the page action.
- This is used e.g. in keygenwizard.c by the action callback that is
- invoked by the finish button to display a "wait" message. */
-void
-gpa_wizard_next_page_no_action (GtkWidget *widget)
-{
- GPAWizard *wizard = g_object_get_data (G_OBJECT (widget), "user_data");
- gtk_notebook_next_page (GTK_NOTEBOOK (wizard->notebook));
-}
-
-/***/
-void gpa_wizard_set_page_switched (GtkWidget *widget,
- GPAWizardPageSwitchedFunc page_switched,
- gpointer param)
-{
- GPAWizard *wizard = g_object_get_data (G_OBJECT (widget), "user_data");
- wizard->page_switched = page_switched;
- wizard->page_switched_data = param;
-}
diff --git a/src/gpawizard.h b/src/gpawizard.h
deleted file mode 100644
index a8908e3..0000000
--- a/src/gpawizard.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* gpawizard.h - The GNU Privacy Assistant
- * Copyright (C) 2000, 2001 G-N-U GmbH.
- *
- * This file is part of GPA
- *
- * GPA is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GPA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef GPAWIZARD_H
-#define GPAWIZARD_H
-
-#include <gtk/gtk.h>
-
-typedef gboolean (*GPAWizardAction)(gpointer user_data);
-
-GtkWidget *gpa_wizard_new (GtkAccelGroup * accel_group,
- GtkSignalFunc close_func, gpointer close_data);
-void gpa_wizard_append_page (GtkWidget * widget, GtkWidget * page_widget,
- gboolean is_last, GPAWizardAction action,
- gpointer user_data);
-
-void gpa_wizard_next_page (GtkWidget * widget);
-
-void gpa_wizard_next_page_no_action (GtkWidget * widget);
-
-typedef void (*GPAWizardPageSwitchedFunc)(GtkWidget * page_widget,
- gpointer param);
-void gpa_wizard_set_page_switched (GtkWidget * widget,
- GPAWizardPageSwitchedFunc,
- gpointer param);
-
-void gpa_wizard_update_buttons (GtkWidget * widget);
-
-#endif /* GPAWIZARD_H */
diff --git a/src/keygenwizard.c b/src/keygenwizard.c
index 8951bae..f50a8c5 100644
--- a/src/keygenwizard.c
+++ b/src/keygenwizard.c
@@ -1,602 +1,665 @@
/* keygendlg.c - The GNU Privacy Assistant
Copyright (C) 2000, 2001 G-N-U GmbH.
Copyright (C) 2008 g10 Code GmbH.
This file is part of GPA
GPA is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
GPA is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/stat.h>
+#include <glib.h>
#include <gtk/gtk.h>
#include <errno.h>
#include <gpgme.h>
+
#include "gpa.h"
#include "gpapastrings.h"
#include "icons.h"
#include "gtktools.h"
#include "gpawidgets.h"
-#include "gpawizard.h"
#include "qdchkpwd.h"
#include "gpgmetools.h"
#include "keygenwizard.h"
-/*
- * The key generation wizard
- *
- * New users should not be overwhelmed by too many options most of which
- * are not easily explained and will only confuse them. To solve that
- * problem we use default values for the algorithm and size of the keys
- * and we use a wizard interface to present the necessary options like
- * user id and password in a step by step manner.
- */
-
+/* The key generation wizard.
+
+ New users should not be overwhelmed by too many options most of which
+ are not easily explained and will only confuse them. To solve that
+ problem we use default values for the algorithm and size of the keys
+ and we use a wizard interface to present the necessary options like
+ user id and password in a step by step manner. */
-/*
- * Helper functions
- */
+/* Helper functions. */
-/* Return a copy of string with leading and trailing whitespace stripped */
+/* Return a copy of string with leading and trailing whitespace
+ stripped. */
static gchar *
-string_strip_dup (gchar * string)
+string_strip_dup (gchar *string)
{
return g_strstrip (g_strdup (string));
}
-/*
- * The wizard itself
- */
-
-
+/* The wizard itself. */
-typedef struct {
+typedef struct
+{
GtkWidget *window;
GtkWidget *wizard;
GtkWidget *name_page;
GtkWidget *email_page;
GtkWidget *passwd_page;
GtkWidget *wait_page;
GtkWidget *final_page;
GtkWidget *backup_page;
GtkWidget *backup_dir_page;
- GtkWidget *image_widget;
- GtkAccelGroup *accel_group;
- GdkPixmap *genkey_pixmap;
- GdkPixmap *backup_pixmap;
-
+
GpaKeyGenWizardGenerateCb generate;
gpointer generate_data;
} GPAKeyGenWizard;
-/* Handler for the activate signals of several entry fields in the
- * wizard. Switch the wizard to the next page. */
-static void
-switch_to_next_page (GtkEditable *editable, gpointer user_data)
-{
- gpa_wizard_next_page (((GPAKeyGenWizard*)user_data)->wizard);
-}
-
-/* internal API */
+/* Internal API. */
static gboolean gpa_keygen_wizard_generate_action (gpointer data);
-/*
- * The user ID pages
- */
+
+/* The user ID pages. */
static GtkWidget *
-gpa_keygen_wizard_simple_page (GPAKeyGenWizard * keygen_wizard,
- const gchar * description_text,
- const gchar * label_text)
+gpa_keygen_wizard_simple_page (GPAKeyGenWizard *keygen_wizard,
+ const gchar *description_text,
+ const gchar *label_text)
{
- GtkWidget * vbox;
- GtkWidget * description;
- GtkWidget * hbox;
- GtkWidget * label;
- GtkWidget * entry;
+ GtkWidget *align;
+ guint pt, pb, pl, pr;
+ GtkWidget *vbox;
+ GtkWidget *description;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *entry;
+
+ align = gtk_alignment_new (0.5, 0.5, 1, 1);
+ gtk_alignment_get_padding (GTK_ALIGNMENT (align), &pt, &pb, &pl, &pr);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (align),
+ pt + 5, pb + 5, pl + 5, pr + 5);
vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (align), vbox);
description = gtk_label_new (description_text);
gtk_box_pack_start (GTK_BOX (vbox), description, TRUE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (description), 0.0, 0.0);
gtk_label_set_line_wrap (GTK_LABEL (description), TRUE);
gtk_label_set_justify (GTK_LABEL (description), GTK_JUSTIFY_LEFT);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
label = gtk_label_new (label_text);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 5);
- g_signal_connect (G_OBJECT (entry), "activate",
- G_CALLBACK (switch_to_next_page), keygen_wizard);
- g_object_set_data (G_OBJECT (vbox), "gpa_keygen_entry", entry);
- g_object_set_data (G_OBJECT (vbox), "gpa_wizard_focus_child", entry);
- return vbox;
+ g_object_set_data (G_OBJECT (align), "gpa_keygen_entry", entry);
+ g_object_set_data (G_OBJECT (align), "gpa_wizard_focus_child", entry);
+
+ return align;
}
+
static gchar *
-gpa_keygen_wizard_simple_get_text (GtkWidget * vbox)
+gpa_keygen_wizard_simple_get_text (GtkWidget *vbox)
{
- GtkWidget * entry;
+ GtkWidget *entry;
entry = g_object_get_data (G_OBJECT (vbox), "gpa_keygen_entry");
return string_strip_dup ((gchar *) gtk_entry_get_text (GTK_ENTRY (entry)));
}
-static GtkWidget *
-gpa_keygen_wizard_name_page (GPAKeyGenWizard * keygen_wizard)
+static void
+gpa_keygen_wizard_simple_grab_focus (GtkWidget *vbox)
{
- return gpa_keygen_wizard_simple_page
- (keygen_wizard,
- _("Please insert your full name."
- "\n\n"
- "Your name will be part of the new key"
- " to make it easier for others to identify"
- " keys."),
- _("Your Name:"));
+ GtkWidget *entry;
+
+ entry = g_object_get_data (G_OBJECT (vbox), "gpa_keygen_entry");
+ gtk_widget_grab_focus (entry);
}
+
static gboolean
-gpa_keygen_wizard_name_validate (gpointer data)
+name_validate_cb (GtkWidget *widget, gpointer data)
{
- GPAKeyGenWizard * keygen_wizard = data;
- gboolean result = TRUE;
- gchar * name = gpa_keygen_wizard_simple_get_text (keygen_wizard->name_page);
+ GPAKeyGenWizard *wizard = data;
+ const gchar *name;
- if (!*name)
- {
- /* The string is empty or consists entirely of whitespace */
- gpa_window_error (_("Please insert your name"), keygen_wizard->window);
- result = FALSE;
- }
+ name = gtk_entry_get_text (GTK_ENTRY (widget));
+ while (*name && g_unichar_isspace (g_utf8_get_char (name)))
+ name = g_utf8_next_char (name);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (wizard->window),
+ wizard->name_page, *name != '\0');
- g_free (name);
- return result;
+ return FALSE;
}
+
static GtkWidget *
-gpa_keygen_wizard_email_page (GPAKeyGenWizard * keygen_wizard)
+keygen_wizard_name_page (GPAKeyGenWizard *wizard)
{
- return gpa_keygen_wizard_simple_page
- (keygen_wizard,
- _("Please insert your email address."
- "\n\n"
- " Your email address will be part of the"
- " new key to make it easier for others to"
- " identify keys."
- " If you have several email addresses, you can add further email"
- " adresses later."),
- _("Your Email Address:"));
+ GtkWidget *widget;
+ GtkWidget *entry;
+
+ widget = gpa_keygen_wizard_simple_page
+ (wizard,
+ _("Please insert your full name.\n\n"
+ "Your name will be part of the new key to make it easier for others"
+ " to identify keys."),
+ _("Your Name:"));
+
+ entry = g_object_get_data (G_OBJECT (widget), "gpa_keygen_entry");
+ g_signal_connect (G_OBJECT (entry), "changed",
+ G_CALLBACK (name_validate_cb), wizard);
+ return widget;
}
static gboolean
-gpa_keygen_wizard_email_validate (gpointer data)
+email_validate_cb (GtkWidget *widget, gpointer data)
{
- GPAKeyGenWizard * keygen_wizard = data;
- gboolean result = TRUE;
- gchar * email;
+ GPAKeyGenWizard *wizard = data;
+ const gchar *email;
+
+ email = gtk_entry_get_text (GTK_ENTRY (widget));
+ while (*email && g_unichar_isspace (g_utf8_get_char (email)))
+ email = g_utf8_next_char (email);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (wizard->window),
+ wizard->email_page, *email != '\0');
- email = gpa_keygen_wizard_simple_get_text (keygen_wizard->email_page);
- if (!*email)
- {
- /* The string is empty or consists entirely of whitespace */
- gpa_window_error (_("Please insert your email address"),
- keygen_wizard->window);
- result = FALSE;
- }
/* FIXME: we should do much more checking. Best would be exactly the
- * same checks gpg does in interactive mode with --gen-key */
+ same checks gpg does in interactive mode with --gen-key. */
- g_free (email);
- return result;
+ return FALSE;
}
-/* Handler for the activate signal of the passphrase entry. Focus the
- * repeat passhrase entry. */
+static GtkWidget *
+keygen_wizard_email_page (GPAKeyGenWizard *wizard)
+{
+ GtkWidget *widget;
+ GtkWidget *entry;
+
+ widget = gpa_keygen_wizard_simple_page
+ (wizard,
+ _("Please insert your email address.\n\n"
+ "Your email address will be part of the new key to make it easier"
+ " for others to identify keys. If you have several email addresses,"
+ " you can add further email adresses later."),
+ _("Your Email Address:"));
+
+ entry = g_object_get_data (G_OBJECT (widget), "gpa_keygen_entry");
+ g_signal_connect (G_OBJECT (entry), "changed",
+ G_CALLBACK (email_validate_cb), wizard);
+ return widget;
+}
+
+
+/* Handler for the activate signal of the passphrase entry. Focus the
+ repeat passhrase entry. */
static void
focus_repeat_passphrase (GtkEditable *editable, gpointer user_data)
{
- gtk_widget_grab_focus ((GtkWidget*)user_data);
+ gtk_widget_grab_focus ((GtkWidget *) user_data);
}
+static gboolean
+passwd_validate_cb (GtkWidget *widget, gpointer data)
+{
+ GPAKeyGenWizard *wizard = data;
+ gboolean result = TRUE;
+ GtkWidget *page;
+ const gchar *passwd;
+ const gchar *passwd_repeat;
+ GtkWidget *entry;
+ GtkWidget *status;
+ char textbuf[50];
+ double quality;
+
+ page = wizard->passwd_page;
+ entry = g_object_get_data (G_OBJECT (page), "gpa_keygen_passwd");
+ passwd = gtk_entry_get_text (GTK_ENTRY (entry));
+ entry = g_object_get_data (G_OBJECT (page), "gpa_keygen_passwd_repeat");
+ passwd_repeat = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (*passwd == '\0' && *passwd_repeat == '\0')
+ {
+ status = g_object_get_data (G_OBJECT (page), "gpa_keygen_passwd_differ");
+ gtk_widget_hide (status);
+
+ status = g_object_get_data (G_OBJECT (page),
+ "gpa_keygen_passwd_strength");
+ gtk_widget_hide (status);
+
+ result = FALSE;
+ }
+ else
+ {
+ status = g_object_get_data (G_OBJECT (page), "gpa_keygen_passwd_differ");
+ if (! strcmp (passwd, passwd_repeat))
+ gtk_widget_hide (status);
+ else
+ {
+ gtk_widget_show (status);
+ result = FALSE;
+ }
+ }
+
+ quality = 0;
+ if (*passwd != '\0')
+ quality = qdchkpwd (passwd);
+ if (quality > 1)
+ quality = 1;
+ status = g_object_get_data (G_OBJECT (page),
+ "gpa_keygen_passwd_strength");
+ if (quality < 0.6)
+ {
+ snprintf (textbuf, sizeof textbuf, "(%d%%)", (int) (quality * 100));
+ gtk_widget_show (status);
+ }
+ else
+ {
+ snprintf (textbuf, sizeof textbuf, "%d%%", (int) (quality * 100));
+ gtk_widget_hide (status);
+ }
+
+ status = g_object_get_data (G_OBJECT (page), "gpa_keygen_quality");
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (status), quality);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (status), textbuf);
+
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (wizard->window),
+ page, result);
+
+ return FALSE;
+}
+
static GtkWidget *
-gpa_keygen_wizard_password_page (GPAKeyGenWizard * keygen_wizard)
+keygen_wizard_passwd_page (GPAKeyGenWizard *wizard)
{
- GtkWidget * vbox;
- GtkWidget * description;
- GtkWidget * table;
- GtkWidget * label;
- GtkWidget * entry, *passwd_entry;
+ GtkWidget *vbox;
+ GtkWidget *description;
+ GtkWidget *status;
+ GtkWidget *table;
+ GtkWidget *align;
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *passwd_entry;
vbox = gtk_vbox_new (FALSE, 0);
description = gtk_label_new
(_("Please choose a passphrase for the new key."));
- gtk_box_pack_start (GTK_BOX (vbox), description, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), description, FALSE, FALSE, 5);
gtk_misc_set_alignment (GTK_MISC (description), 0.0, 0.0);
gtk_label_set_line_wrap (GTK_LABEL (description), TRUE);
gtk_label_set_justify (GTK_LABEL (description), GTK_JUSTIFY_LEFT);
- table = gtk_table_new (2, 2, FALSE);
- gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 5);
- label = gtk_label_new (_("Passphrase: "));
+ status = gtk_label_new (_("In \"Passphrase\" and \"Repeat passphrase\","
+ " you must enter the same passphrase."));
+ gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 5);
+ gtk_misc_set_alignment (GTK_MISC (status), 0.0, 0.0);
+ gtk_label_set_line_wrap (GTK_LABEL (status), TRUE);
+ gtk_label_set_justify (GTK_LABEL (status), GTK_JUSTIFY_LEFT);
+ g_object_set_data (G_OBJECT (vbox), "gpa_keygen_passwd_differ", status);
+
+
+ status = gtk_label_new (_("Warning: The passphrase you have entered is"
+ " not very secure."));
+ gtk_box_pack_start (GTK_BOX (vbox), status, FALSE, FALSE, 5);
+ gtk_misc_set_alignment (GTK_MISC (status), 0.0, 0.0);
+ gtk_label_set_line_wrap (GTK_LABEL (status), TRUE);
+ gtk_label_set_justify (GTK_LABEL (status), GTK_JUSTIFY_LEFT);
+ g_object_set_data (G_OBJECT (vbox), "gpa_keygen_passwd_strength", status);
+
+
+ align = gtk_alignment_new (0, 1, 1, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 5);
+
+ table = gtk_table_new (2, 3, FALSE);
+ gtk_container_add (GTK_CONTAINER (align), table);
+
+ label = gtk_label_new (_("Quality: "));
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
- entry = passwd_entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
+ status = gtk_progress_bar_new ();
+ gtk_table_attach (GTK_TABLE (table), status, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
+ g_object_set_data (G_OBJECT (vbox), "gpa_keygen_quality", status);
+
+ label = gtk_label_new (_("Passphrase: "));
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+
+ entry = gtk_entry_new ();
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
GTK_FILL|GTK_EXPAND, 0, 0, 0);
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
g_object_set_data (G_OBJECT (vbox), "gpa_keygen_passwd", entry);
g_object_set_data (G_OBJECT (vbox), "gpa_wizard_focus_child", entry);
+ passwd_entry = entry;
label = gtk_label_new (_("Repeat Passphrase: "));
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
entry = gtk_entry_new ();
- gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
+ gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
GTK_FILL|GTK_EXPAND, 0, 0, 0);
gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
g_object_set_data (G_OBJECT (vbox), "gpa_keygen_passwd_repeat", entry);
- g_signal_connect (G_OBJECT (entry), "activate",
- G_CALLBACK (switch_to_next_page), keygen_wizard);
+
g_signal_connect (G_OBJECT (passwd_entry), "activate",
- G_CALLBACK (focus_repeat_passphrase), entry);
+ G_CALLBACK (focus_repeat_passphrase), entry);
+
+ g_signal_connect (G_OBJECT (passwd_entry), "changed",
+ G_CALLBACK (passwd_validate_cb), wizard);
+ g_signal_connect (G_OBJECT (entry), "changed",
+ G_CALLBACK (passwd_validate_cb), wizard);
return vbox;
}
+
static gchar *
gpa_keygen_wizard_password_get_password (GtkWidget * vbox)
{
GtkWidget *entry = g_object_get_data (G_OBJECT (vbox), "gpa_keygen_passwd");
return (gchar *) gtk_entry_get_text (GTK_ENTRY (entry));
}
-/* Validate the password in both entries and return TRUE if they're OK,
- * otherwise show a suitable message to the user and return FALSE.
- */
-/* FIXME: We should add some checks for whitespace because leading and
- * trailing whitespace is stripped somewhere in gpapa/gpg and whitespace
- * only passwords are not allowed */
-static gboolean
-gpa_keygen_wizard_password_validate (gpointer data)
-{
- GPAKeyGenWizard *keygen_wizard = data;
- gboolean result = TRUE;
- GtkWidget *vbox = keygen_wizard->passwd_page;
- GtkWidget *entry_passwd = g_object_get_data (G_OBJECT (vbox),
- "gpa_keygen_passwd");
- GtkWidget *entry_repeat = g_object_get_data (G_OBJECT (vbox),
- "gpa_keygen_passwd_repeat");
-
- if (strcmp (gtk_entry_get_text (GTK_ENTRY (entry_passwd)),
- gtk_entry_get_text (GTK_ENTRY (entry_repeat))) != 0)
- {
- gpa_window_error (_("In \"Passphrase\" and \"Repeat passphrase\",\n"
- "you must enter the same passphrase."),
- keygen_wizard->window);
- result = FALSE;
- }
- else if (strlen (gtk_entry_get_text (GTK_ENTRY (entry_passwd))) == 0)
- {
- gpa_window_error (_("You did not enter a passphrase.\n"
- "It is needed to protect your private key."),
- keygen_wizard->window);
- result = FALSE;
- }
- else if (strlen (gtk_entry_get_text (GTK_ENTRY (entry_passwd))) < 10
- || qdchkpwd ((char*)gtk_entry_get_text (GTK_ENTRY (entry_passwd))) < 0.6)
- {
- GtkWidget *dialog;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (keygen_wizard->window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("Warning: You have entered a "
- "passphrase\n"
- "that is obviously not secure.\n\n"
- "Please enter a new passphrase."));
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Enter new passphrase"), GTK_RESPONSE_CANCEL,
- _("Take this one _anyway"), GTK_RESPONSE_OK,
- NULL);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_CANCEL)
- {
- result = FALSE;
- }
- gtk_widget_destroy (dialog);
- }
-
- return result;
-}
-
-/* Backup copies and revocation certificate */
+/* Backup copies and revocation certificate. */
static GtkWidget *
-gpa_keygen_wizard_backup_page (GPAKeyGenWizard * keygen_wizard)
+gpa_keygen_wizard_backup_page (GPAKeyGenWizard *wizard)
{
- GtkWidget * vbox;
- GtkWidget * description;
- GtkWidget * radio;
+ GtkWidget *vbox;
+ GtkWidget *description;
+ GtkWidget *radio;
vbox = gtk_vbox_new (FALSE, 0);
description = gtk_label_new
(_("It is recommended that you create a backup copy of your new key,"
" once it has been generated.\n\n"
"Do you want to create a backup copy?"));
gtk_box_pack_start (GTK_BOX (vbox), description, TRUE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (description), 0.0, 0.0);
gtk_label_set_line_wrap (GTK_LABEL (description), TRUE);
gtk_label_set_justify (GTK_LABEL (description), GTK_JUSTIFY_LEFT);
radio = gtk_radio_button_new_with_mnemonic (NULL, _("Create _backup copy"));
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, TRUE, 5);
g_object_set_data (G_OBJECT (vbox), "gpa_keygen_backup", radio);
radio = gtk_radio_button_new_with_mnemonic_from_widget
(GTK_RADIO_BUTTON (radio), _("Do it _later"));
gtk_box_pack_start (GTK_BOX (vbox), radio, FALSE, TRUE, 5);
return vbox;
}
+
static GtkWidget *
-gpa_keygen_wizard_message_page (const gchar * description_text)
+gpa_keygen_wizard_message_page (const gchar *description_text)
{
- GtkWidget * vbox;
- GtkWidget * description;
+ GtkWidget *vbox;
+ GtkWidget *description;
vbox = gtk_vbox_new (FALSE, 0);
description = gtk_label_new (description_text);
gtk_box_pack_start (GTK_BOX (vbox), description, TRUE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (description), 0.0, 0.0);
gtk_label_set_line_wrap (GTK_LABEL (description), TRUE);
gtk_label_set_justify (GTK_LABEL (description), GTK_JUSTIFY_LEFT);
return vbox;
}
static GtkWidget *
-gpa_keygen_wizard_wait_page (void)
+gpa_keygen_wizard_wait_page (GPAKeyGenWizard *wizard)
{
return gpa_keygen_wizard_message_page
(_("Your key is being generated.\n\n"
"Even on fast computers this may take a while. Please be patient."));
}
static GtkWidget *
-gpa_keygen_wizard_final_page (void)
+gpa_keygen_wizard_final_page (GPAKeyGenWizard * keygen_wizard)
{
return gpa_keygen_wizard_message_page
(_("Congratulations!\n\n"
"You have successfully generated a key."
" The key is indefinitely valid and has a length of 1024 bits."));
}
/* Extract the values the user entered and call gpa_generate_key.
- * Return TRUE if the key was created successfully.
- */
+ Return TRUE if the key was created successfully. */
static gboolean
gpa_keygen_wizard_generate_action (gpointer data)
+//GtkAssistant *assistant, GtkWidget *page, gpointer data)
{
- GPAKeyGenWizard *keygen_wizard = data;
+ GPAKeyGenWizard *wizard = data;
GPAKeyGenParameters params;
gboolean do_backup;
GtkWidget *radio;
memset (¶ms, 0, sizeof params);
- /* Shall we make backups? */
- radio = g_object_get_data (G_OBJECT (keygen_wizard->backup_page),
+ /* Shall we make backups? */
+ radio = g_object_get_data (G_OBJECT (wizard->backup_page),
"gpa_keygen_backup");
do_backup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio));
- /* The User ID */
- params.userID = gpa_keygen_wizard_simple_get_text (keygen_wizard->name_page);
- params.email = gpa_keygen_wizard_simple_get_text (keygen_wizard->email_page);
- params.password = gpa_keygen_wizard_password_get_password (keygen_wizard
- ->passwd_page);
+ /* The User ID. */
+ params.userID = gpa_keygen_wizard_simple_get_text (wizard->name_page);
+ params.email = gpa_keygen_wizard_simple_get_text (wizard->email_page);
+ params.password
+ = gpa_keygen_wizard_password_get_password (wizard->passwd_page);
- /* default values for newbie mode */
+ /* Default values for newbie mode. */
params.algo = GPA_KEYGEN_ALGO_DSA_ELGAMAL;
params.keysize = 1024;
params.expiryDate = NULL;
params.interval = 0;
- /* Switch to the next page showing the "wait" message. */
- gpa_wizard_next_page_no_action (keygen_wizard->wizard);
-
- /* Handle some events so that the page is correctly displayed */
- while (gtk_events_pending())
- gtk_main_iteration();
-
- keygen_wizard->generate (¶ms, do_backup, keygen_wizard->generate_data);
+ wizard->generate (¶ms, do_backup, wizard->generate_data);
g_free (params.userID);
g_free (params.email);
return FALSE;
}
/* Handler for the close button. Destroy the main window */
static void
-gpa_keygen_wizard_close (GtkWidget * widget, gpointer param)
+keygen_wizard_close (GtkWidget *widget, gpointer param)
{
- GPAKeyGenWizard * wizard = param;
+ GPAKeyGenWizard *wizard = param;
gtk_widget_destroy (wizard->window);
}
-/* handler for the destroy signal. */
-static void
-gpa_keygen_wizard_destroy (GtkWidget *widget, gpointer param)
-{
-}
-
-
static void
free_keygen_wizard (gpointer data)
{
- GPAKeyGenWizard * keygen_wizard = data;
+ GPAKeyGenWizard *keygen_wizard = data;
- g_object_unref (keygen_wizard->genkey_pixmap);
- g_object_unref (keygen_wizard->backup_pixmap);
g_free (keygen_wizard);
}
-static void
-page_switched (GtkWidget * page, gpointer data)
+void
+keygen_wizard_prepare_cb (GtkAssistant *assistant, GtkWidget *page,
+ gpointer data)
{
- GPAKeyGenWizard * keygen_wizard = data;
- GdkPixmap * pixmap;
+ GPAKeyGenWizard *wizard = data;
- if (page == keygen_wizard->backup_page
- || page == keygen_wizard->backup_dir_page)
+ if (page == wizard->name_page || page == wizard->email_page)
+ gpa_keygen_wizard_simple_grab_focus (page);
+ else if (page == wizard->passwd_page)
{
- pixmap = keygen_wizard->backup_pixmap;
- }
- else
- {
- pixmap = keygen_wizard->genkey_pixmap;
- }
+ GtkWidget *entry;
+ entry = g_object_get_data (G_OBJECT (page), "gpa_keygen_passwd");
+ gtk_widget_grab_focus (entry);
- gtk_image_set_from_pixmap (GTK_IMAGE (keygen_wizard->image_widget),
- pixmap, NULL);
+ /* FIXME: Update. */
+ passwd_validate_cb (NULL, wizard);
+ }
+ else if (page == wizard->wait_page)
+ gpa_keygen_wizard_generate_action (wizard);
}
GtkWidget *
gpa_keygen_wizard_new (GtkWidget *parent,
GpaKeyGenWizardGenerateCb generate_action,
gpointer data)
{
+ GPAKeyGenWizard *wizard;
GtkWidget *window;
- GtkWidget *wizard;
- GtkWidget *hbox;
- GtkWidget *image_widget;
- GtkAccelGroup *accel_group;
- GPAKeyGenWizard *keygen_wizard;
-
- keygen_wizard = g_malloc (sizeof (*keygen_wizard));
- keygen_wizard->genkey_pixmap = gpa_create_icon_pixmap (parent,
- "wizard_genkey",
- NULL);
- keygen_wizard->backup_pixmap = gpa_create_icon_pixmap (parent,
- "wizard_backup",
- NULL);
-
- keygen_wizard->generate = generate_action;
- keygen_wizard->generate_data = data;
-
- accel_group = gtk_accel_group_new ();
- keygen_wizard->accel_group = accel_group;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- keygen_wizard->window = window;
- gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+ GdkPixbuf *genkey_pixbuf;
+ GdkPixbuf *backup_pixbuf;
+
+
+ wizard = g_malloc (sizeof (*wizard));
+ genkey_pixbuf = gpa_create_icon_pixbuf ("wizard_genkey");
+ backup_pixbuf = gpa_create_icon_pixbuf ("wizard_backup");
+
+ wizard->generate = generate_action;
+ wizard->generate_data = data;
+
+
+ window = gtk_assistant_new ();
+ wizard->window = window;
gtk_window_set_title (GTK_WINDOW (window), _("Generate key"));
- gtk_container_set_border_width (GTK_CONTAINER (window), 5);
g_object_set_data_full (G_OBJECT (window), "user_data",
- keygen_wizard, free_keygen_wizard);
- g_signal_connect_swapped (G_OBJECT (window), "destroy",
- G_CALLBACK (gpa_keygen_wizard_destroy),
- keygen_wizard);
-
- hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_add (GTK_CONTAINER (window), hbox);
-
- image_widget = gtk_image_new_from_pixmap
- (keygen_wizard->genkey_pixmap, NULL);
- keygen_wizard->image_widget = image_widget;
- gtk_box_pack_start (GTK_BOX (hbox), image_widget, FALSE, TRUE, 0);
-
- wizard = gpa_wizard_new (accel_group,
- (GtkSignalFunc) gpa_keygen_wizard_close,
- (GtkSignalFunc) keygen_wizard);
- keygen_wizard->wizard = wizard;
- gtk_box_pack_start (GTK_BOX (hbox), wizard, TRUE, TRUE, 0);
- gpa_wizard_set_page_switched (wizard, page_switched, keygen_wizard);
-
- keygen_wizard->name_page = gpa_keygen_wizard_name_page (keygen_wizard);
- gpa_wizard_append_page (wizard, keygen_wizard->name_page,
- FALSE,
- gpa_keygen_wizard_name_validate, keygen_wizard);
-
- keygen_wizard->email_page = gpa_keygen_wizard_email_page (keygen_wizard);
- gpa_wizard_append_page (wizard, keygen_wizard->email_page,
- FALSE,
- gpa_keygen_wizard_email_validate, keygen_wizard);
-
- keygen_wizard->passwd_page = gpa_keygen_wizard_password_page (keygen_wizard);
- gpa_wizard_append_page (wizard, keygen_wizard->passwd_page,
- FALSE, gpa_keygen_wizard_password_validate,
- keygen_wizard);
-
- keygen_wizard->backup_page = gpa_keygen_wizard_backup_page (keygen_wizard);
- gpa_wizard_append_page (wizard, keygen_wizard->backup_page,
- TRUE,
- gpa_keygen_wizard_generate_action, keygen_wizard);
-
- /* Don't use F as the accelerator in "Finish" because Meta-F is
- * already bound in the entry widget */
-
- keygen_wizard->wait_page = gpa_keygen_wizard_wait_page ();
- gpa_wizard_append_page (wizard, keygen_wizard->wait_page,
- TRUE, NULL, NULL);
-
- keygen_wizard->final_page = gpa_keygen_wizard_final_page ();
- gpa_wizard_append_page (wizard, keygen_wizard->final_page,
- TRUE, NULL, NULL);
+ wizard, free_keygen_wizard);
+
+ /* Set the forward button to be the default. */
+ GTK_WIDGET_SET_FLAGS (GTK_ASSISTANT (window)->forward, GTK_CAN_DEFAULT);
+ gtk_window_set_default (GTK_WINDOW (window), GTK_ASSISTANT (window)->forward);
+
+ wizard->name_page = keygen_wizard_name_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->name_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->name_page,
+ GTK_ASSISTANT_PAGE_CONTENT);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->name_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window), wizard->name_page,
+ genkey_pixbuf);
+
+
+ wizard->email_page = keygen_wizard_email_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->email_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->email_page,
+ GTK_ASSISTANT_PAGE_CONTENT);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->email_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window), wizard->email_page,
+ genkey_pixbuf);
+
+
+ wizard->passwd_page = keygen_wizard_passwd_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->passwd_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->passwd_page,
+ GTK_ASSISTANT_PAGE_CONTENT);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->passwd_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window),
+ wizard->passwd_page, genkey_pixbuf);
+
+
+ /* FIXME: A better GUI would have a "Generate backup" button on the
+ finish page after the key was generated. */
+ wizard->backup_page = gpa_keygen_wizard_backup_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->backup_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->backup_page,
+ GTK_ASSISTANT_PAGE_CONTENT);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->backup_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window),
+ wizard->backup_page,
+ backup_pixbuf);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (wizard->window),
+ wizard->backup_page, TRUE);
+
+
+ /* FIXME: We need to integrate the progress bar for the operation
+ into the page. Also, after the operation completes, the
+ assistant is destroyed, so the final page will never be
+ shown. The whole thing is upside down, and should be redone. */
+ wizard->wait_page = gpa_keygen_wizard_wait_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->wait_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->wait_page,
+ GTK_ASSISTANT_PAGE_PROGRESS);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->wait_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window), wizard->wait_page,
+ genkey_pixbuf);
+
+ /* The final page does not contain information about the generated
+ key. It should also offer a "generate backup" button, then the
+ backup page can be removed. */
+ wizard->final_page = gpa_keygen_wizard_final_page (wizard);
+ gtk_assistant_append_page (GTK_ASSISTANT (window), wizard->final_page);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (window), wizard->final_page,
+ GTK_ASSISTANT_PAGE_SUMMARY);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (window), wizard->final_page,
+ /* FIXME */ _("Generate key"));
+ gtk_assistant_set_page_side_image (GTK_ASSISTANT (window), wizard->final_page,
+ genkey_pixbuf);
+
+ g_signal_connect (G_OBJECT (window), "prepare",
+ G_CALLBACK (keygen_wizard_prepare_cb), wizard);
+ g_signal_connect (G_OBJECT (window), "close",
+ G_CALLBACK (keygen_wizard_close), wizard);
+ g_signal_connect (G_OBJECT (window), "cancel",
+ G_CALLBACK (keygen_wizard_close), wizard);
+
gtk_window_set_modal (GTK_WINDOW (window), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (parent));
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
- /* FIXME: This is a kludge to make sure that the proper buttons are shown
- * (must be done after the show_all). All this should be fixed properly
- * some day */
- gpa_wizard_update_buttons (wizard);
+ g_object_unref (genkey_pixbuf);
+ g_object_unref (backup_pixbuf);
return window;
}
-
-
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Feb 26, 6:26 PM (6 h, 29 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
20/0b/1bd4296d48a7f4684fdb3aaa4b45
Attached To
rGPA Gnu Privacy Assistant
Event Timeline
Log In to Comment