Skip to content

Commit

Permalink
[Fixes bug #987436] Use the default directory if the last saved path …
Browse files Browse the repository at this point in the history
…no longer exists.

Previously, an error dialog was shown.
  • Loading branch information
cameronwhite committed Apr 23, 2012
1 parent 60ddd22 commit ecbdd83
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Pinta.Core/Actions/LayerActions.cs
Expand Up @@ -155,8 +155,8 @@ private void HandlePintaCoreActionsLayersImportFromFileActivated (object sender,
PintaCore.Tools.Commit ();

Gtk.FileChooserDialog fcd = new Gtk.FileChooserDialog (Catalog.GetString ("Open Image File"), null, FileChooserAction.Open, Gtk.Stock.Cancel, Gtk.ResponseType.Cancel, Gtk.Stock.Open, Gtk.ResponseType.Ok);
fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);

fcd.SetCurrentFolder (PintaCore.System.GetDialogDirectory ());
fcd.AlternativeButtonOrder = new int[] { (int) ResponseType.Ok, (int) ResponseType.Cancel };

fcd.AddImagePreview ();
Expand Down
9 changes: 9 additions & 0 deletions Pinta.Core/Managers/SystemManager.cs
Expand Up @@ -86,6 +86,15 @@ static SystemManager ()
public RecentData RecentData { get { return recent_data; } }
#endregion

/// <summary>
/// Returns a directory for use in a dialog. The last dialog directory is
/// returned if it exists, otherwise the default directory is used.
/// </summary>
public string GetDialogDirectory ()
{
return Directory.Exists (LastDialogDirectory) ? LastDialogDirectory : DefaultDialogDirectory;
}

public string GetExecutablePathName ()
{
string executablePathName = System.Environment.GetCommandLineArgs ()[0];
Expand Down
2 changes: 1 addition & 1 deletion Pinta/Actions/File/OpenDocumentAction.cs
Expand Up @@ -64,7 +64,7 @@ private void Activated (object sender, EventArgs e)
fcd.AddFilter (ff2);

fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };
fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);
fcd.SetCurrentFolder (PintaCore.System.GetDialogDirectory ());
fcd.SelectMultiple = true;

fcd.AddImagePreview ();
Expand Down
2 changes: 1 addition & 1 deletion Pinta/Actions/File/SaveDocumentImplementationAction.cs
Expand Up @@ -80,7 +80,7 @@ private bool SaveFileAs (Document document)
Gtk.Stock.Save, Gtk.ResponseType.Ok);

fcd.DoOverwriteConfirmation = true;
fcd.SetCurrentFolder (PintaCore.System.LastDialogDirectory);
fcd.SetCurrentFolder (PintaCore.System.GetDialogDirectory ());
fcd.AlternativeButtonOrder = new int[] { (int)ResponseType.Ok, (int)ResponseType.Cancel };

bool hasFile = document.HasFile;
Expand Down

0 comments on commit ecbdd83

Please sign in to comment.