Code

fix build again for old poppler libs, by reverting a part of my previous commit
[inkscape.git] / src / extension / extension.cpp
index 84f09aedb37b644f44f79a43606f84160ea8a97b..52d5f5148b540e3915a1bf1f5354ca2764dad108 100644 (file)
@@ -34,7 +34,7 @@
 #include "db.h"
 #include "dependency.h"
 #include "timer.h"
-#include "parameter.h"
+#include "param/parameter.h"
 
 namespace Inkscape {
 namespace Extension {
@@ -79,6 +79,9 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
         /* TODO: Handle what happens if we don't have these two */
         while (child_repr != NULL) {
             char const * chname = child_repr->name();
+                       if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) {
+                               chname += strlen(INKSCAPE_EXTENSION_NS);
+                       }
             if (chname[0] == '_') /* Allow _ for translation of tags */
                 chname++;
             if (!strcmp(chname, "id")) {
@@ -288,10 +291,10 @@ Extension::check (void)
 void
 Extension::printFailure (Glib::ustring reason)
 {
-       error_file << _("Extension \"") << name << _("\" failed to load because ");
-       error_file << reason.raw();
-       error_file << std::endl;
-       return;
+    error_file << _("Extension \"") << name << _("\" failed to load because ");
+    error_file << reason.raw();
+    error_file << std::endl;
+    return;
 }
 
 /**
@@ -664,22 +667,25 @@ public:
     function to get each widget.  Then, each of those is placed into
     a Gtk::VBox, which is then returned to the calling function.
 
-    If there are no parameters, this function just returns NULL.
+    If there are no visible parameters, this function just returns NULL.
+    If all parameters are gui_visible = false NULL is returned as well.    
 */
 Gtk::Widget *
 Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
 {
-    if (g_slist_length(parameters) == 0) return NULL;
+    if (param_visible_count() == 0) return NULL;
 
     AutoGUI * agui = Gtk::manage(new AutoGUI());
 
+    //go through the list of parameters to see if there are any non-hidden ones
     for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
         Parameter * param = reinterpret_cast<Parameter *>(list->data);
+        if (param->get_gui_hidden()) continue; //Ignore hidden parameters
         Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
         gchar const * tip = param->get_tooltip();
         agui->addWidget(widg, tip);
-    }
-
+    }    
+    
     agui->show();
     return agui;
 };
@@ -692,23 +698,9 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v
 void
 Extension::paramListString (std::list <std::string> &retlist)
 {
-    //std::list <std::string> retarray;
-
     for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
         Parameter * param = reinterpret_cast<Parameter *>(list->data);
-
-        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);
-
-        // insert parameters subparameters if any (for example notebook parameter has subparams)
-        param->insert_subparam_strings(retlist);
+        param->string(retlist);
     }
 
     return;
@@ -761,7 +753,7 @@ Extension::get_help_widget(void)
     Gtk::VBox * retval = Gtk::manage(new Gtk::VBox());
 
     if (_help == NULL) {
-        Gtk::Label * content = Gtk::manage(new Gtk::Label("Currently there is no help available for this Extension.  Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension."));
+        Gtk::Label * content = Gtk::manage(new Gtk::Label(_("Currently there is no help available for this Extension.  Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension.")));
         retval->pack_start(*content, true, true, 5);
         content->set_line_wrap(true);
         content->show();
@@ -786,6 +778,16 @@ Extension::get_params_widget(void)
     return retval;
 }
 
+unsigned int Extension::param_visible_count ( ) 
+{
+    unsigned int _visible_count = 0;
+    for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
+        Parameter * param = reinterpret_cast<Parameter *>(list->data);
+        if (!param->get_gui_hidden()) _visible_count++;
+    }    
+    return _visible_count;
+}
+
 }  /* namespace Extension */
 }  /* namespace Inkscape */