Code

Pot and Dutch translation update
[inkscape.git] / src / extension / param / parameter.cpp
index b356c297e9c3a75696fbb617024ca097b1e8daf6..94260cc56523e59ed3bdd0416d86a952e21c6e5f 100644 (file)
@@ -1,9 +1,7 @@
-/** \file
- * Parameters for extensions.
+/** @file
+ * @brief Parameters for extensions.
  */
-
-/*
- * Author:
+/* Author:
  *   Ted Gould <ted@gould.cx>
  *   Johan Engelen <johan@shouraizou.nl>
  *
@@ -37,6 +35,7 @@
 #include "bool.h"
 #include "color.h"
 #include "description.h"
+#include "groupheader.h"
 #include "enum.h"
 #include "float.h"
 #include "int.h"
@@ -103,6 +102,7 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
                }
                /* else stays false */
        }
+    const gchar* appearance = in_repr->attribute("appearance");
 
     /* In this case we just don't have enough information */
     if (name == NULL || type == NULL) {
@@ -135,12 +135,18 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
         }
     } else if (!strcmp(type, "description")) {
         param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+    } else if (!strcmp(type, "groupheader")) {
+        param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);        
     } else if (!strcmp(type, "enum")) {
         param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
     } else if (!strcmp(type, "notebook")) {
         param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
     } else if (!strcmp(type, "optiongroup")) {
-        param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+        if (appearance && !strcmp(appearance, "minimal")) {
+            param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::MINIMAL);
+        } else {
+            param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::FULL);
+        }
     } else if (!strcmp(type, "color")) {
         param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
     }
@@ -149,8 +155,6 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
     return param;
 }
 
-
-
 /** \brief  Wrapper to cast to the object and use it's function.  */
 bool
 Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
@@ -201,6 +205,16 @@ Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node)
     return param->get(doc, node);
 }
 
+/** \brief  Wrapper to cast to the object and use it's function.  */
+gchar const *Parameter::get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const * node)
+{
+    ParamRadioButton * param = dynamic_cast<ParamRadioButton *>(this);
+    if (!param) {
+        throw Extension::param_not_optiongroup_param();
+    }
+    return param->get(doc, node);
+}
+
 guint32
 Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node)
 {
@@ -250,6 +264,17 @@ Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node *
         throw Extension::param_not_string_param();
     return stringpntr->set(in, doc, node);
 }
+
+gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node )
+{
+    ParamRadioButton *param = dynamic_cast<ParamRadioButton *>(this);
+    if (!param) {
+        throw Extension::param_not_optiongroup_param();
+    }
+    return param->set(in, doc, node);
+}
+
+
 /** \brief  Wrapper to cast to the object and use it's function.  */
 guint32
 Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node)
@@ -270,7 +295,7 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d
     }
     if (desc != NULL) {
         _desc = g_strdup(desc);
-        // printf("Adding description: '%s' on '%s'\n", _desc, _name);
+//        printf("Adding description: '%s' on '%s'\n", _desc, _name);
     }
     if (gui_tip != NULL) {
         _gui_tip = g_strdup(gui_tip);
@@ -291,6 +316,7 @@ Parameter::~Parameter (void)
     g_free(_name);
     g_free(_text);
        g_free(_gui_tip);
+    g_free(_desc);
 }
 
 /** \brief  Build the name to write the parameter from the extension's
@@ -315,6 +341,7 @@ Parameter::new_child (Inkscape::XML::Node * parent)
     retval->setAttribute("name", _name);
 
     parent->appendChild(retval);
+    Inkscape::GC::release(retval);
     return retval;
 }
 
@@ -341,6 +368,7 @@ Parameter::document_param_node (SPDocument * doc)
         params = xml_doc->createElement("inkscape:extension-param");
         params->setAttribute("extension", extension->get_id());
         defs->appendChild(params);
+        Inkscape::GC::release(params);
     }
 
     return params;
@@ -379,6 +407,15 @@ Parameter::string (std::list <std::string> &list)
     return;
 }
 
+/** \brief  All the code in Notebook::get_param to get the notebook content */
+Parameter *
+Parameter::get_param(const gchar * name)
+{
+    return NULL;
+}
+
+Glib::ustring const extension_pref_root = "/extensions/";
+
 }  /* namespace Extension */
 }  /* namespace Inkscape */
 
@@ -391,4 +428,4 @@ Parameter::string (std::list <std::string> &list)
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :