[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kate
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2005-03-17 17:22:19
Message-ID: 20050317172219.3DED817B90 () office ! kde ! org
[Download RAW message or body]

CVS commit by cullmann: 

read the desktop files for the scripts files
still no caching, first this has to work out ;)
command name + help test read, missing is atm way to disable the command + the gui
integration, perhaps anders has ideas for gui stuff


  A            scripts/jstest.desktop   1.1
  M +35 -3     part/katejscript.cpp   1.21
  M +19 -1     part/katejscript.h   1.7
  M +1 -1      scripts/Makefile.am   1.2


--- kdelibs/kate/part/katejscript.cpp  #1.20:1.21
@@ -494,5 +494,25 @@ void KateJScriptManager::collectScripts 
       if (dfi.exists())
       {
+        KConfig df (desktopFile, true, false);
+        df.setDesktopGroup ();
+
+        // get cmdname, fallback to baseName, if it is empty, therefor not use the kconfig fallback
+        QString cmdname = df.readEntry ("X-Kate-Command");
+        if (cmdname.isEmpty())
+        {
+          QFileInfo fi (*it);
+          cmdname = fi.baseName();
+        }
+
+        if (m_scripts[cmdname])
+          continue;
+
+        KateJScriptManager::Script *s = new KateJScriptManager::Script ();
+
+        s->name = cmdname;
+        s->filename = *it;
+        s->desktopFileExists = true;
 
+        m_scripts.insert (s->name, s);
       }
       else // no desktop file around, fall back to scriptfilename == commandname
@@ -509,4 +529,5 @@ void KateJScriptManager::collectScripts 
         s->name = fi.baseName();
         s->filename = *it;
+        s->desktopFileExists = false;
 
         m_scripts.insert (s->name, s);
@@ -519,5 +540,5 @@ void KateJScriptManager::collectScripts 
 }
 
-bool KateJScriptManager::exec( class Kate::View *view, const QString &_cmd, QString &errorMsg )
+bool KateJScriptManager::exec( Kate::View *view, const QString &_cmd, QString &errorMsg )
 {
   // cast it hardcore, we know that it is really a kateview :)
@@ -561,7 +582,18 @@ bool KateJScriptManager::exec( class Kat
 }
 
-bool KateJScriptManager::help( class Kate::View *, const QString &, QString & )
+bool KateJScriptManager::help( Kate::View *, const QString &cmd, QString &msg )
 {
+  if (!m_scripts[cmd] || !m_scripts[cmd]->desktopFileExists)
+    return false;
+
+  KConfig df (m_scripts[cmd]->desktopFilename(), true, false);
+  df.setDesktopGroup ();
+
+  msg = df.readEntry ("X-Kate-Help");
+
+  if (msg.isEmpty())
   return false;
+
+  return true;
 }
 

--- kdelibs/kate/part/katejscript.h  #1.6:1.7
@@ -102,6 +102,24 @@ class KateJScriptManager : public Kate::
     {
       public:
+        QString desktopFilename ()
+        {
+          return filename.left(filename.length()-2).append ("desktop");
+        }
+
+      public:
+        /**
+         * command name, as used for command line and more
+         */
         QString name;
+
+        /**
+         * filename of the script
+         */
         QString filename;
+
+        /**
+         * has it a desktop file?
+         */
+        bool desktopFileExists;
     };
 
@@ -126,5 +144,5 @@ class KateJScriptManager : public Kate::
     bool exec( class Kate::View *view, const QString &cmd, QString &errorMsg );
 
-    bool help( class Kate::View *, const QString &, QString & );
+    bool help( class Kate::View *view, const QString &cmd, QString &msg );
 
     /**

--- kdelibs/kate/scripts/Makefile.am  #1.1:1.2
@@ -1,2 +1,2 @@
 scriptskatedir = $(kde_datadir)/katepart/scripts
-scriptskate_DATA = jstest.js
+scriptskate_DATA = jstest.desktop jstest.js


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic