X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Fswatches.cpp;h=e6d1ac2b57107159b8e6eff731f01a712260f46b;hb=801206ece4daeed292ba5de447fce95d211909ac;hp=c01217fe6cee529d3520385bb7d19aa85d7ebddc;hpb=a661f8d7f400d6ea7bb82e8255830888423af5e4;p=inkscape.git diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index c01217fe6..e6d1ac2b5 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -12,6 +12,8 @@ # include #endif +#include + #include //for GTK_RESPONSE* types #include @@ -276,7 +278,10 @@ bool parseNum( char*& str, int& val ) { class JustForNow { public: + JustForNow() : _prefWidth(0) {} + Glib::ustring _name; + int _prefWidth; std::vector _colors; }; @@ -354,9 +359,22 @@ static void loadPaletteFile( gchar const *filename ) char* val = trim(sep + 1); char* name = trim(result); if ( *name ) { - if ( strcmp( "Name", name ) == 0 ) { + if ( strcmp( "Name", name ) == 0 ) + { onceMore->_name = val; } + else if ( strcmp( "Columns", name ) == 0 ) + { + gchar* endPtr = 0; + guint64 numVal = g_ascii_strtoull( val, &endPtr, 10 ); + if ( (numVal == G_MAXUINT64) && (ERANGE == errno) ) { + // overflow + } else if ( (numVal == 0) && (endPtr == val) ) { + // failed conversion + } else { + onceMore->_prefWidth = numVal; + } + } } else { // error hasErr = true; @@ -454,6 +472,9 @@ SwatchesPanel::SwatchesPanel() : if ( !possible.empty() ) { JustForNow* first = possible.front(); + if ( first->_prefWidth > 0 ) { + _holder->setColumnPref( first->_prefWidth ); + } for ( std::vector::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) { _holder->addPreview(*it); } @@ -470,7 +491,7 @@ SwatchesPanel::SwatchesPanel() : } - pack_start(*_holder, Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(*_holder, Gtk::PACK_EXPAND_WIDGET); _setTargetFillable(_holder); show_all_children(); @@ -501,6 +522,9 @@ void SwatchesPanel::_handleAction( int setId, int itemId ) if ( itemId >= 0 && itemId < static_cast(possible.size()) ) { _holder->clear(); JustForNow* curr = possible[itemId]; + if ( curr->_prefWidth > 0 ) { + _holder->setColumnPref( curr->_prefWidth ); + } for ( std::vector::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { _holder->addPreview(*it); }