-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+ New feauture from wishlist: drag'n'drop pictures from web browser\n* F... #80
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,17 +393,56 @@ private void MainWindow_DeleteEvent (object o, DeleteEventArgs args) | |
|
||
private void MainWindow_DragDataReceived (object o, DragDataReceivedArgs args) | ||
{ | ||
// TODO: Generate random name for the picture being downloaded | ||
|
||
// Only handle URIs | ||
if (args.Info != 100) | ||
return; | ||
|
||
string fullData = System.Text.Encoding.UTF8.GetString (args.SelectionData.Data); | ||
|
||
foreach (string individualFile in fullData.Split ('\n')) { | ||
string file = individualFile.Trim (); | ||
|
||
if (file.StartsWith ("file://")) | ||
PintaCore.Workspace.OpenFile (new Uri (file).LocalPath); | ||
try { | ||
PintaCore.Workspace.HasOpenPendingDocuments = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not clear why HasOpenPendingDocuments is necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I remember not setting this flag up could lead to something like NullPointerException or so in case of user trying to open more than one document at the same time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it should be removed - the only place it's checked is inside |
||
|
||
foreach (string individualFile in fullData.Split ('\n')) { | ||
string file = individualFile.Trim (); | ||
Console.WriteLine (file); | ||
|
||
if (file.StartsWith ("http") || file.StartsWith("ftp")) { | ||
System.Net.WebClient client = new System.Net.WebClient (); | ||
string tempFilePath = System.IO.Path.GetTempPath () + System.IO.Path.GetFileName(file); | ||
|
||
var progressDialog = PintaCore.Chrome.ProgressDialog; | ||
|
||
try { | ||
progressDialog.Show (); | ||
progressDialog.Title = "Downloading file"; | ||
progressDialog.Text = "File " + file + " is being downloaded to " | ||
+ tempFilePath; | ||
|
||
client.DownloadFile (file, @tempFilePath); | ||
client.DownloadProgressChanged += (sender, e) => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should test this further. It doesn't appear that this ever gets called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I will test it better when I have free time. Thanks for pointing to that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the issue is the |
||
{ | ||
progressDialog.Progress = e.ProgressPercentage; | ||
}; | ||
} finally { | ||
client.Dispose (); | ||
progressDialog.Hide(); | ||
} | ||
|
||
if (System.IO.File.Exists (tempFilePath)) | ||
file = "file://" + tempFilePath; | ||
else | ||
PintaCore.Chrome.ShowErrorDialog(PintaCore.Chrome.MainWindow, | ||
"Download failed", | ||
"Unable to download target file: " + tempFilePath); | ||
} | ||
|
||
if (file.StartsWith ("file://")) | ||
PintaCore.Workspace.OpenFile (new Uri (file).LocalPath); | ||
} | ||
} finally { | ||
PintaCore.Workspace.HasOpenPendingDocuments = false; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, since I think the bug you were trying to fix was recently fixed in master