• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • interfaces
 

interfaces

  • interfaces
  • tdescript
scriptloader.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2001 Ian Reinhart Geiser (geiseri@kde.org)
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #include "scriptloader.h"
20 
21 #include <tdeapplication.h>
22 #include <tdeparts/part.h>
23 #include <tdeparts/componentfactory.h>
24 #include <tdeglobal.h>
25 #include <tdelocale.h>
26 #include <tdeconfig.h>
27 #include <kdesktopfile.h>
28 #include <kstandarsdirs.h>
29 #include <tdestdaccel.h>
30 #include <kdebug.h>
31 
32 #include <tqdir.h>
33 #include <tqfileinfo.h>
34 
35 
36 ScriptLoader::ScriptLoader(TDEMainWindow *parent) : TQObject (parent)
37 {
38  m_parent = parent;
39  m_scripts.clear();
40  m_theAction = new TDESelectAction ( i18n("TDE Scripts"),
41  0,
42  this,
43  TQT_SLOT(runAction()),
44  m_parent->actionCollection(),
45  "scripts");
46 }
47 
48 ScriptLoader::~ScriptLoader()
49 {
50  // Clean out the list
51  m_scripts.clear();
52 }
53 
54 TDESelectAction * ScriptLoader::getScripts()
55 {
56  // Get the available scripts for this application.
57  TQStringList pluginList = "";
58  // Find plugins
59  TQString searchPath = kapp->name();
60  searchPath += "/scripts/";
61  TQDir d(locate( "data", searchPath));
62  kdDebug() << "loading plugin from " << locate( "data", searchPath) << endl;
63  const QFileInfoList *fileList = d.entryInfoList("*.desktop");
64  QFileInfoListIterator it ( *fileList );
65  TQFileInfo *fi;
66  // Find all available script desktop files
67  while( (fi=it.current()))
68  {
69  // Query each desktop file
70  if(KDesktopFile::isDesktopFile(fi->absFilePath()))
71  {
72  KDesktopFile desktop((fi->absFilePath()), true);
73  kdDebug () << "Trying to load script type: " << desktop.readType() << endl;
74  KScriptInterface *tmpIface = KParts::ComponentFactory::createInstanceFromQuery<KScriptInterface>(desktop.readType() );
75  if( tmpIface != 0 )
76  {
77  m_scripts.append(tmpIface);
78  m_scripts.current()->setScript(desktop.readURL());
79  //if(m_parent != 0)
80  //m_scripts.current()->setParent(m_parent);
81  pluginList.append(desktop.readName());
82  }
83  else
84  kdDebug() << desktop.readName() << " could not be loaded!" << endl;
85  }
86  ++it;
87  }
88  m_theAction->clear();
89  m_theAction->setItems(pluginList);
90  return m_theAction;
91 }
92 
93 void ScriptLoader::runAction()
94 {
95  TQString scriptName = m_theAction->currentText();
96 
97 }
98 
99 void ScriptLoader::stopAction()
100 {
101 
102 }
103 
104 #include "scriptloader.moc"
KDesktopFile::readURL
TQString readURL() const
kdDebug
kdbgstream kdDebug(int area=0)
ScriptLoader::stopAction
void stopAction()
Stop the currently running scripts operations.
Definition: scriptloader.cpp:99
TDEMainWindow
KDesktopFile::readType
TQString readType() const
tdelocale.h
ScriptLoader::ScriptLoader
ScriptLoader(TDEMainWindow *parent=0)
Default Constructor.
Definition: scriptloader.cpp:36
TDESelectAction
KDesktopFile
TDESelectAction::currentText
virtual TQString currentText() const
ScriptLoader::getScripts
TDESelectAction * getScripts()
Return the a TDESelectAction with all of the scripts.
Definition: scriptloader.cpp:54
endl
kndbgstream & endl(kndbgstream &s)
ScriptLoader::runAction
void runAction()
Run the current action.
Definition: scriptloader.cpp:93
locate
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
KDesktopFile::readName
TQString readName() const
KScriptInterface
This class is the base for all script engines.
Definition: scriptinterface.h:47
KDesktopFile::isDesktopFile
static bool isDesktopFile(const TQString &path)

interfaces

Skip menu "interfaces"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

interfaces

Skip menu "interfaces"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for interfaces by doxygen 1.8.8
This website is maintained by Timothy Pearson.