Code

Refactoring SPColor to C++ and removing legacy CMYK implementation
[inkscape.git] / src / dialogs / layers-panel.cpp
index 4bd8aebb503f840eaea128685e625fdcfe51dcf7..383d11f57b0e54a0559bd418c21ce9e09bf2fa6b 100644 (file)
@@ -46,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 {
@@ -538,7 +539,9 @@ void LayersPanel::_checkTreeSelection()
             if ( inTree->repr ) {
                 SPCSSAttr *css = sp_repr_css_attr(inTree->repr, "style");
                 if ( css ) {
+                    _opacityConnection.block();
                     _opacity.set_value( sp_repr_css_double_property( css, "opacity", 1.0 ) * 100 );
+                    _opacityConnection.unblock();
                 }
             }
         }
@@ -681,7 +684,6 @@ void LayersPanel::_opacityChanged()
     if ( _desktop && layer && !_opacityConnection.blocked() ) {
         _opacityConnection.block();
 
-
         Gtk::Adjustment* adj = _opacity.get_adjustment();
         SPCSSAttr *css = sp_repr_css_attr_new();
 
@@ -706,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),
@@ -774,10 +776,10 @@ LayersPanel::LayersPanel() :
     _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 ) {