[squeak-dev] The Trunk: Morphic-mt.1279.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Aug 14 13:27:02 UTC 2016


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1279.mcz

==================== Summary ====================

Name: Morphic-mt.1279
Author: mt
Time: 14 August 2016, 3:26:29.973355 pm
UUID: 4a5c662b-fc42-6e44-b6b5-6d7207f8215e
Ancestors: Morphic-mt.1278

Fix and clean-up what happens if you click on a URL in a text but have no Web browser installed. Copy the URL at least into the clipboard then so that you can easily invoke a Web browser on your platform.

=============== Diff against Morphic-mt.1278 ===============

Item was changed:
  ----- Method: TextURL>>actOnClickFor: (in category '*Morphic') -----
  actOnClickFor: anObject
  	"Do what you can with this URL.  Later a web browser."
  
+ 	| m |
- 	| response m |
  
  	(url beginsWith: 'sqPr://') ifTrue: [
  		ProjectLoading thumbnailFromUrl: (url copyFrom: 8 to: url size).
  		^ true		"should not get here, but what the heck"
  	].
  	(url beginsWith: 'code://') ifTrue: [
  		Project current addDeferredUIMessage: [self open: (Compiler evaluate: (url allButFirst: 7))].
  		^ true		"should not get here, but what the heck"
  	].
  	"if it's a web browser, tell it to jump"
  	anObject isWebBrowser
  		ifTrue: [anObject jumpToUrl: url. ^ true]
  		ifFalse: [((anObject respondsTo: #model) and: [anObject model isWebBrowser])
  				ifTrue: [anObject model jumpToUrl: url. ^ true]].
  
  		"if it's a morph, see if it is contained in a web browser"
  		(anObject isKindOf: Morph) ifTrue: [
  			m := anObject.
  			[ m ~= nil ] whileTrue: [
  				(m isWebBrowser) ifTrue: [
  					m  jumpToUrl: url.
  					^true ].
  				(m hasProperty: #webBrowserView) ifTrue: [
  					m model jumpToUrl: url.
  					^true ].
  				m := m owner. ]
  		].
  
  	"no browser in sight.  ask if we should start a new browser"
+ 	WebBrowser defaultOrNil
+ 		ifNil: [Clipboard clipboardText: url]
+ 		ifNotNil: [:wb |
+ 			(UIManager default
+ 				confirm: ('Do you want to open this URL in a Web browser?\\{1}' translated withCRs format: {url})
+ 				title: 'Open Web Page' translated)
+ 					ifTrue: [wb openOnUrl: url].
+ 					^ true ].
- 	((self confirm: 'open a browser to view this URL?' translated) and: [WebBrowser default notNil]) ifTrue: [
- 		WebBrowser default openOnUrl: url.
- 		^ true ].
  
+ 	"Couldn't display in a browser.  Offer to put up just the source"
+ 	(UIManager default
+ 		confirm: ('There is no Web browser installed but the URL was copied to the clipboard:\{1}\\Do you want to view the Web page''s source/response anyway?' translated withCRs format: {url})
+ 		title: 'Open Web Page' translated)
+ 		
+ 		ifTrue: [
+ 			(Smalltalk classNamed: 'WebClient')
+ 				ifNotNil: [:wc | Project current addDeferredUIMessage: [(wc httpGet: url) explore]]
+ 				ifNil: [HTTPSocket httpShowPage: url]].
+ 	
- 	"couldn't display in a browser.  Offer to put up just the source"
- 
- 	response := (UIManager default 
- 				chooseFrom: (Array with: 'View web page as source' translated
- 									with: 'Cancel' translated)
- 				title:  'Couldn''t find a web browser. View\page as source?' withCRs translated).
- 	response = 1 ifTrue: [HTTPSocket httpShowPage: url].
  	^ true!



More information about the Squeak-dev mailing list