#endif
static void compose_attach_update_label(Compose *compose);
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data);
+
static GtkItemFactoryEntry compose_popup_entries[] =
{
{N_("/_Add..."), NULL, compose_attach_cb, 0, NULL},
alertpanel_error(_("New message subject format error."));
else
gtk_entry_set_text(GTK_ENTRY(compose->subject_entry), buf);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(subject);
body_format,
NULL, tmp, FALSE, TRUE,
_("New message body format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
g_free(tmp);
compose_quote_fmt(compose, compose->replyinfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message reply format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
}
compose_quote_fmt(compose, full_msginfo,
body_fmt, qmark, body, FALSE, TRUE,
_("Message forward format error at line %d."));
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_attach_parts(compose, msginfo);
/* process the other fields */
compose_template_apply_fields(compose, tmpl);
+ compose_attach_from_list(compose, quote_fmt_get_attachments_list(), FALSE);
quote_fmt_reset_vartable();
compose_changed_cb(NULL, compose);
}
compose_draft(data, action);
}
-static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+static void compose_attach_from_list(Compose *compose, GList *file_list, gboolean free_data)
{
- Compose *compose = (Compose *)data;
- GList *file_list;
-
- if (compose->redirect_filename != NULL)
- return;
-
- file_list = filesel_select_multiple_files_open(_("Select file"));
-
- if (file_list) {
+ if (compose && file_list) {
GList *tmp;
for ( tmp = file_list; tmp; tmp = tmp->next) {
gchar *utf8_filename = conv_filename_to_utf8(file);
compose_attach_append(compose, file, utf8_filename, NULL);
compose_changed_cb(NULL, compose);
+ if (free_data) {
g_free(file);
+ tmp->data = NULL;
+ }
g_free(utf8_filename);
}
+ }
+}
+
+static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
+{
+ Compose *compose = (Compose *)data;
+ GList *file_list;
+
+ if (compose->redirect_filename != NULL)
+ return;
+
+ file_list = filesel_select_multiple_files_open(_("Select file"));
+
+ if (file_list) {
+ compose_attach_from_list(compose, file_list, TRUE);
g_list_free(file_list);
}
}
"|file{<span style=\"oblique\">sub_expr</span>}\n(|f{<span style=\"oblique\">sub_expr</span>})", N_("insert file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to insert"), /* insert file */
"|program{<span style=\"oblique\">sub_expr</span>}\n(|p{<span style=\"oblique\">sub_expr</span>})\n", N_("insert program output:\n<span style=\"oblique\">sub_expr</span> is evaluated as a command-line to get\nthe output from"), /* insert program output */
"|input{<span style=\"oblique\">sub_expr</span>}\n(|i{<span style=\"oblique\">sub_expr</span>})\n", N_("insert user input:\n<span style=\"oblique\">sub_expr</span> is a variable to be replaced by\nuser-entered text"), /* insert user input */
+ "|attach{<span style=\"oblique\">sub_expr</span>}\n(|a{<span style=\"oblique\">sub_expr</span>})", N_("attach file:\n<span style=\"oblique\">sub_expr</span> is evaluated as the path of the file to attach"), /* attach file */
"", NULL,
N_("<span weight=\"bold\">definition of terms:</span>"), NULL,
"<span style=\"oblique\">expr</span>\n", N_("text that can contain any of the symbols or\ncommands above"),
static gint maxsize = 0;
static gint stacksize = 0;
static GHashTable *var_table = NULL;
+static GList *attachments = NULL;
typedef struct st_buffer
{
return current->buffer;
}
+GList *quote_fmt_get_attachments_list(void)
+{
+ fprintf(stderr, "+ get attachment list %p\n", attachments);
+ return attachments;
+}
+
gint quote_fmt_get_line(void)
{
return line;
g_hash_table_destroy(var_table);
var_table = NULL;
}
+ if (attachments) {
+ fprintf(stderr, "+ freeing attachment list\n");
+ GList *cur = attachments;
+ while (cur) {
+ fprintf(stderr, "-> %s\n", (gchar*)cur->data);
+ g_free(cur->data);
+ cur = g_list_next(cur);
+ }
+ g_list_free(attachments);
+ attachments = NULL;
+ }
}
#ifdef USE_ASPELL
g_free(text);
}
+static void quote_fmt_attach_file(const gchar *filename)
+{
+ fprintf(stderr, "+ adding attachment %s\n", filename);
+ attachments = g_list_append(attachments, g_strdup(filename));
+}
+
static gchar *quote_fmt_complete_address(const gchar *addr)
{
gint count;
%token QUERY_NOT_TO_FOUND_IN_ADDRESSBOOK
/* other tokens */
%token INSERT_FILE INSERT_PROGRAMOUTPUT INSERT_USERINPUT
+%token ATTACH_FILE
%token OPARENT CPARENT
%token CHARACTER
%token SHOW_DATE_EXPR
character_or_special
| query
| query_not
- | insert ;
+ | insert
+ | attach ;
character_or_special:
special
quote_fmt_insert_user_input(sub_expr.buffer);
}
};
+
+attach:
+ ATTACH_FILE
+ {
+ current = &sub_expr;
+ clear_buffer();
+ }
+ OPARENT sub_expr CPARENT
+ {
+ current = &main_expr;
+ if (!dry_run) {
+ quote_fmt_attach_file(sub_expr.buffer);
+ }
+ };