Web Browser in GTK with WebKit

The Web Browser is one of the complicated software after operating system. Now a days the rapid development of web standard or web application is making this software more complex. sooner or later i believe that this will override the complexity of operating system.  We are well aware of the web browsers and use in our every day life. some of of the famous web browsers are Chrome,Internet Explorer,Firefox,Opera,safari etc.

 Here we will learn “how to create your own browser with some limited functions in GTK with webkit in C language on ubuntu linux”.


  • Web content engine library for GTK+ – Development files [libwebkitgtk-3.0-dev]

WebKit is a web content engine. It is able to display content such as HTML, SVG, XML, and others. It also supports DOM, XMLHttpRequest, XSLT, CSS, Javascript/ECMAscript and more. This package provides development files required to create GTK+ applications embedding WebKit.

  • development files for the GTK+ library.

GTK+ is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off tools to complete application suites.

Installing required library

(1) Open terminal and run below command:

Start Coding your Browser Now:

(1) main.c

(2) Build the above code.
gcc main.c -o myBrowser pkg-config --cflags --libs gtk+-2.0 webkit-1.0
(3) Run myBrowser
alen@Alen-Vostro-1550:~/$ ./myBrowser
Below simple UI  would be output:

(4) Load URL in webkit web view.

void webkit_web_view_load_uri ( <a class="link" href="http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView"><span class="type">WebKitWebView</span></a> *web_view,
const <a href="http://developer.gnome.org/glib/stable/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *uri);
This API requests loading of the specified URI string.

Implementation in our sample UI with some basic web browser functions.

As we have made an URL entry in our sample UI. Then  after entering an website address we have to get text from gtk entry widget and pass to webkit_web_view_load_uri (WebKitWebView *web_view, const gchar *uri) function.this will open web address in web view widget.

 Here is complete code:

(5) Now Build above code [main.c]

Run Below command to compile main.c

#gcc main.c -o myBrowser pkg-config --cflags --libs gtk+-2.0 webkit-1.0
Run myBrowser


Creating a Web Browser in GTK with Webkit