index c01217fe6cee529d3520385bb7d19aa85d7ebddc..e6d1ac2b57107159b8e6eff731f01a712260f46b 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
# include <config.h>
#endif
+#include <errno.h>
+
#include <gtk/gtkdialog.h> //for GTK_RESPONSE* types
#include <gtk/gtkdnd.h>
class JustForNow
{
public:
+ JustForNow() : _prefWidth(0) {}
+
Glib::ustring _name;
+ int _prefWidth;
std::vector<ColorItem*> _colors;
};
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;
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);
}
}
- pack_start(*_holder, Gtk::PACK_EXPAND_WIDGET);
+ _getContents()->pack_start(*_holder, Gtk::PACK_EXPAND_WIDGET);
_setTargetFillable(_holder);
show_all_children();
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);
}