summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c0ad9a2)
raw | patch | inline | side by side (parent: c0ad9a2)
author | mental <mental@users.sourceforge.net> | |
Sat, 22 Jul 2006 03:45:16 +0000 (03:45 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Sat, 22 Jul 2006 03:45:16 +0000 (03:45 +0000) |
ChangeLog | patch | blob | history | |
src/style.cpp | patch | blob | history | |
src/style.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 3839320b8b82d8ed0886afd29cdbf3d69b214a44..962901afe3876309f32be7525bd23abeb0e0c6fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-07-21 MenTaLguY <mental@rydia.net>
+
+ * src/style.cpp, src/style.h:
+
+ switch to using sigc++ signals
+
2006-07-21 MenTaLguY <mental@rydia.net>
* src/layer-manager.cpp, src/layer-manager.h:
diff --git a/src/style.cpp b/src/style.cpp
index 567825164b44d1d9933ff52482a8ee9a164c8ae1..e0d6532d451a760b72f6b91e0f389e076e59ad28 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
#include "unit-constants.h"
#include "isnan.h"
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/adaptors/bind.h>
+
using Inkscape::CSSOStringStream;
using std::vector;
style->fill_hreffed = false;
style->stroke_hreffed = false;
- style->fill_listening = false;
- style->stroke_listening = false;
+ new (&style->fill_release_connection) sigc::connection();
+ new (&style->fill_modified_connection) sigc::connection();
+
+ new (&style->stroke_release_connection) sigc::connection();
+ new (&style->stroke_modified_connection) sigc::connection();
return style;
}
if (style->text) sp_text_style_unref(style->text);
sp_style_paint_clear(style, &style->fill);
sp_style_paint_clear(style, &style->stroke);
+ style->fill_release_connection.disconnect();
+ style->fill_release_connection.~connection();
+ style->fill_modified_connection.disconnect();
+ style->fill_modified_connection.~connection();
+ style->stroke_release_connection.disconnect();
+ style->stroke_release_connection.~connection();
+ style->stroke_modified_connection.disconnect();
+ style->stroke_modified_connection.~connection();
g_free(style->stroke_dash.dash);
g_free(style);
}
@@ -1953,8 +1967,9 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare
* Disconnects from possible fill and stroke paint servers.
*/
static void
-sp_style_paint_server_release(SPPaintServer *server, SPStyle *style)
+sp_style_paint_server_release(SPObject *obj, SPStyle *style)
{
+ SPPaintServer *server=static_cast<SPPaintServer *>(obj);
if ((style->fill.type == SP_PAINT_TYPE_PAINTSERVER)
&& (server == style->fill.value.paint.server))
{
* or stroke paint server.
*/
static void
-sp_style_paint_server_modified(SPPaintServer *server, guint flags, SPStyle *style)
+sp_style_paint_server_modified(SPObject *obj, guint flags, SPStyle *style)
{
+ SPPaintServer *server = static_cast<SPPaintServer *>(obj);
if ((style->fill.type == SP_PAINT_TYPE_PAINTSERVER)
&& (server == style->fill.value.paint.server))
{
@@ -2040,15 +2056,18 @@ sp_style_merge_ipaint(SPStyle *style, SPIPaint *paint, SPIPaint const *parent)
}
}
if (style->object || style->cloned) { // connect to signals for style of real objects or clones (this excludes temp styles)
- g_signal_connect(G_OBJECT(paint->value.paint.server), "release",
- G_CALLBACK(sp_style_paint_server_release), style);
- g_signal_connect(G_OBJECT(paint->value.paint.server), "modified",
- G_CALLBACK(sp_style_paint_server_modified), style);
+ SPObject *server = paint->value.paint.server;
+ sigc::connection release_connection
+ = server->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_paint_server_release), style));
+ sigc::connection modified_connection
+ = server->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_style_paint_server_modified), style));
if (paint == &style->fill) {
- style->fill_listening = true;
+ style->fill_release_connection = release_connection;
+ style->fill_modified_connection = modified_connection;
} else {
assert(paint == &style->stroke);
- style->stroke_listening = true;
+ style->stroke_release_connection = release_connection;
+ style->stroke_modified_connection = modified_connection;
}
}
}
@@ -2933,15 +2952,18 @@ sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
}
}
if (style->object || style->cloned) {
- g_signal_connect(G_OBJECT(paint->value.paint.server), "release",
- G_CALLBACK(sp_style_paint_server_release), style);
- g_signal_connect(G_OBJECT(paint->value.paint.server), "modified",
- G_CALLBACK(sp_style_paint_server_modified), style);
+ SPObject *server = paint->value.paint.server;
+ sigc::connection release_connection
+ = server->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_style_paint_server_release), style));
+ sigc::connection modified_connection
+ = server->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_style_paint_server_modified), style));
if (paint == &style->fill) {
- style->fill_listening = true;
+ style->fill_release_connection = release_connection;
+ style->fill_modified_connection = modified_connection;
} else {
assert(paint == &style->stroke);
- style->stroke_listening = true;
+ style->stroke_release_connection = release_connection;
+ style->stroke_modified_connection = modified_connection;
}
}
} else {
sp_object_hunref(SP_OBJECT(paint->value.paint.server), style);
style->fill_hreffed = false;
}
- if (style->fill_listening) {
- g_signal_handlers_disconnect_matched(G_OBJECT(paint->value.paint.server),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, style);
- style->fill_listening = false;
- }
+ style->fill_release_connection.disconnect();
+ style->fill_modified_connection.disconnect();
} else {
assert(paint == &style->stroke); // Only fill & stroke can have a paint server.
if (style->stroke_hreffed) {
sp_object_hunref(SP_OBJECT(paint->value.paint.server), style);
style->stroke_hreffed = false;
}
- if (style->stroke_listening) {
- g_signal_handlers_disconnect_matched(G_OBJECT(paint->value.paint.server),
- G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, style);
- style->stroke_listening = false;
- }
+ style->stroke_release_connection.disconnect();
+ style->stroke_modified_connection.disconnect();
}
paint->value.paint.server = NULL;
diff --git a/src/style.h b/src/style.h
index 3c070a22a6714281e644d6059ea1e42a8e94f122..ad1459a732d2989e001988b21a3f809c1037330d 100644 (file)
--- a/src/style.h
+++ b/src/style.h
#include "sp-marker-loc.h"
#include "sp-filter.h"
+#include <sigc++/connection.h>
+
namespace Inkscape {
namespace XML {
class Node;
/// style has hreffed its fill/stroke paintservers, needs to release.
bool fill_hreffed;
bool stroke_hreffed;
- /// style is listening to changes in fill/stroke paintservers, needs to disconnect.
- bool fill_listening;
- bool stroke_listening;
+
+ sigc::connection fill_release_connection;
+ sigc::connection fill_modified_connection;
+
+ sigc::connection stroke_release_connection;
+ sigc::connection stroke_modified_connection;
};
SPStyle *sp_style_new();