+loadFromURL
authorClaus Gittinger <cg@exept.de>
Mon, 20 Sep 2010 11:32:08 +0200
changeset 2796 f589f0efbaaf
parent 2795 4ad46363cf3c
child 2797 06bae3d05b78
+loadFromURL
ImageEditor.st
--- a/ImageEditor.st	Wed Jul 28 10:06:35 2010 +0200
+++ b/ImageEditor.st	Mon Sep 20 11:32:08 2010 +0200
@@ -17,7 +17,7 @@
 		lastShiftUsedWrap lastGrabbedScreenArea
 		allowedToChangeImageDimensionAndDepth'
 	classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode
-		DefaultRelativeSizes'
+		DefaultRelativeSizes LastURL'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
 !
@@ -442,6 +442,9 @@
 #fileLoadFromFile
 'Select and load an image from a file'
 
+#fileLoadFromURL
+'Load an image from the net, given its URL'
+
 #fileNewImage
 'Create a new image'
 
@@ -2373,6 +2376,12 @@
             translateLabel: true
           )
          (MenuItem
+            activeHelpKey: fileLoadFromURL
+            label: 'Load from URL...'
+            itemValue: doLoadFromURL
+            translateLabel: true
+          )
+         (MenuItem
             label: 'Grab'
             translateLabel: true
             submenu: 
@@ -2519,8 +2528,6 @@
         nil
         nil
       )
-
-    "Modified: / 04-07-2010 / 10:17:15 / cg"
 !
 
 menuMouseButtonColors
@@ -5962,6 +5969,28 @@
     ]
 !
 
+doLoadFromURL
+    "opens a dialog for loading an image from a URL"
+
+    |tempFile url|
+
+    self checkModified ifFalse:[ ^ self ].
+
+    url := Dialog 
+                request:'Load Image from URL'
+                initialAnswer:LastURL.
+
+    url notEmptyOrNil ifTrue:[
+        LastURL := url.
+        tempFile := Filename newTemporary.
+        HTTPInterface get:url destinationFile:tempFile.
+        self loadFromFile:tempFile.
+        tempFile delete
+    ]
+
+    "Created: / 20-09-2010 / 11:30:59 / cg"
+!
+
 doNewImage
     "opens a dialog with choices of size and color map for creating a new image"