The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
how to open url in external browser?
Andre Krause
Guest

dear community,
does someone knows how to open an url from within my game / c code
in an external browser? i know how to do it in win32:

#ifdef LINUX
// todo
#endif

#ifdef _WIN32
#include <shellapi.h>
void open_url(const string& url)
{
ShellExecute(GetActiveWindow(),
"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
#endif


but someone knows how to do under linux and probably for mac os ?

thanks in advance!!
how to open url in external browser?
Casey O'Donnell
Guest

I'd take a look at the code in wxWidgets for this. They've got a
pretty robust implementation. I think it's pretty separable too.

On 5/25/06, Andre Krause <post at andre-krause.net> wrote:
Quote:
dear community,
does someone knows how to open an url from within my game / c code
in an external browser? i know how to do it in win32:

#ifdef LINUX
// todo
#endif

#ifdef _WIN32
#include <shellapi.h>
void open_url(const string& url)
{
ShellExecute(GetActiveWindow(),
"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
#endif
how to open url in external browser?
E. Wing
Guest

Quote:
From: Andre Krause

dear community,
does someone knows how to open an url from within my game / c code
in an external browser? i know how to do it in win32:

#ifdef LINUX
// todo
#endif

#ifdef _WIN32
#include <shellapi.h>
void open_url(const string& url)
{
ShellExecute(GetActiveWindow(),
"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
#endif


but someone knows how to do under linux and probably for mac os ?


For Mac OS X:
[[NSWorkspace sharedWorkspace] openURL:[NSURL
URLWithString:@"http://www.libsdl.org"]];

-Eric
how to open url in external browser?
Daniel Bünzli
Guest

Le 26 mai 06 ? 02:58, E. Wing a ?crit :

Quote:
For Mac OS X:
[[NSWorkspace sharedWorkspace] openURL:[NSURL
URLWithString:@"http://www.libsdl.org"]];

or, if you prefer a C interface, use launch services [1] as follows :

Quote:
#include <ApplicationServices/ApplicationServices.h>

void open_url (const char *link)
{
CFURLRef url = CFURLCreateWithBytes (NULL, (UInt8 *)link, strlen
(link),
kCFStringEncodingASCII, NULL);
LSOpenCFURLRef (url, NULL);
CFRelease (url);
}

Best,

Daniel


[1]
<http://developer.apple.com/documentation/Carbon/Conceptual/
LaunchServicesConcepts/index.html>
<http://developer.apple.com/documentation/Carbon/Reference/
LaunchServicesReference/index.html>
how to open url in external browser?
Chris Nystrom
Guest

On 5/25/06, E. Wing <ewmailing at gmail.com> wrote:
Quote:

Quote:
From: Andre Krause

dear community,
does someone knows how to open an url from within my game / c code
in an external browser? i know how to do it in win32:

#ifdef LINUX
// todo
#endif

Quote:

Quote:
#ifdef _WIN32
#include <shellapi.h>
void open_url(const string& url)
{
ShellExecute(GetActiveWindow(),
"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
#endif


but someone knows how to do under linux and probably for mac os ?



Linux pseudo code:

system("mozilla " + url);

Chris

--
E-Mail: Chris Nystrom <cnystrom at newio.org>
http://www.newio.org/
AIM: nystromchris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060526/875bc7e6/attachment.html
how to open url in external browser?
Christian Biere
Guest

Chris Nystrom wrote:
Quote:
Linux pseudo code:

Quote:
system("mozilla " + url);

That's a joke, right?

--
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060527/ec0efc4b/attachment.pgp
how to open url in external browser?
Chris Nystrom
Guest

On 5/26/06, Christian Biere <christianbiere at gmx.de> wrote:
Quote:

Chris Nystrom wrote:
Quote:
Linux pseudo code:

Quote:
system("mozilla " + url);

That's a joke, right?


Did I mis-read the question? I understood it was to open an external browser
window from a C program on linux. This works for me:

--
#include <stdlib.h>

int
main(void)
{
char command[] = "mozilla http://www.newio.org";

system(command);

return(0);
}
--

Chris

--
E-Mail: Chris Nystrom <cnystrom at newio.org>
http://www.newio.org/
AIM: nystromchris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060527/a575e2b6/attachment.html
how to open url in external browser?
Ryan C. Gordon
Guest

Quote:
Did I mis-read the question? I understood it was to open an external
browser window from a C program on linux. This works for me:

Yes, if you want to run Mozilla. But others want Opera, Firefox,
Konqueror, uh...other things.

This is actually something sorely missing from Linux. The best we've got
right now is the BROWSER variable:

http://www.catb.org/~esr/BROWSER/

Which has worked well for UT200x, and other projects, usually with a
default string like this if not set:

"firefox:opera:mozilla:netscape"

(putting Konqueror in that list was too risky, since it might launch all
of KDE on an otherwise-Gnome desktop. End users can set this to
"BROWSER='kfmclient openURL'" if they like, though.)

Such a mess.

--ryan.
how to open url in external browser?
Bill Kendrick
Guest

On Fri, May 26, 2006 at 11:19:52PM -0500, Chris Nystrom wrote:
Quote:

Linux pseudo code:

system("mozilla " + url);

Wrong! ;^P (I don't use Mozilla, I use Konqueror. If I _did_ use the
Mozilla browser, it's called "SeaMonkey" now[*]. And most other people
have switched to Firefox, anyway.)

What you probably want is covered here:

"Standards/mime-actions-spec"
http://www.freedesktop.org/wiki/Standards_2fmime_2dactions_2dspec

The freedesktop.org Shared MIME database provides a single way to store
static information about MIME types and rules for determining a type.


[*] I actually do use SeaMonkey at work, where I'm stuck on WinXP.

--
-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/