summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33ac04c)
raw | patch | inline | side by side (parent: 33ac04c)
author | mental <mental@users.sourceforge.net> | |
Fri, 21 Jul 2006 19:05:07 +0000 (19:05 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Fri, 21 Jul 2006 19:05:07 +0000 (19:05 +0000) |
ChangeLog | patch | blob | history | |
src/selection.cpp | patch | blob | history | |
src/selection.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 878b79a90c7569babd32333d3231bfc794bab9a9..7d4312a70b2f3781450f94f15c6cbeb39ac58e59 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-07-21 MenTaLguY <mental@rydia.net>
+
+ * src/selection.cpp, src/selection.h:
+
+ switch to sigc++ signals for "modified" and "release"
+
2006-07-21 MenTaLguY <mental@rydia.net>
* src/ui/view/edit-widget.cpp, src/ui/view/edit-widget.cpp:
diff --git a/src/selection.cpp b/src/selection.cpp
index ae11a1432717c7a69453ed42cf188a1fa755aeb5..a27e45cb290280da0e57ed6b6fa577c38f156601 100644 (file)
--- a/src/selection.cpp
+++ b/src/selection.cpp
#include "sp-shape.h"
+#include <sigc++/functors/mem_fun.h>
#define SP_SELECTION_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE + 1)
_items(NULL),
_desktop(desktop),
_selection_context(NULL),
- _context_release_handler_id(0),
_flags(0),
_idle(0)
{
}
}
-void
-Selection::_release(SPObject *obj, Selection *selection)
-{
- selection->remove(obj);
-}
-
/* Handler for selected objects "modified" signal */
-void
-Selection::_schedule_modified(SPObject *obj, guint flags, Selection *selection)
-{
- if (!selection->_idle) {
+void Selection::_schedule_modified(SPObject *obj, guint flags) {
+ if (!this->_idle) {
/* Request handling to be run in _idle loop */
- selection->_idle = g_idle_add_full(SP_SELECTION_UPDATE_PRIORITY, GSourceFunc(&Selection::_emit_modified), selection, NULL);
+ this->_idle = g_idle_add_full(SP_SELECTION_UPDATE_PRIORITY, GSourceFunc(&Selection::_emit_modified), this, NULL);
}
/* Collect all flags */
- selection->_flags |= flags;
+ this->_flags |= flags;
}
gboolean
if (NULL == _selection_context) {
_selection_context = desktop()->currentLayer();
sp_object_ref(_selection_context, NULL);
- _context_release_handler_id = g_signal_connect(
- G_OBJECT(_selection_context), "release",
- G_CALLBACK(&Selection::_releaseSelectionContext),
- this);
+ _context_release_connection = _selection_context->connectRelease(sigc::mem_fun(*this, &Selection::_releaseContext));
}
} else {
_releaseContext(_selection_context);
_changed_signal.emit(this);
}
-void
-Selection::_releaseSelectionContext(SPObject *obj, Selection *selection)
-{
- selection->_releaseContext(obj);
-}
-
void
Selection::_releaseContext(SPObject *obj)
{
if (NULL == _selection_context || _selection_context != obj)
return;
- g_signal_handler_disconnect(G_OBJECT(_selection_context), _context_release_handler_id);
+ _context_release_connection.disconnect();
+
sp_object_unref(_selection_context, NULL);
- _context_release_handler_id = 0;
_selection_context = NULL;
}
_invalidateCachedLists();
while (_objs) {
SPObject *obj=reinterpret_cast<SPObject *>(_objs->data);
- sp_signal_disconnect_by_data(obj, this);
- _objs = g_slist_remove(_objs, obj);
+ _remove(obj);
}
}
_removeObjectAncestors(obj);
_objs = g_slist_prepend(_objs, obj);
- g_signal_connect(G_OBJECT(obj), "release",
- G_CALLBACK(&Selection::_release), this);
- g_signal_connect(G_OBJECT(obj), "modified",
- G_CALLBACK(&Selection::_schedule_modified), this);
-
- /*
- if (!SP_IS_SHAPE(obj)) {
- printf("This is not a shape\n");
- }
- */
+
+ _release_connections[obj] = obj->connectRelease(sigc::mem_fun(*this, (void (Selection::*)(SPObject *))&Selection::remove));
+ _modified_connections[obj] = obj->connectModified(sigc::mem_fun(*this, &Selection::_schedule_modified));
}
void Selection::set(SPObject *object, bool persist_selection_context) {
}
void Selection::_remove(SPObject *obj) {
- sp_signal_disconnect_by_data(obj, this);
+ _modified_connections[obj].disconnect();
+ _modified_connections.erase(obj);
+
+ _release_connections[obj].disconnect();
+ _release_connections.erase(obj);
+
_objs = g_slist_remove(_objs, obj);
}
diff --git a/src/selection.h b/src/selection.h
index d633d5c3bb9e3e522125a8169b00f012f71a7752..1dcaa53ff3d836082dc63d253d128dcd6171b524 100644 (file)
--- a/src/selection.h
+++ b/src/selection.h
*/
#include <vector>
+#include <map>
#include <sigc++/sigc++.h>
#include "libnr/nr-rect.h"
/** @brief Issues modification notification signals */
static gboolean _emit_modified(Selection *selection);
/** @brief Schedules an item modification signal to be sent */
- static void _schedule_modified(SPObject *obj, guint flags, Selection *selection);
- /** @brief Releases a selected object that is being removed */
- static void _release(SPObject *obj, Selection *selection);
- /** @brief Releases an active layer object that is being removed */
- static void _releaseSelectionContext(SPObject *obj, Selection *selection);
+ void _schedule_modified(SPObject *obj, guint flags);
/** @brief Issues modified selection signal */
void _emitModified(guint flags);
GC::soft_ptr<SPDesktop> _desktop;
SPObject* _selection_context;
- gulong _context_release_handler_id;
guint _flags;
guint _idle;
+ std::map<SPObject *, sigc::connection> _modified_connections;
+ std::map<SPObject *, sigc::connection> _release_connections;
+ sigc::connection _context_release_connection;
+
sigc::signal<void, Selection *> _changed_signal;
sigc::signal<void, Selection *, guint> _modified_signal;
};