[prev in list] [next in list] [prev in thread] [next in thread]
List: sylpheed
Subject: [sylpheed:21986] multiple attachment selection patch
From: Jared Yanovich <phirerunner () comcast ! net>
Date: 2003-11-23 6:05:26
[Download RAW message or body]
I find multiple attachment selection as being rather useful and made
this patch to add support for it. Thought someone else might find it
useful as well.
- Jared
Index: compose.c
===================================================================
RCS file: /cvsroot/sylpheed/sylpheed/src/compose.c,v
retrieving revision 1.251
diff -u -r1.251 compose.c
--- compose.c 10 Nov 2003 04:49:34 -0000 1.251
+++ compose.c 22 Nov 2003 19:48:23 -0000
@@ -5291,12 +5291,13 @@
static void compose_attach_cb(gpointer data, guint action, GtkWidget *widget)
{
Compose *compose = (Compose *)data;
- gchar *file;
+ GSList *files = NULL;
- file = filesel_select_file(_("Select file"), NULL);
+ files = filesel_select_files(_("Select file"), NULL);
- if (file) {
- compose_attach_append(compose, file, file, NULL);
+ for (; files; files = g_slist_next(files)) {
+ compose_attach_append(compose, (gchar *)files->data,
+ (gchar *)files->data, NULL);
compose_changed_cb(NULL, compose);
}
}
Index: filesel.c
===================================================================
RCS file: /cvsroot/sylpheed/sylpheed/src/filesel.c,v
retrieving revision 1.10
diff -u -r1.10 filesel.c
--- filesel.c 6 Jun 2003 04:01:53 -0000 1.10
+++ filesel.c 22 Nov 2003 19:48:23 -0000
@@ -119,6 +119,90 @@
MANAGE_WINDOW_SIGNALS_CONNECT(filesel);
}
+GSList *filesel_select_files(const gchar *title, const GSList *files)
+{
+ static GSList *filenames = NULL;
+ static gchar *cwd = NULL;
+
+ filesel_create(title);
+
+ gtk_clist_set_selection_mode(GTK_CLIST(GTK_FILE_SELECTION(
+ filesel)->file_list), GTK_SELECTION_MULTIPLE);
+
+ manage_window_set_transient(GTK_WINDOW(filesel));
+
+ if (filenames) {
+ g_slist_free(filenames);
+ filenames = NULL;
+ }
+
+ if (!cwd)
+ cwd = g_strconcat(startup_dir, G_DIR_SEPARATOR_S, NULL);
+
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), cwd);
+
+ if (files) {
+ gchar *str, *file;
+ GList *row;
+ gint idx = 0;
+
+ for (row = GTK_CLIST(GTK_FILE_SELECTION(filesel)->file_list)->row_list;
+ row;
+ idx++, row = g_list_next(row)) {
+ gtk_clist_get_text(GTK_CLIST(GTK_FILE_SELECTION(
+ filesel)->file_list), idx, 0, &str);
+ file = g_basename(str);
+ if (g_slist_find(filenames, file))
+ gtk_clist_select_row(GTK_CLIST(GTK_FILE_SELECTION(
+ filesel)->file_list), idx, 0);
+ g_free(file);
+ }
+
+ gtk_entry_select_region(GTK_ENTRY(GTK_FILE_SELECTION(
+ filesel)->selection_entry), 0, -1);
+ }
+
+ gtk_widget_show(filesel);
+
+ filesel_ack = filesel_fin = FALSE;
+
+ while (filesel_fin == FALSE)
+ gtk_main_iteration();
+
+ if (filesel_ack) {
+ gchar *dir, *str, *file;
+ GList *row;
+ gint idx = 0;
+
+ if (g_list_length(GTK_CLIST(GTK_FILE_SELECTION(filesel)->file_list)->row_list)) {
+ /* Get associated directory path */
+ str = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
+ dir = g_dirname(str);
+ g_free(cwd);
+ cwd = g_strconcat(dir, G_DIR_SEPARATOR_S, NULL);
+ g_free(dir);
+
+ for (row = GTK_CLIST(GTK_FILE_SELECTION(filesel)->file_list)->row_list;
+ row;
+ idx++, row = g_list_next(row)) {
+ if (GTK_CLIST_ROW(row)->state == GTK_STATE_SELECTED) {
+ gtk_clist_get_text(
+ GTK_CLIST(GTK_FILE_SELECTION(filesel)->file_list),
+ idx, 0, &str);
+ filenames = g_slist_prepend(filenames,
+ g_strconcat(cwd, str, NULL));
+ }
+ }
+ }
+ }
+
+ manage_window_focus_out(filesel, NULL, NULL);
+ gtk_widget_destroy(filesel);
+ GTK_EVENTS_FLUSH();
+
+ return filenames;
+}
+
static void filesel_ok_cb(GtkWidget *widget, gpointer data)
{
filesel_ack = TRUE;
Index: filesel.h
===================================================================
RCS file: /cvsroot/sylpheed/sylpheed/src/filesel.h,v
retrieving revision 1.2
diff -u -r1.2 filesel.h
--- filesel.h 25 Sep 2000 15:25:46 -0000 1.2
+++ filesel.h 22 Nov 2003 19:48:23 -0000
@@ -23,5 +23,6 @@
#include <glib.h>
gchar *filesel_select_file(const gchar *title, const gchar *file);
+GSList *filesel_select_files(const gchar *title, const GSList *files);
#endif /* __FILESEL_H__ */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic