X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdialogs%2Flayers-panel.cpp;h=383d11f57b0e54a0559bd418c21ce9e09bf2fa6b;hb=569ef8f6dbacc8a8b0b933d02a806c2e091ce02b;hp=3a7463ff30dfb1d891a6eb4e404c46c51a08ecf1;hpb=4ec52515516e3a6bf2fbc3ed01a7e179bde16d20;p=inkscape.git diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp index 3a7463ff3..383d11f57 100644 --- a/src/dialogs/layers-panel.cpp +++ b/src/dialogs/layers-panel.cpp @@ -33,7 +33,6 @@ #include "sp-item.h" #include "widgets/icon.h" #include -#include #include "prefs-utils.h" #include "xml/repr.h" #include "svg/css-ostringstream.h" @@ -47,13 +46,14 @@ namespace Dialogs { LayersPanel* LayersPanel::instance = 0; -LayersPanel& LayersPanel::getInstance() +LayersPanel* +LayersPanel::create(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) { if ( !instance ) { - instance = new LayersPanel(); + instance = new LayersPanel(behavior_factory); } - return *instance; + return instance; } enum { @@ -539,7 +539,9 @@ void LayersPanel::_checkTreeSelection() if ( inTree->repr ) { SPCSSAttr *css = sp_repr_css_attr(inTree->repr, "style"); if ( css ) { - _opacity.set_value( sp_repr_css_double_property( css, "opacity", 1.0 ) ); + _opacityConnection.block(); + _opacity.set_value( sp_repr_css_double_property( css, "opacity", 1.0 ) * 100 ); + _opacityConnection.unblock(); } } } @@ -588,7 +590,7 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) item->setHidden( !newValue ); item->updateRepr(); sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - /* TODO: annotate */ "layers-panel.cpp:591"); + newValue? _("Unhide layer") : _("Hide layer")); } break; @@ -599,7 +601,7 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) item->setLocked( newValue ); item->updateRepr(); sp_document_done( _desktop->doc() , SP_VERB_DIALOG_LAYERS, - /* TODO: annotate */ "layers-panel.cpp:602"); + newValue? _("Lock layer") : _("Unlock layer")); } break; } @@ -682,12 +684,11 @@ void LayersPanel::_opacityChanged() if ( _desktop && layer && !_opacityConnection.blocked() ) { _opacityConnection.block(); - Gtk::Adjustment* adj = _opacity.get_adjustment(); SPCSSAttr *css = sp_repr_css_attr_new(); Inkscape::CSSOStringStream os; - os << CLAMP( adj->get_value(), 0.0, 1.0 ); + os << CLAMP( adj->get_value() / 100, 0.0, 1.0 ); sp_repr_css_set_property( css, "opacity", os.str().c_str() ); sp_desktop_apply_css_recursive( layer, css, true ); @@ -695,8 +696,8 @@ void LayersPanel::_opacityChanged() sp_repr_css_attr_unref( css ); - sp_document_maybe_done( _desktop->doc(), "layers:opacity", SP_VERB_NONE, - /* TODO: annotate */ "layers-panel.cpp:699" ); + sp_document_maybe_done( _desktop->doc(), "layers:opacity", SP_VERB_DIALOG_LAYERS, + _("Change layer opacity")); _opacityConnection.unblock(); } @@ -707,8 +708,8 @@ void LayersPanel::_opacityChanged() /** * Constructor */ -LayersPanel::LayersPanel() : - Inkscape::UI::Widget::Panel( Glib::ustring(), "dialogs.layers" ), +LayersPanel::LayersPanel(Inkscape::UI::Dialog::Behavior::BehaviorFactory behavior_factory) : + Inkscape::UI::Dialog::Dialog(behavior_factory, "dialogs.layers", SP_VERB_DIALOG_LAYERS), _maxNestDepth(20), _mgr(0), _desktop(0), @@ -761,23 +762,24 @@ LayersPanel::LayersPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); - _opacityBox.pack_start( *manage( new Gtk::Label(_("Opacity:"))), Gtk::PACK_SHRINK ); + _opacityBox.pack_start( *manage( new Gtk::Label(_("Opacity, %:"))), Gtk::PACK_SHRINK ); _opacity.set_draw_value(false); - _opacity.set_value(1.0); - _opacity.set_range(0.0, 1.0); - _opacity.set_increments(0.01, 0.1); + _opacity.set_value(100.0); + _opacity.set_range(0.0, 100.0); + _opacity.set_increments(1, 10); _opacityBox.pack_start( _opacity, Gtk::PACK_EXPAND_WIDGET ); - Gtk::SpinButton* spinBtn = manage( new Gtk::SpinButton(*_opacity.get_adjustment(), 0.0, 3) ); + _spinBtn.configure(*_opacity.get_adjustment(), 0, 1); - _opacityBox.pack_end( *spinBtn, Gtk::PACK_SHRINK ); + _spinBtn.set_width_chars(5); + _opacityBox.pack_end( _spinBtn, Gtk::PACK_SHRINK ); _watching.push_back( &_opacityBox ); - _getContents()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET ); + get_vbox()->pack_start( _scroller, Gtk::PACK_EXPAND_WIDGET ); - _getContents()->pack_end(_opacityBox, Gtk::PACK_SHRINK); - _getContents()->pack_end(_buttonsRow, Gtk::PACK_SHRINK); + get_vbox()->pack_end(_opacityBox, Gtk::PACK_SHRINK); + get_vbox()->pack_end(_buttonsRow, Gtk::PACK_SHRINK); _opacityConnection = _opacity.get_adjustment()->signal_value_changed().connect( sigc::mem_fun(*this, &LayersPanel::_opacityChanged) ); @@ -854,15 +856,11 @@ LayersPanel::LayersPanel() : } g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this ); - - setDesktop( targetDesktop ); - - show_all_children(); - restorePanelPrefs(); + // restorePanelPrefs(); } LayersPanel::~LayersPanel() @@ -895,7 +893,7 @@ void LayersPanel::setDesktop( SPDesktop* desktop ) _desktop = SP_ACTIVE_DESKTOP; if ( _desktop ) { - setLabel( _desktop->doc()->name ); + //setLabel( _desktop->doc()->name ); _mgr = _desktop->layer_manager; if ( _mgr ) {