Commit d9a54382 authored by Christopher Davis's avatar Christopher Davis 🌱

color-selection: Take hex codes that don't start with "#"

Previously if a user input a valid hex code, but left out
"#", `gdk_rgba_parse ()` would fail.

This commit ensures that we prepend "#" before parsing, so
that codes without it are still handled properly.

Closes #109
parent 5b7418aa
Pipeline #128096 passed with stage
in 47 seconds
......@@ -1960,8 +1960,8 @@ get_screen_color (GtkWidget *button)
}
static void
hex_changed (UNUSED GtkWidget *hex_entry,
gpointer data)
hex_changed (GtkWidget *hex_entry,
gpointer data)
{
Gcolor3ColorSelection *colorsel;
Gcolor3ColorSelectionPrivate *priv;
......@@ -1975,6 +1975,11 @@ hex_changed (UNUSED GtkWidget *hex_entry,
return;
text = gtk_editable_get_chars (GTK_EDITABLE (priv->hex_entry), 0, -1);
if (!g_str_has_prefix (text, "#"))
{
text = g_strconcat ("#", text, NULL);
}
if (gdk_rgba_parse (&color, text))
{
priv->color[COLORSEL_RED] = color.red;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment