summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b268783)
raw | patch | inline | side by side (parent: b268783)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 9 Mar 2009 07:39:42 +0000 (07:39 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 9 Mar 2009 07:39:42 +0000 (07:39 +0000) |
src/widgets/sp-color-notebook.cpp | patch | blob | history |
index 9766a9498e494d3052ddbfd052874bf0e9a5eb9d..779895de43bf1524401217284ae1259e9b07e034 100644 (file)
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);
}
}