summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b829244)
raw | patch | inline | side by side (parent: b829244)
author | Jon A. Cruz <jon@joncruz.org> | |
Tue, 27 Apr 2010 07:48:04 +0000 (00:48 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Tue, 27 Apr 2010 07:48:04 +0000 (00:48 -0700) |
index eb7265b2d269171bdb3f4c4b027f3c44033ac088..1988865d10c98b88221d875eb5292d5b1c6ba92b 100644 (file)
--- a/src/document-subset.cpp
+++ b/src/document-subset.cpp
/* remove obj's record */
_doRemove(obj);
}
-
+
changed_signal.emit();
}
diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index 8c45c7e53642fdebabb75b930ce24efb09909ab2..db7384622ee6dc6d007b73e69588402baabfe551 100644 (file)
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
_layer_connection.disconnect();
_document_connection.disconnect();
_resource_connection.disconnect();
+ _document = 0;
}
void LayerManager::setCurrentLayer( SPObject* obj )
LayerWatcher *eye = new LayerWatcher(this, layer, connection);
_watchers.push_back( eye );
SP_OBJECT_REPR(layer)->addObserver(*eye);
-
+
_addOne(layer);
}
}
diff --git a/src/layer-manager.h b/src/layer-manager.h
index 81f75e002aef5144ef16cbc8937a5a3d27b7ccb2..5b5d25eb2aaf5deb342bae5baa017fe2f94b0bae 100644 (file)
--- a/src/layer-manager.h
+++ b/src/layer-manager.h
void renameLayer( SPObject* obj, gchar const *label, bool uniquify );
sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) {
- return _layer_changed_signal.connect(slot);
+ return _layer_changed_signal.connect(slot);
}
sigc::connection connectLayerDetailsChanged(const sigc::slot<void, SPObject *> & slot) {
- return _details_changed_signal.connect(slot);
+ return _details_changed_signal.connect(slot);
}
private:
index 98bf236fc0c3bf1c106b447e6e32a431f9de218f..ff3a13ab2dd74d62e9ddb7806a4da8effffb495b 100644 (file)
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
* Authors:
* Jon A. Cruz
*
- * Copyright (C) 2006 Jon A. Cruz
+ * Copyright (C) 2006,2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
namespace Inkscape {
namespace UI {
-namespace Dialogs {
+namespace Dialog {
-LayersPanel&
-LayersPanel::getInstance()
+LayersPanel& LayersPanel::getInstance()
{
return *new LayersPanel();
}
SPObject* _target;
};
-static gboolean layers_panel_activated(Inkscape::Application * /*inkscape*/, SPDesktop *desktop, gpointer data )
-{
- if ( data )
- {
- LayersPanel* panel = reinterpret_cast<LayersPanel*>(data);
- panel->setDesktop(desktop);
- }
-
- return FALSE;
-}
-
-static gboolean layers_panel_deactivated( GtkObject */*object*/, GdkEvent * /*event*/, gpointer data )
-{
- if ( data )
- {
- LayersPanel* panel = reinterpret_cast<LayersPanel*>(data);
- panel->setDesktop(NULL);
- }
-
- return FALSE;
-}
-
void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback )
{
bool set = false;
@@ -348,12 +325,12 @@ bool LayersPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIt
void LayersPanel::_layersChanged()
{
// g_message("_layersChanged()");
- if(_desktop) {
+ if (_desktop) {
SPDocument* document = _desktop->doc();
SPObject* root = document->root;
if ( root ) {
_selectedConnection.block();
- if ( _mgr && _mgr->includes( root ) ) {
+ if ( _desktop->layer_manager && _desktop->layer_manager->includes( root ) ) {
SPObject* target = _desktop->currentLayer();
_store->clear();
void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level )
{
- if ( layer && (level < _maxNestDepth) ) {
- unsigned int counter = _mgr->childCount(layer);
+ if ( _desktop && _desktop->layer_manager && layer && (level < _maxNestDepth) ) {
+ unsigned int counter = _desktop->layer_manager->childCount(layer);
for ( unsigned int i = 0; i < counter; i++ ) {
- SPObject *child = _mgr->nthChildOf(layer, i);
+ SPObject *child = _desktop->layer_manager->nthChildOf(layer, i);
if ( child ) {
#if DUMP_LAYERS
g_message(" %3d layer:%p {%s} [%s]", level, child, child->id, child->label() );
void LayersPanel::_pushTreeSelectionToCurrent()
{
// TODO hunt down the possible API abuse in getting NULL
- if ( _desktop && _desktop->currentRoot() ) {
+ if ( _desktop && _desktop->layer_manager && _desktop->currentRoot() ) {
SPObject* inTree = _selectedLayer();
if ( inTree ) {
SPObject* curr = _desktop->currentLayer();
if ( curr != inTree ) {
- _mgr->setCurrentLayer( inTree );
+ _desktop->layer_manager->setCurrentLayer( inTree );
}
} else {
- _mgr->setCurrentLayer( _desktop->doc()->root );
+ _desktop->layer_manager->setCurrentLayer( _desktop->doc()->root );
}
}
}
void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& /*path*/, Gtk::TreeModel::iterator const& iter )
{
Gtk::TreeModel::Row row = *iter;
- if ( row ) {
+ if ( row && _desktop && _desktop->layer_manager) {
SPObject* obj = row[_model->_colObject];
if ( obj ) {
gchar const* oldLabel = obj->label();
Glib::ustring tmp = row[_model->_colLabel];
if ( oldLabel && oldLabel[0] && !tmp.empty() && (tmp != oldLabel) ) {
- _mgr->renameLayer( obj, tmp.c_str(), FALSE );
+ _desktop->layer_manager->renameLayer( obj, tmp.c_str(), FALSE );
row[_model->_colLabel] = obj->label();
}
}
@@ -583,13 +560,14 @@ bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & /*mod
*/
LayersPanel::LayersPanel() :
UI::Widget::Panel("", "/dialogs/layers", SP_VERB_DIALOG_LAYERS),
+ deskTrack(),
_maxNestDepth(20),
- _mgr(0),
_desktop(0),
_model(0),
_pending(0),
_toggleEvent(0),
- _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND)
+ _compositeSettings(SP_VERB_DIALOG_LAYERS, "layers", UI::Widget::SimpleFilterModifier::BLEND),
+ desktopChangeConn()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_maxNestDepth = prefs->getIntLimited("/dialogs/layers/maxDepth", 20, 1, 1000);
(*it)->set_sensitive( false );
}
- g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK( layers_panel_activated ), this );
- g_signal_connect( G_OBJECT(INKSCAPE), "deactivate_desktop", G_CALLBACK( layers_panel_deactivated ), this );
-
setDesktop( targetDesktop );
show_all_children();
// restorePanelPrefs();
+
+ // Connect this up last
+ desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &LayersPanel::setDesktop) );
+ deskTrack.connect(GTK_WIDGET(gobj()));
}
LayersPanel::~LayersPanel()
if ( _model )
{
delete _model;
+ _model = 0;
+ }
+
+ if (_pending) {
+ delete _pending;
+ _pending = 0;
}
if ( _toggleEvent )
gdk_event_free( _toggleEvent );
_toggleEvent = 0;
}
+
+ desktopChangeConn.disconnect();
+ deskTrack.disconnect();
}
_layerChangedConnection.disconnect();
_layerUpdatedConnection.disconnect();
_changedConnection.disconnect();
- if ( _mgr ) {
- _mgr = 0;
- }
if ( _desktop ) {
_desktop = 0;
}
if ( _desktop ) {
//setLabel( _desktop->doc()->name );
- _mgr = _desktop->layer_manager;
- if ( _mgr ) {
- _layerChangedConnection = _mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
- _layerUpdatedConnection = _mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );
- _changedConnection = _mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) );
+ LayerManager *mgr = _desktop->layer_manager;
+ if ( mgr ) {
+ _layerChangedConnection = mgr->connectCurrentLayerChanged( sigc::mem_fun(*this, &LayersPanel::_selectLayer) );
+ _layerUpdatedConnection = mgr->connectLayerDetailsChanged( sigc::mem_fun(*this, &LayersPanel::_updateLayer) );
+ _changedConnection = mgr->connectChanged( sigc::mem_fun(*this, &LayersPanel::_layersChanged) );
}
_layersChanged();
g_message(" {%s} [%s]", layer->id, layer->label() );
}
*/
+ deskTrack.setBase(desktop);
}
diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h
index 16b3be3508802fc239e6d8e7e00b25ba02217b53..4f2a654350901a671a6bd185a85693800c18beb2 100644 (file)
--- a/src/ui/dialog/layers.h
+++ b/src/ui/dialog/layers.h
* Authors:
* Jon A. Cruz
*
- * Copyright (C) 2006 Jon A. Cruz
+ * Copyright (C) 2006,2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
//#include "ui/previewholder.h"
#include "ui/widget/panel.h"
#include "ui/widget/object-composite-settings.h"
+#include "desktop-tracker.h"
class SPObject;
class LayerManager;
namespace UI {
-namespace Dialogs {
+namespace Dialog {
/**
virtual ~LayersPanel();
//virtual void setOrientation( Gtk::AnchorType how );
-
+
static LayersPanel& getInstance();
void setDesktop( SPDesktop* desktop );
// Internal
sigc::connection _selectedConnection;
+ DesktopTracker deskTrack;
int _maxNestDepth;
- Inkscape::LayerManager* _mgr;
SPDesktop* _desktop;
ModelColumns* _model;
InternalUIBounce* _pending;
UI::Widget::StyleSubject::CurrentLayer _subject;
UI::Widget::ObjectCompositeSettings _compositeSettings;
+ sigc::connection desktopChangeConn;
};