summaryrefslogtreecommitdiffstats
path: root/src/dialogs/swatches.cpp
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2006-02-27 08:01:11 +0000
committerjoncruz <joncruz@users.sourceforge.net>2006-02-27 08:01:11 +0000
commitf99276f7156e87fa29d8b95e8b3effa3fc98e236 (patch)
tree825040a2a31d53a28e5bce10ac913d90f8bd943b /src/dialogs/swatches.cpp
parentAllowed Private Use Area chacters to be entered. (diff)
downloadinkscape-f99276f7156e87fa29d8b95e8b3effa3fc98e236.tar.gz
inkscape-f99276f7156e87fa29d8b95e8b3effa3fc98e236.zip
Refactoring embedded swatches panel.
(bzr r185)
Diffstat (limited to 'src/dialogs/swatches.cpp')
-rw-r--r--src/dialogs/swatches.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp
index d55a559d8..64250c41c 100644
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
@@ -276,7 +276,10 @@ bool parseNum( char*& str, int& val ) {
class JustForNow
{
public:
+ JustForNow() : _prefWidth(0) {}
+
Glib::ustring _name;
+ int _prefWidth;
std::vector<ColorItem*> _colors;
};
@@ -354,9 +357,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 +470,9 @@ SwatchesPanel::SwatchesPanel() :
if ( !possible.empty() ) {
JustForNow* first = possible.front();
+ if ( first->_prefWidth > 0 ) {
+ _holder->setColumnPref( first->_prefWidth );
+ }
for ( std::vector<ColorItem*>::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) {
_holder->addPreview(*it);
}
@@ -501,6 +520,9 @@ void SwatchesPanel::_handleAction( int setId, int itemId )
if ( itemId >= 0 && itemId < static_cast<int>(possible.size()) ) {
_holder->clear();
JustForNow* curr = possible[itemId];
+ if ( curr->_prefWidth > 0 ) {
+ _holder->setColumnPref( curr->_prefWidth );
+ }
for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) {
_holder->addPreview(*it);
}