diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index c6ab06507..d4d26e601 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -16,6 +16,7 @@ #include <errno.h> #include <map> #include <algorithm> +#include <iomanip> #include <set> #include "swatches.h" @@ -380,7 +381,7 @@ static char* trim( char* str ) { str++; } str--; - while ( str > ret && (( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n') ) { + while ( str >= ret && (( *str == ' ' || *str == '\t' ) || *str == '\r' || *str == '\n') ) { *str-- = 0; } return ret; @@ -453,9 +454,16 @@ void _loadPaletteFile(Glib::ustring path, gboolean user/*=FALSE*/) } if ( !hasErr && *ptr ) { char* n = trim(ptr); - if (n != NULL) { + if (n != NULL && *n) { name = g_dpgettext2(NULL, "Palette", n); } + if (name == "") { + name = Glib::ustring::compose("#%1%2%3", + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), r), + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), g), + Glib::ustring::format(std::hex, std::setw(2), std::setfill(L'0'), b) + ).uppercase(); + } } if ( !hasErr ) { // Add the entry now |
