Code

typo fixed
[inkscape.git] / src / ui / dialog / scriptdialog.cpp
index a0f7f433788d7bedc5224009a3c478ccc6ae3f0d..a8c0286d68f3cfcaa41182306c75be5c58a8dfdf 100644 (file)
@@ -1,9 +1,4 @@
 /*
- * This dialog is for launching scripts whose main purpose if
- * the scripting of Inkscape itself.
- *
- * Authors:
- *   Bob Jamison
  *   Other dudes from The Inkscape Organization
  *
  * Copyright (C) 2004, 2005 Authors
@@ -103,6 +98,7 @@ class ScriptDialogImpl : public ScriptDialog
 };
 
 static char *defaultPythonCodeStr =
+#if defined(WITH_PYTHON)
     "# This is a sample Python script.\n"
     "# To run it, select 'Execute Python' from the File menu above.\n"
     "desktop = inkscape.getDesktop()\n"
@@ -110,6 +106,21 @@ static char *defaultPythonCodeStr =
     "document = desktop.getDocument()\n"
     "document.hello()\n"
     "dialogmanager.showAbout()\n"
+#elif defined(WITH_PERL)
+    "# This is a sample Perl script.\n"
+    "# To run it, select 'Execute Perl' from the File menu above.\n"
+    "my $desktop = $inkscape->getDesktop();\n"
+    "my $dialogmanager = $inkscape->getDialogManager();\n"
+    "my $document = $desktop->getDocument();\n"
+    "$document->hello();\n"
+    "$dialogmanager->showAbout();\n"
+#else
+    "# This is where you could type a script.\n"
+    "# However, no scripting languages have been compiled\n"
+    "# into Inkscape, so this window has no functionality.\n"
+    "# When compiling Inkscape, run \"configure\" with\n"
+    "# \"--with-python\" and/or \"--with-perl\".\n"
+#endif
     "";
 
 
@@ -146,7 +157,8 @@ lang)
     Glib::ustring output;
     Glib::ustring error;
     Inkscape::Extension::Script::InkscapeScript engine;
-    engine.interpretScript(script, output, error, lang);
+    bool ok = engine.interpretScript(script, output, error, lang);
+    if (!ok) return;
     outputText.get_buffer()->set_text(output);
     errorText.get_buffer()->set_text(error);
 }
@@ -182,10 +194,14 @@ ScriptDialogImpl::ScriptDialogImpl()
     menuBar.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_File"), fileMenu) );
     fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_Clear"),
            sigc::mem_fun(*this, &ScriptDialogImpl::clear) ) );
+#ifdef WITH_PYTHON
     fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_Execute Python"),
            sigc::mem_fun(*this, &ScriptDialogImpl::executePython) ) );
+#endif
+#ifdef WITH_PERL
     fileMenu.items().push_back( Gtk::Menu_Helpers::MenuElem(_("_Execute Perl"),
            sigc::mem_fun(*this, &ScriptDialogImpl::executePerl) ) );
+#endif
     mainVBox->pack_start(menuBar, Gtk::PACK_SHRINK);
 
     //### Set up the script field
@@ -218,6 +234,8 @@ ScriptDialogImpl::ScriptDialogImpl()
     errorTextFrame.add(errorTextScroll);
     mainVBox->pack_start(errorTextFrame);
 
+    // sick of this thing shrinking too much
+    set_size_request(350, 400);
     show_all_children();
 
 }