public override void LoadPath (string path, string suggestedFilename, System.Action finishedCallback)
{
lock (this) {
// One document per window
if (loading || Document != null) {
new Client ().LoadPath (path, suggestedFilename);
return;
}
loading = true;
}
if (!path.StartsWith ("file://")) {
path = System.IO.Path.GetFullPath (path);
}
Configuration.LastOpenFolder = System.IO.Path.GetDirectoryName (suggestedFilename ?? path);
status_label.Text = Catalog.GetString ("Loading document...");
ThreadAssist.SpawnFromMain (delegate {
try {
Document = new Document ();
Document.Load (path, PasswordProvider, suggestedFilename != null);
if (suggestedFilename != null) {
Document.SuggestedSavePath = suggestedFilename;
}
ThreadAssist.BlockingProxyToMain (delegate {
IconView.SetDocument (Document);
BookmarkView.SetDocument (Document);
RecentManager.Default.AddItem (Document.Uri);
Document.Changed += UpdateForDocument;
UpdateForDocument ();
OnDocumentLoaded ();
});
} catch (Exception e) {
Document = null;
ThreadAssist.BlockingProxyToMain (delegate {
status_label.Text = "";
if (e is System.IO.FileNotFoundException) {
try {
RecentManager.Default.RemoveItem (new Uri(path).AbsoluteUri);
} catch {}
}
});
Hyena.Log.Exception (e);
Hyena.Log.Error (
Catalog.GetString ("Error Loading Document"),
String.Format (Catalog.GetString ("There was an error loading {0}"), GLib.Markup.EscapeText (path ?? "")), true
);
} finally {
lock (this) {
loading = false;
}
if (finishedCallback != null)
finishedCallback ();
}
});
}