tazweb rev 34

Fix notify_load_status_cb and move button home on the right
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 14 23:00:52 2011 +0200 (2011-04-14)
parents 2b9ac01011b0
children db6bb81f702f
files src/main.c
line diff
     1.1 --- a/src/main.c	Thu Apr 14 22:24:19 2011 +0200
     1.2 +++ b/src/main.c	Thu Apr 14 23:00:52 2011 +0200
     1.3 @@ -13,10 +13,10 @@
     1.4  
     1.5  static GtkWidget* main_window;
     1.6  static WebKitWebView* web_view;
     1.7 +static GtkWidget* uri_entry;
     1.8  static gchar* main_title;
     1.9  static gdouble load_progress;
    1.10  static guint status_context_id;
    1.11 -static GtkWidget* uri_entry;
    1.12  
    1.13  /* Page title to window title */
    1.14  static void
    1.15 @@ -32,6 +32,14 @@
    1.16  }
    1.17  
    1.18  static void
    1.19 +activate_uri_entry_cb (GtkWidget* entry, gpointer data)
    1.20 +{
    1.21 +	const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
    1.22 +	g_assert (uri);
    1.23 +	webkit_web_view_load_uri (web_view, uri);
    1.24 +}
    1.25 +
    1.26 +static void
    1.27  notify_title_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data)
    1.28  {
    1.29      if (main_title)
    1.30 @@ -49,11 +57,14 @@
    1.31  }
    1.32  
    1.33  static void
    1.34 -activate_uri_entry_cb (GtkWidget* entry, gpointer data)
    1.35 +notify_load_status_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data)
    1.36  {
    1.37 -	const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry));
    1.38 -	g_assert (uri);
    1.39 -	webkit_web_view_load_uri (web_view, uri);
    1.40 +    if (webkit_web_view_get_load_status (web_view) == WEBKIT_LOAD_COMMITTED) {
    1.41 +        WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view);
    1.42 +        const gchar* uri = webkit_web_frame_get_uri (frame);
    1.43 +        if (uri)
    1.44 +            gtk_entry_set_text (GTK_ENTRY (uri_entry), uri);
    1.45 +    }
    1.46  }
    1.47  
    1.48  static void
    1.49 @@ -83,6 +94,12 @@
    1.50      webkit_web_view_go_forward (web_view);
    1.51  }
    1.52  
    1.53 +static void
    1.54 +refresh_cb (GtkWidget* widget, gpointer data)
    1.55 +{
    1.56 +    webkit_web_view_reload (web_view);
    1.57 +}
    1.58 +
    1.59  /* Fullscreen and unfullscreen action */
    1.60  static void 
    1.61  fullscreen_cb (GtkWindow* window, gpointer data)
    1.62 @@ -116,6 +133,7 @@
    1.63  
    1.64      g_signal_connect (web_view, "notify::title", G_CALLBACK (notify_title_cb), web_view);
    1.65      g_signal_connect (web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view);
    1.66 +    g_signal_connect (web_view, "notify::load-status", G_CALLBACK (notify_load_status_cb), web_view);
    1.67  
    1.68      return scrolled_window;
    1.69  }
    1.70 @@ -130,11 +148,6 @@
    1.71  
    1.72      GtkToolItem* item;
    1.73  
    1.74 -    /* The Home button */
    1.75 -    item = gtk_tool_button_new_from_stock (GTK_STOCK_HOME);
    1.76 -    g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_home_cb), NULL);
    1.77 -    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
    1.78 -
    1.79      /* The back button */
    1.80      item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK);
    1.81      g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_back_cb), NULL);
    1.82 @@ -144,6 +157,11 @@
    1.83      item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
    1.84      g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_forward_cb), NULL);
    1.85      gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
    1.86 +
    1.87 +    /* The Reload button */
    1.88 +    item = gtk_tool_button_new_from_stock (GTK_STOCK_REFRESH);
    1.89 +    g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (refresh_cb), NULL);
    1.90 +    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
    1.91      
    1.92      /* Expand to have help icon on the right 
    1.93      * item = gtk_tool_item_new ();
    1.94 @@ -159,16 +177,21 @@
    1.95  	g_signal_connect (G_OBJECT (uri_entry), "activate",
    1.96  		G_CALLBACK (activate_uri_entry_cb), NULL);
    1.97  	gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
    1.98 -    
    1.99 -    /* The TazWeb doc button */
   1.100 -    item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO);
   1.101 -    g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (tazweb_doc_cb), NULL);
   1.102 +
   1.103 +	/* The Home button */
   1.104 +    item = gtk_tool_button_new_from_stock (GTK_STOCK_HOME);
   1.105 +    g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_home_cb), NULL);
   1.106      gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   1.107  
   1.108      /* The Fullscreen button */
   1.109      item = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
   1.110      g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (fullscreen_cb), NULL);
   1.111      gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   1.112 +    
   1.113 +    /* The TazWeb doc button */
   1.114 +    item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO);
   1.115 +    g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (tazweb_doc_cb), NULL);
   1.116 +    gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
   1.117  
   1.118      return toolbar;
   1.119  }