{
static gchar *filename = NULL;
static gchar *cwd = NULL;
+ gchar *startdir = NULL;
+ gchar *realfile = NULL;
filesel_create(title, FALSE);
filename = NULL;
}
- if (!cwd)
+ /* try to extract the directory and filename from file */
+ if (file) {
+ startdir = g_dirname(file);
+ realfile = g_basename(file);
+ } else {
+ realfile = file;
+ }
+
+ /* use sylpheed's startup directory if we can't find anything useful */
+ if (!startdir || !strcmp(startdir, ".")) {
cwd = g_strconcat(sylpheed_get_startup_dir(), G_DIR_SEPARATOR_S, NULL);
+ } else {
+ cwd = g_strconcat(startdir, G_DIR_SEPARATOR_S, NULL);
+ }
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), cwd);
- if (file) {
+ if (realfile) {
gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel),
- file);
- filesel_oldfilename = g_strdup(file);
+ realfile);
+ filesel_oldfilename = g_strdup(realfile);
} else {
filesel_oldfilename = NULL;
}
if (filesel_oldfilename)
g_free(filesel_oldfilename);
+ if (startdir)
+ g_free(startdir);
+
manage_window_focus_out(filesel, NULL, NULL);
gtk_widget_destroy(filesel);
GTK_EVENTS_FLUSH();
fname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
list = g_list_append(list, g_strdup(fname));
}
+ /* store dir of first entry */
+ if (NULL != (fname = list->data) && *fname) {
+ gchar *dir;
+ if (NULL != (dir = g_dirname(fname))) {
+ g_free(cwd);
+ cwd = g_strconcat(dir, G_DIR_SEPARATOR_S, NULL);
+ g_free(dir);
+ }
+ }
}
manage_window_focus_out(filesel, NULL, NULL);