dynamically-added custom headers
authorColin Leroy <colin@colino.net>
Sun, 15 Sep 2002 23:43:12 +0000 (23:43 +0000)
committerColin Leroy <colin@colino.net>
Sun, 15 Sep 2002 23:43:12 +0000 (23:43 +0000)
ChangeLog.claws
configure.in
src/compose.c

index fa2837b..71ca8f0 100644 (file)
@@ -1,3 +1,9 @@
+2002-09-15 [colin]     0.8.2claws51
+
+       * src/compose.c
+               Allow dynamically-added custom headers
+               Yet not reparsed if reedited
+
 2002-09-15 [alfons]    0.8.2claws50
 
        * src/prefs_account.c
index f9e059a..0af2944 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws50
+EXTRA_VERSION=claws51
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index ff31fb3..f0a9f1e 100644 (file)
@@ -3881,6 +3881,9 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        gchar buf[BUFFSIZE];
        gchar *str;
        gchar *name;
+       GSList *list;
+       gchar * std_headers[] = {"To", "Cc", "Bcc", "Newsgroups", "Reply-To", "Followup-To", NULL};
+
        /* struct utsname utsbuf; */
 
        g_return_val_if_fail(fp != NULL, -1);
@@ -4125,10 +4128,35 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                                fprintf(fp, "Disposition-Notification-To: %s\n", compose->account->address);
                }
        }
-       
+
+       /* get special headers */
+       for (list = compose->header_list; list; list = list->next) {
+               ComposeHeaderEntry *headerentry;
+               gchar * headerentryname;
+               gchar * headerentryvalue;
+               gchar **string;
+               gboolean standard_header = FALSE;
+
+               headerentry = ((ComposeHeaderEntry *)list->data);
+               headerentryname = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry)));
+               headerentryvalue = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
+               if (strstr(headerentryname,":"))
+                       headerentryname = strtok(headerentryname,":");
+               string = std_headers;
+               while (*string != NULL) {
+                       if (!strcmp(*string,headerentryname))
+                               standard_header = TRUE;
+                       string++;
+               }
+               if (!standard_header && !IS_IN_CUSTOM_HEADER(headerentryname))
+                       fprintf(fp,"%s: %s\n",headerentryname, headerentryvalue);
+                               
+               g_free(headerentryname);
+       }
+
        /* separator between header and body */
        fputs("\n", fp);
-
+       
        return 0;
 }
 
@@ -4192,6 +4220,7 @@ static void compose_create_header_entry(Compose *compose)
        GList *combo_list = NULL;
        gchar **string, *header;
        ComposeHeaderEntry *headerentry;
+       gboolean standard_header = FALSE;
 
        headerentry = g_new0(ComposeHeaderEntry, 1);
 
@@ -4204,12 +4233,21 @@ static void compose_create_header_entry(Compose *compose)
        }
        gtk_combo_set_popdown_strings(GTK_COMBO(combo), combo_list);
        g_list_free(combo_list);
-       gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), FALSE);
+       gtk_editable_set_editable(GTK_EDITABLE(GTK_COMBO(combo)->entry), TRUE);
        gtk_widget_show(combo);
        gtk_table_attach(GTK_TABLE(compose->header_table), combo, 0, 1, compose->header_nextrow, compose->header_nextrow+1, GTK_SHRINK, GTK_FILL, 0, 0);
        if(compose->header_last) {      
-               header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
-       } else {
+               gchar *last_header_entry = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+               string = headers;
+               while (*string != NULL) {
+                       if (!strcmp(*string,last_header_entry))
+                               standard_header = TRUE;
+                       string++;
+               }
+               if (standard_header)
+                       header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(compose->header_last->combo)->entry));
+       }
+       if (!compose->header_last || !standard_header) {
                switch(compose->account->protocol) {
                        case A_NNTP:
                                header = prefs_common.trans_hdr ? _("Newsgroups:") : "Newsgroups:";