]> git.tokkee.org Git - inkscape.git/commitdiff

Code

r11514@tres: ted | 2006-04-24 22:19:54 -0700
authorgouldtj <gouldtj@users.sourceforge.net>
Tue, 2 May 2006 05:27:56 +0000 (05:27 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Tue, 2 May 2006 05:27:56 +0000 (05:27 +0000)
 Added in some helper functions.

src/extension/parameter.cpp
src/extension/parameter.h

index 0e67d96c85b741794be3d98e96a88aef205416b9..00bc8369a783453463dc080ac15f2ba8d6df2238 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "extension.h"
 #include "prefs-utils.h"
+#include "document-private.h"
+#include "sp-object.h"
 
 #include "parameter.h"
 
@@ -510,6 +512,37 @@ Parameter::pref_name (void)
     return g_strdup_printf("%s.%s", extension->get_id(), _name);
 }
 
+/** \brief  Build the name to write the parameter in a node object.  This
+            requires the inkscape namespace and the other info. */
+gchar *
+Parameter::node_name (void)
+{
+    return g_strdup_printf("inkscape:extension-param-%s-%s", extension->get_id(), _name);
+}
+
+Inkscape::XML::Node *
+Parameter::document_param_node (SPDocument * doc)
+{
+    Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc));
+    Inkscape::XML::Node * params = NULL;
+
+    for (Inkscape::XML::Node * child = defs->firstChild();
+            child != NULL;
+            child = child->next()) {
+        if (!strcmp(child->name(), "inkscape:extension-param")) {
+            params = child;
+            break;
+        }
+    }
+
+    if (params == NULL) {
+        params = sp_repr_new("inkscape:extension-param");
+        defs->appendChild(params);
+    }
+
+    return params;
+}
+
 /** \brief  Basically, if there is no widget pass a NULL. */
 Gtk::Widget *
 Parameter::get_widget (void)
index 67cceff60c935a00ef6b001d2d431d43d30230cc..a29c5cb672723f53e2dd133f212b8a015c954c13 100644 (file)
@@ -48,7 +48,12 @@ protected:
     _scope_t _scope;
     /** \brief  Text for the GUI selection of this. */
     gchar *       _text;
-    gchar *       pref_name (void);
+
+
+    /* **** funcs **** */
+    gchar *               pref_name (void);
+    gchar *               node_name (void);
+    Inkscape::XML::Node * document_param_node (SPDocument * doc);
 
 public:
                   Parameter  (const gchar * name,