[Commits] compose.c 1.382.2.613 1.382.2.614
mones at claws-mail.org
mones at claws-mail.org
Wed Oct 10 01:58:45 CEST 2012
Update of /home/claws-mail/claws/src
In directory srv:/tmp/cvs-serv24032/src
Modified Files:
Tag: gtk2
compose.c
Log Message:
2012-10-09 [mones] 3.8.1cvs86
* doc/man/claws-mail.1
* src/compose.c
* src/common/utils.c
New extra headers feature for adding user-defined
extra headers to the combobox in the compose window
Headers are stablished in 'extraheaderrc', one per
line with a final colon
Index: compose.c
===================================================================
RCS file: /home/claws-mail/claws/src/compose.c,v
retrieving revision 1.382.2.613
retrieving revision 1.382.2.614
diff -u -d -r1.382.2.613 -r1.382.2.614
--- compose.c 16 Sep 2012 21:56:20 -0000 1.382.2.613
+++ compose.c 9 Oct 2012 23:58:42 -0000 1.382.2.614
@@ -183,6 +183,7 @@
#define MAX_REFERENCES_LEN 999
static GList *compose_list = NULL;
+static GSList *extra_headers = NULL;
static Compose *compose_generic_new (PrefsAccount *account,
const gchar *to,
@@ -6597,6 +6598,54 @@
gtk_widget_show(menuitem);
}
+void compose_add_extra_header(gchar *header, GtkListStore *model)
+{
+ GtkTreeIter iter;
+ if (strcmp(header, "")) {
+ COMBOBOX_ADD(model, header, COMPOSE_TO);
+ }
+}
+
+void compose_add_extra_header_entries(GtkListStore *model)
+{
+ FILE *exh;
+ gchar *exhrc;
+ gchar buf[BUFFSIZE];
+ gint lastc;
+
+ if (extra_headers == NULL) {
+ exhrc = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "extraheaderrc", NULL);
+ if ((exh = g_fopen(exhrc, "rb")) == NULL) {
+ debug_print("extra headers file not found\n");
+ goto extra_headers_done;
+ }
+ while (fgets(buf, BUFFSIZE, exh) != NULL) {
+ lastc = strlen(buf) - 1; /* remove trailing \n */
+ buf[lastc] = (buf[lastc] == '\n')? '\0': buf[lastc];
+ --lastc;
+ if (lastc > 0 && buf[0] != '#' && buf[lastc] == ':') {
+ buf[lastc] = '\0'; /* remove trailing : for comparison */
+ if (custom_header_is_allowed(buf)) {
+ buf[lastc] = ':';
+ extra_headers = g_slist_prepend(extra_headers, g_strdup(buf));
+ }
+ else
+ g_message("disallowed extra header line: %s\n", buf);
+ }
+ else {
+ if (buf[0] != '#')
+ g_message("invalid extra header line: %s\n", buf);
+ }
+ }
+ fclose(exh);
+extra_headers_done:
+ g_free(exhrc);
+ extra_headers = g_slist_prepend(extra_headers, g_strdup("")); /* end of list */
+ extra_headers = g_slist_reverse(extra_headers);
+ }
+ g_slist_foreach(extra_headers, (GFunc)compose_add_extra_header, (gpointer)model);
+}
+
static void compose_create_header_entry(Compose *compose)
{
gchar *headers[] = {"To:", "Cc:", "Bcc:", "Newsgroups:", "Reply-To:", "Followup-To:", NULL};
@@ -6632,6 +6681,7 @@
COMPOSE_REPLYTO);
COMBOBOX_ADD(model, prefs_common_translated_header_name("Followup-To:"),
COMPOSE_FOLLOWUPTO);
+ compose_add_extra_header_entries(model);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(combo))), "grab_focus",
@@ -8492,6 +8542,9 @@
slist_free_strings(compose->header_list);
g_slist_free(compose->header_list);
+ slist_free_strings(extra_headers);
+ extra_headers = NULL;
+
compose->header_list = compose->newsgroup_list = compose->to_list = NULL;
g_hash_table_destroy(compose->email_hashtable);
More information about the Commits
mailing list