summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2009-03-09 07:39:42 +0000
committerjoncruz <joncruz@users.sourceforge.net>2009-03-09 07:39:42 +0000
commitc6f6e6c514fb0bec07cffccdd4368e8bd445a0af (patch)
treef39956ab247c37b319ddfd191b28097bfc98b4c3 /src/widgets
parentadded 2geom/utils.cpp - unused, but useful (diff)
downloadinkscape-c6f6e6c514fb0bec07cffccdd4368e8bd445a0af.tar.gz
inkscape-c6f6e6c514fb0bec07cffccdd4368e8bd445a0af.zip
Made text entry handle standard web-hex values. Fixes bug #168121.
(bzr r7457)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/sp-color-notebook.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp
index 9766a9498..779895de4 100644
--- a/src/widgets/sp-color-notebook.cpp
+++ b/src/widgets/sp-color-notebook.cpp
@@ -448,18 +448,36 @@ void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry)
const gchar *t = gtk_entry_get_text( entry );
if (t) {
- gchar *e = 0;
- guint rgba = strtoul (t, &e, 16);
- if ( e != t ) {
- ptrdiff_t len=e-t;
+ Glib::ustring text = t;
+ bool changed = false;
+ if (!text.empty() && text[0] == '#') {
+ changed = true;
+ text.erase(0,1);
+ if (text.size() == 6) {
+ // it was a standard RGB hex
+ unsigned int alph = SP_COLOR_F_TO_U(_alpha);
+ gchar* tmp = g_strdup_printf("%02x", alph);
+ text += tmp;
+ g_free(tmp);
+ }
+ }
+ gchar* str = g_strdup(text.c_str());
+ gchar* end = 0;
+ guint64 rgba = g_ascii_strtoull( str, &end, 16 );
+ if ( end != str ) {
+ ptrdiff_t len = end - str;
if ( len < 8 ) {
rgba = rgba << ( 4 * ( 8 - len ) );
}
_updatingrgba = TRUE;
+ if ( changed ) {
+ gtk_entry_set_text( entry, str );
+ }
SPColor color( rgba );
setColorAlpha( color, SP_RGBA32_A_F(rgba), true );
_updatingrgba = FALSE;
}
+ g_free(str);
}
}