summaryrefslogtreecommitdiffstats
path: root/src/ui/previewholder.cpp
diff options
context:
space:
mode:
authorMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
committerMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
commit509ca3687330fea576ea67ae6c7f31d16e66b800 (patch)
tree9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/ui/previewholder.cpp
parentupdated to latest trunk (diff)
parent[Bug #1695016] Xaml export misses some radialGradients. (diff)
downloadinkscape-509ca3687330fea576ea67ae6c7f31d16e66b800.tar.gz
inkscape-509ca3687330fea576ea67ae6c7f31d16e66b800.zip
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/ui/previewholder.cpp')
-rw-r--r--src/ui/previewholder.cpp146
1 files changed, 24 insertions, 122 deletions
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index 5e75179a3..6fec65124 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -12,18 +12,12 @@
#include "previewholder.h"
-#include "preferences.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
#include <gtkmm/scrollbar.h>
#include <gtkmm/adjustment.h>
-
-#if WITH_GTKMM_3_0
-# include <gtkmm/grid.h>
-#else
-# include <gtkmm/table.h>
-#endif
+#include <gtkmm/grid.h>
#define COLUMNS_FOR_SMALL 16
#define COLUMNS_FOR_LARGE 8
@@ -55,7 +49,6 @@ PreviewHolder::PreviewHolder() :
((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC);
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
_insides->set_name( "PreviewHolderGrid" );
_insides->set_column_spacing(8);
@@ -66,21 +59,9 @@ PreviewHolder::PreviewHolder() :
_scroller->set_hexpand();
_scroller->set_vexpand();
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
- _insides->set_col_spacings( 8 );
-
- // Add a container with the scroller and a spacer
- Gtk::Table* spaceHolder = Gtk::manage( new Gtk::Table(1, 2) );
-#endif
-
_scroller->add( *_insides );
-#if WITH_GTKMM_3_0
spaceHolder->attach( *_scroller, 0, 0, 1, 1);
-#else
- spaceHolder->attach( *_scroller, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
pack_start(*spaceHolder, Gtk::PACK_EXPAND_WIDGET);
}
@@ -93,11 +74,7 @@ PreviewHolder::~PreviewHolder()
bool PreviewHolder::on_scroll_event(GdkEventScroll *event)
{
// Scroll horizontally by page on mouse wheel
-#if WITH_GTKMM_3_0
- Glib::RefPtr<Gtk::Adjustment> adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
-#else
- Gtk::Adjustment *adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
-#endif
+ auto adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment();
if (!adj) {
return FALSE;
@@ -141,7 +118,6 @@ void PreviewHolder::addPreview( Previewable* preview )
Gtk::Widget* label = Gtk::manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
Gtk::Widget* thing = Gtk::manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach(*thing, 0, i, 1, 1);
@@ -149,10 +125,6 @@ void PreviewHolder::addPreview( Previewable* preview )
label->set_hexpand();
label->set_valign(Gtk::ALIGN_CENTER);
_insides->attach(*label, 1, i, 1, 1);
-#else
- _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
- _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK );
-#endif
}
break;
@@ -168,44 +140,25 @@ void PreviewHolder::addPreview( Previewable* preview )
int col = i % width;
int row = i / width;
-#if !WITH_GTKMM_3_0
- // If the existing grid isn't wide enough, we need to resize
- // it and re-pack the existing widgets
- if ( _insides && width > (int)_insides->property_n_columns() ) {
- _insides->resize( height, width );
-#endif
- std::vector<Gtk::Widget*>kids = _insides->get_children();
- int childCount = (int)kids.size();
- // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
-
- // Loop through the existing widgets and move them to new location
- for ( int j = 1; j < childCount; j++ ) {
- Gtk::Widget* target = kids[childCount - (j + 1)];
- int col2 = j % width;
- int row2 = j / width;
- Glib::RefPtr<Gtk::Widget> handle(target);
- _insides->remove( *target );
-
-#if WITH_GTKMM_3_0
- target->set_hexpand();
- target->set_vexpand();
- _insides->attach( *target, col2, row2, 1, 1);
-#else
- _insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
- }
-#if WITH_GTKMM_3_0
- thing->set_hexpand();
- thing->set_vexpand();
- _insides->attach(*thing, col, row, 1, 1);
-#else
- } else if ( col == 0 ) {
- // we just started a new row
- _insides->resize( row + 1, width );
- }
-
- _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
+ auto kids = _insides->get_children();
+ int childCount = (int)kids.size();
+ // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
+
+ // Loop through the existing widgets and move them to new location
+ for ( int j = 1; j < childCount; j++ ) {
+ auto target = kids[childCount - (j + 1)];
+ int col2 = j % width;
+ int row2 = j / width;
+ Glib::RefPtr<Gtk::Widget> handle(target);
+ _insides->remove( *target );
+
+ target->set_hexpand();
+ target->set_vexpand();
+ _insides->attach( *target, col2, row2, 1, 1);
+ }
+ thing->set_hexpand();
+ thing->set_vexpand();
+ _insides->attach(*thing, col, row, 1, 1);
}
}
@@ -303,14 +256,10 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation )
// g_message(" anchor:%d", _anchor);
Gtk::VBox::on_size_allocate( allocation );
- if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
+/* if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
Gtk::Requisition req;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req_natural;
_insides->get_preferred_size(req, req_natural);
-#else
- req = _insides->size_request();
-#endif
gint delta = allocation.get_width() - req.width;
if ( (delta > 4) && req.height < allocation.get_height() ) {
@@ -318,7 +267,7 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation )
} else {
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER );
}
- }
+ }*/
}
//void PreviewHolder::on_size_request( Gtk::Requisition* requisition )
@@ -352,43 +301,27 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int&
if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) {
Gtk::Requisition req;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req_natural;
_scroller->get_preferred_size(req, req_natural);
-#else
- req = _scroller->size_request();
-#endif
int currW = _scroller->get_width();
if ( currW > req.width ) {
req.width = currW;
}
-#if GTK_CHECK_VERSION(3,0,0)
- Gtk::Scrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
-#else
- Gtk::HScrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
-#endif
+ auto hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar();
if ( hs ) {
Gtk::Requisition scrollReq;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition scrollReq_natural;
hs->get_preferred_size(scrollReq, scrollReq_natural);
-#else
- scrollReq = hs->size_request();
-#endif
// the +8 is a temporary hack
req.height -= scrollReq.height + 8;
}
Gtk::Requisition req2;
-#if GTK_CHECK_VERSION(3,0,0)
Gtk::Requisition req2_natural;
const_cast<Gtk::Widget*>(thing)->get_preferred_size(req2, req2_natural);
-#else
- req2 = const_cast<Gtk::Widget*>(thing)->size_request();
-#endif
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;
@@ -416,21 +349,11 @@ void PreviewHolder::rebuildUI()
switch(_view) {
case VIEW_TYPE_LIST:
{
-
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
_insides->set_column_spacing(8);
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
- _insides->set_col_spacings( 8 );
-#endif
if (_border == BORDER_WIDE) {
-#if WITH_GTKMM_3_0
_insides->set_row_spacing(1);
-#else
- _insides->set_row_spacings( 1 );
-#endif
}
for ( unsigned int i = 0; i < items.size(); i++ ) {
@@ -439,7 +362,6 @@ void PreviewHolder::rebuildUI()
Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border));
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach(*thing, 0, i, 1, 1);
@@ -447,10 +369,6 @@ void PreviewHolder::rebuildUI()
label->set_hexpand();
label->set_valign(Gtk::ALIGN_CENTER);
_insides->attach(*label, 1, i, 1, 1);
-#else
- _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
- _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK );
-#endif
}
_scroller->add( *_insides );
@@ -473,28 +391,16 @@ void PreviewHolder::rebuildUI()
if ( !_insides ) {
calcGridSize( thing, items.size(), width, height );
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
if (_border == BORDER_WIDE) {
_insides->set_column_spacing(1);
_insides->set_row_spacing(1);
}
-#else
- _insides = Gtk::manage(new Gtk::Table( height, width ));
- if (_border == BORDER_WIDE) {
- _insides->set_col_spacings( 1 );
- _insides->set_row_spacings( 1 );
- }
-#endif
}
-#if WITH_GTKMM_3_0
thing->set_hexpand();
thing->set_vexpand();
_insides->attach( *thing, col, row, 1, 1);
-#else
- _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
-#endif
if ( ++col >= width ) {
col = 0;
@@ -502,11 +408,7 @@ void PreviewHolder::rebuildUI()
}
}
if ( !_insides ) {
-#if WITH_GTKMM_3_0
_insides = Gtk::manage(new Gtk::Grid());
-#else
- _insides = Gtk::manage(new Gtk::Table( 1, 2 ));
-#endif
}
_scroller->add( *_insides );