sync with sylpheed 0.6.6cvs1
[claws.git] / src / prefs_template.c
index 6250aae1e619da2e05cc264f3da4545a522c698c..6e5d726699d2fc3978ae6cb8e2f29165acffa699 100644 (file)
@@ -37,6 +37,7 @@
 #include "manage_window.h"
 #include "prefs_common.h"
 #include "compose.h"
+#include "addr_compl.h"
 #include "quote_fmt.h"
 
 static struct Templates {
@@ -150,7 +151,6 @@ static void prefs_template_window_create(void)
        hbox1 = gtk_hbox_new(FALSE, 8);
        gtk_widget_show(hbox1);
        gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
-       gtk_container_set_border_width(GTK_CONTAINER(hbox1), 2);
 
        label1 = gtk_label_new(_("Template name"));
        gtk_widget_show(label1);
@@ -168,6 +168,7 @@ static void prefs_template_window_create(void)
        gtk_table_set_col_spacings(GTK_TABLE(table), 4);
 
        ADD_ENTRY(entry_to, _("To:"), 0);
+       address_completion_register_entry(GTK_ENTRY(entry_to));
        ADD_ENTRY(entry_subject, _("Subject:"), 1);
 
 #undef ADD_ENTRY
@@ -275,6 +276,8 @@ static void prefs_template_window_create(void)
        gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
                            GTK_SIGNAL_FUNC(prefs_template_cancel_cb), NULL);
 
+       address_completion_start(window);
+
        templates.window = window;
        templates.ok_btn = ok_btn;
        templates.clist_tmpls = clist_tmpls;
@@ -444,10 +447,19 @@ static gint prefs_template_clist_set_row(gint row)
        name = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_name),
                                      0, -1);
        subject = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_subject),
-                                     0, -1);
+                                        0, -1);
        to = gtk_editable_get_chars(GTK_EDITABLE(templates.entry_to),
                                    0, -1);
 
+       if (subject && *subject == '\0') {
+               g_free(subject);
+               subject = NULL;
+       }
+       if (to && *to == '\0') {
+               g_free(to);
+               to = NULL;
+       }
+
        tmpl = g_new(Template, 1);
        tmpl->name = name;
        tmpl->subject = subject;