aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/mail-config.c41
-rw-r--r--mail/mail-config.h3
-rw-r--r--mail/mail-display.c19
4 files changed, 58 insertions, 14 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index f37fa60ca4..072ac00183 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,14 @@
2002-01-25 Jeffrey Stedfast <fejj@ximian.com>
+ * mail-display.c (save_data_cb): Save the pathname.
+ (save_part): Use the new mail_config cruft to get the last used
+ save pathname.
+
+ * mail-config.c (config_read): Read in last_filesel_dir string.
+ (mail_config_write_on_exit): Save the last_filesel_dir setting.
+ (mail_config_get_last_filesel_dir): New
+ (mail_config_set_last_filesel_dir): New
+
* component-factory.c (destination_folder_handle_motion): Do some
NULL checking on the url before using it.
(destination_folder_handle_drop): Make sure the uri is non-NULL
diff --git a/mail/mail-config.c b/mail/mail-config.c
index d1e322bb0b..d56e42cbae 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -109,6 +109,8 @@ typedef struct {
MailConfigNewMailNotify notify;
char *notify_filename;
+
+ char *last_filesel_dir;
} MailConfig;
static MailConfig *config = NULL;
@@ -307,6 +309,21 @@ mail_config_clear (void)
g_slist_free (config->news);
config->news = NULL;
}
+
+ g_free (config->pgp_path);
+ config->pgp_path = NULL;
+
+ g_free (config->default_charset);
+ config->default_charset = NULL;
+
+ g_free (config->filter_log_path);
+ config->filter_log_path = NULL;
+
+ g_free (config->notify_filename);
+ config->notify_filename = NULL;
+
+ g_free (config->last_filesel_dir);
+ config->last_filesel_dir = NULL;
}
static void
@@ -652,6 +669,10 @@ config_read (void)
config->notify_filename = bonobo_config_get_string (
config->db, "/Mail/Notify/new_mail_notification_sound_file", NULL);
+
+ /* last filesel dir */
+ config->last_filesel_dir = bonobo_config_get_string (
+ config->db, "/Mail/Filesel/last_filesel_dir", NULL);
}
#define bonobo_config_set_string_wrapper(db, path, val, ev) bonobo_config_set_string (db, path, val ? val : "", ev)
@@ -957,6 +978,10 @@ mail_config_write_on_exit (void)
bonobo_config_set_string_wrapper (config->db, "/Mail/Notify/new_mail_notification_sound_file",
config->notify_filename, NULL);
+ /* last filesel dir */
+ bonobo_config_set_string_wrapper (config->db, "/Mail/Filesel/last_filesel_dir",
+ config->last_filesel_dir, NULL);
+
if (config->threaded_hash)
g_hash_table_foreach_remove (config->threaded_hash, hash_save_state, "Threads");
@@ -1189,6 +1214,22 @@ mail_config_set_filter_log_path (const char *path)
config->filter_log_path = g_strdup (path);
}
+const char *
+mail_config_get_last_filesel_dir (void)
+{
+ if (config->last_filesel_dir)
+ return config->last_filesel_dir;
+ else
+ return g_get_home_dir ();
+}
+
+void
+mail_config_set_last_filesel_dir (const char *path)
+{
+ g_free (config->last_filesel_dir);
+ config->last_filesel_dir = g_strdup (path);
+}
+
gboolean
mail_config_get_hide_deleted (void)
{
diff --git a/mail/mail-config.h b/mail/mail-config.h
index fb8082a919..a517481f55 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -127,6 +127,9 @@ void mail_config_set_filter_log (gboolean value);
const char *mail_config_get_filter_log_path (void);
void mail_config_set_filter_log_path (const char *path);
+const char *mail_config_get_last_filesel_dir (void);
+void mail_config_set_last_filesel_dir (const char *path);
+
gboolean mail_config_get_empty_trash_on_exit (void);
void mail_config_set_empty_trash_on_exit (gboolean value);
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 15cd27809c..116dba913f 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -71,7 +71,6 @@ struct _PixbufLoader {
};
static GHashTable *thumbnail_cache = NULL;
-static char *save_pathname = NULL; /* preserves last directory in save dialog */
/*----------------------------------------------------------------------*
* Callbacks
@@ -154,7 +153,7 @@ save_data_cb (GtkWidget *widget, gpointer user_data)
{
GtkFileSelection *file_select = (GtkFileSelection *)
gtk_widget_get_ancestor (widget, GTK_TYPE_FILE_SELECTION);
- char *p;
+ char *dir;
/* uh, this doesn't really feel right, but i dont know what to do better */
gtk_widget_hide (GTK_WIDGET (file_select));
@@ -162,14 +161,9 @@ save_data_cb (GtkWidget *widget, gpointer user_data)
FALSE);
/* preserve the pathname */
- g_free (save_pathname);
- save_pathname = g_strdup (gtk_file_selection_get_filename (file_select));
- if((p = strrchr (save_pathname, '/')) != NULL)
- p[0] = 0;
- else {
- g_free (save_pathname);
- save_pathname = NULL;
- }
+ dir = g_dirname (gtk_file_selection_get_filename (file_select));
+ mail_config_set_last_filesel_dir (dir);
+ g_free (dir);
gtk_widget_destroy (GTK_WIDGET (file_select));
}
@@ -243,10 +237,7 @@ save_part (CamelMimePart *part)
g_return_if_fail (part != NULL);
camel_object_ref (CAMEL_OBJECT (part));
- if (save_pathname == NULL)
- save_pathname = g_strdup (g_get_home_dir ());
-
- filename = make_safe_filename (save_pathname, part);
+ filename = make_safe_filename (mail_config_get_last_filesel_dir (), part);
file_select = GTK_FILE_SELECTION (
gtk_file_selection_new (_("Save Attachment")));