2006-02-21 [wwp] 2.0.0cvs69
[claws.git] / src / plugins / pgpcore / prefs_gpg.c
index d5a28666f840ccc1c58b0c8ffe40b39b20f5d2e0..591a4250d33da5a93208a266f323b998ce81c020 100644 (file)
@@ -14,7 +14,7 @@
  *
  * 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #include <gtk/gtk.h>
@@ -65,100 +65,49 @@ static void prefs_gpg_create_widget_func(PrefsPage *_page,
        struct GPGPage *page = (struct GPGPage *) _page;
        struct GPGConfig *config;
 
-        /*
-         * BEGIN GLADE CODE 
-         * DO NOT EDIT 
-         */
-       GtkWidget *table;
        GtkWidget *checkbtn_passphrase_grab;
        GtkWidget *checkbtn_store_passphrase;
        GtkWidget *checkbtn_auto_check_signatures;
        GtkWidget *checkbtn_gpg_warning;
-       GtkWidget *label7;
-       GtkWidget *label6;
-       GtkWidget *label9;
-       GtkWidget *label10;
        GtkWidget *hbox1;
-       GtkWidget *label11;
+       GtkWidget *vbox1, *vbox2;
+       GtkWidget *label_expire1;
        GtkObject *spinbtn_store_passphrase_adj;
        GtkWidget *spinbtn_store_passphrase;
-       GtkWidget *label12;
+       GtkWidget *label_expire2;
+       GtkWidget *frame_passphrase;
        GtkTooltips *tooltips;
 
        tooltips = gtk_tooltips_new();
 
-       table = gtk_table_new(5, 2, FALSE);
-       gtk_widget_show(table);
-       gtk_container_set_border_width(GTK_CONTAINER(table), 8);
-       gtk_table_set_row_spacings(GTK_TABLE(table), 4);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
-
-       checkbtn_passphrase_grab = gtk_check_button_new_with_label("");
-       gtk_widget_show(checkbtn_passphrase_grab);
-       gtk_table_attach(GTK_TABLE(table), checkbtn_passphrase_grab, 0, 1,
-                        3, 4, (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-
-       checkbtn_store_passphrase = gtk_check_button_new_with_label("");
-       gtk_widget_show(checkbtn_store_passphrase);
-       gtk_table_attach(GTK_TABLE(table), checkbtn_store_passphrase, 0, 1,
-                        1, 2, (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-
-       checkbtn_auto_check_signatures =
-           gtk_check_button_new_with_label("");
-       gtk_widget_show(checkbtn_auto_check_signatures);
-       gtk_table_attach(GTK_TABLE(table), checkbtn_auto_check_signatures,
-                        0, 1, 0, 1,
-                        (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-
-       checkbtn_gpg_warning = gtk_check_button_new_with_label("");
-       gtk_widget_show(checkbtn_gpg_warning);
-       gtk_table_attach(GTK_TABLE(table), checkbtn_gpg_warning, 0, 1, 4,
-                        5, (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-
-       label7 = gtk_label_new(_("Store passphrase in memory"));
-       gtk_widget_show(label7);
-       gtk_table_attach(GTK_TABLE(table), label7, 1, 2, 1, 2,
-                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label7), 0, 0.5);
+       vbox1 = gtk_vbox_new (FALSE, VSPACING);
+       gtk_widget_show (vbox1);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
 
-       label6 = gtk_label_new(_("Automatically check signatures"));
-       gtk_widget_show(label6);
-       gtk_table_attach(GTK_TABLE(table), label6, 1, 2, 0, 1,
-                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label6), 0, 0.5);
+       vbox2 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox2);
+       gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
 
-       label9 =
-           gtk_label_new(_("Grab input while entering a passphrase"));
-       gtk_widget_show(label9);
-       gtk_table_attach(GTK_TABLE(table), label9, 1, 2, 3, 4,
-                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label9), 0, 0.5);
-
-       label10 =
-           gtk_label_new(_
-                         ("Display warning on startup if GnuPG doesn't work"));
-       gtk_widget_show(label10);
-       gtk_table_attach(GTK_TABLE(table), label10, 1, 2, 4, 5,
-                        (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label10), 0, 0.5);
+       PACK_CHECK_BUTTON (vbox2, checkbtn_auto_check_signatures,
+                       _("Automatically check signatures"));
+
+       PACK_FRAME(vbox1, frame_passphrase, _("Passphrase"));
 
-       hbox1 = gtk_hbox_new(FALSE, 8);
-       gtk_widget_show(hbox1);
-       gtk_table_attach(GTK_TABLE(table), hbox1, 1, 2, 2, 3,
-                        (GtkAttachOptions) (GTK_SHRINK | GTK_FILL),
-                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
+       vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
+       gtk_widget_show (vbox2);
+       gtk_container_add (GTK_CONTAINER (frame_passphrase), vbox2);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
 
-       label11 = gtk_label_new(_("Expire after"));
-       gtk_widget_show(label11);
-       gtk_box_pack_start(GTK_BOX(hbox1), label11, FALSE, FALSE, 0);
+       PACK_CHECK_BUTTON (vbox2, checkbtn_store_passphrase,
+                       _("Store passphrase in memory"));
+
+       hbox1 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox1);
+       gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
+
+       label_expire1 = gtk_label_new(_("Expire after"));
+       gtk_widget_show (label_expire1);
+       gtk_box_pack_start (GTK_BOX (hbox1), label_expire1, FALSE, FALSE, 0);
 
        spinbtn_store_passphrase_adj =
            gtk_adjustment_new(1, 0, 1440, 1, 10, 10);
@@ -168,7 +117,7 @@ static void prefs_gpg_create_widget_func(PrefsPage *_page,
        gtk_widget_show(spinbtn_store_passphrase);
        gtk_box_pack_start(GTK_BOX(hbox1), spinbtn_store_passphrase, FALSE,
                           FALSE, 0);
-       gtk_widget_set_size_request(spinbtn_store_passphrase, 64, -2);
+       gtk_widget_set_size_request(spinbtn_store_passphrase, 64, -1);
        gtk_tooltips_set_tip(tooltips, spinbtn_store_passphrase,
                             _
                             ("Setting to '0' will store the passphrase for the whole session"),
@@ -176,13 +125,24 @@ static void prefs_gpg_create_widget_func(PrefsPage *_page,
        gtk_spin_button_set_numeric(GTK_SPIN_BUTTON
                                    (spinbtn_store_passphrase), TRUE);
 
-       label12 = gtk_label_new(_("minute(s)"));
-       gtk_widget_show(label12);
-       gtk_box_pack_start(GTK_BOX(hbox1), label12, TRUE, TRUE, 0);
-       gtk_misc_set_alignment(GTK_MISC(label12), 0.0, 0.5);
-        /* 
-         * END GLADE CODE
-         */
+       label_expire2 = gtk_label_new(_("minute(s)"));
+       gtk_widget_show(label_expire2);
+       gtk_box_pack_start(GTK_BOX(hbox1), label_expire2, FALSE, FALSE, 0);
+       gtk_misc_set_alignment(GTK_MISC(label_expire2), 0.0, 0.5);
+
+       SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, label_expire1);
+       SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, spinbtn_store_passphrase);
+       SET_TOGGLE_SENSITIVITY (checkbtn_store_passphrase, label_expire2);
+
+       PACK_CHECK_BUTTON (vbox2, checkbtn_passphrase_grab,
+                       _("Grab input while entering a passphrase"));
+
+       vbox2 = gtk_vbox_new (FALSE, 0);
+       gtk_widget_show (vbox2);
+       gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
+
+       PACK_CHECK_BUTTON (vbox2, checkbtn_gpg_warning,
+                       _("Display warning on startup if GnuPG doesn't work"));
 
        config = prefs_gpg_get_config();
 
@@ -198,7 +158,7 @@ static void prefs_gpg_create_widget_func(PrefsPage *_page,
        page->checkbtn_passphrase_grab = checkbtn_passphrase_grab;
        page->checkbtn_gpg_warning = checkbtn_gpg_warning;
 
-       page->page.widget = table;
+       page->page.widget = vbox1;
 }
 
 static void prefs_gpg_destroy_widget_func(PrefsPage *_page)
@@ -232,6 +192,7 @@ struct GPGAccountPage
        GtkWidget *key_by_from;
        GtkWidget *key_custom;
        GtkWidget *keyid;
+       GtkWidget *keyid_label;
 
        PrefsAccount *account;
 };
@@ -242,6 +203,7 @@ void key_custom_toggled(GtkToggleButton *togglebutton, gpointer user_data)
        gboolean active;
 
        active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->key_custom));
+       gtk_widget_set_sensitive(GTK_WIDGET(page->keyid_label), active);
        gtk_widget_set_sensitive(GTK_WIDGET(page->keyid), active);
        if (!active)
                gtk_editable_delete_text(GTK_EDITABLE(page->keyid), 0, -1);
@@ -255,7 +217,6 @@ static void prefs_gpg_account_create_widget_func(PrefsPage *_page,
        PrefsAccount *account = (PrefsAccount *) data;
        GPGAccountConfig *config;
 
-       /*** BEGIN GLADE CODE ***/
        GtkWidget *vbox;
        GtkWidget *frame1;
        GtkWidget *table1;
@@ -263,10 +224,7 @@ static void prefs_gpg_account_create_widget_func(PrefsPage *_page,
        GtkWidget *key_default;
        GtkWidget *key_by_from;
        GtkWidget *key_custom;
-       GtkWidget *label13;
-       GtkWidget *label14;
-       GtkWidget *label15;
-       GtkWidget *label16;
+       GtkWidget *keyid_label;
        GtkWidget *keyid;
 
        vbox = gtk_vbox_new(FALSE, 0);
@@ -284,74 +242,58 @@ static void prefs_gpg_account_create_widget_func(PrefsPage *_page,
        gtk_table_set_row_spacings(GTK_TABLE(table1), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table1), 4);
 
-       key_default = gtk_radio_button_new_with_label(key_group, "");
+       key_default = gtk_radio_button_new_with_label(key_group,
+                       _("Use default GnuPG key"));
        key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_default));
        gtk_widget_show(key_default);
-       gtk_table_attach(GTK_TABLE(table1), key_default, 0, 1, 0, 1,
+       gtk_table_attach(GTK_TABLE(table1), key_default, 0, 3, 0, 1,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
 
-       key_by_from = gtk_radio_button_new_with_label(key_group, "");
+       key_by_from = gtk_radio_button_new_with_label(key_group,
+               _("Select key by your email address"));
        key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_by_from));
        gtk_widget_show(key_by_from);
-       gtk_table_attach(GTK_TABLE(table1), key_by_from, 0, 1, 1, 2,
+       gtk_table_attach(GTK_TABLE(table1), key_by_from, 0, 3, 1, 2,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
 
-       key_custom = gtk_radio_button_new_with_label(key_group, "");
+       key_custom = gtk_radio_button_new_with_label(key_group,
+               _("Specify key manually"));
        key_group = gtk_radio_button_group(GTK_RADIO_BUTTON(key_custom));
        gtk_widget_show(key_custom);
-       gtk_table_attach(GTK_TABLE(table1), key_custom, 0, 1, 2, 3,
-                        (GtkAttachOptions) (GTK_FILL),
-                        (GtkAttachOptions) (0), 0, 0);
-
-       label13 = gtk_label_new(_("Use default GnuPG key"));
-       gtk_widget_show(label13);
-       gtk_table_attach(GTK_TABLE(table1), label13, 1, 3, 0, 1,
-                        (GtkAttachOptions) (GTK_FILL),
-                        (GtkAttachOptions) (0), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label13), 0, 0.5);
-
-       label14 = gtk_label_new(_("Select key by your email address"));
-       gtk_widget_show(label14);
-       gtk_table_attach(GTK_TABLE(table1), label14, 1, 3, 1, 2,
-                        (GtkAttachOptions) (GTK_FILL),
-                        (GtkAttachOptions) (0), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label14), 0, 0.5);
-
-       label15 = gtk_label_new(_("Specify key manually"));
-       gtk_widget_show(label15);
-       gtk_table_attach(GTK_TABLE(table1), label15, 1, 3, 2, 3,
+       gtk_table_attach(GTK_TABLE(table1), key_custom, 0, 3, 2, 3,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
-       gtk_misc_set_alignment(GTK_MISC(label15), 0, 0.5);
 
-       label16 = gtk_label_new(_("User or key ID:"));
-       gtk_widget_show(label16);
-       gtk_table_attach(GTK_TABLE(table1), label16, 1, 2, 3, 4,
+       keyid_label = gtk_label_new(_("User or key ID:"));
+       gtk_widget_show(keyid_label);
+       gtk_table_attach(GTK_TABLE(table1), keyid_label, 0, 2, 3, 4,
                         (GtkAttachOptions) (GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
-       gtk_label_set_justify(GTK_LABEL(label16), GTK_JUSTIFY_LEFT);
+       gtk_label_set_justify(GTK_LABEL(keyid_label), GTK_JUSTIFY_LEFT);
 
        keyid = gtk_entry_new();
        gtk_widget_show(keyid);
        gtk_table_attach(GTK_TABLE(table1), keyid, 2, 3, 3, 4,
                         (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                         (GtkAttachOptions) (0), 0, 0);
-       /*** END GLADE CODE ***/
 
        config = prefs_gpg_account_get_config(account);
        switch (config->sign_key) {
        case SIGN_KEY_DEFAULT:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_default), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid_label), FALSE);
                gtk_widget_set_sensitive(GTK_WIDGET(keyid), FALSE);
                break;
        case SIGN_KEY_BY_FROM:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_by_from), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid_label), FALSE);
                gtk_widget_set_sensitive(GTK_WIDGET(keyid), FALSE);
                break;
        case SIGN_KEY_CUSTOM:
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_custom), TRUE);
+               gtk_widget_set_sensitive(GTK_WIDGET(keyid_label), TRUE);
                gtk_widget_set_sensitive(GTK_WIDGET(keyid), TRUE);
                break;
        }
@@ -365,6 +307,7 @@ static void prefs_gpg_account_create_widget_func(PrefsPage *_page,
        page->key_by_from = key_by_from;
        page->key_custom = key_custom;
        page->keyid = keyid;
+       page->keyid_label = keyid_label;
 
        page->page.widget = vbox;
        page->account = account;