From 87005219713e6eaa9b7421c761ee700077ae2a55 Mon Sep 17 00:00:00 2001 From: Paul Mangan Date: Sat, 12 Oct 2002 10:34:49 +0000 Subject: [PATCH] add Cc and Bcc to template --- ChangeLog.claws | 8 ++++++++ configure.in | 2 +- src/compose.c | 5 +++++ src/prefs_template.c | 34 ++++++++++++++++++++++++++++++++-- src/template.c | 12 ++++++++++++ src/template.h | 2 ++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index d93e7a3bc..df45e0e6f 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,11 @@ +2002-10-12 [paul] 0.8.5claws23 + + * src/compose.c + src/prefs_template.c + src/template.[ch] + add Cc and Bcc to templates. Patch submitted by + John L. Males. + 2002-10-12 [colin] 0.8.5claws22 * src/folderview.c diff --git a/configure.in b/configure.in index e01cff201..9e0b36d9e 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,7 @@ MINOR_VERSION=8 MICRO_VERSION=5 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws22 +EXTRA_VERSION=claws23 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target diff --git a/src/compose.c b/src/compose.c index 1a9fe289c..c8027b9ff 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5372,6 +5372,11 @@ static void compose_template_apply(Compose *compose, Template *tmpl, tmpl->subject); if (tmpl->to && *tmpl->to != '\0') compose_entry_append(compose, tmpl->to, COMPOSE_TO); + if (tmpl->cc && *tmpl->cc != '\0') + compose_entry_append(compose, tmpl->cc, COMPOSE_CC); + + if (tmpl->bcc && *tmpl->bcc != '\0') + compose_entry_append(compose, tmpl->bcc, COMPOSE_BCC); if (replace) gtk_stext_clear(GTK_STEXT(compose->text)); diff --git a/src/prefs_template.c b/src/prefs_template.c index ca3d2a547..ff2feda02 100644 --- a/src/prefs_template.c +++ b/src/prefs_template.c @@ -46,6 +46,8 @@ static struct Templates { GtkWidget *entry_name; GtkWidget *entry_subject; GtkWidget *entry_to; + GtkWidget *entry_cc; + GtkWidget *entry_bcc; GtkWidget *text_value; } templates; @@ -110,6 +112,8 @@ static void prefs_template_window_create(void) GtkWidget *entry_name; GtkWidget *table; GtkWidget *entry_to; + GtkWidget *entry_cc; + GtkWidget *entry_bcc; GtkWidget *entry_subject; GtkWidget *scroll2; GtkWidget *text_value; @@ -168,7 +172,9 @@ static void prefs_template_window_create(void) ADD_ENTRY(entry_to, _("To:"), 0); address_completion_register_entry(GTK_ENTRY(entry_to)); - ADD_ENTRY(entry_subject, _("Subject:"), 1); + ADD_ENTRY(entry_cc, _("Cc:"), 1) + ADD_ENTRY(entry_bcc, _("Bcc:"), 2) + ADD_ENTRY(entry_subject, _("Subject:"), 3); #undef ADD_ENTRY @@ -280,6 +286,8 @@ static void prefs_template_window_create(void) templates.entry_name = entry_name; templates.entry_subject = entry_subject; templates.entry_to = entry_to; + templates.entry_cc = entry_cc; + templates.entry_bcc = entry_bcc; templates.text_value = text_value; } @@ -372,6 +380,8 @@ static void prefs_template_select_cb(GtkCList *clist, gint row, gint column, tmpl_def.name = _("Template"); tmpl_def.subject = ""; tmpl_def.to = ""; + tmpl_def.cc = ""; + tmpl_def.bcc = ""; tmpl_def.value = ""; if (!(tmpl = gtk_clist_get_row_data(clist, row))) @@ -380,6 +390,10 @@ static void prefs_template_select_cb(GtkCList *clist, gint row, gint column, gtk_entry_set_text(GTK_ENTRY(templates.entry_name), tmpl->name); gtk_entry_set_text(GTK_ENTRY(templates.entry_to), tmpl->to ? tmpl->to : ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_cc), + tmpl->cc ? tmpl->cc : ""); + gtk_entry_set_text(GTK_ENTRY(templates.entry_bcc), + tmpl->bcc ? tmpl->bcc : ""); gtk_entry_set_text(GTK_ENTRY(templates.entry_subject), tmpl->subject ? tmpl->subject : ""); @@ -416,6 +430,8 @@ static gint prefs_template_clist_set_row(gint row) gchar *name; gchar *subject; gchar *to; + gchar *cc; + gchar *bcc; gchar *value; gchar *title[1]; @@ -446,6 +462,10 @@ static gint prefs_template_clist_set_row(gint row) 0, -1); to = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_to), 0, -1); + cc = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_cc), + 0, -1); + bcc = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_bcc), + 0, -1); if (subject && *subject == '\0') { g_free(subject); @@ -455,11 +475,21 @@ static gint prefs_template_clist_set_row(gint row) g_free(to); to = NULL; } - + if (cc && *cc == '\0') { + g_free(cc); + cc = NULL; + } + if (bcc && *bcc == '\0') { + g_free(bcc); + bcc = NULL; + } + tmpl = g_new(Template, 1); tmpl->name = name; tmpl->subject = subject; tmpl->to = to; + tmpl->cc = cc; + tmpl->bcc = bcc; tmpl->value = value; title[0] = name; diff --git a/src/template.c b/src/template.c index fc2974ee5..659769e18 100644 --- a/src/template.c +++ b/src/template.c @@ -49,6 +49,8 @@ static Template *template_load(gchar *filename) tmpl->name = NULL; tmpl->subject = NULL; tmpl->to = NULL; + tmpl->cc = NULL; + tmpl->bcc = NULL; tmpl->value = NULL; while (fgets(buf, sizeof(buf), fp) != NULL) { @@ -60,6 +62,10 @@ static Template *template_load(gchar *filename) tmpl->subject = g_strdup(g_strstrip(buf + 8)); else if (!g_strncasecmp(buf, "To:", 3)) tmpl->to = g_strdup(g_strstrip(buf + 3)); + else if (!g_strncasecmp(buf, "Cc:", 3)) + tmpl->cc = g_strdup(g_strstrip(buf + 3)); + else if (!g_strncasecmp(buf, "Bcc:", 4)) + tmpl->bcc = g_strdup(g_strstrip(buf + 4)); } if (!tmpl->name) { @@ -86,6 +92,8 @@ void template_free(Template *tmpl) g_free(tmpl->name); g_free(tmpl->subject); g_free(tmpl->to); + g_free(tmpl->cc); + g_free(tmpl->bcc); g_free(tmpl->value); g_free(tmpl); } @@ -192,6 +200,10 @@ void template_write_config(GSList *tmpl_list) fprintf(fp, "Subject: %s\n", tmpl->subject); if (tmpl->to && *tmpl->to != '\0') fprintf(fp, "To: %s\n", tmpl->to); + if (tmpl->cc && *tmpl->cc != '\0') + fprintf(fp, "Cc: %s\n", tmpl->cc); + if (tmpl->bcc && *tmpl->bcc != '\0') + fprintf(fp, "Bcc: %s\n", tmpl->bcc); fputs("\n", fp); fwrite(tmpl->value, sizeof(gchar) * strlen(tmpl->value), 1, fp); fclose(fp); diff --git a/src/template.h b/src/template.h index f5037e080..ece4fed22 100644 --- a/src/template.h +++ b/src/template.h @@ -28,6 +28,8 @@ struct _Template { gchar *name; gchar *subject; gchar *to; + gchar *cc; + gchar *bcc; gchar *value; }; -- 2.25.1