commit: 36fd8fd0611c578b1a3eb4b5bf47dec49cfd9a8f
parent: 577063a6b416b35e4ef5f10242118d2eed67e7fe
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 7 Jan 2019 04:39:55 +0100
badwolf.c: statusbar → entry
Diffstat:
M | badwolf.c | 33 | +++++++++++++++++++++++---------- |
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -5,34 +5,47 @@
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
-static gboolean closeWebViewCb(WebKitWebView *_webView, GtkWidget *window)
+static gboolean WebViewCb_close(WebKitWebView *_webView, GtkWidget *window)
{
gtk_widget_destroy(window);
return TRUE;
}
+static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GtkWidget *location)
+{
+ const gchar *location_uri;
+
+ location_uri = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(webView));
+
+ gtk_entry_set_text(GTK_ENTRY(location), location_uri);
+
+ return TRUE;
+}
+
int main(int argc, char *argv[])
{
char *target_url = "about:blank";
- GtkWidget *main_window, *box, *statusbar;
+ GtkWidget *main_window, *box, *location;
WebKitWebView *webView;
- if(argv[1])
- target_url = argv[1];
+ if(argv[1]) target_url = argv[1];
gtk_init(0, 0);
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- statusbar = gtk_statusbar_new();
- box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ location = gtk_entry_new();
+ box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
+ webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
gtk_container_add(GTK_CONTAINER(main_window), box);
- gtk_box_pack_start(box, webView, TRUE, TRUE, 0);
- gtk_box_pack_end(box, statusbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(location), FALSE, FALSE, 0);
+ gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(webView), TRUE, TRUE, 0);
+
+ gtk_entry_set_text(GTK_ENTRY(location), target_url);
g_signal_connect(main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(webView, "close", G_CALLBACK(closeWebViewCb), main_window);
+ g_signal_connect(webView, "close", G_CALLBACK(WebViewCb_close), main_window);
+ g_signal_connect(webView, "notify::uri", G_CALLBACK(WebViewCb_notify__uri), location);
WebKitSettings *settings = webkit_web_view_get_settings(webView);