X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fextension%2Fextension.cpp;h=825a935adc93d0babac69cf0c9210fc498d0391a;hb=c2b22c9f829b2eb90f50a77c15a37af0d1114849;hp=fe23ec5574112c4d7b974ae566e368ebf9846b0a;hpb=b6ae2ff55ce50b104521cce0a0c2e96f40881006;p=inkscape.git diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index fe23ec557..825a935ad 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -91,15 +91,15 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat if (!strcmp(chname, "help")) { _help = g_strdup (sp_repr_children(child_repr)->content()); } /* name */ - if (!strcmp(chname, "param")) { + if (!strcmp(chname, "param") || !strcmp(chname, "_param")) { Parameter * param; param = Parameter::make(child_repr, this); if (param != NULL) parameters = g_slist_append(parameters, param); - } /* param */ + } /* param || _param */ if (!strcmp(chname, "dependency")) { _deps.push_back(new Dependency(child_repr)); - } /* param */ + } /* dependency */ child_repr = sp_repr_next(child_repr); } @@ -131,7 +131,15 @@ Extension::~Extension (void) delete timer; timer = NULL; /** \todo Need to do parameters here */ - + + // delete parameters: + for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { + Parameter * param = reinterpret_cast(list->data); + delete param; + } + g_slist_free(parameters); + + for (unsigned int i = 0 ; i < _deps.size(); i++) { delete _deps[i]; } @@ -420,6 +428,13 @@ Extension::get_param_string (const gchar * name, const SPDocument * doc, const I return param->get_string(doc, node); } +const gchar * +Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +{ + Parameter* param = param_shared(name, parameters); + return param->get_enum(doc, node); +} + /** \return The value of the parameter identified by the name \brief Gets a parameter identified by name with the bool placed @@ -479,6 +494,24 @@ Extension::get_param_float (const gchar * name, const SPDocument * doc, const In return param->get_float(doc, node); } +/** + \return The string value for the parameter specified + \brief Gets a parameter identified by name with the float placed + in value. + \param name The name of the parameter to get + \param doc The document to look in for document specific parameters + \param node The node to look in for a specific parameter + + Look up in the parameters list, then execute the function on that + found parameter. +*/ +guint32 +Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +{ + Parameter* param = param_shared(name, parameters); + return param->get_color(doc, node); +} + /** \return The passed in value \brief Sets a parameter identified by name with the boolean @@ -559,6 +592,25 @@ Extension::set_param_string (const gchar * name, const gchar * value, SPDocument return param->set_string(value, doc, node); } +/** + \return The passed in value + \brief Sets a parameter identified by name with the string + in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + \param doc The document to look in for document specific parameters + \param node The node to look in for a specific parameter + + Look up in the parameters list, then execute the function on that + found parameter. +*/ +guint32 +Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, Inkscape::XML::Node * node) +{ + Parameter* param = param_shared(name, parameters); + return param->set_color(color, doc, node); +} + /** \brief A function to open the error log file. */ void Extension::error_file_open (void) @@ -597,10 +649,9 @@ public: */ void addWidget (Gtk::Widget * widg, gchar const * tooltip) { if (widg == NULL) return; - this->pack_start(*widg, true, true); + this->pack_start(*widg, true, true, 2); if (tooltip != NULL) { _tooltips.set_tip(*widg, Glib::ustring(tooltip)); - // printf("Setting tooltip: %s\n", tooltip); } return; }; @@ -616,7 +667,7 @@ public: If there are no parameters, this function just returns NULL. */ Gtk::Widget * -Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node) +Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { if (g_slist_length(parameters) == 0) return NULL; @@ -624,7 +675,7 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node) for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast(list->data); - Gtk::Widget * widg = param->get_widget(doc, node); + Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); gchar const * tip = param->get_tooltip(); agui->addWidget(widg, tip); } @@ -635,29 +686,30 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node) /** \brief A function to get the parameters in a string form - \return A string with all the parameters as command line arguements - - I don't really like this function, but it works for now. + \return An array with all the parameters in it. - \todo Do this better. */ -Glib::ustring * -Extension::paramString (void) +void +Extension::paramListString (std::list &retlist) { - Glib::ustring * param_string = new Glib::ustring(""); + //std::list retarray; for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast(list->data); - *param_string += " --"; - *param_string += param->name(); - *param_string += "="; - Glib::ustring * paramstr = param->string(); - *param_string += *paramstr; - delete paramstr; + std::string param_string; + param_string += "--"; + param_string += param->name(); + param_string += "="; + Glib::ustring * out = param->string(); + param_string += *out; + delete out; + + retlist.insert(retlist.end(), param_string); } + //g_message("paramstring=%s", param_string->c_str()); - return param_string; + return; } /* Extension editor dialog stuff */