summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a81c11f)
raw | patch | inline | side by side (parent: a81c11f)
author | mental <mental@users.sourceforge.net> | |
Fri, 21 Jul 2006 05:42:47 +0000 (05:42 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Fri, 21 Jul 2006 05:42:47 +0000 (05:42 +0000) |
ChangeLog | patch | blob | history | |
src/document.cpp | patch | blob | history | |
src/sp-object.cpp | patch | blob | history | |
src/sp-object.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 7304f0b1137ddf1ca9be0c3ae3eee4f70a24d065..afffdfe099af76453b1438ee580a57d81ad41107 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-07-21 MenTaLguY <mental@rydia.net>
+
+ * src/document.cpp, src/sp-object.cpp, src/sp-object.h:
+
+ sp_object_invoke_release -> SPObject::releaseReferences,
+ plus the introduction of sigc++ signals for "release" and
+ "modified" which will eventually replace the GObject signals
+
2006-07-20 MenTaLguY <mental@rydia.net>
* src/libnrtype/RasterFont.h, src/libnrtype/font-instance.h:
diff --git a/src/document.cpp b/src/document.cpp
index 44e13b4f20df8e1ffbe8bc5ffe9da8a54ba4dd1e..3077198cf149a0b327efb470d0998ab1f17c2c7f 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
sp_document_clear_undo(this);
if (root) {
- sp_object_invoke_release(root);
+ root->releaseReferences();
sp_object_unref(root);
root = NULL;
}
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 8a96258e8477388ce3cff8c0e18de0c930b6f144..43611e9edeaed74adfeafd632bd12f24cb665a24 100644 (file)
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
object->_collection_policy = SPObject::COLLECT_WITH_PARENT;
+ new (&object->_release_signal) sigc::signal<void, SPObject *>();
+ new (&object->_modified_signal) sigc::signal<void, SPObject *, unsigned int>();
new (&object->_delete_signal) sigc::signal<void, SPObject *>();
new (&object->_position_changed_signal) sigc::signal<void, SPObject *>();
object->_successor = NULL;
(* ((GObjectClass *) (parent_class))->finalize)(object);
}
+ spobject->_release_signal.~signal();
+ spobject->_modified_signal.~signal();
spobject->_delete_signal.~signal();
spobject->_position_changed_signal.~signal();
}
g_return_if_fail(SP_IS_OBJECT(object));
g_return_if_fail(object->parent == parent);
- sp_object_invoke_release(object);
+ object->releaseReferences();
SPObject *prev=NULL;
for ( SPObject *child = parent->children ; child && child != object ;
@@ -859,45 +863,41 @@ sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::No
sp_repr_add_listener(repr, &object_event_vector, object);
}
-void
-sp_object_invoke_release(SPObject *object)
-{
- g_assert(object != NULL);
- g_assert(SP_IS_OBJECT(object));
-
- g_assert(object->document);
- g_assert(object->repr);
+void SPObject::releaseReferences() {
+ g_assert(this->document);
+ g_assert(this->repr);
- sp_repr_remove_listener_by_data(object->repr, object);
+ sp_repr_remove_listener_by_data(this->repr, this);
- g_signal_emit(G_OBJECT(object), object_signals[RELEASE], 0);
+ g_signal_emit(G_OBJECT(this), object_signals[RELEASE], 0);
+ this->_release_signal.emit(this);
/* all hrefs should be released by the "release" handlers */
- g_assert(object->hrefcount == 0);
+ g_assert(this->hrefcount == 0);
- if (!SP_OBJECT_IS_CLONED(object)) {
- if (object->id) {
- object->document->bindObjectToId(object->id, NULL);
+ if (!SP_OBJECT_IS_CLONED(this)) {
+ if (this->id) {
+ this->document->bindObjectToId(this->id, NULL);
}
- g_free(object->id);
- object->id = NULL;
+ g_free(this->id);
+ this->id = NULL;
- g_free(object->_default_label);
- object->_default_label = NULL;
+ g_free(this->_default_label);
+ this->_default_label = NULL;
- object->document->bindObjectToRepr(object->repr, NULL);
+ this->document->bindObjectToRepr(this->repr, NULL);
} else {
- g_assert(!object->id);
+ g_assert(!this->id);
}
- if (object->style) {
- object->style = sp_style_unref(object->style);
+ if (this->style) {
+ this->style = sp_style_unref(this->style);
}
- Inkscape::GC::release(object->repr);
+ Inkscape::GC::release(this->repr);
- object->document = NULL;
- object->repr = NULL;
+ this->document = NULL;
+ this->repr = NULL;
}
/**
g_object_ref(G_OBJECT(this));
g_signal_emit(G_OBJECT(this), object_signals[MODIFIED], 0, flags);
+ _modified_signal.emit(this, flags);
g_object_unref(G_OBJECT(this));
}
diff --git a/src/sp-object.h b/src/sp-object.h
index 054fb6c7af14b6e35a6b932f0a6a2f5176908d0d..b563d8d3b8abd708a263cde9f92fae961533e9b9 100644 (file)
--- a/src/sp-object.h
+++ b/src/sp-object.h
Inkscape::XML::Node *repr; /* Our xml representation */
gchar *id; /* Our very own unique id */
+ /** @brief cleans up an SPObject, releasing its references and
+ * requesting that references to it be released
+ */
+ void releaseReferences();
+
+ /** @brief connects to the release request signal
+ *
+ * @param slot the slot to connect
+ *
+ * @returns the sigc::connection formed
+ */
+ sigc::connection connectRelease(sigc::slot<void, SPObject *> slot) {
+ return _release_signal.connect(slot);
+ }
+
/**
* Represents the style properties, whether from presentation attributes, the <tt>style</tt>
* attribute, or inherited.
*/
void emitModified(unsigned int flags);
+ /** @brief Connects to the modification notification signal
+ *
+ * @param slot the slot to connect
+ *
+ * @returns the connection formed thereby
+ */
+ sigc::connection connectModified(
+ sigc::slot<void, SPObject *, unsigned int> slot
+ ) {
+ return _modified_signal.connect(slot);
+ }
+
void _sendDeleteSignalRecursive();
void _updateTotalHRefCount(int increment);
}
void _requireSVGVersion(Inkscape::Version version);
+ sigc::signal<void, SPObject *> _release_signal;
sigc::signal<void, SPObject *> _delete_signal;
sigc::signal<void, SPObject *> _position_changed_signal;
+ sigc::signal<void, SPObject *, unsigned int> _modified_signal;
SPObject *_successor;
CollectionPolicy _collection_policy;
gchar *_label;
SPObject *sp_object_get_child_by_repr(SPObject *object, Inkscape::XML::Node *repr);
void sp_object_invoke_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned);
-void sp_object_invoke_release(SPObject *object);
void sp_object_set(SPObject *object, unsigned int key, gchar const *value);