Launching a web browser from Squeak?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Launching a web browser from Squeak?

John Maloney
Does anyone know how to launch a Web browser from within Squeak? I need
to be able to pass the URL to the browser to open. It would be really
great if I could also tell the browser how big to be and where to open
on the screen.

I realize the solution will probably be highly platform dependent; I'm
interesting in solutions for Windows, Macs, and Linux.

I'd be grateful for any tips or hints.

Thank you!

        -- John


Reply | Threaded
Open this post in threaded view
|

RE: Launching a web browser from Squeak?

Ramon Leon
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On
> Behalf Of John Maloney
> Sent: Thursday, May 11, 2006 2:38 PM
> To: The general-purpose Squeak developers list
> Subject: Launching a web browser from Squeak?
>
> Does anyone know how to launch a Web browser from within
> Squeak? I need to be able to pass the URL to the browser to
> open. It would be really great if I could also tell the
> browser how big to be and where to open on the screen.
>
> I realize the solution will probably be highly platform
> dependent; I'm interesting in solutions for Windows, Macs, and Linux.
>
> I'd be grateful for any tips or hints.
>
> Thank you!
>
> -- John

Have you looked at the ExternalWebBrowser package on SqueakMap?  It does
exactly that.

Reply | Threaded
Open this post in threaded view
|

Re: Launching a web browser from Squeak?

Klaus D. Witzel
In reply to this post by John Maloney
Hi John,

for windoze try

  Win32Shell new shellOpen: 'http://www.squeak.org/'

which opens the default Web browser with dimension and screen location  
default or, if the Web browser is already running, navigates to the URL. I  
use Opera on WinXP.

/Klaus

On Thu, 11 May 2006 23:38:02 +0200, John Maloney <[hidden email]>  
wrote:

> Does anyone know how to launch a Web browser from within Squeak? I need  
> to be able to pass the URL to the browser to open. It would be really  
> great if I could also tell the browser how big to be and where to open  
> on the screen.
>
> I realize the solution will probably be highly platform dependent; I'm  
> interesting in solutions for Windows, Macs, and Linux.
>
> I'd be grateful for any tips or hints.
>
> Thank you!
>
> -- John
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Launching a web browser from Squeak?

Laurence Rozier
On the Mac if you load the Applescript package from SqueakMap, you can then use:

Applescript browse: 'http://www.squeak.org'

-Laurence

On 5/11/06, Klaus D. Witzel <[hidden email]> wrote:
Hi John,

for windoze try

  Win32Shell new shellOpen: 'http://www.squeak.org/'

which opens the default Web browser with dimension and screen location
default or, if the Web browser is already running, navigates to the URL. I
use Opera on WinXP.

/Klaus

On Thu, 11 May 2006 23:38:02 +0200, John Maloney <[hidden email]>
wrote:

> Does anyone know how to launch a Web browser from within Squeak? I need
> to be able to pass the URL to the browser to open. It would be really
> great if I could also tell the browser how big to be and where to open
> on the screen.
>
> I realize the solution will probably be highly platform dependent; I'm
> interesting in solutions for Windows, Macs, and Linux.
>
> I'd be grateful for any tips or hints.
>
> Thank you!
>
>       -- John
>
>
>






Reply | Threaded
Open this post in threaded view
|

Re: Launching a web browser from Squeak?

Michael Rueger-2
In reply to this post by John Maloney
John Maloney wrote:
> Does anyone know how to launch a Web browser from within Squeak? I need
> to be able to pass the URL to the browser to open. It would be really
> great if I could also tell the browser how big to be and where to open
> on the screen.
>
> I realize the solution will probably be highly platform dependent; I'm
> interesting in solutions for Windows, Macs, and Linux.

For Sophie we just solved that problem :-)
Below is  the windows part, hot of the grill.
The usual disclaimers about exploding CPUs etc apply...

Cheers

Michael

----------

Win32Services

openURIOrPath: uriOrPath

        "Win32Services new openURIOrPath:'http://www.yahoo.com/'"
        "Win32Services new
openURIOrPath:'D:\users\michael\projects\mellon\Sophie\dev\current\iTweak\build.6.19'
"
        | shellString |
        shellString := uriOrPath , 0 asCharacter.
        ^self apiShellExecute: 0 with: 'open' with: shellString with: nil with:
nil with: 1


apiShellExecute: aWindowHandle with: aCmdString with: target with: para
with: dir with: flag

"HINSTANCE ShellExecute(
     HWND hwnd,
     LPCTSTR lpOperation,
     LPCTSTR lpFile,
     LPCTSTR lpParameters,
     LPCTSTR lpDirectory,
     INT nShowCmd
);"
        <apicall: long 'ShellExecuteA' (ulong  char* char* char* char* long)
module: 'shell32.dll'>
        ^self externalCallFailed

Reply | Threaded
Open this post in threaded view
|

