diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compose.c | 16 | ||||
-rw-r--r-- | src/filesel.c | 51 | ||||
-rw-r--r-- | src/filesel.h | 3 | ||||
-rw-r--r-- | src/main.c | 3 |
4 files changed, 56 insertions, 17 deletions
diff --git a/src/compose.c b/src/compose.c index f86d3274..18622d79 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5257,19 +5257,23 @@ static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget) static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget) { Compose *compose = (Compose *)data; - gchar *file; - gchar *utf8_filename; + GSList *files; + GSList *cur; - file = filesel_select_file(_("Select file"), NULL, - GTK_FILE_CHOOSER_ACTION_OPEN); + files = filesel_select_files(_("Select files"), NULL, + GTK_FILE_CHOOSER_ACTION_OPEN); + + for (cur = files; cur != NULL; cur = cur->next) { + gchar *file = (gchar *)cur->data; + gchar *utf8_filename; - if (file && *file) { utf8_filename = conv_filename_to_utf8(file); compose_attach_append(compose, file, utf8_filename, NULL); g_free(utf8_filename); + g_free(file); } - g_free(file); + g_slist_free(files); } static void compose_insert_file_cb(gpointer data, guint action, diff --git a/src/filesel.c b/src/filesel.c index d480bc92..67db7881 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -29,16 +29,45 @@ #include "alertpanel.h" #include "utils.h" -static GtkWidget *filesel_create(const gchar *title, - GtkFileChooserAction action); +static GSList *filesel_select_file_full (const gchar *title, + const gchar *file, + GtkFileChooserAction action, + gboolean multiple); + +static GtkWidget *filesel_create (const gchar *title, + GtkFileChooserAction action); + gchar *filesel_select_file(const gchar *title, const gchar *file, GtkFileChooserAction action) { + GSList *list; + gchar *selected = NULL; + + list = filesel_select_file_full(title, file, action, FALSE); + if (list) { + selected = (gchar *)list->data; + slist_free_strings(list->next); + } + g_slist_free(list); + + return selected; +} + +GSList *filesel_select_files(const gchar *title, const gchar *file, + GtkFileChooserAction action) +{ + return filesel_select_file_full(title, file, action, TRUE); +} + +static GSList *filesel_select_file_full(const gchar *title, const gchar *file, + GtkFileChooserAction action, + gboolean multiple) +{ static gchar *cwd = NULL; GtkWidget *dialog; - gchar *filename = NULL; gchar *prev_dir; + GSList *list = NULL; if (!cwd) cwd = g_strdup(startup_dir); @@ -57,24 +86,24 @@ gchar *filesel_select_file(const gchar *title, const gchar *file, gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), file); + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), + multiple); + gtk_widget_show(dialog); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - filename = gtk_file_chooser_get_filename - (GTK_FILE_CHOOSER(dialog)); - if (filename) { - gchar *dir; - - dir = g_dirname(filename); + list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); + if (list) { g_free(cwd); - cwd = dir; + cwd = gtk_file_chooser_get_current_folder + (GTK_FILE_CHOOSER(dialog)); } } manage_window_focus_out(dialog, NULL, NULL); gtk_widget_destroy(dialog); - return filename; + return list; } gchar *filesel_save_as(const gchar *file) diff --git a/src/filesel.h b/src/filesel.h index 098e31c1..24764d9c 100644 --- a/src/filesel.h +++ b/src/filesel.h @@ -26,6 +26,9 @@ gchar *filesel_select_file (const gchar *title, const gchar *file, GtkFileChooserAction action); +GSList *filesel_select_files (const gchar *title, + const gchar *file, + GtkFileChooserAction action); gchar *filesel_save_as (const gchar *file); @@ -739,6 +739,9 @@ static void migrate_old_config(void) if (is_file_exist(OLD_RC_DIR G_DIR_SEPARATOR_S FOLDER_LIST)) copy_file(OLD_RC_DIR G_DIR_SEPARATOR_S FOLDER_LIST, RC_DIR G_DIR_SEPARATOR_S FOLDER_LIST, FALSE); + if (is_file_exist(OLD_RC_DIR G_DIR_SEPARATOR_S "mime.types")) + copy_file(OLD_RC_DIR G_DIR_SEPARATOR_S "mime.types", + RC_DIR G_DIR_SEPARATOR_S "mime.types", FALSE); if (is_dir_exist(OLD_RC_DIR G_DIR_SEPARATOR_S TEMPLATE_DIR)) conv_copy_dir(OLD_RC_DIR G_DIR_SEPARATOR_S TEMPLATE_DIR, |