tazweb rev 52

Add a search entry in toolbar and use home.html for personnal page (keep just one button and start page to slitaz webhome)
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 21 21:09:24 2011 +0200 (2011-04-21)
parents 6f282db96e72
children b7fd9f2aff8d
files data/home.html data/page.html src/main.c tazweb
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/data/home.html	Thu Apr 21 21:09:24 2011 +0200
     1.3 @@ -0,0 +1,70 @@
     1.4 +<!DOCTYPE html>
     1.5 +<html xmlns="http://www.w3.org/1999/xhtml">
     1.6 +<head>
     1.7 +	<title>My Page</title>
     1.8 +	<meta charset="utf-8" />
     1.9 +	<link rel="stylesheet" type="text/css" href="style.css" />
    1.10 +</head>
    1.11 +<body>
    1.12 +
    1.13 +<div id="header">
    1.14 +	<h1>My Page</h1>
    1.15 +</div>
    1.16 +
    1.17 +<!-- Start content -->
    1.18 +<div id="content">
    1.19 +
    1.20 +<!--
    1.21 +	Welcome to your personal and custom TazWeb page: a pure xHTML 5 file
    1.22 +	with some CSS for the design, you can customize it as you want. To add
    1.23 +	a section title you can use <h2></h2> elements and <div></div> to
    1.24 +	organize content.
    1.25 +
    1.26 +	Here is an example of a bookmark entry, copy and paste it somewhere
    1.27 +	between an <ul></ul> element to add an entry in the list.
    1.28 +	
    1.29 +	<li>
    1.30 +		<a href="URL">NAME</a>
    1.31 +		: DESCRIPTION
    1.32 +	</li>
    1.33 +-->
    1.34 +
    1.35 +<div id="cloud">
    1.36 +	<a class="tag4" href="http://www.slitaz.org/">SliTaz Website</a>
    1.37 +	<a class="tag6" href="http://scn.slitaz.org/">SCN</a>
    1.38 +	<a class="tag8" href="http://wikipedia.org/">Wikipedia</a>
    1.39 +	<a class="tag5" href="http://forum.slitaz.org/">SliTaz Forum</a>
    1.40 +	<a class="tag4" href="http://www.google.com/">Google</a>
    1.41 +	<a class="tag6" href="http://doc.slitaz.org/">SliTaz Wiki</a>
    1.42 +	<a class="tag5" href="http://twitter.com">Twitter</a>
    1.43 +	<a class="tag2" href="http://search.yahoo.com/">Yahoo</a>
    1.44 +	<a class="tag8" href="http://tazpanel:82/">TazPanel</a>
    1.45 +</div>
    1.46 +
    1.47 +<!-- A nice bookmarks list (Uncomment img to have favicons) -->
    1.48 +<div id="bookmarks">
    1.49 +	<h2>Bookmarks</h2>
    1.50 +	<ul>
    1.51 +		<li>
    1.52 +			<!-- <img src="http://www.slitaz.org/favicon.ico" /> -->
    1.53 +			<a href="http://bugs.slitaz.org/">bugs.slitaz.org</a>
    1.54 +			: SliTaz Bug tracker
    1.55 +		</li>
    1.56 +		<li>
    1.57 +			<!-- <img src="http://www.gnu.org/favicon.ico" /> -->
    1.58 +			<a href="http://www.gnu.org/">www.gnu.org</a>
    1.59 +			: The GNU Website
    1.60 +		</li>
    1.61 +		<li>
    1.62 +			<!-- <img src="http://is.gd/isgd_favicon.ico" /> -->
    1.63 +			<a href="http://is.gd/">is.gd</a>
    1.64 +			: URL shortener
    1.65 +		</li>
    1.66 +	</ul>
    1.67 +</div>
    1.68 +
    1.69 +<!-- End content -->
    1.70 +</div>
    1.71 +
    1.72 +</body>
    1.73 +</html>
     2.1 --- a/data/page.html	Thu Apr 21 19:43:42 2011 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,70 +0,0 @@
     2.4 -<!DOCTYPE html>
     2.5 -<html xmlns="http://www.w3.org/1999/xhtml">
     2.6 -<head>
     2.7 -	<title>My Page</title>
     2.8 -	<meta charset="utf-8" />
     2.9 -	<link rel="stylesheet" type="text/css" href="style.css" />
    2.10 -</head>
    2.11 -<body>
    2.12 -
    2.13 -<div id="header">
    2.14 -	<h1>My Page</h1>
    2.15 -</div>
    2.16 -
    2.17 -<!-- Start content -->
    2.18 -<div id="content">
    2.19 -
    2.20 -<!--
    2.21 -	Welcome to your personal and custom TazWeb page: a pure xHTML 5 file
    2.22 -	with some CSS for the design, you can customize it as you want. To add
    2.23 -	a section title you can use <h2></h2> elements and <div></div> to
    2.24 -	organize content.
    2.25 -
    2.26 -	Here is an example of a bookmark entry, copy and paste it somewhere
    2.27 -	between an <ul></ul> element to add an entry in the list.
    2.28 -	
    2.29 -	<li>
    2.30 -		<a href="URL">NAME</a>
    2.31 -		: DESCRIPTION
    2.32 -	</li>
    2.33 --->
    2.34 -
    2.35 -<div id="cloud">
    2.36 -	<a class="tag4" href="http://www.slitaz.org/">SliTaz Website</a>
    2.37 -	<a class="tag6" href="http://scn.slitaz.org/">SCN</a>
    2.38 -	<a class="tag8" href="http://wikipedia.org/">Wikipedia</a>
    2.39 -	<a class="tag5" href="http://forum.slitaz.org/">SliTaz Forum</a>
    2.40 -	<a class="tag4" href="http://www.google.com/">Google</a>
    2.41 -	<a class="tag6" href="http://doc.slitaz.org/">SliTaz Wiki</a>
    2.42 -	<a class="tag5" href="http://twitter.com">Twitter</a>
    2.43 -	<a class="tag2" href="http://search.yahoo.com/">Yahoo</a>
    2.44 -	<a class="tag8" href="http://tazpanel:82/">TazPanel</a>
    2.45 -</div>
    2.46 -
    2.47 -<!-- A nice bookmarks list (Uncomment img to have favicons) -->
    2.48 -<div id="bookmarks">
    2.49 -	<h2>Bookmarks</h2>
    2.50 -	<ul>
    2.51 -		<li>
    2.52 -			<!-- <img src="http://www.slitaz.org/favicon.ico" /> -->
    2.53 -			<a href="http://bugs.slitaz.org/">bugs.slitaz.org</a>
    2.54 -			: SliTaz Bug tracker
    2.55 -		</li>
    2.56 -		<li>
    2.57 -			<!-- <img src="http://www.gnu.org/favicon.ico" /> -->
    2.58 -			<a href="http://www.gnu.org/">www.gnu.org</a>
    2.59 -			: The GNU Website
    2.60 -		</li>
    2.61 -		<li>
    2.62 -			<!-- <img src="http://is.gd/isgd_favicon.ico" /> -->
    2.63 -			<a href="http://is.gd/">is.gd</a>
    2.64 -			: URL shortener
    2.65 -		</li>
    2.66 -	</ul>
    2.67 -</div>
    2.68 -
    2.69 -<!-- End content -->
    2.70 -</div>
    2.71 -
    2.72 -</body>
    2.73 -</html>
     3.1 --- a/src/main.c	Thu Apr 21 19:43:42 2011 +0200
     3.2 +++ b/src/main.c	Thu Apr 21 21:09:24 2011 +0200
     3.3 @@ -14,10 +14,12 @@
     3.4  static GtkWidget* main_window;
     3.5  static WebKitWebView* web_view;
     3.6  static GtkWidget* uri_entry;
     3.7 +static GtkWidget* search_entry;
     3.8  static gchar* main_title;
     3.9  static gdouble load_progress;
    3.10  static guint status_context_id;
    3.11 -const char* config;
    3.12 +const gchar* config;
    3.13 +const gchar* uri;
    3.14  
    3.15  /* Create an icon */
    3.16  static GdkPixbuf*
    3.17 @@ -33,7 +35,7 @@
    3.18  get_config ()
    3.19  {
    3.20  	config = g_strdup_printf ("%s/.config/tazweb", g_get_home_dir ());
    3.21 -	if (!g_file_test(config, G_FILE_TEST_EXISTS)) {
    3.22 +	if (! g_file_test(config, G_FILE_TEST_EXISTS)) {
    3.23  		g_mkdir (config, 0700);
    3.24  		system ("cp /usr/share/tazweb/* $HOME/.config/tazweb");
    3.25  	}
    3.26 @@ -74,47 +76,48 @@
    3.27  {
    3.28  	if (webkit_web_view_get_load_status (web_view) == WEBKIT_LOAD_COMMITTED) {
    3.29  		WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view);
    3.30 -		const gchar* uri = webkit_web_frame_get_uri (frame);
    3.31 +		uri = webkit_web_frame_get_uri (frame);
    3.32  		if (uri)
    3.33  			gtk_entry_set_text (GTK_ENTRY (uri_entry), uri);
    3.34  	}
    3.35  }
    3.36  
    3.37 -/* URL entry callback function */
    3.38 -static void
    3.39 -activate_uri_entry_cb (GtkWidget* entry, gpointer data)
    3.40 -{
    3.41 -	const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
    3.42 -	g_assert (uri);
    3.43 -	webkit_web_view_load_uri (web_view, uri);
    3.44 -}
    3.45 -
    3.46  static void
    3.47  destroy_cb (GtkWidget* widget, gpointer data)
    3.48  {
    3.49  	gtk_main_quit ();
    3.50  }
    3.51  
    3.52 -/* Home button function */
    3.53 +/* URL entry callback function */
    3.54  static void
    3.55 -go_home_cb (GtkWidget* widget, gpointer data)
    3.56 +activate_uri_entry_cb (GtkWidget* entry, gpointer data)
    3.57  {
    3.58 -	const gchar* uri = ("file:///usr/share/webhome/index.html");
    3.59 +	uri = gtk_entry_get_text (GTK_ENTRY (entry));
    3.60  	g_assert (uri);
    3.61  	webkit_web_view_load_uri (web_view, uri);
    3.62  }
    3.63  
    3.64 -/* My page button function */
    3.65 +/* Search entry callback function */
    3.66  static void
    3.67 -my_page_cb (GtkWidget* widget, gpointer data)
    3.68 +activate_search_entry_cb (GtkWidget* entry, gpointer data)
    3.69  {
    3.70 -	const gchar* uri = g_strdup_printf ("file://%s/.config/tazweb/page.html",
    3.71 +	uri = g_strdup_printf ("http://www.google.com/search?q=%s",
    3.72 +			gtk_entry_get_text (GTK_ENTRY (entry)));
    3.73 +	g_assert (uri);
    3.74 +	webkit_web_view_load_uri (web_view, uri);
    3.75 +}
    3.76 +
    3.77 +/* Home button callback function */
    3.78 +static void
    3.79 +go_home_cb (GtkWidget* widget, gpointer data)
    3.80 +{
    3.81 +	uri = g_strdup_printf ("file://%s/.config/tazweb/home.html",
    3.82  			g_get_home_dir ());
    3.83  	g_assert (uri);
    3.84  	webkit_web_view_load_uri (web_view, uri);
    3.85  }
    3.86  
    3.87 -/* Fullscreen and unfullscreen function */
    3.88 +/* Fullscreen and unfullscreen callback function */
    3.89  static void
    3.90  fullscreen_cb (GtkWindow* window, gpointer data)
    3.91  {
    3.92 @@ -127,11 +130,11 @@
    3.93  		gtk_window_fullscreen (GTK_WINDOW (main_window));
    3.94  }
    3.95  
    3.96 -/* TazWeb doc function */
    3.97 +/* TazWeb doc callback function */
    3.98  static void
    3.99  tazweb_doc_cb (GtkWidget* widget, gpointer data)
   3.100  {
   3.101 -	const gchar* uri = ("file:///usr/share/doc/tazweb/tazweb.html");
   3.102 +	uri = ("file:///usr/share/doc/tazweb/tazweb.html");
   3.103  	g_assert (uri);
   3.104  	webkit_web_view_load_uri (web_view, uri);
   3.105  }
   3.106 @@ -141,7 +144,7 @@
   3.107  download_requested_cb (WebKitWebView *web_view, WebKitDownload *download,
   3.108  		gpointer user_data)
   3.109  {
   3.110 -	const gchar* uri = webkit_download_get_uri (download);
   3.111 +	uri = webkit_download_get_uri (download);
   3.112  	gchar *buffer;
   3.113  	asprintf (&buffer, "tazbox dl-out %s", uri);
   3.114  	system (buffer);
   3.115 @@ -187,12 +190,6 @@
   3.116  			G_CALLBACK (go_home_cb), NULL);
   3.117  	gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   3.118  
   3.119 -	/* The personal page button */
   3.120 -	item = gtk_tool_button_new_from_stock (GTK_STOCK_PREFERENCES);
   3.121 -	g_signal_connect (G_OBJECT (item), "clicked",
   3.122 -			G_CALLBACK (my_page_cb), NULL);
   3.123 -	gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   3.124 -
   3.125  	/* The URL entry */
   3.126  	item = gtk_tool_item_new ();
   3.127  	gtk_tool_item_set_expand (item, TRUE);
   3.128 @@ -201,6 +198,14 @@
   3.129  	g_signal_connect (G_OBJECT (uri_entry), "activate",
   3.130  					  G_CALLBACK (activate_uri_entry_cb), NULL);
   3.131  	gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   3.132 +	
   3.133 +	/* The Search entry */
   3.134 +	item = gtk_tool_item_new ();
   3.135 +	search_entry = gtk_entry_new ();
   3.136 +	gtk_container_add (GTK_CONTAINER (item), search_entry);
   3.137 +	g_signal_connect (G_OBJECT (search_entry), "activate",
   3.138 +					  G_CALLBACK (activate_search_entry_cb), NULL);
   3.139 +	gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   3.140  
   3.141  	/* The TazWeb doc button */
   3.142  	item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO);
   3.143 @@ -248,8 +253,8 @@
   3.144  	main_window = create_window ();
   3.145  	gtk_container_add (GTK_CONTAINER (main_window), vbox);
   3.146  
   3.147 -	/* Home page url or file */
   3.148 -	gchar* uri = (gchar*) (argc > 1 ? argv[1] :
   3.149 +	/* Start page url or file */
   3.150 +	uri = (gchar*) (argc > 1 ? argv[1] :
   3.151  			"file:///usr/share/webhome/index.html");
   3.152  	webkit_web_view_load_uri (web_view, uri);
   3.153  
     4.1 Binary file tazweb has changed