From 8435052ef25dc903d1d438b137a9348ec681020b Mon Sep 17 00:00:00 2001 From: mfloryan Date: Wed, 9 Apr 2008 09:51:44 +0000 Subject: [PATCH] Following this thread: http://www.nabble.com/Extension-parameters-td9064285.html#a9064285 cleaned up python webbrowser_* scripts by replacing with one generic launch_webbrowser.py. This required a bit of work with extensions to handle hidden GUI parameters better. URLs are now in the inkscape_help_*.inx files. --- .../extensions/inkscape_help_askaquestion.inx | 5 ++-- .../extensions/inkscape_help_commandline.inx | 5 ++-- share/extensions/inkscape_help_faq.inx | 5 ++-- share/extensions/inkscape_help_keys.inx | 5 ++-- share/extensions/inkscape_help_manual.inx | 5 ++-- share/extensions/inkscape_help_relnotes.inx | 5 ++-- share/extensions/inkscape_help_reportabug.inx | 5 ++-- share/extensions/inkscape_help_svgspec.inx | 5 ++-- share/extensions/launch_webbrowser.py | 18 +++++++++++++ share/extensions/webbrowser_askaquestion.py | 14 ----------- share/extensions/webbrowser_commandline.py | 14 ----------- share/extensions/webbrowser_faq.py | 14 ----------- share/extensions/webbrowser_keys.py | 14 ----------- share/extensions/webbrowser_manual.py | 14 ----------- share/extensions/webbrowser_relnotes.py | 14 ----------- share/extensions/webbrowser_reportabug.py | 15 ----------- share/extensions/webbrowser_svgspec.py | 15 ----------- src/extension/extension.cpp | 23 +++++++++++++---- src/extension/extension.h | 2 +- src/extension/implementation/script.cpp | 25 ++++++++++--------- src/extension/param/parameter.h | 10 +++++--- 21 files changed, 81 insertions(+), 151 deletions(-) create mode 100644 share/extensions/launch_webbrowser.py delete mode 100644 share/extensions/webbrowser_askaquestion.py delete mode 100755 share/extensions/webbrowser_commandline.py delete mode 100755 share/extensions/webbrowser_faq.py delete mode 100755 share/extensions/webbrowser_keys.py delete mode 100755 share/extensions/webbrowser_manual.py delete mode 100755 share/extensions/webbrowser_relnotes.py delete mode 100755 share/extensions/webbrowser_reportabug.py delete mode 100755 share/extensions/webbrowser_svgspec.py diff --git a/share/extensions/inkscape_help_askaquestion.inx b/share/extensions/inkscape_help_askaquestion.inx index df1194dcc..455ced8cd 100644 --- a/share/extensions/inkscape_help_askaquestion.inx +++ b/share/extensions/inkscape_help_askaquestion.inx @@ -1,12 +1,13 @@ <_name>Ask Us a Question org.inkscape.help.askaquestion - webbrowser_askaquestion.py + launch_webbrowser.py + http://answers.launchpad.net/inkscape/+addquestion all diff --git a/share/extensions/inkscape_help_commandline.inx b/share/extensions/inkscape_help_commandline.inx index 23771f857..c3b30bcb3 100644 --- a/share/extensions/inkscape_help_commandline.inx +++ b/share/extensions/inkscape_help_commandline.inx @@ -1,12 +1,13 @@ <_name>Command Line Options org.inkscape.help.commandline - webbrowser_commandline.py + launch_webbrowser.py + http://inkscape.org/doc/inkscape-man.html all diff --git a/share/extensions/inkscape_help_faq.inx b/share/extensions/inkscape_help_faq.inx index dae3700a6..3eb4827a8 100644 --- a/share/extensions/inkscape_help_faq.inx +++ b/share/extensions/inkscape_help_faq.inx @@ -1,12 +1,13 @@ <_name>FAQ org.inkscape.help.faq - webbrowser_faq.py + launch_webbrowser.py + http://wiki.inkscape.org/wiki/index.php/FAQ all diff --git a/share/extensions/inkscape_help_keys.inx b/share/extensions/inkscape_help_keys.inx index 774649ad8..4e1e21591 100644 --- a/share/extensions/inkscape_help_keys.inx +++ b/share/extensions/inkscape_help_keys.inx @@ -1,12 +1,13 @@ <_name>Keys and Mouse Reference org.inkscape.help.keys - webbrowser_keys.py + launch_webbrowser.py + http://inkscape.org/doc/keys046.html all diff --git a/share/extensions/inkscape_help_manual.inx b/share/extensions/inkscape_help_manual.inx index 1224f48c9..3faacc250 100644 --- a/share/extensions/inkscape_help_manual.inx +++ b/share/extensions/inkscape_help_manual.inx @@ -1,12 +1,13 @@ <_name>Inkscape Manual org.inkscape.help.manual - webbrowser_manual.py + launch_webbrowser.py + http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.php all diff --git a/share/extensions/inkscape_help_relnotes.inx b/share/extensions/inkscape_help_relnotes.inx index c01f5b35c..6988b6c12 100644 --- a/share/extensions/inkscape_help_relnotes.inx +++ b/share/extensions/inkscape_help_relnotes.inx @@ -1,12 +1,13 @@ <_name>New in This Version org.inkscape.help.relnotes - webbrowser_relnotes.py + launch_webbrowser.py + http://wiki.inkscape.org/wiki/index.php/ReleaseNotes046 all diff --git a/share/extensions/inkscape_help_reportabug.inx b/share/extensions/inkscape_help_reportabug.inx index 4bd4387b9..e52202ce6 100644 --- a/share/extensions/inkscape_help_reportabug.inx +++ b/share/extensions/inkscape_help_reportabug.inx @@ -1,12 +1,13 @@ <_name>Report a Bug org.inkscape.help.reportabug - webbrowser_reportabug.py + launch_webbrowser.py + http://inkscape.org/report_bugs.php all diff --git a/share/extensions/inkscape_help_svgspec.inx b/share/extensions/inkscape_help_svgspec.inx index 2757c69da..d78f4c377 100644 --- a/share/extensions/inkscape_help_svgspec.inx +++ b/share/extensions/inkscape_help_svgspec.inx @@ -1,12 +1,13 @@ <_name>SVG 1.1 Specification org.inkscape.help.svgspec - webbrowser_svgspec.py + launch_webbrowser.py + http://www.w3.org/TR/SVG11/ all diff --git a/share/extensions/launch_webbrowser.py b/share/extensions/launch_webbrowser.py new file mode 100644 index 000000000..d27d6d1f4 --- /dev/null +++ b/share/extensions/launch_webbrowser.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import webbrowser, threading +from optparse import OptionParser + +class VisitWebSiteWithoutLockingInkscape(threading.Thread): + def __init__(self): + threading.Thread.__init__ (self) + parser = OptionParser() + parser.add_option("-u", "--url", action="store", type="string", + default="http://www.inkscape.org/", + dest="url", help="The URL to open in web browser") + (self.options, args) = parser.parse_args() + + def run(self): + webbrowser.open(self.options.url) + +vwswli = VisitWebSiteWithoutLockingInkscape() +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 index 13bdf6eee..000000000 --- a/share/extensions/webbrowser_askaquestion.py +++ /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 index 33bc4b1df..000000000 --- a/share/extensions/webbrowser_commandline.py +++ /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 index 58e3164fb..000000000 --- a/share/extensions/webbrowser_faq.py +++ /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 index 1b2512663..000000000 --- a/share/extensions/webbrowser_keys.py +++ /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 index 8bc374b97..000000000 --- a/share/extensions/webbrowser_manual.py +++ /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 index a47932397..000000000 --- a/share/extensions/webbrowser_relnotes.py +++ /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 index 3fb01a753..000000000 --- a/share/extensions/webbrowser_reportabug.py +++ /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 index b523eada8..000000000 --- a/share/extensions/webbrowser_svgspec.py +++ /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() - diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index a4ae7de9b..1229749f5 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -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 * 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(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(list->data); + if (!param->get_gui_hidden()) _visible_count++; + } + return _visible_count; +} + } /* namespace Extension */ } /* namespace Inkscape */ diff --git a/src/extension/extension.h b/src/extension/extension.h index 4af65dc92..6cdb1f44c 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -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 */ diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index b395f6f1d..cededca51 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -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 &in_command, for (std::list::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 &in_command, for (std::list::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())) { diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index ca3a2a0d4..1aeafbd7c 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -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 * 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 &list); virtual void string (std::string &string); }; -- 2.30.2