summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08325ce)
raw | patch | inline | side by side (parent: 08325ce)
author | kiirala <kiirala@users.sourceforge.net> | |
Mon, 2 Jun 2008 15:47:48 +0000 (15:47 +0000) | ||
committer | kiirala <kiirala@users.sourceforge.net> | |
Mon, 2 Jun 2008 15:47:48 +0000 (15:47 +0000) |
src/sp-filter.cpp | patch | blob | history | |
src/sp-filter.h | patch | blob | history | |
src/ui/dialog/filter-effects-dialog.cpp | patch | blob | history |
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index 150033895202aea50541345839874ed4431463a5..e020f6814f2d18d9d450a8c38e5657a617c2f0d5 100644 (file)
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
using std::map;
using std::pair;
+#include <gtkmm.h>
+
#include "attributes.h"
#include "document.h"
#include "sp-filter.h"
filter->_image_name = new std::map<gchar *, int, ltstr>;
filter->_image_name->clear();
+ filter->_image_number_next = 0;
filter->filterRes = NumberOptNumber();
return value;
}
+Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) {
+ g_assert(filter != NULL);
+ int largest = 0;
+
+ SPObject *primitive_obj = filter->children;
+ while (primitive_obj) {
+ if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(primitive_obj);
+ char const *result = repr->attribute("result");
+ int index;
+ if (result && sscanf(result, "result%d", &index) == 1) {
+ if (index > largest) {
+ largest = index;
+ }
+ }
+ }
+ primitive_obj = primitive_obj->next;
+ }
+
+ return "result" + Glib::Ascii::dtostr(largest + 1);
+}
+
bool ltstr::operator()(const char* s1, const char* s2) const
{
return strcmp(s1, s2) < 0;
diff --git a/src/sp-filter.h b/src/sp-filter.h
index 3e9bb3cb09871726142fd8f67bda45a4853dadde..d0a449c47591671e2b5457d8b59969c6485acf18 100644 (file)
--- a/src/sp-filter.h
+++ b/src/sp-filter.h
#include <map>
+#include <gtkmm.h>
+
#include "number-opt-number.h"
#include "sp-object.h"
#include "sp-filter-units.h"
int sp_filter_get_image_name(SPFilter *filter, gchar const *name);
int sp_filter_set_image_name(SPFilter *filter, gchar const *name);
+/*
+ * Returns a result image name that is not in use inside this filter.
+ */
+Glib::ustring sp_filter_get_new_result_name(SPFilter *filter);
+
#endif /* !SP_FILTER_H_SEEN */
/*
index c7694ef09ea696d774db4b2a7159f9ee0c560407..98951f28c4c25755d75f9f784e7b72ab069be069 100644 (file)
@@ -1917,7 +1917,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
// Make sure the target has a result
const gchar *gres = repr->attribute("result");
if(!gres) {
- result = "result" + Glib::Ascii::dtostr(SP_FILTER(prim->parent)->_image_number_next);
+ result = sp_filter_get_new_result_name(SP_FILTER(prim->parent));
repr->setAttribute("result", result.c_str());
in_val = result.c_str();
}