* src/prefs.h
authorChristoph Hohmann <reboot@gmx.ch>
Fri, 11 Jan 2002 15:01:47 +0000 (15:01 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Fri, 11 Jan 2002 15:01:47 +0000 (15:01 +0000)
        set sensitivity in SET_TOGGLE_SENSITIVITY macro from
toggle widget, because non static prefs can not use
prefs_set_* functions
* src/prefs_account.c
        toggle smtp auth password field sensitivity if
        user id is empty and add descrition of usage for
        these fields
* src/prefs_folder_item.c
        use SET_TOGGLE_SENSITIVITY macro to instead of extra
        callbacks

ChangeLog.claws
src/prefs.h
src/prefs_account.c
src/prefs_folder_item.c

index 30d05ad..a25d0d5 100644 (file)
@@ -1,3 +1,17 @@
+2002-01-11 [christoph] 0.6.6claws49
+
+       * src/prefs.h
+               set sensitivity in SET_TOGGLE_SENSITIVITY macro from
+               toggle widget, because non static prefs can not use
+               prefs_set_* functions
+       * src/prefs_account.c
+               toggle smtp auth password field sensitivity if
+               user id is empty and add descrition of usage for
+               these fields
+       * src/prefs_folder_item.c
+               use SET_TOGGLE_SENSITIVITY macro to instead of extra
+               callbacks
+
 2002-01-11 [melvin]    0.6.6claws48
 
        * src/compose.c
index f680ece..4ff46a2 100644 (file)
@@ -130,7 +130,7 @@ struct _PrefsDialog
 
 #define SET_TOGGLE_SENSITIVITY(togglewid, targetwid) \
 { \
-       gtk_widget_set_sensitive(targetwid, FALSE); \
+       gtk_widget_set_sensitive(targetwid, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglewid))); \
        gtk_signal_connect(GTK_OBJECT(togglewid), "toggled", \
                           GTK_SIGNAL_FUNC(prefs_button_toggled), targetwid); \
 }
index da15a4c..23cdfe5 100644 (file)
@@ -178,6 +178,8 @@ static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
                                           gpointer user_data);
 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
                                          gpointer user_data);
+static void prefs_account_smtp_userid_cb(GtkEditable *editable,
+                                        gpointer smtp_passwd);
 
 static PrefParam param[] = {
        /* Basic */
@@ -270,7 +272,7 @@ static PrefParam param[] = {
         &send.smtp_auth_chkbtn,
         prefs_set_data_from_toggle, prefs_set_toggle},
 
-       {"smtp_user_id", "ENV_USER", &tmp_ac_prefs.smtp_userid, P_STRING,
+       {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
         &send.smtp_userid_entry, prefs_set_data_from_entry, prefs_set_entry},
 
        {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_STRING,
@@ -1061,6 +1063,7 @@ static void prefs_account_send_create(void)
        GtkWidget *frame3;
        GtkWidget *vbox3;
        GtkWidget *smtp_auth_chkbtn;
+       GtkWidget *hbox2;
        GtkWidget *smtp_auth_hbox;
        GtkWidget *label;
        GtkWidget *uid_label;
@@ -1111,6 +1114,20 @@ static void prefs_account_send_create(void)
        PACK_CHECK_BUTTON (vbox3, smtp_auth_chkbtn,
                _("SMTP Authentication (SMTP AUTH)"));
 
+       hbox2 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox2);
+       gtk_box_pack_start (GTK_BOX (vbox3), hbox2, FALSE, FALSE, 0);
+
+       label = gtk_label_new ("");
+       gtk_widget_show (label);
+       gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
+       gtk_widget_set_usize (label, 16, -1);
+
+       label = gtk_label_new (_("(Leave User ID empty to use receive server's account information)"));
+       gtk_widget_show (label);
+       gtk_box_pack_start (GTK_BOX (hbox2), label,
+                           FALSE, FALSE, 0);
+
        smtp_auth_hbox = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (smtp_auth_hbox);
        gtk_box_pack_start (GTK_BOX (vbox3), smtp_auth_hbox, FALSE, FALSE, 0);
@@ -1125,20 +1142,17 @@ static void prefs_account_send_create(void)
        gtk_box_pack_start (GTK_BOX (smtp_auth_hbox), uid_label,
                            FALSE, FALSE, 0);
        gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
-       SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, uid_label);
 
        smtp_userid_entry = gtk_entry_new ();
        gtk_widget_show (smtp_userid_entry);
        gtk_widget_set_usize (smtp_userid_entry, DEFAULT_ENTRY_WIDTH, -1);
        gtk_box_pack_start (GTK_BOX (smtp_auth_hbox), smtp_userid_entry,
                            TRUE, TRUE, 0);
-       SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, smtp_userid_entry);
 
        pass_label = gtk_label_new (_("Password"));
        gtk_widget_show (pass_label);
        gtk_box_pack_start (GTK_BOX (smtp_auth_hbox), pass_label,
                            FALSE, FALSE, 0);
