summaryrefslogtreecommitdiffstats
path: root/parts/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'parts/scripting')
-rw-r--r--parts/scripting/Makefile.am20
-rw-r--r--parts/scripting/README18
-rw-r--r--parts/scripting/kdevscripting.desktop77
-rw-r--r--parts/scripting/kdevscripting.rc8
-rw-r--r--parts/scripting/scriptingglobalconfig.cpp48
-rw-r--r--parts/scripting/scriptingglobalconfig.h41
-rw-r--r--parts/scripting/scriptingglobalconfigbase.ui51
-rw-r--r--parts/scripting/scriptingpart.cpp108
-rw-r--r--parts/scripting/scriptingpart.h57
9 files changed, 428 insertions, 0 deletions
diff --git a/parts/scripting/Makefile.am b/parts/scripting/Makefile.am
new file mode 100644
index 00000000..3613afd2
--- /dev/null
+++ b/parts/scripting/Makefile.am
@@ -0,0 +1,20 @@
+INCLUDES = -I$(top_srcdir)/lib/interfaces -I$(top_srcdir)/lib/util $(all_includes)
+
+kde_module_LTLIBRARIES = libkdevscripting.la
+libkdevscripting_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
+libkdevscripting_la_LIBADD = $(top_builddir)/lib/libkdevelop.la
+
+libkdevscripting_la_SOURCES = scriptingpart.cpp scriptingglobalconfigbase.ui \
+ scriptingglobalconfig.cpp
+
+METASOURCES = AUTO
+
+appsharedir = $(kde_datadir)/kdevscripting
+appshare_DATA =
+
+servicedir = $(kde_servicesdir)
+service_DATA = kdevscripting.desktop
+
+rcdir = $(kde_datadir)/kdevscripting
+rc_DATA = kdevscripting.rc
+noinst_HEADERS = scriptingglobalconfig.h scriptingpart.h
diff --git a/parts/scripting/README b/parts/scripting/README
new file mode 100644
index 00000000..566feaa9
--- /dev/null
+++ b/parts/scripting/README
@@ -0,0 +1,18 @@
+KScript In KDevelop
+
+KScriptInterface allows us to have a generic way to add scripting languages to KDE applications. KScriptInterface is not really a scripting language per say, but an interface so that applications can embed scripting languages without explicitly linking to them. This allows all runtime linkage to the different interpreters. Currently the most effective way for scripts to communicate with applications is via DCOP. KScriptInterface script engines provide some convinences methods to access the dcop interfaces of the embedding application.
+
+In KDevelop we have the ability to use scripts written for Kate, since the KateText interface is fully exported to DCOP. By default KDevelop will import Kate scripts. Users can also add other search paths for loading scripts.
+
+To add a new script to KDevelop you need two parts. The first part is a simple desktop file that has the meta-information for the script. The basic format is like this:
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Import Weather
+Comment=Import current weather icon graphic into an album.
+Type=ShellScript/bash
+X-KDE-ScriptName=importweather.sh
+
+The "Name" is the part that will appear in the KDevelop "Scripts" menu, and the "X-KDE-ScriptName" is the name of the script you wish to attach to that menu action. The last part the "Type" is the type of the script runner you wish to execute the script with.
+
+The second part is the actual script that has a script runner. Currently shell and KJSEmbed are supported, but Kommander support is rumored to be happening. There are also perl and python script runners in kdenonbeta.
diff --git a/parts/scripting/kdevscripting.desktop b/parts/scripting/kdevscripting.desktop
new file mode 100644
index 00000000..f2ba27ed
--- /dev/null
+++ b/parts/scripting/kdevscripting.desktop
@@ -0,0 +1,77 @@
+[Desktop Entry]
+Type=Service
+Exec=blubb
+Name=KDevscripting
+Name[da]=KDevelop scriptning
+Name[nds]=KDevelop-Skriptschrieven
+Name[sk]=KDev skriptovanie
+Name[sv]=KDevelop-skriptanvändning
+Name[zh_TW]=KDevelop 文稿
+GenericName=Scripting
+GenericName[ca]=Scripts
+GenericName[da]=Scriptning
+GenericName[de]=Skriptunterstützung
+GenericName[el]=Γραφή σεναρίων
+GenericName[es]=Guiones
+GenericName[et]=Skriptikeele plugin
+GenericName[eu]=Script-a
+GenericName[fa]=دست‌نوشته
+GenericName[fr]=Scriptage
+GenericName[ga]=Scriptiú
+GenericName[hu]=Szkriptszerkesztő
+GenericName[it]=Script
+GenericName[nds]=Skriptünnerstütten
+GenericName[ne]=स्क्रिप्टिङ
+GenericName[pl]=Skrypty
+GenericName[pt]='Scripting'
+GenericName[ru]=Сценарии
+GenericName[sk]=Skriptovanie
+GenericName[sl]=Skriptiranje
+GenericName[sr]=Скриптовање
+GenericName[sr@Latn]=Skriptovanje
+GenericName[sv]=Skriptanvändning
+GenericName[tr]=Betik Yazma
+GenericName[zh_CN]=脚本
+GenericName[zh_TW]=文稿
+Comment=The Scripting plugin offers KScript based scripting of the KDevelop application
+Comment[ca]=El connector per als scripts ofereix scripts basats en KScript de l'aplicació KDevelop
+Comment[da]=Scriptning-plugin stiller KScript-baseret scriptning til rådighed for KDevelop
+Comment[de]=Das "Skript"-Modul bietet KScript-basierte Automatisierung für KDevelop
+Comment[el]=Το πρόσθετο γραφής σεναρίων προσφέρει σενάρια της μορφής KScript της εφαρμογής KDevelop
+Comment[es]=El complemento de guiones ofrece guiones basados en KScript de la aplicación KDevelop
+Comment[et]=Skriptikeele plugin võimaldab KDevelopis kasutada skriptikeelt KScripti alusel
+Comment[eu]=Script-a pluginak KScript-en oinarritutako KDevelop aplikazioaren script zerbitzuak eskeintzen ditu
+Comment[fa]=وصلۀ دست‌نوشته، دست‌نوشتۀ کاربرد KDevelop بر مبنای KScript را ارائه می‌دهد.
+Comment[fr]=Le module externe Scriptage fournit le scriptage basé sur KScript de l'application KDevelop
+Comment[gl]=A extensión Scripting ofrece scripting baseado en KScript para a aplicación de KDevelop
+Comment[hu]=A Szkriptszerkesztő KScript-alapú szkriptkészítést tesz lehetővé a KDevelophoz
+Comment[it]=Il plugin di script offre lo script basato su KScript dell'applicazione KDevelop
+Comment[ms]=Plugin Scripting memberikan scripting berasaskan KScript pada aplikasi KDevelop
+Comment[nds]=Dat Skript-Moduul stellt en op KSkript opbuut Skriptbewerken för KDevelop praat.
+Comment[ne]=यो स्क्रिप्टिङ प्लगइनले केडीई विकास अनुप्रयोगको स्क्रिप्टिङमा आधारित केडीई स्क्रिप्टिङ प्रस्ताव गर्दछ
+Comment[nl]=De scripting-plugin maakt KScript gebaseerde scripting van de KDevelop-toepassing mogelijk.
+Comment[pl]=Wtyczka skrypty pozwala ja skrypty oparte o KScript w programie KDevelop
+Comment[pt]=O 'plugin' de 'scripting' oferece funcionalidade de 'scripting' da aplicação KDevelop baseados no KScript
+Comment[pt_BR]=O plug-in de scripting oferece scripts baseados no KScript do aplicativo KDevelop
+Comment[ru]=Модуль сценариев позволяет автоматизировать работу с помощью KScript
+Comment[sk]=Modul poskytuje KScript skriptovanie KDevelop aplikácie
+Comment[sr]=Прикључак за скриптовање нуди скриптовање помоћу KScript-а за KDevelop
+Comment[sr@Latn]=Priključak za skriptovanje nudi skriptovanje pomoću KScript-a za KDevelop
+Comment[sv]=Skriptinsticksprogrammet erbjuder KScript-baserad styrning av programmet KDevelop.
+Comment[tr]=Betik Yazma eklentisi KDevelop uygulamasına KScript tabanlı betik yazmayı sunar.
+Comment[zh_CN]=脚本插件可为 KDevelop 应用程序提供基于 KScript 的脚本。
+Comment[zh_TW]=文稿外掛程式提供 KDevelop 應用程式一個 KScript 基礎的文稿機制。
+Icon=shellscript
+ServiceTypes=KDevelop/Plugin
+
+X-KDevelop-Plugin-Version=1
+X-KDevelop-Plugin-Homepage=http://www.sourcextreme.com/projects/kdevelop
+X-KDevelop-Plugin-BugsEmailAddress=geiseri@sourcextreme.com
+X-KDevelop-Plugin-Copyright=(C) by ian reinhart geiser
+
+X-KDevelop-Args=
+
+X-KDevelop-Scope=Global
+X-KDE-Library=libkdevscripting
+X-KDevelop-Version=5
+X-KDevelop-Properties=CodeEditing
diff --git a/parts/scripting/kdevscripting.rc b/parts/scripting/kdevscripting.rc
new file mode 100644
index 00000000..217bece1
--- /dev/null
+++ b/parts/scripting/kdevscripting.rc
@@ -0,0 +1,8 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartplugin name="scripting" library="libscriptingplugin" version="1.0">
+<MenuBar>
+ <Menu name="scripts"><Text>S&amp;cripts</Text>
+ <ActionList name="script_actions"/>
+ </Menu>
+</MenuBar>
+</kpartplugin>
diff --git a/parts/scripting/scriptingglobalconfig.cpp b/parts/scripting/scriptingglobalconfig.cpp
new file mode 100644
index 00000000..80d7a57f
--- /dev/null
+++ b/parts/scripting/scriptingglobalconfig.cpp
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2005 by ian reinhart geiser *
+ * ian@geiseri.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "scriptingglobalconfig.h"
+
+#include "scriptingpart.h"
+#include <keditlistbox.h>
+#include <kapplication.h>
+#include <kconfig.h>
+scriptingGlobalConfig::scriptingGlobalConfig(scriptingPart *part, QWidget *parent, const char *name)
+ : scriptingGlobalConfigBase(parent, name), m_part(part)
+{
+ // read kconfig and post list to the m_dirs
+ KConfig *cfg = kapp->config();
+ QStringList searchDirs = cfg->readListEntry("SearchDirs");
+ m_dirs->clear();
+ m_dirs->insertStringList(searchDirs);
+}
+
+void scriptingGlobalConfig::accept()
+{
+ // read mdirs and save to kconfig
+ KConfig *cfg = kapp->config();
+ if( !m_dirs->isEnabled() )
+ cfg->writeEntry("SearchDirs", QStringList() );
+ else
+ cfg->writeEntry("SearchDirs", m_dirs->items() );
+ m_part->setupActions();
+}
+
+#include "scriptingglobalconfig.moc"
diff --git a/parts/scripting/scriptingglobalconfig.h b/parts/scripting/scriptingglobalconfig.h
new file mode 100644
index 00000000..3dd89938
--- /dev/null
+++ b/parts/scripting/scriptingglobalconfig.h
@@ -0,0 +1,41 @@
+/***************************************************************************
+ * Copyright (C) 2005 by ian reinhart geiser *
+ * ian@geiseri.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef SCRIPTING_GLOBAL_CONFIG_H
+#define SCRIPTING_GLOBAL_CONFIG_H
+
+#include "scriptingglobalconfigbase.h"
+
+class scriptingPart;
+
+class scriptingGlobalConfig: public scriptingGlobalConfigBase
+{
+ Q_OBJECT
+public:
+ scriptingGlobalConfig(scriptingPart *part, QWidget *parent = 0, const char *name = 0);
+
+public slots:
+ void accept();
+
+private:
+ scriptingPart *m_part;
+};
+
+#endif
diff --git a/parts/scripting/scriptingglobalconfigbase.ui b/parts/scripting/scriptingglobalconfigbase.ui
new file mode 100644
index 00000000..19647501
--- /dev/null
+++ b/parts/scripting/scriptingglobalconfigbase.ui
@@ -0,0 +1,51 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>scriptingGlobalConfigBase</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>scriptingGlobalConfigBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Scripting</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KEditListBox">
+ <property name="name">
+ <cstring>m_dirs</cstring>
+ </property>
+ <property name="title">
+ <string>Search Custom Directories for Scripts</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;NOTE&lt;/b&gt; These are directories to search in that are found in your KDE resource directories. So if you add the string "kate/scripts" to the list then KScript will look in "$KDEDIRS/data/kate/scripts" for scripts. This will allow you to get scripts in your home directory as well as system wide ones.</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>keditlistbox.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/parts/scripting/scriptingpart.cpp b/parts/scripting/scriptingpart.cpp
new file mode 100644
index 00000000..803f2644
--- /dev/null
+++ b/parts/scripting/scriptingpart.cpp
@@ -0,0 +1,108 @@
+/***************************************************************************
+ * Copyright (C) 2005 by ian reinhart geiser *
+ * ian@geiseri.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "scriptingpart.h"
+
+#include <qtimer.h>
+#include <qpopupmenu.h>
+#include <qwhatsthis.h>
+
+#include <klocale.h>
+#include <kaction.h>
+#include <kdialogbase.h>
+#include <kiconloader.h>
+#include <kmessagebox.h>
+#include <kdevplugininfo.h>
+#include <kdevgenericfactory.h>
+
+#include <kdevcore.h>
+#include <kdevmainwindow.h>
+#include <configwidgetproxy.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include "scriptingglobalconfig.h"
+#include "kscriptactionmanager.h"
+
+typedef KDevGenericFactory<scriptingPart> scriptingFactory;
+KDevPluginInfo data("kdevscripting");
+K_EXPORT_COMPONENT_FACTORY( libkdevscripting, scriptingFactory( data ) )
+
+#define GLOBALDOC_OPTIONS 1
+#define PROJECTDOC_OPTIONS 2
+
+scriptingPart::scriptingPart(QObject *parent, const char *name, const QStringList &/*args*/)
+ : KDevPlugin(&data, parent, name ? name : "scriptingPart"), m_scripts(0L)
+{
+ setInstance(scriptingFactory::instance());
+ setXMLFile("kdevscripting.rc");
+
+ m_configProxy = new ConfigWidgetProxy(core());
+ m_configProxy->createGlobalConfigPage(i18n("Scripting"), GLOBALDOC_OPTIONS, info()->icon());
+ connect(m_configProxy, SIGNAL(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int )),
+ this, SLOT(insertConfigWidget(const KDialogBase*, QWidget*, unsigned int)));
+
+
+
+ QTimer::singleShot(0, this, SLOT(init()));
+}
+
+scriptingPart::~scriptingPart()
+{
+ delete m_configProxy;
+ delete m_scripts;
+}
+
+void scriptingPart::init()
+{
+// delayed initialization stuff goes here
+ m_scripts = new KScriptActionManager(this,actionCollection());
+ setupActions();
+}
+
+void scriptingPart::setupActions()
+{
+ kdDebug() << "Load plugins" << endl;
+ // Read KConfig and get the list of custom directories.
+ QStringList searchDirs;
+ searchDirs += "kate/scripts";
+
+ KConfig *cfg = kapp->config();
+ searchDirs += cfg->readListEntry("SearchDirs");
+
+ unplugActionList(QString::fromLatin1( "script_actions" ));
+ plugActionList( QString::fromLatin1( "script_actions" ), m_scripts->scripts(core(),searchDirs));
+}
+
+void scriptingPart::insertConfigWidget(const KDialogBase *dlg, QWidget *page, unsigned int pageNo)
+{
+// create configuraton dialogs here
+ switch (pageNo)
+ {
+ case GLOBALDOC_OPTIONS:
+ {
+ scriptingGlobalConfig *w = new scriptingGlobalConfig(this, page, "global config");
+ connect(dlg, SIGNAL(okClicked()), w, SLOT(accept()));
+ break;
+ }
+ }
+}
+
+
+#include "scriptingpart.moc"
diff --git a/parts/scripting/scriptingpart.h b/parts/scripting/scriptingpart.h
new file mode 100644
index 00000000..7ebd08b7
--- /dev/null
+++ b/parts/scripting/scriptingpart.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * Copyright (C) 2005 by ian reinhart geiser *
+ * ian@geiseri.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef KDEVSCRIPTING_H
+#define KDEVSCRIPTING_H
+
+#include <kdevplugin.h>
+
+#include <qguardedptr.h>
+
+class QPopupMenu;
+class KAction;
+class KDialogBase;
+class Context;
+class ConfigWidgetProxy;
+class KScriptActionManager;
+/**
+Please read the README.dox file for more info about this part
+*/
+class scriptingPart: public KDevPlugin
+{
+ Q_OBJECT
+public:
+ scriptingPart(QObject *parent, const char *name, const QStringList &args);
+ ~scriptingPart();
+
+ public slots:
+ void setupActions();
+private slots:
+ void init();
+ void insertConfigWidget(const KDialogBase *dlg, QWidget *page, unsigned int pageNo);
+
+
+
+private:
+ ConfigWidgetProxy *m_configProxy;
+ KScriptActionManager *m_scripts;
+};
+
+#endif