diff --git a/src/keydeletedlg.c b/src/keydeletedlg.c index 8b1f72b..e34ba83 100644 --- a/src/keydeletedlg.c +++ b/src/keydeletedlg.c @@ -1,162 +1,165 @@ /* kexdeletedlg.c - 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 */ #include #include #include #include "gpa.h" #include "gtktools.h" #include "gpawidgets.h" #include "keydeletedlg.h" #include "keytable.h" /* Emit a last warning that a secret key is going to be deleted, and ask for * confirmation. */ static gboolean confirm_delete_secret (GtkWidget * parent) { GtkWidget * window; GtkWidget * label; GtkWidget * hbox; window = gtk_dialog_new_with_buttons (_("Removing Secret Key"), GTK_WINDOW(parent), GTK_DIALOG_MODAL, _("_Yes"), GTK_RESPONSE_YES, _("_No"), GTK_RESPONSE_NO, NULL); gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_NO); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); gtk_container_set_border_width (GTK_CONTAINER (hbox), 10); GtkWidget *image_warning; image_warning = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG); gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (image_warning), TRUE, TRUE, 0); label = gtk_label_new (_("If you delete this key, you won't be able to\n" "read messages encrypted with it.\n\n" "Are you really sure you want to delete it?")); gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); GtkBox *box = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))); gtk_box_pack_start(GTK_BOX (box), hbox, TRUE, TRUE, 0); gtk_widget_show_all (window); if (gtk_dialog_run (GTK_DIALOG (window)) == GTK_RESPONSE_YES) { gtk_widget_destroy (window); return TRUE; } else { gtk_widget_destroy (window); return FALSE; } } /* Run the delete key dialog as a modal dialog and return TRUE if the * user chose Yes, FALSE otherwise. Display information about the public * key key in the dialog so that the user knows which key is to be * deleted. If has_secret_key is true, display a special warning for * deleting secret keys. */ gboolean gpa_delete_dialog_run (GtkWidget * parent, gpgme_key_t key) { GtkWidget * window; GtkWidget * vbox; GtkWidget * label; GtkWidget * info; gboolean has_secret_key = (gpa_keytable_lookup_key (gpa_keytable_get_secret_instance(), key->subkeys->fpr) != NULL); window = gtk_dialog_new_with_buttons (_("Remove Key"), GTK_WINDOW(parent), GTK_DIALOG_MODAL, _("_Yes"), GTK_RESPONSE_YES, _("_No"), GTK_RESPONSE_NO, NULL); gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_YES); gtk_container_set_border_width (GTK_CONTAINER (window), 5); vbox = gtk_dialog_get_content_area (GTK_DIALOG (window)); // vbox = GTK_DIALOG (window)->vbox; gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); label = gtk_label_new (_("You have selected the following key " "for removal:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5); info = gpa_key_info_new (key); gtk_box_pack_start (GTK_BOX (vbox), info, TRUE, TRUE, 5); if (has_secret_key) { label = gtk_label_new (_("This key has a secret key." " Deleting this key cannot be undone," " unless you have a backup copy.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5); } else { label = gtk_label_new (_("This key is a public key." " Deleting this key cannot be undone easily," " although you may be able to get a new copy " " from the owner or from a key server.")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5); } label = gtk_label_new (_("Are you sure you want to delete this key?")); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 5); gtk_widget_show_all (window); if (gtk_dialog_run (GTK_DIALOG (window)) == GTK_RESPONSE_YES) { if (has_secret_key) { gboolean result = confirm_delete_secret (window); gtk_widget_destroy (window); return result; } else { gtk_widget_destroy (window); return TRUE; } } else { gtk_widget_destroy (window); return FALSE; } } /* gpa_delete_dialog_run */ diff --git a/src/keysigndlg.c b/src/keysigndlg.c index d6197e9..81e224c 100644 --- a/src/keysigndlg.c +++ b/src/keysigndlg.c @@ -1,159 +1,170 @@ /* keysigndlg.c - The GNU Privacy Assistant Copyright (C) 2000, 2001 G-N-U GmbH. Copyright (C) 2005, 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 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 GPA; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include #include #include #include #include #include #include #include "gpa.h" #include "gtktools.h" #include "gpawidgets.h" #include "keysigndlg.h" /* Run the key sign dialog for signing the public key key with the * default key as a modal dialog and return when the user ends the * dialog. If the user clicks OK, return TRUE and set sign_locally * according to the "sign locally" check box. * * If the user clicked Cancel, return FALSE and do not modify *sign_locally * * When in simplified_ui mode, don't show the "sign locally" check box * and if the user clicks OK, set *sign_locally to false. */ gboolean gpa_key_sign_run_dialog (GtkWidget * parent, gpgme_key_t key, gboolean * sign_locally) { GtkWidget *window; GtkWidget *vboxSign; GtkWidget *check = NULL; GtkWidget *grid; GtkWidget *label; GtkWidget *uid_box; GtkResponseType response; gchar *string; gpgme_user_id_t uid; window = gtk_dialog_new_with_buttons (_("Sign Key"), GTK_WINDOW(parent), GTK_DIALOG_MODAL, _("_Yes"), GTK_RESPONSE_YES, _("_No"), GTK_RESPONSE_NO, NULL); gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_YES); gtk_container_set_border_width (GTK_CONTAINER (window), 5); // vboxSign = GTK_DIALOG (window)->vbox; - vboxSign = GTK_WIDGET (gtk_dialog_get_content_area(window)); + vboxSign = GTK_WIDGET (gtk_dialog_get_content_area (GTK_DIALOG (window))); gtk_container_set_border_width (GTK_CONTAINER (vboxSign), 5); label = gtk_label_new (_("Do you want to sign the following key?")); gtk_box_pack_start (GTK_BOX (vboxSign), label, FALSE, TRUE, 5); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); grid = gtk_grid_new (); gtk_box_pack_start (GTK_BOX (vboxSign), grid, FALSE, TRUE, 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 4); gtk_grid_set_row_spacing (GTK_GRID (grid), 2); /* Build this first, so that we can know how may user ID's there are */ uid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); uid = key->uids; while (uid) { if (!uid->revoked) { /* One user ID on each line. */ string = gpa_gpgme_key_get_userid (uid); label = gtk_label_new (string); gpa_add_tooltip (label, string); g_free (string); gtk_label_set_max_width_chars (GTK_LABEL (label), GPA_MAX_UID_WIDTH); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); gtk_box_pack_start (GTK_BOX(uid_box), label, TRUE, TRUE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); + } uid = uid->next; } label = gtk_label_new (key->uids->next == NULL ? _("User Name:") : _("User Names:")); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0); + gtk_widget_set_halign (GTK_WIDGET (label), 1.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.0); + gtk_grid_attach (GTK_GRID (grid), uid_box, 1, 0, 1, 1); label = gtk_label_new (_("Fingerprint:")); gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 1.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); string = gpa_gpgme_key_format_fingerprint (key->subkeys->fpr); label = gtk_label_new (string); g_free (string); gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); + label = gtk_label_new (_("Check the name and fingerprint carefully to" " be sure that it really is the key you want to sign.")); gtk_box_pack_start (GTK_BOX (vboxSign), label, FALSE, TRUE, 10); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 1.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); if (key->uids->next) { label = gtk_label_new (_("All user names in this key will be signed.")); gtk_box_pack_start (GTK_BOX (vboxSign), label, FALSE, TRUE, 10); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 1.0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); } label = gtk_label_new (_("The key will be signed with your default" " private key.")); gtk_box_pack_start (GTK_BOX (vboxSign), label, FALSE, TRUE, 5); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_widget_set_halign (GTK_WIDGET (label), 0.0); + gtk_widget_set_valign (GTK_WIDGET (label), 0.5); if (! gpa_options_get_simplified_ui (gpa_options_get_instance ())) { check = gtk_check_button_new_with_mnemonic (_("Sign only _locally")); gtk_box_pack_start (GTK_BOX (vboxSign), check, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), *sign_locally); } gtk_widget_show_all (window); response = gtk_dialog_run (GTK_DIALOG (window)); if (response == GTK_RESPONSE_YES) { *sign_locally = check && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check)); gtk_widget_destroy (window); return TRUE; } else { gtk_widget_destroy (window); return FALSE; } }