-       SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, pass_label);
 
        smtp_passwd_entry = gtk_entry_new ();
        gtk_widget_show (smtp_passwd_entry);
@@ -1146,7 +1160,11 @@ static void prefs_account_send_create(void)
        gtk_box_pack_start (GTK_BOX (smtp_auth_hbox), smtp_passwd_entry,
                            TRUE, TRUE, 0);
        gtk_entry_set_visibility (GTK_ENTRY (smtp_passwd_entry), FALSE);
-       SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, smtp_passwd_entry);
+
+       SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, smtp_auth_hbox);
+       gtk_signal_connect(GTK_OBJECT(smtp_userid_entry), "changed",
+                          GTK_SIGNAL_FUNC(prefs_account_smtp_userid_cb), smtp_passwd_entry);
+       prefs_account_smtp_userid_cb(GTK_EDITABLE(smtp_userid_entry), smtp_passwd_entry);
 
        PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_chkbtn,
                _("Authenticate with POP3 before sending"));
@@ -2007,3 +2025,19 @@ static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
        gtk_widget_set_sensitive(basic.uid_entry,  !use_mailcmd);
        gtk_widget_set_sensitive(basic.pass_entry, !use_mailcmd);
 }
+
+static void prefs_account_smtp_userid_cb(GtkEditable *editable,
+                                        gpointer smtp_passwd)
+{
+       gchar *buf;
+       gboolean use_smtp_userid;
+       
+       buf = gtk_editable_get_chars(editable, 0, -1);
+       if(buf[0] == '\0') {
+               use_smtp_userid = FALSE;
+       } else {
+               use_smtp_userid = TRUE;
+       }
+       gtk_widget_set_sensitive(GTK_WIDGET(smtp_passwd), use_smtp_userid);
+       g_free(buf);
+}
index 8d1b24a..9da7aba 100644 (file)
@@ -104,14 +104,6 @@ void prefs_folder_item_cancel_cb           (GtkWidget *widget,
                                                 struct PrefsFolderItemDialog *dialog);
 void prefs_folder_item_ok_cb                   (GtkWidget *widget, 
                                                 struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_default_to_cb           (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_simplify_subject_cb     (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_folder_chmod_cb         (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
-void prefs_folder_item_default_account_cb      (GtkWidget *widget, 
-                                                struct PrefsFolderItemDialog *dialog);
 gint prefs_folder_item_chmod_mode              (gchar *folder_chmod);
 
 
@@ -352,13 +344,11 @@ void prefs_folder_item_create(void *folderview, FolderItem *item)
                         rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_default_to), 
                                     item->prefs->enable_default_to);
-       gtk_signal_connect(GTK_OBJECT(checkbtn_default_to), "toggled",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_default_to_cb), dialog);
 
        entry_default_to = gtk_entry_new();
        gtk_widget_show(entry_default_to);
        gtk_table_attach_defaults(GTK_TABLE(table), entry_default_to, 1, 2, rowcount, rowcount + 1);
-       gtk_editable_set_editable(GTK_EDITABLE(entry_default_to), item->prefs->enable_default_to);
+       SET_TOGGLE_SENSITIVITY(checkbtn_default_to, entry_default_to);
        gtk_entry_set_text(GTK_ENTRY(entry_default_to), SAFE_STRING(item->prefs->default_to));
        address_completion_register_entry(GTK_ENTRY(entry_default_to));
 
@@ -371,15 +361,12 @@ void prefs_folder_item_create(void *folderview, FolderItem *item)
                         rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_simplify_subject), 
                                     item->prefs->enable_simplify_subject);
