tazweb rev 178

Handle cookies (cleaned in in click or can be disable with --nocookies)
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 13 01:50:53 2017 +0100 (2017-03-13)
parents 1603951a52b8
children 3d4f8134bd2f
files Makefile README src/tazweb.c
line diff
     1.1 --- a/Makefile	Sun Mar 12 17:56:20 2017 +0100
     1.2 +++ b/Makefile	Mon Mar 13 01:50:53 2017 +0100
     1.3 @@ -50,12 +50,12 @@
     1.4  	mkdir -p \
     1.5  		$(DESTDIR)$(DOCDIR)/$(PACKAGE) \
     1.6  		$(DESTDIR)$(PREFIX)/bin \
     1.7 -		$(DESTDIR)/var/www/cgi-bin \
     1.8 +		$(DESTDIR)$(PREFIX)/lib/tazweb \
     1.9  		$(DESTDIR)$(PREFIX)/share/tazweb \
    1.10  		$(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps \
    1.11  		$(DESTDIR)$(PREFIX)/share/applications
    1.12  	install -m 0755 $(PACKAGE) $(DESTDIR)$(PREFIX)/bin
    1.13 -	install -m 0755 $(PACKAGE)-helper $(DESTDIR)$(PREFIX)/bin
    1.14 +	install -m 0755 lib/helper.sh $(DESTDIR)$(PREFIX)/lib/tazweb
    1.15  	cp -d doc/* $(DESTDIR)$(DOCDIR)/$(PACKAGE)
    1.16  	install -m 0644 data/tazweb.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/32x32/apps
    1.17  	install -m 0644 data/tazweb.desktop $(DESTDIR)$(PREFIX)/share/applications
     2.1 --- a/README	Sun Mar 12 17:56:20 2017 +0100
     2.2 +++ b/README	Mon Mar 13 01:50:53 2017 +0100
     2.3 @@ -3,29 +3,19 @@
     2.4  
     2.5  
     2.6  TazWeb is a radically simple and very light web browser providing a single
     2.7 -window with one small bottom toolbar using buttons, a URL and search entry,
     2.8 -and a contextual menu but no menubar or tabs. Please keep the code simple
     2.9 +window with one small toolbar using buttons, a URL and search entry,
    2.10 +and a contextual menu but no menubar. Please keep the code simple
    2.11  and clean. If you are motivated and want to add some more functionality, 
    2.12  please talk to the AUTHOR before committing anything in the repos.
    2.13  
    2.14 -TazWeb uses a custom page in the user Freedesktop directory to let users add
    2.15 -any content to it and get with one click from the toolbar. We may have
    2.16 -an external apps/script to handle that file for users who can't manage to
    2.17 -edit pure xHTML.
    2.18 -
    2.19  This application have been created for Tazpanel and future SliTaz integrated
    2.20 -Web applications. The goal is by far to have a fully-featured web browser. But
    2.21 -if you find a way to provide a simple plugins mechanism, that would be great.
    2.22 -
    2.23 -The idea with TazWeb is to have a minimal interface, the approach is to
    2.24 -build all the GUI with xHTML and CSS like in TazPanel.
    2.25 +Web applications and it become a daily usable browser. The idea with TazWeb 
    2.26 +is to have a minimal interface, the approach is to build all the GUI with 
    2.27 +xHTML and CSS like in TazPanel or welkow web applications.
    2.28  
    2.29  For general and end-user documentation have a look at doc/tazweb.html.
    2.30  TazWeb is published, like webkit source under a free BSD license.
    2.31  
    2.32 -BUG: Right clicking on "Open Link in New Window" is connecting to an event
    2.33 -but doesn't work.
    2.34 -
    2.35  
    2.36  Build and install
    2.37  -----------------
    2.38 @@ -45,13 +35,20 @@
    2.39  --------------------
    2.40  The Qt port is actually only a little toy to play with!
    2.41  
    2.42 -$ cd src
    2.43 -$ qmake
    2.44 -$ make
    2.45 +$ make qt
    2.46 +$ ./tazweb-qt
    2.47 +
    2.48 +
    2.49 +TazWeb helper script
    2.50 +--------------------
    2.51 +TazWeb use a set of SHell functions from /usr/lib/tazweb/helper.sh. These
    2.52 +functions are used to handle bookmarks and cookies. The GTK gui parts use
    2.53 +yad and some functions will generated html files to be used by tazweb menu
    2.54 +or buttons.
    2.55  
    2.56  
    2.57  Coding notes
    2.58 -------------
    2.59 +--------------------------------------------------------------------------------
    2.60  
    2.61      * To get the filename of a WebKitDownload:
    2.62        file = webkit_download_get_suggested_filename (download);
    2.63 @@ -79,8 +76,8 @@
    2.64        webkit_web_view_set_editable (webview, TRUE);
    2.65  
    2.66  
    2.67 -i18n
    2.68 -----
    2.69 +Translation (i18n)
    2.70 +--------------------------------------------------------------------------------
    2.71  Internationalization of TazWeb was introduced since version 1.6.4.
    2.72  Its standard GLib technique is described in developer notes:
    2.73  http://developer.gnome.org/glib/2.32/glib-I18N.html
     3.1 --- a/src/tazweb.c	Sun Mar 12 17:56:20 2017 +0100
     3.2 +++ b/src/tazweb.c	Mon Mar 13 01:50:53 2017 +0100
     3.3 @@ -4,9 +4,9 @@
     3.4   * as a contextual menu, but no menu bar or tabs. Commented line code
     3.5   * starts with // and comments are between * *
     3.6   *
     3.7 - * Copyright (C) 2011-2014 SliTaz GNU/Linux - BSD License
     3.8 + * Copyright (C) 2011-2017 SliTaz GNU/Linux - BSD License
     3.9   * See AUTHORS and LICENSE for detailed information
    3.10 - * 
    3.11 + *
    3.12   */
    3.13  
    3.14  #include <glib.h>
    3.15 @@ -15,12 +15,13 @@
    3.16  
    3.17  #include <gtk/gtk.h>
    3.18  #include <webkit/webkit.h>
    3.19 -//#include <libsoup/soup.h> // for cookies ?
    3.20 +#include <libsoup/soup.h> // for cookies
    3.21  
    3.22  #define HOME		g_get_home_dir()
    3.23  #define CONFIG		g_strdup_printf("%s/.config/tazweb", HOME)
    3.24  #define BMTXT		g_strdup_printf("%s/bookmarks.txt", CONFIG)
    3.25  #define BMURL		g_strdup_printf("%s/bookmarks.html", CONFIG)
    3.26 +#define COOKIES		g_strdup_printf("%s/cookies.txt", CONFIG)
    3.27  #define WEBHOME		"file:///usr/share/webhome/index.html"
    3.28  #define SEARCH		"http://duckduckgo.com/?q=%s&t=slitaz"
    3.29  
    3.30 @@ -31,10 +32,15 @@
    3.31  static WebKitWebFrame *frame;
    3.32  static gint count = 0;
    3.33  static gboolean notoolbar;
    3.34 -static gboolean noquit;
    3.35 +static gboolean nocookies;
    3.36  static gboolean kiosk;
    3.37 +
    3.38 +
    3.39  const gchar* uri;
    3.40  
    3.41 +SoupSession		*session;
    3.42 +SoupCookieJar	*cookiejar;
    3.43 +
    3.44  /* Create an icon */
    3.45  static GdkPixbuf*
    3.46  create_pixbuf(const gchar* image)
    3.47 @@ -59,12 +65,12 @@
    3.48  	GString *string;
    3.49  	gdouble progress;
    3.50  	gchar *title;
    3.51 -	
    3.52 +
    3.53  	string = g_string_new(webkit_web_view_get_title(webview));
    3.54  	progress = webkit_web_view_get_progress(webview) * 100;
    3.55  	if (progress < 100)
    3.56  		g_string_append_printf(string, " [ %f%% ] ", progress);
    3.57 -	
    3.58 +
    3.59  	title = g_string_free(string, FALSE);
    3.60  	gtk_window_set_title(window, title);
    3.61  	g_free(title);
    3.62 @@ -109,11 +115,11 @@
    3.63  view_source_cb(GtkWidget* widget, WebKitWebView* webview)
    3.64  {
    3.65  	gboolean source;
    3.66 -	
    3.67 +
    3.68  	frame = webkit_web_view_get_main_frame(webview);
    3.69  	uri = webkit_web_frame_get_uri(frame);
    3.70  	source = webkit_web_view_get_view_source_mode(webview);
    3.71 -	
    3.72 +
    3.73  	webkit_web_view_set_view_source_mode(webview, !source);
    3.74  	webkit_web_view_reload(webview);
    3.75  }
    3.76 @@ -147,14 +153,25 @@
    3.77  search_icon_press_cb(GtkWidget *search, GtkEntryIconPosition pos,
    3.78  		GdkEvent *event, WebKitWebView* webview)
    3.79  {
    3.80 -    search_web(search, webview);
    3.81 +	search_web(search, webview);
    3.82  }
    3.83  
    3.84 -/* Navigation button function: */
    3.85 +/* 
    3.86 + * 
    3.87 + * Navigation functions
    3.88 + * 
    3.89 + */
    3.90 +
    3.91 +static void
    3.92 +bookmarks_edit_cb(GtkWidget* widget, WebKitWebView* webview)
    3.93 +{
    3.94 +	system("/usr/lib/tazweb/helper.sh edit_bookmarks");
    3.95 +}
    3.96 +
    3.97  static void
    3.98  go_bookmarks_cb(GtkWidget* widget, WebKitWebView* webview)
    3.99  {
   3.100 -	system("tazweb-helper html_bookmarks");
   3.101 +	system("/usr/lib/tazweb/helper.sh html_bookmarks");
   3.102  	uri = g_strdup_printf("file://%s", BMURL);
   3.103  	g_assert(uri);
   3.104  	webkit_web_view_load_uri(webview, uri);
   3.105 @@ -171,28 +188,15 @@
   3.106  static void
   3.107  go_back_cb(GtkWidget* widget, WebKitWebView* webview)
   3.108  {
   3.109 -    webkit_web_view_go_back(webview);
   3.110 +	webkit_web_view_go_back(webview);
   3.111  }
   3.112  
   3.113  static void
   3.114  go_forward_cb(GtkWidget* widget, WebKitWebView* webview)
   3.115  {
   3.116 -    webkit_web_view_go_forward(webview);
   3.117 +	webkit_web_view_go_forward(webview);
   3.118  }
   3.119  
   3.120 -/* Fullscreen and unfullscreen callback function */
   3.121 -//static void
   3.122 -//fullscreen_cb(GtkWindow* window, gpointer data)
   3.123 -//{
   3.124 -	//GdkWindowState state;
   3.125 -	//state = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(mainwindow)));
   3.126 -
   3.127 -	//if(state & GDK_WINDOW_STATE_FULLSCREEN)
   3.128 -		//gtk_window_unfullscreen(GTK_WINDOW(mainwindow));
   3.129 -	//else
   3.130 -		//gtk_window_fullscreen(GTK_WINDOW(mainwindow));
   3.131 -//}
   3.132 -
   3.133  /* TazWeb doc callback function */
   3.134  static void
   3.135  tazweb_doc_cb(GtkWidget* widget, WebKitWebView *webview)
   3.136 @@ -202,7 +206,7 @@
   3.137  	webkit_web_view_load_uri(webview, uri);
   3.138  }
   3.139  
   3.140 -/* Download function */
   3.141 +/* Download functions */
   3.142  static gboolean
   3.143  download_requested_cb(WebKitWebView *webview, WebKitDownload *download,
   3.144  		gpointer user_data)
   3.145 @@ -232,10 +236,24 @@
   3.146  static void
   3.147  print_page_cb (GtkWidget *widget, gpointer data)
   3.148  {
   3.149 -    webkit_web_frame_print (webkit_web_view_get_main_frame (
   3.150 -        WEBKIT_WEB_VIEW (webview)));
   3.151 +	webkit_web_frame_print (webkit_web_view_get_main_frame (
   3.152 +		WEBKIT_WEB_VIEW (webview)));
   3.153  }
   3.154  
   3.155 +
   3.156 +/* Fullscreen and unfullscreen callback function */
   3.157 +//static void
   3.158 +//fullscreen_cb(GtkWindow* window, gpointer data)
   3.159 +//{
   3.160 +	//GdkWindowState state;
   3.161 +	//state = gdk_window_get_state(gtk_widget_get_window(GTK_WIDGET(mainwindow)));
   3.162 +
   3.163 +	//if(state & GDK_WINDOW_STATE_FULLSCREEN)
   3.164 +		//gtk_window_unfullscreen(GTK_WINDOW(mainwindow));
   3.165 +	//else
   3.166 +		//gtk_window_fullscreen(GTK_WINDOW(mainwindow));
   3.167 +//}
   3.168 +
   3.169  /* New webview callbacks */
   3.170  static WebKitWebView*
   3.171  create_web_view_cb(WebKitWebView* webview, WebKitWebFrame* web_frame,
   3.172 @@ -262,46 +280,66 @@
   3.173  }
   3.174  
   3.175  /* Add a bookmark */
   3.176 -void add_bookmark_cb(GtkWidget *widget, gpointer data)
   3.177 +void
   3.178 +add_bookmark_cb(GtkWidget *widget, gpointer data)
   3.179  {
   3.180  	const gchar* title;
   3.181  	const gchar* buffer;
   3.182 -	
   3.183 +
   3.184  	title = webkit_web_view_get_title(WEBKIT_WEB_VIEW (webview));
   3.185  	uri = webkit_web_view_get_uri(WEBKIT_WEB_VIEW (webview));
   3.186 -	
   3.187 +
   3.188  	asprintf(&buffer, "echo '%s|%s' >> %s", title, uri, BMTXT);
   3.189  	system(buffer);
   3.190  }
   3.191  
   3.192 +/* Setup session cookies */
   3.193 +void
   3.194 +cookies_setup(void)
   3.195 +{
   3.196 +	if (cookiejar) {
   3.197 +		soup_session_remove_feature(session,
   3.198 +			(SoupSessionFeature*)cookiejar);
   3.199 +		g_object_unref(cookiejar);
   3.200 +		cookiejar = NULL;
   3.201 +	}
   3.202 +
   3.203 +	cookiejar = soup_cookie_jar_text_new(COOKIES, 0);
   3.204 +	soup_session_add_feature(session, (SoupSessionFeature*)cookiejar);
   3.205 +}
   3.206 +
   3.207 +static void
   3.208 +cookies_view_cb(GtkWidget* widget, WebKitWebView* webview)
   3.209 +{
   3.210 +	system("/usr/lib/tazweb/helper.sh html_cookies");
   3.211 +	uri = g_strdup_printf("file://%s/cookies.html", CONFIG);
   3.212 +	g_assert(uri);
   3.213 +	webkit_web_view_load_uri(webview, uri);
   3.214 +}
   3.215 +
   3.216 +static void
   3.217 +cookies_clean_cb(GtkWidget* widget, WebKitWebView* webview)
   3.218 +{
   3.219 +	system("/usr/lib/tazweb/helper.sh clean_cookies");
   3.220 +}
   3.221 +
   3.222  /* Add items to WebKit contextual menu */
   3.223  static void
   3.224  populate_menu_cb(WebKitWebView *webview, GtkMenu *menu, gpointer data)
   3.225  {
   3.226  	GtkWidget* item;
   3.227 -	
   3.228 -	/* Separator */
   3.229 -	item = gtk_separator_menu_item_new();
   3.230 -	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.231 -
   3.232 -	/* Zoom in */
   3.233 -	item = gtk_image_menu_item_new_with_label(_("Zoom in"));
   3.234 -	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.235 -	gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU));
   3.236 -	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.237 -	g_signal_connect(item, "activate", G_CALLBACK(zoom_in_cb), webview);
   3.238 -	
   3.239 -	/* Zoom out */
   3.240 -	item = gtk_image_menu_item_new_with_label(_("Zoom out"));
   3.241 -	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.242 -	gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU));
   3.243 -	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.244 -	g_signal_connect(item, "activate", G_CALLBACK(zoom_out_cb), webview);
   3.245  
   3.246  	/* Separator */
   3.247  	item = gtk_separator_menu_item_new();
   3.248  	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.249 -
   3.250 +	
   3.251 +	/* Bookmark */
   3.252 +	item = gtk_image_menu_item_new_with_label(_("Bookmarks"));
   3.253 +	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.254 +	gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU));
   3.255 +	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.256 +	g_signal_connect(item, "activate", G_CALLBACK(go_bookmarks_cb), webview);
   3.257 +	
   3.258  	if (! kiosk) {
   3.259  		/* Add a bookmark */
   3.260  		item = gtk_image_menu_item_new_with_label(_("Add a bookmark"));
   3.261 @@ -309,8 +347,19 @@
   3.262  		gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
   3.263  		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.264  		g_signal_connect(item, "activate", G_CALLBACK(add_bookmark_cb), webview);
   3.265 +		
   3.266 +		/* Edit bookmarks */
   3.267 +		item = gtk_image_menu_item_new_with_label(_("Edit bookmarks"));
   3.268 +		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.269 +		gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU));
   3.270 +		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.271 +		g_signal_connect(item, "activate", G_CALLBACK(bookmarks_edit_cb), webview);
   3.272 +		
   3.273 +		/* Separator */
   3.274 +		item = gtk_separator_menu_item_new();
   3.275 +		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.276  	}
   3.277 -
   3.278 +	
   3.279  	/* Printing */
   3.280  	item = gtk_image_menu_item_new_with_label(_("Print this page"));
   3.281  	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.282 @@ -324,25 +373,62 @@
   3.283  	gtk_image_new_from_stock(GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU));
   3.284  	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.285  	g_signal_connect(item, "activate", G_CALLBACK(view_source_cb), webview);
   3.286 +	
   3.287 +	/* Separator */
   3.288 +	item = gtk_separator_menu_item_new();
   3.289 +	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.290 +	
   3.291 +	/* Zoom in */
   3.292 +	item = gtk_image_menu_item_new_with_label(_("Zoom in"));
   3.293 +	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.294 +	gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU));
   3.295 +	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.296 +	g_signal_connect(item, "activate", G_CALLBACK(zoom_in_cb), webview);
   3.297 +
   3.298 +	/* Zoom out */
   3.299 +	item = gtk_image_menu_item_new_with_label(_("Zoom out"));
   3.300 +	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.301 +	gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU));
   3.302 +	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.303 +	g_signal_connect(item, "activate", G_CALLBACK(zoom_out_cb), webview);
   3.304  
   3.305  	/* Separator */
   3.306  	item = gtk_separator_menu_item_new();
   3.307  	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.308  
   3.309 +	/* Cookies */
   3.310 +	if (! nocookies) {
   3.311 +		item = gtk_image_menu_item_new_with_label(_("View cookies"));
   3.312 +		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.313 +		gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_MENU));
   3.314 +		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.315 +		g_signal_connect(item, "activate", G_CALLBACK(cookies_view_cb), webview);
   3.316 +		
   3.317 +		item = gtk_image_menu_item_new_with_label(_("Clean all cookies"));
   3.318 +		gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.319 +		gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
   3.320 +		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.321 +		g_signal_connect(item, "activate", G_CALLBACK(cookies_clean_cb), webview);
   3.322 +		
   3.323 +		/* Separator */
   3.324 +		item = gtk_separator_menu_item_new();
   3.325 +		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.326 +	}
   3.327 +
   3.328  	/* TazWeb documentation */
   3.329  	item = gtk_image_menu_item_new_with_label(_("TazWeb manual"));
   3.330  	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.331  	gtk_image_new_from_stock(GTK_STOCK_HELP, GTK_ICON_SIZE_MENU));
   3.332  	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.333  	g_signal_connect(item, "activate", G_CALLBACK(tazweb_doc_cb), webview);
   3.334 -	
   3.335 +
   3.336  	/* Quit TazWeb */
   3.337  	item = gtk_image_menu_item_new_with_label(_("Quit TazWeb"));
   3.338  	gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
   3.339  	gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));
   3.340  	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
   3.341  	g_signal_connect(item, "activate", G_CALLBACK(destroy_cb), webview);
   3.342 -	
   3.343 +
   3.344  	gtk_widget_show_all(GTK_WIDGET(menu));
   3.345  }
   3.346  
   3.347 @@ -352,7 +438,7 @@
   3.348  		WebKitWebView* webview)
   3.349  {
   3.350  	WebKitWebSettings *settings;
   3.351 -	
   3.352 +
   3.353  	browser = gtk_scrolled_window_new(NULL, NULL);
   3.354  	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(browser),
   3.355  			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   3.356 @@ -374,7 +460,7 @@
   3.357  			G_CALLBACK(webview_ready_cb), window);
   3.358  	g_signal_connect(webview, "close-web-view",
   3.359  			G_CALLBACK(close_webview_cb), window);
   3.360 -	
   3.361 +
   3.362  	/* Impossible to open in new window or download in kiosk mode */
   3.363  	if (! kiosk) {
   3.364  		g_signal_connect(webview, "download-requested",
   3.365 @@ -394,7 +480,7 @@
   3.366  create_toolbar(GtkWidget* urientry, GtkWidget* search, WebKitWebView* webview)
   3.367  {
   3.368  	GtkToolItem* item;
   3.369 -	
   3.370 +
   3.371  	toolbar = gtk_toolbar_new();
   3.372  	gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar),
   3.373  			GTK_ORIENTATION_HORIZONTAL);
   3.374 @@ -402,18 +488,18 @@
   3.375  			GTK_TOOLBAR_BOTH_HORIZ);
   3.376  
   3.377  	/* The back button */
   3.378 -    item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
   3.379 -    g_signal_connect(G_OBJECT(item), "clicked",
   3.380 +	item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
   3.381 +	g_signal_connect(G_OBJECT(item), "clicked",
   3.382  			G_CALLBACK(go_back_cb), webview);
   3.383 -    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.384 +	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.385  
   3.386 -    /* The forward button */
   3.387 -    item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
   3.388 -    g_signal_connect(G_OBJECT(item), "clicked",
   3.389 +	/* The forward button */
   3.390 +	item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
   3.391 +	g_signal_connect(G_OBJECT(item), "clicked",
   3.392  			G_CALLBACK(go_forward_cb), webview);
   3.393 -    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.394 +	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.395  
   3.396 -    /* Home button */
   3.397 +	/* Home button */
   3.398  	item = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
   3.399  	g_signal_connect(G_OBJECT(item), "clicked",
   3.400  			G_CALLBACK(go_home_cb), webview);
   3.401 @@ -422,19 +508,20 @@
   3.402  	/* URL entry */
   3.403  	item = gtk_tool_item_new();
   3.404  	gtk_tool_item_set_expand(item, TRUE);
   3.405 -	gtk_widget_set_size_request(urientry, 0, 20);
   3.406 +	//gtk_widget_set_size_request(urientry, 0, 20);
   3.407  	gtk_container_add(GTK_CONTAINER(item), urientry);
   3.408  	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.409  	g_signal_connect(G_OBJECT(urientry), "activate",
   3.410  			G_CALLBACK(uri_entry_cb), webview);
   3.411 -	
   3.412 +
   3.413  	/* Separator */
   3.414  	item = gtk_separator_tool_item_new();
   3.415 -	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1); 
   3.416 -	
   3.417 +	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.418 +
   3.419  	/* Search entry */
   3.420  	item = gtk_tool_item_new();
   3.421 -	gtk_widget_set_size_request(search, 160, 20);
   3.422 +	gtk_tool_item_set_expand(item, FALSE);
   3.423 +	gtk_widget_set_size_request(GTK_WIDGET(item), 200, 0);
   3.424  	gtk_container_add(GTK_CONTAINER(item), search);
   3.425  	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
   3.426  	gtk_entry_set_icon_from_stock(GTK_ENTRY(search),
   3.427 @@ -443,7 +530,7 @@
   3.428  			G_CALLBACK(search_icon_press_cb), webview);
   3.429  	g_signal_connect(G_OBJECT(search), "activate",
   3.430  			G_CALLBACK(search_entry_cb), webview);
   3.431 -	
   3.432 +
   3.433  	/* Bookmark button */
   3.434  	item = gtk_tool_button_new_from_stock(GTK_STOCK_PROPERTIES);
   3.435  	g_signal_connect(G_OBJECT(item), "clicked",
   3.436 @@ -460,7 +547,7 @@
   3.437  	GtkWidget *window;
   3.438  	GtkWidget *urientry;
   3.439  	GtkWidget *search;
   3.440 -	
   3.441 +
   3.442  	g_atomic_int_inc(&count);
   3.443  
   3.444  	/* Default TazWeb window */
   3.445 @@ -476,31 +563,34 @@
   3.446  	urientry = gtk_entry_new();
   3.447  	search = gtk_entry_new();
   3.448  	vbox = gtk_vbox_new(FALSE, 0);
   3.449 -	
   3.450 +
   3.451  	/* Pack box and container */
   3.452  	if (! notoolbar)
   3.453  		gtk_box_pack_start(GTK_BOX(vbox),
   3.454  			create_toolbar(urientry, search, webview), FALSE, FALSE, 0);
   3.455  	gtk_box_pack_start(GTK_BOX(vbox),
   3.456  			create_browser(window, urientry, search, webview), TRUE, TRUE, 0);
   3.457 -	
   3.458 +
   3.459  	gtk_container_add(GTK_CONTAINER(window), vbox);
   3.460 -	
   3.461 +
   3.462  	if (newwebview)
   3.463  		*newwebview = webview;
   3.464 -	
   3.465 -	return window;	
   3.466 +
   3.467 +	return window;
   3.468  }
   3.469  
   3.470  int
   3.471  main(int argc, char* argv[])
   3.472  {
   3.473  	textdomain (GETTEXT_PACKAGE);
   3.474 -	
   3.475 +
   3.476  	while (argc > 1) {
   3.477  		if (!strcmp(argv[1],"--notoolbar")) {
   3.478  			notoolbar++;
   3.479  		}
   3.480 +		if (!strcmp(argv[1],"--nocookies")) {
   3.481 +			nocookies++;
   3.482 +		}
   3.483  		else if (!strcmp(argv[1],"--kiosk")) {
   3.484  			kiosk++;
   3.485  		}
   3.486 @@ -510,7 +600,7 @@
   3.487  			useragent = argv[1];
   3.488  		}
   3.489  		else if (!strcmp(argv[1],"--help")) {
   3.490 -			printf ("Usage: tazweb [--notoolbar|--kiosk|--useragent] [ua]\n");
   3.491 +			printf ("Usage: tazweb [--notoolbar|--nocookies|--kiosk|--useragent] [ua]\n");
   3.492  			printf ("Bookmarks: %s\n", BMTXT);
   3.493  			return 0;
   3.494  		}
   3.495 @@ -518,32 +608,39 @@
   3.496  		argc--;
   3.497  		argv++;
   3.498  	}
   3.499 -	
   3.500 +
   3.501  	/* Initialize GTK */
   3.502  	gtk_init(NULL, NULL);
   3.503 -	
   3.504 +
   3.505  	/* Get a default bookmarks.txt if missing */
   3.506  	if (! g_file_test(BMTXT, G_FILE_TEST_EXISTS)) {
   3.507  		system("install -m 0700 -d $HOME/.config/tazweb");
   3.508  		system("install -m 0600 /usr/share/tazweb/bookmarks.txt \
   3.509  			$HOME/.config/tazweb/bookmarks.txt");
   3.510 -	} 
   3.511 +	}
   3.512  
   3.513  	/* Load the start page file or the url in argument */
   3.514  	uri =(char*)(argc > 1 ? argv[1] : WEBHOME);
   3.515  	if (argv[1])
   3.516  		check_requested_uri();
   3.517 -		
   3.518 +
   3.519  	mainwindow = create_window(&webview);
   3.520  	gtk_widget_show_all(mainwindow);
   3.521  	
   3.522 +	/* Handle cookies */
   3.523 +	if (! nocookies) {
   3.524 +		session = webkit_get_default_session();
   3.525 +		snprintf(COOKIES, sizeof COOKIES, "%s", COOKIES);
   3.526 +		cookies_setup();
   3.527 +	}
   3.528 +	
   3.529  	/* Fullscreen for Kiosk mode */
   3.530  	if (kiosk)
   3.531  		gtk_window_fullscreen(GTK_WINDOW(mainwindow));
   3.532 -	
   3.533 +
   3.534  	webkit_web_view_load_uri(webview, uri);
   3.535  	gtk_widget_grab_focus(GTK_WIDGET(webview));
   3.536  	gtk_main();
   3.537 -	
   3.538 +
   3.539  	return 0;
   3.540  }