Lines 32-38
static GtkWidget* uri_entry;
Link Here
|
32 |
static GtkStatusbar* main_statusbar; |
32 |
static GtkStatusbar* main_statusbar; |
33 |
static WebKitWebView* web_view; |
33 |
static WebKitWebView* web_view; |
34 |
static gchar* main_title; |
34 |
static gchar* main_title; |
35 |
static gint load_progress; |
35 |
static gdouble load_progress; |
36 |
static guint status_context_id; |
36 |
static guint status_context_id; |
37 |
|
37 |
|
38 |
static void |
38 |
static void |
Lines 49-55
update_title (GtkWindow* window)
Link Here
|
49 |
GString* string = g_string_new (main_title); |
49 |
GString* string = g_string_new (main_title); |
50 |
g_string_append (string, " - WebKit Launcher"); |
50 |
g_string_append (string, " - WebKit Launcher"); |
51 |
if (load_progress < 100) |
51 |
if (load_progress < 100) |
52 |
g_string_append_printf (string, " (%d%%)", load_progress); |
52 |
g_string_append_printf (string, " (%f%%)", load_progress); |
53 |
gchar* title = g_string_free (string, FALSE); |
53 |
gchar* title = g_string_free (string, FALSE); |
54 |
gtk_window_set_title (window, title); |
54 |
gtk_window_set_title (window, title); |
55 |
g_free (title); |
55 |
g_free (title); |
Lines 74-91
title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar
Link Here
|
74 |
} |
74 |
} |
75 |
|
75 |
|
76 |
static void |
76 |
static void |
77 |
progress_change_cb (WebKitWebView* page, gint progress, gpointer data) |
77 |
notify_load_status_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data) |
78 |
{ |
78 |
{ |
79 |
load_progress = progress; |
79 |
if (webkit_web_view_get_load_status (web_view) == WEBKIT_LOAD_COMMITTED) { |
80 |
update_title (GTK_WINDOW (main_window)); |
80 |
WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view); |
|
|
81 |
const gchar* uri = webkit_web_frame_get_uri (frame); |
82 |
if (uri) |
83 |
gtk_entry_set_text (GTK_ENTRY (uri_entry), uri); |
84 |
} |
81 |
} |
85 |
} |
82 |
|
86 |
|
83 |
static void |
87 |
static void |
84 |
load_commit_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) |
88 |
notify_progress_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data) |
85 |
{ |
89 |
{ |
86 |
const gchar* uri = webkit_web_frame_get_uri(frame); |
90 |
load_progress = webkit_web_view_get_progress (web_view); |
87 |
if (uri) |
91 |
update_title (GTK_WINDOW (main_window)); |
88 |
gtk_entry_set_text (GTK_ENTRY (uri_entry), uri); |
|
|
89 |
} |
92 |
} |
90 |
|
93 |
|
91 |
static void |
94 |
static void |
Lines 115-124
create_browser ()
Link Here
|
115 |
web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ()); |
118 |
web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ()); |
116 |
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view)); |
119 |
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view)); |
117 |
|
120 |
|
118 |
g_signal_connect (G_OBJECT (web_view), "title-changed", G_CALLBACK (title_change_cb), web_view); |
121 |
g_signal_connect (web_view, "title-changed", G_CALLBACK (title_change_cb), web_view); |
119 |
g_signal_connect (G_OBJECT (web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), web_view); |
122 |
g_signal_connect (web_view, "notify::load-status", G_CALLBACK (notify_load_status_cb), web_view); |
120 |
g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view); |
123 |
g_signal_connect (web_view, "notify::progress", G_CALLBACK (notify_progress_cb), web_view); |
121 |
g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view); |
124 |
g_signal_connect (web_view, "hovering-over-link", G_CALLBACK (link_hover_cb), web_view); |
122 |
|
125 |
|
123 |
return scrolled_window; |
126 |
return scrolled_window; |
124 |
} |
127 |
} |
Lines 174-180
create_window ()
Link Here
|
174 |
GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
177 |
GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
175 |
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); |
178 |
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); |
176 |
gtk_widget_set_name (window, "GtkLauncher"); |
179 |
gtk_widget_set_name (window, "GtkLauncher"); |
177 |
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy_cb), NULL); |
180 |
g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL); |
178 |
|
181 |
|
179 |
return window; |
182 |
return window; |
180 |
} |
183 |
} |
Lines 183-188
int
Link Here
|
183 |
main (int argc, char* argv[]) |
186 |
main (int argc, char* argv[]) |
184 |
{ |
187 |
{ |
185 |
gtk_init (&argc, &argv); |
188 |
gtk_init (&argc, &argv); |
|
|
189 |
if (!g_thread_supported ()) |
190 |
g_thread_init (NULL); |
186 |
|
191 |
|
187 |
GtkWidget* vbox = gtk_vbox_new (FALSE, 0); |
192 |
GtkWidget* vbox = gtk_vbox_new (FALSE, 0); |
188 |
gtk_box_pack_start (GTK_BOX (vbox), create_toolbar (), FALSE, FALSE, 0); |
193 |
gtk_box_pack_start (GTK_BOX (vbox), create_toolbar (), FALSE, FALSE, 0); |