Ubuntu Forums Archive Viewer

How to open the default web browser from within a C program

Archived thread 1002045 from Programming Talk. Markdown source: Programming_Talk/thread_1002045_How_to_open_the_default_web_browser_from_within_a_.md

Original URL About this archive
#1

Hi,

We're writing cross-platform applications in C, via GTK+, that have help systems associated with them. Currently, the Linux side of the fence opens a GTK+ window and populates it with help text (no links!) while the Windoze side uses Microshaft's compiled help system. What we'd *like* to do is to switch to HTML help across the board, display the help by programmatically opening a web browser, and use the HTML editor of our choice on either platform. I know how to open the default web browser under Windoze, but ...in Linux? Help! On this one I'm clueless and not having a lot of luck in web searches on the topic. Again, here are the goals:

=> Know how to determine the 'default' (if such a concept exists) browser and path on a Linux box ...from within a running C program, and then to run it with to open an HTML file (our help system.)

Thanks, Brian

#2

tananaBrian said: Hi,

We're writing cross-platform applications in C, via GTK+, that have help systems associated with them. Currently, the Linux side of the fence opens a GTK+ window and populates it with help text (no links!) while the Windoze side uses Microshaft's compiled help system. What we'd *like* to do is to switch to HTML help across the board, display the help by programmatically opening a web browser, and use the HTML editor of our choice on either platform. I know how to open the default web browser under Windoze, but ...in Linux? Help! On this one I'm clueless and not having a lot of luck in web searches on the topic. Again, here are the goals:

=> Know how to determine the 'default' (if such a concept exists) browser and path on a Linux box ...from within a running C program, and then to run it with to open an HTML file (our help system.)

Thanks, Brian For Gnome, you can read the gconf key /desktop/gnome/applications/browser/exec. I don't know about KDE.

Oh, also, check out xdg-open. It's probably better than messing with gconf, but I have no direct experience with it.

#3

gtk_show_uri (), in gtk >= 2.14

#4

What you want is xdg-open. Open up a terminal and try it for yourself


xdg-open http://www.google.com
#5

I second xdg-open. It's a desktop-neutral way to opening things, installed in Ubuntu by default.

#6

The information you have given kknd, is it be useful because i couldn't find any solution through out the search except on ubuntu forum.