Added an option to disable the startup warning about GnuPG (from
authorSergey Vlasov <vsu@users.sourceforge.net>
Wed, 2 May 2001 15:09:36 +0000 (15:09 +0000)
committerSergey Vlasov <vsu@users.sourceforge.net>
Wed, 2 May 2001 15:09:36 +0000 (15:09 +0000)
common preferences or the warning window itself).

ChangeLog.claws
src/alertpanel.c
src/alertpanel.h
src/main.c
src/prefs_common.c
src/prefs_common.h

index 29f51d9a87c12b53d0e5b23926d83d4a2d7fd6ee..771ededbc0d86c2e4675512b1a737f3323ffd4a4 100644 (file)
@@ -1,3 +1,27 @@
+2001-05-02 [sergey]
+
+       * src/alertpanel.h (AlertValue): added G_ALERT_VALUE_MASK,
+       G_ALERTDISABLE.
+
+       * src/alertpanel.c (alertpanel_create): new argument can_disable,
+       all existing callers changed to pass FALSE; create a check button
+       to disable the message.
+       (alertpanel_message_with_disable): new function.
+       (alertpanel_show): mask value with G_ALERT_VALUE_MASK.
+       (alertpanel_button_toggled): new function.
+       (alertpanel_button_clicked, alertpanel_close): set value using
+       G_ALERT_VALUE_MASK.
+
+       * src/prefs_common.h (PrefsCommon): new field gpgme_warning.
+
+       * src/prefs_common.c (prefs_privacy_create): new check button
+       checkbtn_gpgme_warning.
+
+       * src/main.c (main): moved preferences reading before gpgme
+       initialization; check prefs_common.gpgme_warning before giving the
+       GnuPG warning and set it to FALSE if the user wants to disable the
+       warning.
+
 2001-05-02 [hiroyuki]
 
        * src/prefs_display_headers.c: modified the layout and some labels.
index e504148439639d48b31ba35a8734eb114d605fa6..73d322a179d4c4a4a7645428347dab096311ab5d 100644 (file)
@@ -48,7 +48,10 @@ static void alertpanel_create                (const gchar    *title,
                                         const gchar    *message,
                                         const gchar    *button1_label,
                                         const gchar    *button2_label,
-                                        const gchar    *button3_label);
+                                        const gchar    *button3_label,
+                                        gboolean        can_disable);
+static void alertpanel_button_toggled  (GtkToggleButton *button,
+                                        gpointer        data);
 static void alertpanel_button_clicked  (GtkWidget      *widget,
                                         gpointer        data);
 static void alertpanel_close           (GtkWidget      *widget,
@@ -67,7 +70,7 @@ AlertValue alertpanel(const gchar *title,
                alertpanel_is_open = TRUE;
 
        alertpanel_create(title, message, button1_label, button2_label,
-                         button3_label);
+                         button3_label, FALSE);
        alertpanel_show();
 
        debug_print("return value = %d\n", value);
@@ -81,10 +84,23 @@ void alertpanel_message(const gchar *title, const gchar *message)
        else
                alertpanel_is_open = TRUE;
 
-       alertpanel_create(title, message, NULL, NULL, NULL);
+       alertpanel_create(title, message, NULL, NULL, NULL, FALSE);
        alertpanel_show();
 }
 