Re: Launching a web browser from Squeak?

johnmci
mmm I'm sure there is some mac code that Michael made me write this  
morning.

Actually I'll note if you started a shell you could just do 'open  
URL...'
but using the proper API calls give  you a bit more control to figure  
out what happen.


openOSBrowserOnURI: uri
        MacLaunchServices callLSOpenCFURL: uri

callLSOpenCFURL: aURI
        | aURIString urlRef |

        aURIString := aURI printString.
        urlRef := MacCFURL callCFURLCreateFromString: aURIString.
        self apiLSOpenCFURLRef: urlRef outLaunchedURL: nil.
        MacCFType apiCFRelease: urlRef.

callCFURLCreateFromString: aString
        | byteArray length encoding createdURL |
        byteArray := aString asByteArray.
        length := aString size.
        encoding :=  0. "MacRoman"
        createdURL _ self apiCFURLCreateWithBytes: nil cString: byteArray  
length: length encoding: encoding base: nil.
        ^createdURL
       
apiCFURLCreateWithBytes: allocator cString: aByteArray length:  
aLength encoding: aEncoding base: aURL
        <cdecl: MacCFURL* 'CFURLCreateWithBytes' (void* char* long long  
MacCFURL* ) module:'Carbon.framework'>
        ^ self externalCallFailed

"CFURLRef CFURLCreateWithBytes (
    CFAllocatorRef allocator,
    const UInt8 *URLBytes,
    CFIndex length,
    CFStringEncoding encoding,
    CFURLRef baseURL
);"

apiLSOpenCFURLRef: inURL  outLaunchedURL: outURL

        <cdecl: long 'LSOpenCFURLRef' ( MacCFURL* MacCFURL*)  
module:'Carbon.framework'>
        ^ self externalCallFailed

"OSStatus LSOpenCFURLRef (
    CFURLRef inURL,
    CFURLRef *outLaunchedURL
);"

apiCFRelease: aRef
        <cdecl: void 'CFRelease' (MacCFType*) module:'Carbon.framework'>
        ^self externalCallFailed

"void CFRelease (
    CFTypeRef cf
);"

FFI class types are a exercise for the reader...



On 11-May-06, at 3:27 PM, Michael Rueger wrote:

> John Maloney wrote:
>> Does anyone know how to launch a Web browser from within Squeak? I  
>> need to be able to pass the URL to the browser to open. It would  
>> be really great if I could also tell the browser how big to be and  
>> where to open on the screen.
>> I realize the solution will probably be highly platform dependent;  
>> I'm interesting in solutions for Windows, Macs, and Linux.
>
> For Sophie we just solved that problem :-)
> Below is  the windows part, hot of the grill.
> The usual disclaimers about exploding CPUs etc apply...

--
========================================================================
===
John M. McIntosh <[hidden email]> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
========================================================================
===


Reply | Threaded
Open this post in threaded view
|

Re: Launching a web browser from Squeak?

David T. Lewis
In reply to this post by John Maloney
On Thu, May 11, 2006 at 05:38:02PM -0400, John Maloney wrote:
> Does anyone know how to launch a Web browser from within Squeak? I need
> to be able to pass the URL to the browser to open. It would be really
> great if I could also tell the browser how big to be and where to open
> on the screen.
>
> I realize the solution will probably be highly platform dependent; I'm
> interesting in solutions for Windows, Macs, and Linux.
>
> I'd be grateful for any tips or hints.

I don't know of a cross-platform way to do it, but for Unix VMs you
can for example inspect this:

   "OSProcess command: 'konqueror http://www.squeak.org'"
  or:
   "OSProcess command: 'mozilla http://www.squeak.org'"

The web browser is going to be running in an independent process
managed by whatever X window manager the user might happen to be
using, so in general you should not expect to have much control
over its size and placement. Once the external browser program
is running, you can kill it from Squeak, but that is about all
the control you will have.

Many X programs allow initial size and position to be specified
with the "-geometry" command line parameter (see "man X" man
page on most any unix system for an explanation). I did not look
carefully, but this did not seem to have any useful effect on the
web browsers I tried. In any case, on the off chance that it
did work on some browser of interest, the expression might
look something like this:

  "OSProcess command 'foobrowser -geometry 600x400+40+20 http://www.squeak.org'"

Of course Squeak does not know anything about the coordinate system
of the X display on which it resides, so attempting to control
the geometry may be a bad idea regardless. X makes more or less
the same assumptions that Squeak does: the user is in control of
of the UI, and programs should not attempt to "help" the user
by making assumptions about window placement etc.

It is hard to know in advance what web browsers are available,
as there are many available and this is likely to vary according
to the flavor of Unix/Linux/BSD and the individual preferences of
the user. Also, OSProcess must be installed from SqueakMap, which
would not be a default configuration for most users.

Dave