Code

Following this thread: http://www.nabble.com/Extension-parameters-td9064285.html...
authormfloryan <mfloryan@users.sourceforge.net>
Wed, 9 Apr 2008 09:51:44 +0000 (09:51 +0000)
committermfloryan <mfloryan@users.sourceforge.net>
Wed, 9 Apr 2008 09:51:44 +0000 (09:51 +0000)
21 files changed:
share/extensions/inkscape_help_askaquestion.inx
share/extensions/inkscape_help_commandline.inx
share/extensions/inkscape_help_faq.inx
share/extensions/inkscape_help_keys.inx
share/extensions/inkscape_help_manual.inx
share/extensions/inkscape_help_relnotes.inx
share/extensions/inkscape_help_reportabug.inx
share/extensions/inkscape_help_svgspec.inx
share/extensions/launch_webbrowser.py [new file with mode: 0644]
share/extensions/webbrowser_askaquestion.py [deleted file]
share/extensions/webbrowser_commandline.py [deleted file]
share/extensions/webbrowser_faq.py [deleted file]
share/extensions/webbrowser_keys.py [deleted file]
share/extensions/webbrowser_manual.py [deleted file]
share/extensions/webbrowser_relnotes.py [deleted file]
share/extensions/webbrowser_reportabug.py [deleted file]
share/extensions/webbrowser_svgspec.py [deleted file]
src/extension/extension.cpp
src/extension/extension.h
src/extension/implementation/script.cpp
src/extension/param/parameter.h

index df1194dcce4ccac44128358a0078ca911c90a073..455ced8cdb7f83d52b78bc22e4ff5ac2146db350 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>Ask Us a Question</_name>
     <id>org.inkscape.help.askaquestion</id>
-       <dependency type="executable" location="extensions">webbrowser_askaquestion.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://answers.launchpad.net/inkscape/+addquestion</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_askaquestion.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index 23771f857403ea5d22adf43e14ddbc93104d1611..c3b30bcb3be6f397f00128939b627ded631b54a3 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>Command Line Options</_name>
     <id>org.inkscape.help.commandline</id>
-       <dependency type="executable" location="extensions">webbrowser_commandline.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://inkscape.org/doc/inkscape-man.html</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_commandline.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index dae3700a6fc18aae2b664a502309090df9ba8578..3eb4827a819de13b63b4a3cd9ade112b547ab7bf 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>FAQ</_name>
     <id>org.inkscape.help.faq</id>
-       <dependency type="executable" location="extensions">webbrowser_faq.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://wiki.inkscape.org/wiki/index.php/FAQ</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_faq.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index 774649ad8f66ec9ed0e3fb3ec078e9770dd32f38..4e1e2159166f6168330ac3526c0f3d14385b6cdf 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>Keys and Mouse Reference</_name>
     <id>org.inkscape.help.keys</id>
-       <dependency type="executable" location="extensions">webbrowser_keys.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://inkscape.org/doc/keys046.html</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_keys.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index 1224f48c937524a156fbdcc806ac68d00ea45252..3faacc25067216e23d5289a46863f8a8b7010764 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>Inkscape Manual</_name>
     <id>org.inkscape.help.manual</id>
-       <dependency type="executable" location="extensions">webbrowser_manual.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.php</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_manual.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index c01f5b35c287948e9ba0ba10c702e550a3450ee7..6988b6c125a53e5652796032e54c695b4c1c5952 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>New in This Version</_name>
     <id>org.inkscape.help.relnotes</id>
-       <dependency type="executable" location="extensions">webbrowser_relnotes.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_relnotes.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index 4bd4387b9a61663f5a087731186b8a07ac24a19e..e52202ce69a018807e033ca0472c269406acc25d 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>Report a Bug</_name>
     <id>org.inkscape.help.reportabug</id>
-       <dependency type="executable" location="extensions">webbrowser_reportabug.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://inkscape.org/report_bugs.php</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_reportabug.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
index 2757c69da79096a6d04b64c485d905b6bde89a04..d78f4c377b250236b090f14a0069a5bd30ed7f9b 100644 (file)
@@ -1,12 +1,13 @@
 <inkscape-extension>
     <_name>SVG 1.1 Specification</_name>
     <id>org.inkscape.help.svgspec</id>
-       <dependency type="executable" location="extensions">webbrowser_svgspec.py</dependency>
+       <dependency type="executable" location="extensions">launch_webbrowser.py</dependency>
+       <param name="url" gui-hidden="1" type="string">http://www.w3.org/TR/SVG11/</param>
     <effect needs-document="no">
                <object-type>all</object-type>
                <effects-menu hidden="yes"/>
     </effect>
     <script>
-        <command reldir="extensions" interpreter="python">webbrowser_svgspec.py</command>
+        <command reldir="extensions" interpreter="python">launch_webbrowser.py</command>
     </script>
 </inkscape-extension>
diff --git a/share/extensions/launch_webbrowser.py b/share/extensions/launch_webbrowser.py
new file mode 100644 (file)
index 0000000..d27d6d1
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python \r
+import webbrowser, threading\r
+from optparse import OptionParser\r
+\r
+class VisitWebSiteWithoutLockingInkscape(threading.Thread):\r
+    def __init__(self):\r
+        threading.Thread.__init__ (self)\r
+        parser = OptionParser()\r
+        parser.add_option("-u", "--url", action="store", type="string", \r
+                        default="http://www.inkscape.org/", \r
+                        dest="url", help="The URL to open in web browser")\r
+        (self.options, args) = parser.parse_args()        \r
+\r
+    def run(self):       \r
+        webbrowser.open(self.options.url)\r
+        \r
+vwswli = VisitWebSiteWithoutLockingInkscape()\r
+vwswli.start()
\ No newline at end of file
diff --git a/share/extensions/webbrowser_askaquestion.py b/share/extensions/webbrowser_askaquestion.py
deleted file mode 100644 (file)
index 13bdf6e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://answers.launchpad.net/inkscape/+addquestion"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_commandline.py b/share/extensions/webbrowser_commandline.py
deleted file mode 100755 (executable)
index 33bc4b1..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://inkscape.org/doc/inkscape-man.html"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_faq.py b/share/extensions/webbrowser_faq.py
deleted file mode 100755 (executable)
index 58e3164..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://wiki.inkscape.org/wiki/index.php/FAQ"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_keys.py b/share/extensions/webbrowser_keys.py
deleted file mode 100755 (executable)
index 1b25126..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://inkscape.org/doc/keys046.html"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_manual.py b/share/extensions/webbrowser_manual.py
deleted file mode 100755 (executable)
index 8bc374b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.php"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_relnotes.py b/share/extensions/webbrowser_relnotes.py
deleted file mode 100755 (executable)
index a479323..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
diff --git a/share/extensions/webbrowser_reportabug.py b/share/extensions/webbrowser_reportabug.py
deleted file mode 100755 (executable)
index 3fb01a7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://inkscape.org/report_bugs.php"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
-
diff --git a/share/extensions/webbrowser_svgspec.py b/share/extensions/webbrowser_svgspec.py
deleted file mode 100755 (executable)
index b523ead..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python 
-import webbrowser, threading
-url = "http://www.w3.org/TR/SVG11/"
-
-class VisitWebSiteWithoutLockingInkscape(threading.Thread):
-    def __init__(self, url):
-        self.url = url
-        threading.Thread.__init__ (self)
-
-    def run(self):       
-        webbrowser.open(self.url)
-        
-vwswli = VisitWebSiteWithoutLockingInkscape(url)
-vwswli.start()
-
index a4ae7de9b8fecfc43d82fea87a88020a1e22347f..1229749f5339d73acb616da57b36ce6a688d018f 100644 (file)
@@ -664,22 +664,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;
 };
@@ -747,7 +750,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();
@@ -772,6 +775,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 */
 
index 4af65dc92fb5b5f7fea833a1ce859ab159ace026..6cdb1f44c1b7ca531c8713ef7c37fc10b9349ef0 100644 (file)
@@ -138,7 +138,7 @@ public:
               the appropriate function in code so that it'll work in the
               future.
     */
-    unsigned int param_visible_count ( ) { return param_count(); };
+    unsigned int param_visible_count ( );
 
 public:
     /** An error class for when a parameter is called on a type it is not */
index b395f6f1d648c97f8099dca97b51e5ecbe555c03..cededca516c13fe2abb8b4e9d310dcdae090d687 100644 (file)
@@ -98,7 +98,7 @@ struct interpreter_t {
 */
 static interpreter_t const interpreterTab[] = {
         {"perl",   "perl-interpreter",   "perl"   },
-#ifdef _WIN32
+#ifdef WIN32
         {"python", "python-interpreter", "pythonw" },
 #else
         {"python", "python-interpreter", "python" },
@@ -142,7 +142,7 @@ resolveInterpreterExecutable(const Glib::ustring &interpNameArg)
         return interpName;
     }
 
-#ifdef _WIN32
+#ifdef WIN32
 
     // 2.  Windows.  Try looking relative to inkscape.exe
     RegistryTool rt;
@@ -359,7 +359,7 @@ bool
 Script::load(Inkscape::Extension::Extension *module)
 {
     if (module->loaded())
-        return TRUE;
+        return true;
 
     helper_extension = "";
 
@@ -374,6 +374,7 @@ Script::load(Inkscape::Extension::Extension *module)
                     if (interpretstr != NULL) {
                         Glib::ustring interpString =
                             resolveInterpreterExecutable(interpretstr);
+                        //g_message("Found: %s and %s",interpString.c_str(),interpretstr);
                         command.insert(command.end(), interpretstr);
                     }
                     Glib::ustring tmp = "\"";
@@ -393,7 +394,7 @@ Script::load(Inkscape::Extension::Extension *module)
         child_repr = sp_repr_next(child_repr);
     }
 
-    //g_return_val_if_fail(command.length() > 0, FALSE);
+    //g_return_val_if_fail(command.length() > 0, false);
 
     return true;
 }
@@ -437,14 +438,14 @@ Script::check(Inkscape::Extension::Extension *module)
                         /* I've got the command */
                         bool existance = check_existance(command_text);
                         if (!existance)
-                            return FALSE;
+                            return false;
                     }
                 }
 
                 if (!strcmp(child_repr->name(), "helper_extension")) {
                     gchar const *helper = sp_repr_children(child_repr)->content();
                     if (Inkscape::Extension::db.get(helper) == NULL) {
-                        return FALSE;
+                        return false;
                     }
                 }
 
@@ -486,7 +487,7 @@ ScriptDocCache::ScriptDocCache (Inkscape::UI::View::View * view) :
 
     Inkscape::Extension::save(
               Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE),
-              view->doc(), _filename.c_str(), FALSE, FALSE, FALSE);
+              view->doc(), _filename.c_str(), false, false, false);
 
     return;
 }
@@ -679,11 +680,11 @@ Script::save(Inkscape::Extension::Output *module,
     if (helper_extension.size() == 0) {
         Inkscape::Extension::save(
                    Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE),
-                   doc, tempfilename_in.c_str(), FALSE, FALSE, FALSE);
+                   doc, tempfilename_in.c_str(), false, false, false);
     } else {
         Inkscape::Extension::save(
                    Inkscape::Extension::db.get(helper_extension.c_str()),
-                   doc, tempfilename_in.c_str(), FALSE, FALSE, FALSE);
+                   doc, tempfilename_in.c_str(), false, false, false);
     }
 
 
@@ -980,9 +981,8 @@ Script::execute (const std::list<std::string> &in_command,
     for (std::list<std::string>::const_iterator i = in_command.begin();
             i != in_command.end(); i++) {
         std::string param_str = *i;
-        //std::cout << "params " << param_str << std::endl;
         do {
-            //std::cout << "param " << param_str << std::endl;
+            //g_message("param: %s", param_str.c_str());
             size_t first_space = param_str.find_first_of(' ');
             size_t first_quote = param_str.find_first_of('"');
             //std::cout << "first space " << first_space << std::endl;
@@ -1028,7 +1028,8 @@ Script::execute (const std::list<std::string> &in_command,
 
     for (std::list<std::string>::const_iterator i = in_params.begin();
             i != in_params.end(); i++) {
-        argv.push_back(*i);
+       //g_message("Script parameter: %s",(*i)g.c_str());
+        argv.push_back(*i);        
     }
 
     if (!(filein.empty())) {
index ca3a2a0d4603210745bfcf4b73eae1a51d715211..1aeafbd7cf4bc37988974f79c2f9f4cf405409d5 100644 (file)
@@ -61,8 +61,8 @@ protected:
     gchar *  _text;
     /** \brief  Whether the GUI is visible */
     bool _gui_hidden;
-       /** \brief  A tip for the GUI if there is one */
-       gchar *  _gui_tip;
+    /** \brief  A tip for the GUI if there is one */
+    gchar *  _gui_tip;
 
 
     /* **** funcs **** */
@@ -77,7 +77,7 @@ public:
                               const gchar * desc,
                               const Parameter::_scope_t scope,
                               bool gui_hidden,
-                                                         const gchar * gui_tip,
+                              const gchar * gui_tip,
                               Inkscape::Extension::Extension * ext);
                   Parameter  (const gchar * name,
                               const gchar * guitext,
@@ -108,8 +108,12 @@ public:
 
     static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
     virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+
     gchar const * get_tooltip (void) { return _desc; }
 
+    /** \brief  Indicates if the GUI for this parameter is hidden or not */
+    bool         get_gui_hidden ()   { return _gui_hidden; }
+
     virtual void string (std::list <std::string> &list);
     virtual void string (std::string &string);
 };