Commit 4f97f7a5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Made the file open and save dialogs use the last used folder instead of

2005-01-13  Michael Natterer  <mitch@gimp.org>

	Made the file open and save dialogs use the last used folder
	instead of defaulting to current directory. Fixes bug #162385.

	* app/widgets/gimpfiledialog.[ch] (gimp_file_dialog_set_uri):
	removed this function because it had no functionality except
	creating usability problems.

	* app/actions/file-commands.c: use gtk_file_chooser_set_uri()
	instead but *only* if we already have an uri from an alread open
	image or the document hinstory.

	* app/widgets/gimpfiledialog.c (gimp_file_dialog_set_image): set
	the file chooser's uri only if we have an uri from the image
	itself. Leave the current folder untouched otherwise and just set
	the current name (e.g. "Untitled").

	* app/dialogs/file-save-dialog.c (file_save_dialog_save_image): on
	successful save, remember the used uri by attaching it to the
	"gimp" instance.

	(file_save_dialog_new): set the last saved uri's folder on the
	newly created file save dialog.
parent 85727947
2005-01-13 Michael Natterer <mitch@gimp.org>
Made the file open and save dialogs use the last used folder
instead of defaulting to current directory. Fixes bug #162385.
* app/widgets/gimpfiledialog.[ch] (gimp_file_dialog_set_uri):
removed this function because it had no functionality except
creating usability problems.
* app/actions/file-commands.c: use gtk_file_chooser_set_uri()
instead but *only* if we already have an uri from an alread open
image or the document hinstory.
* app/widgets/gimpfiledialog.c (gimp_file_dialog_set_image): set
the file chooser's uri only if we have an uri from the image
itself. Leave the current folder untouched otherwise and just set
the current name (e.g. "Untitled").
* app/dialogs/file-save-dialog.c (file_save_dialog_save_image): on
successful save, remember the used uri by attaching it to the
"gimp" instance.
(file_save_dialog_new): set the last saved uri's folder on the
newly created file save dialog.
2005-01-13 Sven Neumann <sven@gimp.org>
* app/units.c
......
......@@ -94,10 +94,17 @@ void
file_open_from_image_cmd_callback (GtkAction *action,
gpointer data)
{
GtkWidget *widget;
GimpImage *image;
GtkWidget *widget;
const gchar *uri = NULL;
return_if_no_widget (widget, data);
file_open_dialog_show (widget, action_data_get_image (data), NULL, FALSE);
image = action_data_get_image (data);
if (image)
uri = gimp_object_get_name (GIMP_OBJECT (image));
file_open_dialog_show (widget, NULL, uri, FALSE);
}
void
......@@ -365,7 +372,8 @@ file_open_dialog_show (GtkWidget *parent,
if (dialog)
{
gimp_file_dialog_set_uri (GIMP_FILE_DIALOG (dialog), gimage, uri);
if (uri)
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
if (open_as_layer)
{
......@@ -410,7 +418,6 @@ file_save_dialog_show (GimpImage *gimage,
}
}
if (dialog)
{
gtk_window_set_title (GTK_WINDOW (dialog), title);
......
......@@ -68,7 +68,8 @@ static gboolean file_save_dialog_save_image (GtkWidget *save_dialog,
GtkWidget *
file_save_dialog_new (Gimp *gimp)
{
GtkWidget *dialog;
GtkWidget *dialog;
const gchar *uri;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
......@@ -78,6 +79,26 @@ file_save_dialog_new (Gimp *gimp)
GTK_STOCK_SAVE,
GIMP_HELP_FILE_SAVE);
uri = g_object_get_data (G_OBJECT (gimp), "gimp-file-save-last-uri");
if (uri)
{
gchar *folder_uri = g_path_get_dirname (uri);
#ifdef __GNUC__
#warning: FIXME: should use set_uri() but idle stuff in the file chooser seems to override set_current_name() when called immediately after set_uri()
#endif
if (folder_uri)
{
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
folder_uri);
g_free (folder_uri);
}
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "");
}
g_signal_connect (dialog, "response",
G_CALLBACK (file_save_dialog_response),
gimp);
......@@ -234,6 +255,8 @@ file_save_dialog_save_image (GtkWidget *save_dialog,
GimpPDBStatusType status;
GError *error = NULL;
g_object_ref (gimage);
status = file_save_as (gimage,
gimp_get_user_context (gimage->gimp),
GIMP_PROGRESS (save_dialog),
......@@ -244,6 +267,12 @@ file_save_dialog_save_image (GtkWidget *save_dialog,
save_a_copy,
&error);
if (status == GIMP_PDB_SUCCESS)
g_object_set_data_full (G_OBJECT (gimage->gimp), "gimp-file-save-last-uri",
g_strdup (uri), (GDestroyNotify) g_free);
g_object_unref (gimage);
if (status != GIMP_PDB_SUCCESS &&
status != GIMP_PDB_CANCEL)
{
......
......@@ -388,43 +388,6 @@ gimp_file_dialog_set_file_proc (GimpFileDialog *dialog,
file_proc);
}
void
gimp_file_dialog_set_uri (GimpFileDialog *dialog,
GimpImage *gimage,
const gchar *uri)
{
gchar *real_uri = NULL;
g_return_if_fail (GIMP_IS_FILE_DIALOG (dialog));
g_return_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage));
if (gimage)
{
real_uri = g_strdup (gimp_object_get_name (GIMP_OBJECT (gimage)));
}
else if (uri)
{
real_uri = g_strdup (uri);
}
if (real_uri)
{
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), real_uri);
}
else
{
gchar *current = g_get_current_dir ();
real_uri = g_filename_to_uri (current, NULL, NULL);
g_free (current);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog),
real_uri);
}
g_free (real_uri);
}
void
gimp_file_dialog_set_image (GimpFileDialog *dialog,
GimpImage *gimage,
......@@ -448,10 +411,20 @@ gimp_file_dialog_set_image (GimpFileDialog *dialog,
if (uri)
uri_set = gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
gimp_file_dialog_set_file_proc (dialog, NULL);
if (! uri_set)
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "");
{
const gchar *name = gimp_image_get_uri (gimage);
gchar *current;
gimp_file_dialog_set_file_proc (dialog, NULL);
if (! name)
name = "";
current = g_path_get_basename (name);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), current);
g_free (current);
}
}
......
......@@ -77,9 +77,6 @@ void gimp_file_dialog_set_sensitive (GimpFileDialog *dialog,
void gimp_file_dialog_set_file_proc (GimpFileDialog *dialog,
PlugInProcDef *file_proc);
void gimp_file_dialog_set_uri (GimpFileDialog *dialog,
GimpImage *gimage,
const gchar *uri);
void gimp_file_dialog_set_image (GimpFileDialog *dialog,
GimpImage *gimage,
gboolean save_a_copy);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment