[SDL] SDL 1.3 roadmap...

Gabriele Greco gabriele.greco at darts.it
Tue Oct 9 05:59:25 PDT 2007


Andre Krause wrote:
> i know - this is exactly the problem with linux. isnt it a shame?
> but maybe someone here on the list can take the burden and find a method 
> that work for the most common linux distro's ? and on systems, where no 
> reliable method is known, open_url could return false if it was not able 
> to open the url. so the application could present at least the 
>   
Yes, while mac and win32 have simple, documented, ways to do so on linux 
it's more tricky:

void
openurl(const char *url)
{
#ifdef WIN32
    ShellExecute(GetActiveWindow(),
         "open", url, NULL, NULL, SW_SHOWNORMAL);
#elif defined(__APPLE__)
    char buffer[256];
    snprintf(buffer, sizeof(buffer), "open %s", url);
    system(buffer);
#else
    char *apps[] = {"x-www-browser",
                    "firefox", // iceweasel has an alias on debian
                    "opera",
                    "mozilla",
                    "galeon",
                    "konqueror", NULL};

    char buffer[256];
    int i = 0;

    while (apps[i]) {
        snprintf(buffer, sizeof(buffer), "which %s >/dev/null", apps[i]);
        if (system(buffer) == 0) {
            snprintf(buffer, sizeof(buffer), "%s %s", apps[i], url);
            system(buffer);
            return;
        }
        i++;
    }
#endif

}

-- 
Bye,
 Gabry



More information about the SDL mailing list