# HG changeset patch # User Christophe Lincoln # Date 1302814852 -7200 # Node ID 8fde5fee9c8b799fe7f5699e4df10548c60a4a98 # Parent 2b9ac01011b0ab45b07567b10e8c2001e8759353 Fix notify_load_status_cb and move button home on the right diff -r 2b9ac01011b0 -r 8fde5fee9c8b src/main.c --- a/src/main.c Thu Apr 14 22:24:19 2011 +0200 +++ b/src/main.c Thu Apr 14 23:00:52 2011 +0200 @@ -13,10 +13,10 @@ static GtkWidget* main_window; static WebKitWebView* web_view; +static GtkWidget* uri_entry; static gchar* main_title; static gdouble load_progress; static guint status_context_id; -static GtkWidget* uri_entry; /* Page title to window title */ static void @@ -32,6 +32,14 @@ } static void +activate_uri_entry_cb (GtkWidget* entry, gpointer data) +{ + const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry)); + g_assert (uri); + webkit_web_view_load_uri (web_view, uri); +} + +static void notify_title_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data) { if (main_title) @@ -49,11 +57,14 @@ } static void -activate_uri_entry_cb (GtkWidget* entry, gpointer data) +notify_load_status_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data) { - const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry)); - g_assert (uri); - webkit_web_view_load_uri (web_view, uri); + if (webkit_web_view_get_load_status (web_view) == WEBKIT_LOAD_COMMITTED) { + WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view); + const gchar* uri = webkit_web_frame_get_uri (frame); + if (uri) + gtk_entry_set_text (GTK_ENTRY (uri_entry), uri); + } } static void @@ -83,6 +94,12 @@ webkit_web_view_go_forward (web_view); } +static void +refresh_cb (GtkWidget* widget, gpointer data) +{ + webkit_web_view_reload (web_view); +} + /* Fullscreen and unfullscreen action */ static void fullscreen_cb (GtkWindow* window, gpointer data) @@ -116,6 +133,7 @@ g_signal_connect (web_view, "notify::title", G_CALLBACK (notify_title_cb), web_view); g_signal_connect (web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view); + g_signal_connect (web_view, "notify::load-status", G_CALLBACK (notify_load_status_cb), web_view); return scrolled_window; } @@ -130,11 +148,6 @@ GtkToolItem* item; - /* The Home button */ - item = gtk_tool_button_new_from_stock (GTK_STOCK_HOME); - g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_home_cb), NULL); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); - /* The back button */ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_BACK); g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_back_cb), NULL); @@ -144,6 +157,11 @@ item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD); g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_forward_cb), NULL); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + /* The Reload button */ + item = gtk_tool_button_new_from_stock (GTK_STOCK_REFRESH); + g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (refresh_cb), NULL); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); /* Expand to have help icon on the right * item = gtk_tool_item_new (); @@ -159,16 +177,21 @@ g_signal_connect (G_OBJECT (uri_entry), "activate", G_CALLBACK (activate_uri_entry_cb), NULL); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); - - /* The TazWeb doc button */ - item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO); - g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (tazweb_doc_cb), NULL); + + /* The Home button */ + item = gtk_tool_button_new_from_stock (GTK_STOCK_HOME); + g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_home_cb), NULL); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); /* The Fullscreen button */ item = gtk_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN); g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (fullscreen_cb), NULL); gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); + + /* The TazWeb doc button */ + item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO); + g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (tazweb_doc_cb), NULL); + gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); return toolbar; }