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 authored and aperezdc committed Jun 20, 2023
1 parent 7489ca5 commit 51e0951
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions platform/gtk4/cog-platform-gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,17 @@ on_refresh_clicked(GtkWidget* widget, gpointer user_data)
static void
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);
struct platform_window *win = user_data;
GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(win->url_entry));
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 51e0951

Please sign in to comment.