Code

Get rid of the SP_DT_* macros which do nothing more than provide additional, confusin...
[inkscape.git] / src / ui / previewholder.cpp
index c2bc133270f5e5e20664f4ac096a096a5a34eb62..bcb4d0282c6f8e7510187af44c4a7e011740f5d4 100644 (file)
@@ -35,7 +35,7 @@ PreviewHolder::PreviewHolder() :
     _prefCols(0),
     _updatesFrozen(false),
     _anchor(Gtk::ANCHOR_CENTER),
-    _baseSize(Gtk::ICON_SIZE_MENU),
+    _baseSize(Inkscape::ICON_SIZE_MENU),
     _view(VIEW_TYPE_LIST)
 {
     _scroller = manage(new Gtk::ScrolledWindow());
@@ -123,7 +123,7 @@ void PreviewHolder::thawUpdates()
     rebuildUI();
 }
 
-void PreviewHolder::setStyle(Gtk::BuiltinIconSize size, ViewType view)
+void PreviewHolder::setStyle( Inkscape::IconSize size, ViewType view )
 {
     if ( size != _baseSize || view != _view ) {
         _baseSize = size;
@@ -189,7 +189,8 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
     height = 1;
 
     if ( _anchor == Gtk::ANCHOR_SOUTH || _anchor == Gtk::ANCHOR_NORTH ) {
-        Gtk::Requisition req = _scroller->size_request();
+        Gtk::Requisition req;
+        _scroller->size_request(req);
         int currW = _scroller->get_width();
         if ( currW > req.width ) {
             req.width = currW;
@@ -197,22 +198,24 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
 
         Gtk::HScrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
         if ( hs ) {
-            Gtk::Requisition scrollReq = hs->size_request();
+            Gtk::Requisition scrollReq;
+            hs->size_request(scrollReq);
 
             // the +8 is a temporary hack
             req.height -= scrollReq.height + 8;
         }
 
-        Gtk::Requisition req2 = thing->size_request();
+        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 = _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;
         }