-       gtk_signal_connect(GTK_OBJECT(checkbtn_simplify_subject), "toggled",
-                          GTK_SIGNAL_FUNC(prefs_folder_item_simplify_subject_cb), dialog);
 
        entry_simplify_subject = gtk_entry_new();
        gtk_widget_show(entry_simplify_subject);
        gtk_table_attach_defaults(GTK_TABLE(table), entry_simplify_subject, 1, 2, 
                                  rowcount, rowcount + 1);
-       gtk_editable_set_editable(GTK_EDITABLE(entry_simplify_subject), 
-                                 item->prefs->enable_simplify_subject);
+       SET_TOGGLE_SENSITIVITY(checkbtn_simplify_subject, entry_simplify_subject);
        gtk_entry_set_text(GTK_ENTRY(entry_simplify_subject), 
                           SAFE_STRING(item->prefs->simplify_subject_regexp));
 
@@ -393,15 +380,12 @@ void prefs_folder_item_create(void *folderview, FolderItem *item)
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_chmod), 
                                     item->prefs->enable_folder_chmod);
-       gtk_signal_connect(GTK_OBJECT(checkbtn_folder_chmod), "toggled",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_folder_chmod_cb), dialog);
 
        entry_folder_chmod = gtk_entry_new();
        gtk_widget_show(entry_folder_chmod);
        gtk_table_attach_defaults(GTK_TABLE(table), entry_folder_chmod, 1, 2, 
                                  rowcount, rowcount + 1);
-       gtk_editable_set_editable(GTK_EDITABLE(entry_folder_chmod), 
-                                 item->prefs->enable_folder_chmod);
+       SET_TOGGLE_SENSITIVITY(checkbtn_folder_chmod, entry_folder_chmod);
        if (item->prefs->folder_chmod) {
                gchar *buf;
 
@@ -419,8 +403,6 @@ void prefs_folder_item_create(void *folderview, FolderItem *item)
                         rowcount, rowcount + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_account), 
                                     item->prefs->enable_default_account);
-       gtk_signal_connect(GTK_OBJECT(checkbtn_enable_default_account), "toggled",
-                           GTK_SIGNAL_FUNC(prefs_folder_item_default_account_cb), dialog);
 
        optmenu_default_account = gtk_option_menu_new ();
        gtk_widget_show (optmenu_default_account);
@@ -453,7 +435,7 @@ void prefs_folder_item_create(void *folderview, FolderItem *item)
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
 
-       gtk_widget_set_sensitive(optmenu_default_account, item->prefs->enable_default_account);
+       SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_account, optmenu_default_account);
 
        rowcount++;
 
@@ -566,23 +548,6 @@ void prefs_folder_item_ok_cb(GtkWidget *widget,
        prefs_folder_item_destroy(dialog);
 }
 
-void prefs_folder_item_default_to_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) 
-{
-       gtk_editable_set_editable(GTK_EDITABLE(dialog->entry_default_to),
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_default_to)));
-}
-
-void prefs_folder_item_simplify_subject_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) 
-{
-       gtk_editable_set_editable(GTK_EDITABLE(dialog->entry_simplify_subject),
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_simplify_subject)));
-}
-
-void prefs_folder_item_folder_chmod_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) {
-       gtk_editable_set_editable(GTK_EDITABLE(dialog->entry_folder_chmod),
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_folder_chmod)));
-}
-
 gint prefs_folder_item_chmod_mode(gchar *folder_chmod) 
 {
        gint newmode = 0;
@@ -596,9 +561,3 @@ gint prefs_folder_item_chmod_mode(gchar *folder_chmod)
 
        return newmode;
 }
-
-void prefs_folder_item_default_account_cb(GtkWidget *widget, struct PrefsFolderItemDialog *dialog) 
-{
-       gtk_widget_set_sensitive(dialog->optmenu_default_account,
-           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->checkbtn_enable_default_account)));
-}