Skip to content

Commit

Permalink
gtk4: Prefix a scheme if none provided
Browse files Browse the repository at this point in the history
This is just a small quality of life improvement where entering
"example.org" into the entry will prefix "http://".
  • Loading branch information
TingPing committed Jun 20, 2023
1 parent 49c2de4 commit 81a8132
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion platform/gtk4/cog-platform-gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,15 @@ on_entry_activated(GtkWidget* widget, gpointer user_data)
{
struct platform_window* win = user_data;
GtkEntryBuffer* buffer = gtk_entry_get_buffer(GTK_ENTRY(win->url_entry));
const gchar* uri = gtk_entry_buffer_get_text(buffer);
const gchar* user_input = gtk_entry_buffer_get_text(buffer);
g_autoptr(GError) error = NULL;
g_autofree gchar* uri = cog_uri_guess_from_user_input(user_input, FALSE, &error);

if (error) {
g_warning("Failed to parse user input \"%s\": %s", user_input, error->message);
return;
}

webkit_web_view_load_uri(win->web_view, uri);
}

Expand Down

0 comments on commit 81a8132

Please sign in to comment.