add Cc and Bcc to template
authorPaul Mangan <paul@claws-mail.org>
Sat, 12 Oct 2002 10:34:49 +0000 (10:34 +0000)
committerPaul Mangan <paul@claws-mail.org>
Sat, 12 Oct 2002 10:34:49 +0000 (10:34 +0000)
ChangeLog.claws
configure.in
src/compose.c
src/prefs_template.c
src/template.c
src/template.h

index d93e7a3..df45e0e 100644 (file)
@@ -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
index e01cff2..9e0b36d 100644 (file)
@@ -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
index 1a9fe28..c8027b9 100644 (file)
@@ -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));
index ca3d2a5..ff2feda 100644 (file)
@@ -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;
index fc2974e..659769e 100644 (file)
@@ -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);
index f5037e0..ece4fed 100644 (file)
@@ -28,6 +28,8 @@ struct _Template {
        gchar *name;
        gchar *subject;
        gchar *to;
+       gchar *cc;
+       gchar *bcc;             
        gchar *value;
 };