diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/previewfillable.h | 2 | ||||
| -rw-r--r-- | src/ui/previewholder.cpp | 27 | ||||
| -rw-r--r-- | src/ui/previewholder.h | 3 | ||||
| -rw-r--r-- | src/ui/widget/panel.cpp | 127 | ||||
| -rw-r--r-- | src/ui/widget/panel.h | 7 |
5 files changed, 130 insertions, 36 deletions
diff --git a/src/ui/previewfillable.h b/src/ui/previewfillable.h index e73edbf63..95662732a 100644 --- a/src/ui/previewfillable.h +++ b/src/ui/previewfillable.h @@ -31,6 +31,8 @@ public: virtual void setOrientation( Gtk::AnchorType how ) = 0; virtual Inkscape::IconSize getPreviewSize() const = 0; virtual ViewType getPreviewType() const = 0; + virtual void setWrap( bool b ) = 0; + virtual bool getWrap() const = 0; }; diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index bcb4d0282..5d87eb4f5 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -36,7 +36,8 @@ PreviewHolder::PreviewHolder() : _updatesFrozen(false), _anchor(Gtk::ANCHOR_CENTER), _baseSize(Inkscape::ICON_SIZE_MENU), - _view(VIEW_TYPE_LIST) + _view(VIEW_TYPE_LIST), + _wrap(false) { _scroller = manage(new Gtk::ScrolledWindow()); _insides = manage(new Gtk::Table( 1, 2 )); @@ -142,7 +143,7 @@ void PreviewHolder::setOrientation( Gtk::AnchorType how ) 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_ALWAYS, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER ); } break; @@ -162,6 +163,28 @@ void PreviewHolder::setOrientation( Gtk::AnchorType how ) } } +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_ALWAYS, _wrap ? Gtk::POLICY_AUTOMATIC : Gtk::POLICY_NEVER ); + } + break; + default: + { + (void)0; + // do nothing; + } + } + rebuildUI(); + } +} + void PreviewHolder::setColumnPref( int cols ) { _prefCols = cols; diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index 42f5b119b..046cdf7c7 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -38,6 +38,8 @@ public: virtual void setColumnPref( int cols ); virtual Inkscape::IconSize getPreviewSize() const { return _baseSize; } virtual ViewType getPreviewType() const { return _view; } + virtual void setWrap( bool b ); + virtual bool getWrap() const { return _wrap; } protected: virtual void on_size_allocate( Gtk::Allocation& allocation ); @@ -56,6 +58,7 @@ private: Gtk::AnchorType _anchor; Inkscape::IconSize _baseSize; ViewType _view; + bool _wrap; }; } //namespace UI diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 2112ea7b2..4ecbda1b8 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -25,23 +25,17 @@ namespace Inkscape { namespace UI { namespace Widget { +static const int PANEL_SETTING_SIZE = 0; +static const int PANEL_SETTING_MODE = 1; +static const int PANEL_SETTING_WRAP = 2; +static const int PANEL_SETTING_NEXTFREE = 3; + /** * Construct a Panel * * \param label Label. */ -Panel::Panel( const gchar *prefs_path, bool menuDesired ) : - _prefs_path(NULL), - _menuDesired(menuDesired), - _tempArrow( Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT ), - menu(0), - _fillable(0) -{ - _prefs_path = prefs_path; - init(); -} - Panel::Panel() : _prefs_path(NULL), _menuDesired(false), @@ -52,14 +46,14 @@ Panel::Panel() : init(); } -Panel::Panel( Glib::ustring const &label, bool menuDesired ) : - _prefs_path(NULL), +Panel::Panel( Glib::ustring const &label, gchar const* prefs_path, bool menuDesired ) : + _prefs_path(prefs_path), _menuDesired(menuDesired), + label(label), _tempArrow( Gtk::ARROW_LEFT, Gtk::SHADOW_ETCHED_OUT ), menu(0), _fillable(0) { - this->label = label; init(); } @@ -84,12 +78,17 @@ void Panel::init() guint panel_size = 0; if (_prefs_path) { - panel_size = prefs_get_int_attribute_limited (_prefs_path, "panel_size", 1, 0, 10); + panel_size = prefs_get_int_attribute_limited( _prefs_path, "panel_size", 1, 0, 10 ); } guint panel_mode = 0; if (_prefs_path) { - panel_mode = prefs_get_int_attribute_limited (_prefs_path, "panel_mode", 1, 0, 10); + panel_mode = prefs_get_int_attribute_limited( _prefs_path, "panel_mode", 1, 0, 10 ); + } + + guint panel_wrap = 0; + if (_prefs_path) { + panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 ); } menu = new Gtk::Menu(); @@ -109,7 +108,7 @@ void Panel::init() if ( i == panel_size ) { single->set_active(true); } - single->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), 0, i) ); + single->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_SIZE, i) ); } } menu->append( *manage(new Gtk::SeparatorMenuItem()) ); @@ -126,12 +125,33 @@ void Panel::init() } menu->append( *one ); + nonHorizontal.push_back( one ); menu->append( *two ); - menu->append( *manage(new Gtk::SeparatorMenuItem()) ); - one->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), 1, 0) ); - two->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), 1, 1) ); + nonHorizontal.push_back( two ); + Gtk::MenuItem* sep = manage( new Gtk::SeparatorMenuItem()); + menu->append( *sep ); + nonHorizontal.push_back( sep ); + one->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_MODE, 0) ); + two->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), PANEL_SETTING_MODE, 1) ); + + { + Glib::ustring wrapLab(_("Wrap")); + Gtk::CheckMenuItem *check = manage(new Gtk::CheckMenuItem(wrapLab)); + check->set_active( panel_wrap ); + menu->append( *check ); + nonVertical.push_back(check); + + check->signal_toggled().connect( sigc::bind<Gtk::CheckMenuItem*>(sigc::mem_fun(*this, &Panel::_wrapToggled), check) ); + + sep = manage( new Gtk::SeparatorMenuItem()); + menu->append( *sep ); + nonVertical.push_back( sep ); + } menu->show_all_children(); + for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) { + (*iter)->hide(); + } //closeButton.set_label("X"); @@ -160,8 +180,9 @@ void Panel::init() show_all_children(); - bounceCall (0, panel_size); - bounceCall (1, panel_mode); + bounceCall( PANEL_SETTING_SIZE, panel_size ); + bounceCall( PANEL_SETTING_MODE, panel_mode ); + bounceCall( PANEL_SETTING_WRAP, panel_wrap ); } void Panel::setLabel(Glib::ustring const &label) @@ -185,14 +206,31 @@ void Panel::setOrientation( Gtk::AnchorType how ) topBar.remove(menuPopper); rightBar.pack_start(menuPopper, false, false); menuPopper.unreference(); - } + for ( std::vector<Gtk::Widget*>::iterator iter = nonHorizontal.begin(); iter != nonHorizontal.end(); ++iter ) { + (*iter)->hide(); + } + for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) { + (*iter)->show(); + } + } + // Ensure we are not in "list" mode + bounceCall( PANEL_SETTING_MODE, 1 ); topBar.remove(tabTitle); } break; default: - ; // nothing for now + { + if ( _menuDesired ) { + for ( std::vector<Gtk::Widget*>::iterator iter = nonHorizontal.begin(); iter != nonHorizontal.end(); ++iter ) { + (*iter)->show(); + } + for ( std::vector<Gtk::Widget*>::iterator iter = nonVertical.begin(); iter != nonVertical.end(); ++iter ) { + (*iter)->hide(); + } + } + } } } } @@ -200,7 +238,7 @@ void Panel::setOrientation( Gtk::AnchorType how ) void Panel::_regItem( Gtk::MenuItem* item, int group, int id ) { menu->append( *item ); - item->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), group + 2, id) ); + item->signal_activate().connect( sigc::bind<int, int>( sigc::mem_fun(*this, &Panel::bounceCall), group + PANEL_SETTING_NEXTFREE, id) ); item->show(); } @@ -214,16 +252,23 @@ void Panel::restorePanelPrefs() if (_prefs_path) { panel_mode = prefs_get_int_attribute_limited (_prefs_path, "panel_mode", 1, 0, 10); } - bounceCall (0, panel_size); - bounceCall (1, panel_mode); + guint panel_wrap = 0; + if (_prefs_path) { + panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 ); + } + bounceCall( PANEL_SETTING_SIZE, panel_size ); + bounceCall( PANEL_SETTING_MODE, panel_mode ); + bounceCall( PANEL_SETTING_WRAP, panel_wrap ); } void Panel::bounceCall(int i, int j) { menu->set_active(0); switch ( i ) { - case 0: - if (_prefs_path) prefs_set_int_attribute (_prefs_path, "panel_size", j); + case PANEL_SETTING_SIZE: + if (_prefs_path) { + prefs_set_int_attribute( _prefs_path, "panel_size", j ); + } if ( _fillable ) { ViewType currType = _fillable->getPreviewType(); switch ( j ) { @@ -257,8 +302,10 @@ void Panel::bounceCall(int i, int j) } } break; - case 1: - if (_prefs_path) prefs_set_int_attribute (_prefs_path, "panel_mode", j); + case PANEL_SETTING_MODE: + if (_prefs_path) { + prefs_set_int_attribute (_prefs_path, "panel_mode", j); + } if ( _fillable ) { Inkscape::IconSize currSize = _fillable->getPreviewSize(); switch ( j ) { @@ -277,8 +324,24 @@ void Panel::bounceCall(int i, int j) } } break; + case PANEL_SETTING_WRAP: + if (_prefs_path) { + prefs_set_int_attribute (_prefs_path, "panel_wrap", j ? 1 : 0); + } + if ( _fillable ) { + _fillable->setWrap( j ); + } + break; default: - _handleAction( i - 2, j ); + _handleAction( i - PANEL_SETTING_NEXTFREE, j ); + } +} + + +void Panel::_wrapToggled(Gtk::CheckMenuItem* toggler) +{ + if ( toggler ) { + bounceCall( PANEL_SETTING_WRAP, toggler->get_active() ? 1 : 0 ); } } diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index cf201d6da..e091c82a1 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -14,6 +14,7 @@ #ifndef SEEN_INKSCAPE_UI_WIDGET_PANEL_H #define SEEN_INKSCAPE_UI_WIDGET_PANEL_H +#include <vector> #include <gtkmm/arrow.h> #include <gtkmm/box.h> #include <gtkmm/eventbox.h> @@ -34,8 +35,7 @@ class Panel : public Gtk::VBox public: Panel(); virtual ~Panel(); - Panel(Glib::ustring const &label, bool menuDesired = false ); - Panel(const gchar *prefs_path, bool menuDesired = false ); + Panel(Glib::ustring const &label, gchar const *prefs_path = 0, bool menuDesired = false ); void setLabel(Glib::ustring const &label); Glib::ustring const &getLabel() const; @@ -60,6 +60,7 @@ private: void bounceCall(int i, int j); void _popper(GdkEventButton* btn); + void _wrapToggled(Gtk::CheckMenuItem* toggler); Glib::ustring label; @@ -71,6 +72,8 @@ private: Gtk::EventBox menuPopper; Gtk::Button closeButton; Gtk::Menu* menu; + std::vector<Gtk::Widget*> nonHorizontal; + std::vector<Gtk::Widget*> nonVertical; PreviewFillable *_fillable; }; |
