Posts

Showing posts with the label build

Build your own browser

Image
Build your own browser using GTK and webkit2. ./browser "http://www.google.com" To add content blocking, connect to the "decide-policy" signal and use webkit_policy_decision_ignore() . browser.c #include <gtk/gtkx.h> #include <webkit2/webkit2.h> int main(int argc, char* argv[]) {   // Initialize GTK+   gtk_init(&argc, &argv);   // Create an 800x600 window that will contain the browser instance   GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);   g_signal_connect(window, "delete-event", gtk_main_quit, NULL);   gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);        // Create a browser instance   WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());   gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));   // Load a web page into the browser instance   webkit_web_view_load_uri(webView, argv[1]);   // Make sure the main window and all its contents are visib...