Re: launching web-browser



On 5/21/05, Peter Bloomfield <peterbloomfield bellsouth net> wrote:
On 05/21/2005 08:51:05 AM, Gyözö Both wrote:
thanks for your answers. if possible, i'd like to have a
solution that only uses gtk/glib, i wouldn't want to have a
gnome-dependency in my app. is there a way?

I use this as a fallback: it just runs a commmand with an argument
which can be set from my application's preferences. The default is
"mozilla" for the command and "-remote 'openURL(%s)'" for the
argument. Very stupid, but it does sort-of work.

        static gboolean shown = FALSE;

        BufInfo buf;
        char txt[512];
        BufInfo buf2;
        char txt2[512];
 
        char url2[FILENAME_MAX];

        expand_variables( url, url2 );

        buf_init_static( &buf, txt, 512 );
        buf_appendf( &buf, "%s %s", BOX_BROWSER, BOX_BROWSER_REMOTE );
        buf_init_static( &buf2, txt2, 512 );
        buf_appendf( &buf2, buf_all( &buf ), url2 );

        if( systemf( "%s", buf_all( &buf2 ) ) ) {
                error_top( _( "Unable to open location." ) );
                error_sub( _(
                        "Attempted to launch browser with command:\n"
                        "  %s\n"
                        "You can change this command in Preferences." ),
                        buf_all( &buf2 ) );
                box_alert( par );
        }
        else if( !shown ) {
                box_info( par, 
                        _( "Browser window opened." ),
                        _( "Opened window for URL:\n"
                        "  %s\n"
                        "You may need to switch desktops to see the "
                        "new window." ),
                        url2 );

                /* Only show 1st time.
                 */
                shown = TRUE;
        }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]