+AlertValue alertpanel_message_with_disable(const gchar *title,
+                                          const gchar  *message)
+{
+       if (alertpanel_is_open)
+               return;
+       else
+               alertpanel_is_open = TRUE;
+
+       alertpanel_create(title, message, NULL, NULL, NULL, TRUE);
+       alertpanel_show();
+       return value;
+}
+
 void alertpanel_notice(const gchar *format, ...)
 {
        va_list args;
@@ -130,7 +146,7 @@ static void alertpanel_show(void)
        manage_window_set_transient(GTK_WINDOW(dialog));
        value = G_ALERTWAIT;
 
-       while (value == G_ALERTWAIT)
+       while ((value & G_ALERT_VALUE_MASK) == G_ALERTWAIT)
                gtk_main_iteration();
 
        gtk_widget_destroy(dialog);
@@ -143,7 +159,8 @@ static void alertpanel_create(const gchar *title,
                              const gchar *message,
                              const gchar *button1_label,
                              const gchar *button2_label,
-                             const gchar *button3_label)
+                             const gchar *button3_label,
+                             gboolean     can_disable)
 {
        static GdkFont *titlefont;
        GtkStyle *style;
@@ -156,6 +173,9 @@ static void alertpanel_create(const gchar *title,
        GtkWidget *button3;
        const gchar *label2;
        const gchar *label3;
+       GtkWidget *hbox2;
+       GtkWidget *disable_chkbtn;
+       GtkWidget *box_for_buttons;
 
        debug_print(_("Creating alert panel dialog...\n"));
 
@@ -217,7 +237,24 @@ static void alertpanel_create(const gchar *title,
                                button2_label ? &button2 : NULL, label2,
                                button3_label ? &button3 : NULL, label3);
 
-       gtk_box_pack_end(GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
+       if (can_disable) {
+               hbox2 = gtk_hbox_new(FALSE, 8);
+               gtk_box_pack_end(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
+               disable_chkbtn = gtk_check_button_new_with_label
+                       (_("Show this message next time"));
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_chkbtn),
+                                            TRUE);
+               gtk_signal_connect(GTK_OBJECT(disable_chkbtn), "toggled",
+                                  GTK_SIGNAL_FUNC(alertpanel_button_toggled),
+                                  GUINT_TO_POINTER(G_ALERTDISABLE));
+               gtk_box_pack_start(GTK_BOX(hbox2), disable_chkbtn,
+                                  TRUE, TRUE, 0);
+               box_for_buttons = hbox2;
+       } else
+               box_for_buttons = vbox;
+
+       gtk_box_pack_end(GTK_BOX(box_for_buttons), confirm_area,
+                        FALSE, FALSE, 0);
        gtk_widget_grab_default(button1);
        gtk_widget_grab_focus(button1);
        if (button2_label && *button2_label == '+') {
@@ -244,9 +281,18 @@ static void alertpanel_create(const gchar *title,
        gtk_widget_show_all(dialog);
 }
 
+static void alertpanel_button_toggled(GtkToggleButton *button,
+                                     gpointer data)
+{
+       if (gtk_toggle_button_get_active(button))
+               value &= ~GPOINTER_TO_UINT(data);
+       else
+               value |= GPOINTER_TO_UINT(data);
+}
+
 static void alertpanel_button_clicked(GtkWidget *widget, gpointer data)
 {
-       value = (AlertValue)data;
+       value = (value & ~G_ALERT_VALUE_MASK) | (AlertValue)data;
 }
 
 static void alertpanel_close(GtkWidget *widget, GdkEventAny *event,
@@ -256,5 +302,5 @@ static void alertpanel_close(GtkWidget *widget, GdkEventAny *event,
                if (((GdkEventKey *)event)->keyval != GDK_Escape)
                        return;
 
-       value = (AlertValue)data;
+       value = (value & ~G_ALERT_VALUE_MASK) | (AlertValue)data;
 }
index d85eec92c0832d1b4135a703b2426f50f11bf86b..203b5106adac6a824ec2ef352ba4ccd767602095 100644 (file)
@@ -28,7 +28,10 @@ typedef enum
        G_ALERTDEFAULT,
        G_ALERTALTERNATE,
        G_ALERTOTHER,
-       G_ALERTWAIT
+       G_ALERTWAIT,
+
+       G_ALERT_VALUE_MASK      = 0x0000FFFF,
+       G_ALERTDISABLE          = 0x00010000
 } AlertValue;
 
 AlertValue alertpanel  (const gchar    *title,
@@ -40,6 +43,9 @@ AlertValue alertpanel (const gchar    *title,
 void alertpanel_message        (const gchar    *title,
                         const gchar    *message);
 
+AlertValue alertpanel_message_with_disable(const gchar *title,
+                                          const gchar  *message);
+
 void alertpanel_notice (const gchar    *format,
                         ...) G_GNUC_PRINTF(1, 2);
 void alertpanel_warning        (const gchar    *format,
index c153022e0243717d54b8a984517d0dd33078ce36..622528f98355d62e43cf993b52314203851a5c0b 100644 (file)
@@ -198,24 +198,33 @@ int main(int argc, char *argv[])
 
        srandom((gint)time(NULL));
 
+       prefs_common_read_config();
+       prefs_common_save_config();
+       prefs_filter_read_config();
+       prefs_filter_write_config();
+       prefs_display_headers_read_config();
+       prefs_display_headers_write_config();
+
 #if USE_GPGME
        if (gpgme_check_engine()) {  /* Also does some gpgme init */
                rfc2015_disable_all();
                debug_print("gpgme_engine_version:\n%s\n",
                            gpgme_get_engine_info());
-               alertpanel_warning(_("GnuPG is not installed properly.\n"
-                                    "OpenPGP support disabled."));
+
+               if (prefs_common.gpgme_warning) {
+                       AlertValue v = alertpanel_message_with_disable
+                               (_("Warning"),
+                                _("GnuPG is not installed properly.\n"
+                                  "OpenPGP support disabled."));
+                       if (v & G_ALERTDISABLE) {
+                               prefs_common.gpgme_warning = FALSE;
+                               prefs_common_save_config();
+                       }
+               }
        }
        gpgme_register_idle(idle_function_for_gpgme);
 #endif
 
-       prefs_common_read_config();
-       prefs_common_save_config();
-       prefs_filter_read_config();
-       prefs_filter_write_config();
-       prefs_display_headers_read_config();
-       prefs_display_headers_write_config();
-
        gtkut_widget_init();
 
        mainwin = main_window_create
index 60c738eefe497f3f779c60b2427ee9c4061c666d..243dcd604d179aa6b03fa28516dcb50e7adb0b5b 100644 (file)
@@ -127,6 +127,7 @@ static struct Message {
 
 #if USE_GPGME
 static struct Privacy {
+       GtkWidget *checkbtn_gpgme_warning;
        GtkWidget *checkbtn_default_encrypt;
        GtkWidget *checkbtn_default_sign;
        GtkWidget *checkbtn_auto_check_signatures;
@@ -426,6 +427,9 @@ static PrefParam param[] = {
 
 #if USE_GPGME
        /* Privacy */
+       {"gpgme_warning", "TRUE", &prefs_common.gpgme_warning, P_BOOL,
+        &privacy.checkbtn_gpgme_warning,
+        prefs_set_data_from_toggle, prefs_set_toggle},
        {"default_encrypt", "FALSE", &prefs_common.default_encrypt, P_BOOL,
         &privacy.checkbtn_default_encrypt,
         prefs_set_data_from_toggle, prefs_set_toggle},
@@ -1543,6 +1547,7 @@ static void prefs_privacy_create(void)
        GtkWidget *vbox1;
        GtkWidget *vbox2;
        GtkWidget *hbox1;
+       GtkWidget *checkbtn_gpgme_warning;
        GtkWidget *checkbtn_default_encrypt;
        GtkWidget *checkbtn_default_sign;
        GtkWidget *checkbtn_auto_check_signatures;
@@ -1561,6 +1566,10 @@ static void prefs_privacy_create(void)
        gtk_widget_show (vbox2);
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
 
+       PACK_CHECK_BUTTON
+               (vbox2, checkbtn_gpgme_warning,
+                _("Display warning on startup if GnuPG does not work"));
+
        PACK_CHECK_BUTTON (vbox2, checkbtn_default_encrypt,
                           _("Encrypt message by default"));
 
@@ -1594,6 +1603,7 @@ static void prefs_privacy_create(void)
        /* FIXME: disabled because not implemented */
        gtk_widget_set_sensitive(optmenu, FALSE);
 
+       privacy.checkbtn_gpgme_warning   = checkbtn_gpgme_warning;
        privacy.checkbtn_default_encrypt = checkbtn_default_encrypt;
        privacy.checkbtn_default_sign    = checkbtn_default_sign;
        privacy.checkbtn_auto_check_signatures
index c10bc0d06199c039a380b868e5817851ae117a9d..dbb3d3761541a44009827da433edad9d2e3d1851 100644 (file)
@@ -147,6 +147,7 @@ struct _PrefsCommon
        gchar *mime_audio_player;
 
        /* Privacy */
+       gboolean gpgme_warning;
        gboolean default_encrypt;
        gboolean default_sign;
         gboolean auto_check_signatures;