void
set_uri(const char *uri, struct Client *c) {
- gtk_widget_grab_focus(c->location);
- const char *goal = (strcmp(cfg.home_uri, uri) == 0) ? cfg.default_uri : uri;
- gtk_entry_set_text(GTK_ENTRY(c->location), goal);
- gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
+ if (!gtk_widget_is_focus(c->location)) {
+ gtk_entry_set_text(GTK_ENTRY(c->location), uri);
+ }
}
WebKitWebView *
fprintf(stderr, __NAME__ ": Can't open FIFO at all.\n");
} else {
if (write(cooperative_pipe_fp, "", 0) == -1) {
- /* Could not do an empty write to the FIFO which means there's no
- * one listening. */
+ /* Could not do an empty write to the FIFO which means there's
+ * no one listening. */
close(cooperative_pipe_fp);
towatch = g_io_channel_new_file(fifopath, "r+", NULL);
g_io_add_watch(towatch, G_IO_IN, (GIOFunc)remote_msg, NULL);
* now. Not updating the location bar in this scenario is important,
* because we would override the "WEB PROCESS CRASHED" message. */
if (t != NULL && strlen(t) > 0) {
- gtk_entry_set_text(GTK_ENTRY(c->location), t);
+ set_uri(t, c);
if (cfg.history_file != NULL && !cfg.private) {
fp = fopen(cfg.history_file, "a");
/* This was taken almost verbatim from the example in WebKit's
* documentation:
*
- * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html */
+ * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html
+ */
js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object),
result, &err);
}
if (!gtk_widget_is_focus(c->location))
- gtk_entry_set_text(GTK_ENTRY(c->location), to_show);
+ set_uri(to_show, c);
}
void
webkit_web_view_go_forward(WEBKIT_WEB_VIEW(c->web_view));
return TRUE;
} else if (def_key("location", GDK_KEY_t) == key) {
- set_uri(uri, c);
+ gtk_widget_grab_focus(c->location);
+ const char *goal = (strcmp(cfg.home_uri, uri) == 0 || !uri)
+ ? cfg.default_uri
+ : uri;
+ gtk_entry_set_text(GTK_ENTRY(c->location), goal);
+ gtk_editable_set_position(GTK_EDITABLE(c->location), -1);
return TRUE;
} else if (def_key("print", GDK_KEY_Print) == key) {
WebKitPrintOperation *operation =