index b89e68adceabc145164e38132e21d4123266cea7..1717e5053c0cc2b5f1d5fe2e6254a7abc24b7433 100644 (file)
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
_prefCols(0),
_updatesFrozen(false),
_anchor(Gtk::ANCHOR_CENTER),
_prefCols(0),
_updatesFrozen(false),
_anchor(Gtk::ANCHOR_CENTER),
- _baseSize(Gtk::ICON_SIZE_MENU),
- _view(VIEW_TYPE_LIST)
+ _baseSize(Inkscape::ICON_SIZE_MENU),
+ _view(VIEW_TYPE_LIST),
+ _wrap(false)
{
_scroller = manage(new Gtk::ScrolledWindow());
_insides = manage(new Gtk::Table( 1, 2 ));
{
_scroller = manage(new Gtk::ScrolledWindow());
_insides = manage(new Gtk::Table( 1, 2 ));
rebuildUI();
}
rebuildUI();
}
-void PreviewHolder::setStyle(Gtk::BuiltinIconSize size, ViewType view)
+void PreviewHolder::setStyle( Inkscape::IconSize size, ViewType view )
{
if ( size != _baseSize || view != _view ) {
_baseSize = size;
{
if ( size != _baseSize || view != _view ) {
_baseSize = size;
case Gtk::ANCHOR_NORTH:
case Gtk::ANCHOR_SOUTH:
{
case Gtk::ANCHOR_NORTH:
case Gtk::ANCHOR_SOUTH:
{
- dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC );
+ dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER );
}
break;
}
break;
}
}
}
}
+void PreviewHolder::setWrap( bool b )
+{
+ if ( b != _wrap ) {
+ _wrap = b;
+ switch ( _anchor )
+ {
+ case Gtk::ANCHOR_NORTH:
+ case Gtk::ANCHOR_SOUTH:
+ {
+ dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER );
+ }
+ break;
+ default:
+ {
+ (void)0;
+ // do nothing;
+ }
+ }
+ rebuildUI();
+ }
+}
+
void PreviewHolder::setColumnPref( int cols )
{
_prefCols = cols;
void PreviewHolder::setColumnPref( int cols )
{
_prefCols = cols;
@@ -208,14 +231,14 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
Gtk::Requisition req2;
const_cast<Gtk::Widget*>(thing)->size_request(req2);
Gtk::Requisition req2;
const_cast<Gtk::Widget*>(thing)->size_request(req2);
- int h2 = req.height / req2.height;
- int w2 = req.width / req2.width;
+ int h2 = ((req2.height > 0) && (req.height > req2.height)) ? (req.height / req2.height) : 1;
+ int w2 = ((req2.width > 0) && (req.width > req2.width)) ? (req.width / req2.width) : 1;
width = (itemCount + (h2 - 1)) / h2;
if ( width < w2 ) {
width = w2;
}
} else {
width = (itemCount + (h2 - 1)) / h2;
if ( width < w2 ) {
width = w2;
}
} else {
- width = _baseSize == Gtk::ICON_SIZE_MENU ? COLUMNS_FOR_SMALL : COLUMNS_FOR_LARGE;
+ width = (_baseSize == Inkscape::ICON_SIZE_MENU || _baseSize == Inkscape::ICON_SIZE_DECORATION) ? COLUMNS_FOR_SMALL : COLUMNS_FOR_LARGE;
if ( _prefCols > 0 ) {
width = _prefCols;
}
if ( _prefCols > 0 ) {
width = _prefCols;
}