]> jfr.im git - irc/kvirc/kvirc-scripts.git/commitdiff
Addonize the newsticker
authorSzymon Tomasz Stefanek <redacted>
Thu, 24 Mar 2011 23:35:58 +0000 (23:35 +0000)
committerSzymon Tomasz Stefanek <redacted>
Thu, 24 Mar 2011 23:35:58 +0000 (23:35 +0000)
newsticker/INSTALL [deleted file]
newsticker/install.kvs
newsticker/makedist.sh [deleted file]
newsticker/src/actions.kvs
newsticker/src/configuration.kvs
newsticker/src/qtwrapper.kvs
newsticker/utils/installer.kvs [deleted file]

diff --git a/newsticker/INSTALL b/newsticker/INSTALL
deleted file mode 100644 (file)
index fbb9bbc..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Installation :
---------------
- 1. Ctrl-Alt-M to open the addon manager
- 2. Click on "Install an addon"
- 3. Choose the file "install.kvs" where unzipped the addon
- 4. Then it should be installed, and configurable using the "Configuration" button
index 1df690cf959c776beba7a7345b2e772aca2afba9..66139b907a99f696c37e37f31a8db6963cb00ff6 100644 (file)
@@ -4,11 +4,38 @@
 
 # register the script: this must be the first instruction executed
 # since it will abort with an error when a greater version is already installed
-addon.register("newsticker","1.2.0",$tr("Newsticker: The RSS News Reader","newsticker"),$tr("Displays RSS news feeds from various sources","newsticker"),"3.2.0.99.20051230",newsticker_32.png)
+addon.register(
+               "newsticker",
+               "1.2.0",
+               $tr("Newsticker: The RSS News Reader","newsticker"),
+               $tr("Displays RSS news feeds from various sources","newsticker"),
+               "4.0.4",
+               newsticker_32.png
+       )
 {
        # This is our uninstall callback: it will be called by KVIrc when addon.uninstall is invoked
        
-       newsticker::core::uninstall
+       # The stuff should be destroyed in reverse order, if possible.
+       
+       # Close any running instance
+       newsticker::close
+       
+       # Kill aliases
+       alias("newsticker::close"){}
+       alias("newsticker::show"){}
+       
+       # Kill actions
+       action.destroy "newsticker::toggle";
+       
+       # Kill classes (reversed order)
+       objects.killClass -q "newsticker::window"
+       objects.killClass -q "newsticker::configuration"
+       objects.killClass -q "newsticker::controller"
+       objects.killClass -q "newsticker::qtwrapper"
+       objects.killClass -q "newsticker::source"
+       objects.killClass -q "newsticker::rss::reader"
+       objects.killClass -q "newsticker::rss::entrylist"
+       objects.killClass -q "newsticker::rss::entry"
 }
 
 addon.setconfigurecallback(newsticker)
@@ -20,34 +47,30 @@ addon.setconfigurecallback(newsticker)
 # Ok, addon.register succeeded. We can go on with the installation.
 
 # get the installer helper class (this is pretty standard and included in the distro)
-include "utils/installer.kvs"
 
 # Get the path that this script was launched from
 %mypath = $file.extractPath($0)
 //%mypath = $str.lefttolast($0,/)
-# The installer will copy our files and generate automatically
-# an uninstallation alias for them
-%installer = $new(installer,0,myinstaller)
-# copy files in each subdirectory
-# the pics
-%installer->$copyFiles("%mypath/pics/","*.png",$file.localdir("pics"))
-# the translations
-#%installer->$copyFiles("%mypath/locale/","*.mo",$file.localdir("locale"))
-# the documentation
-#%installer->$copyFiles("%mypath/help/en/newsticker/","*.html",$file.localdir("help/en/newsticker"))
-# parse source files
-%installer->$includeFiles("%mypath/src/","*.kvs")
-# then generate the uninstall alias
-%installer->$generateUninstallAlias("newsticker::core::uninstall")
-# finally kill the installer helper
-delete %installer
-
-# fetch the complete script
-//include "src/main.kvs"
 
+addon.copyfiles "newsticker" "pics" "%mypath/pics/*.png"
+addon.copyfiles "newsticker" "locale" "%mypath/locale/*.mo"
+addon.copyfiles "newsticker" "help" "%mypath/help/en/newsticker/*.html"
+
+parse "%mypath/src/rssentry.kvs"
+parse "%mypath/src/rssentrylist.kvs"
+parse "%mypath/src/rssreader.kvs"
+parse "%mypath/src/source.kvs"
+parse "%mypath/src/qtwrapper.kvs"
+parse "%mypath/src/configuration.kvs"
+parse "%mypath/src/controller.kvs"
+parse "%mypath/src/window.kvs"
+
+parse "%mypath/src/aliases.kvs"
+parse "%mypath/src/actions.kvs"
 
 # make sure any previous instance is closed
 newsticker::close
+
 # show it up :)
 newsticker::show
 
diff --git a/newsticker/makedist.sh b/newsticker/makedist.sh
deleted file mode 100755 (executable)
index 53fccac..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-# Version of the script
-version="1.1.0"
-
-# Choose the file types you want to include
-filetypes='*.kvs *.png *.po'
-
-#################################################3
-
-test ! -f install.kvs && echo Bad directory && exit
-
-test -z "$(grep '"'$version'"' install.kvs)" && echo "Wrong version ($version)" && exit
-
-dir=$(pwd)
-name=$(basename $dir)-$version
-
-\rm -rf $name*
-mkdir $name
-for file in INSTALL README AUTHORS FAQ ; do
-       test -f $file && cp $file $name
-done
-
-for itype in $(seq 1 $(echo $filetypes | wc -w)) ; do
-       for file in $(find . -name "$(echo "$filetypes" | cut -d" " -f$itype)" -print) ; do
-               dir=$name/$(dirname $file| cut -c3-)
-               mkdir -p $dir
-               cp -f $file $dir
-       done
-done
-
-zip -r $name.zip $name
-\rm -r $name
-               
-
index f1687c6680c998bd9125579f473e9abfd2fdb8c6..3e012ca0f55bcc6af5af6f578e5d16c4d6ce98f2 100644 (file)
@@ -1,4 +1,10 @@
-action.create -t="tools" (newsticker::toggle,$tr("Show Newsticker","newsticker"),$tr("Shows the Newsticker Window","newsticker"),"newsticker_32.png","newsticker_16.png")
+action.create -t="tools" (
+               "newsticker::toggle",
+               $tr("Show Newsticker","newsticker"),
+               $tr("Shows the Newsticker Window","newsticker"),
+               "newsticker_32.png",
+               "newsticker_16.png"
+       )
 {
        newsticker::show
 }
index 3823b079f2c90146499e8b5cec3c66a4039e47f9..d2b67d1e2a4081ad92617fc939a8f2f5bd9901b5 100644 (file)
@@ -2,8 +2,10 @@ class(newsticker::core::configuration::sourceeditor,dialog)
 {
        constructor()
        {
-               if ($str.contains($features(),"QT4"))@$setWindowTitle($tr("Edit source","newsticker"))
-                 else @$setWindowTitle($tr("Edit source","newsticker"))
+               if ($str.contains($features(),"QT4"))
+                       @$setWindowTitle($tr("Edit source","newsticker"))
+               else
+                       @$setWindowTitle($tr("Edit source","newsticker"))
                %l = $new(layout,$this)
 
                %lb = $new(label,$this)
index 84f0f41cb8ccf9dfe13c15e43179772aa88f4aba..8441ca25f6b7a8a76636403ef01b326c3d68b09c 100644 (file)
@@ -2,8 +2,10 @@ class(listviewwrapper,listview)
 {
        constructor()
        {
-               if ($str.contains($features(),"QT4")) {@%qt4=$true;@%idx=0;}
-               else @%qt4=$false
+               if ($str.contains($features(),"QT4"))
+                       {@%qt4=$true;@%idx=0;}
+               else
+                       @%qt4=$false
        
        }
        selectedItem()
diff --git a/newsticker/utils/installer.kvs b/newsticker/utils/installer.kvs
deleted file mode 100644 (file)
index e6221a2..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-        A helper class for installing and parsing files,
-        and generating an uninstallation alias on the fly.
-
-       Example :
-       include "utils/installer.kvs"
-       %installer = $new(installer,0,myinstaller)
-       %installer->$copyFiles(pics,*.png,$file.localdir(pics))
-       %installer->$includeFiles(src,*.kvs)
-       %installer->generateUninstallAlias("foo::uninstall")
-       delete %installer
-*/
-class(installer,object)
-{
-       constructor()
-       {
-       }
-       
-       copyFiles($0 = source dir,$1 = file regexp,$2 = target dir)
-       {
-               if(!$file.exists($0))return
-               if($isempty($0))
-               {
-                       echo "[Installer] SCRIPT BUG: The first argument to installer_copyfiles must be a source directory"
-                       halt
-               }
-       
-               if($isempty($1))
-               {
-                       echo "[Installer] SCRIPT BUG: The second argument to installer_copyfiles must be a file name or file regexp"
-                       halt
-               }
-       
-               if($isempty($2))
-               {
-                       echo "[Installer] SCRIPT BUG: The third argument to installer_copyfiles must be a destination directory"
-                       halt
-               }
-       
-               if($file.exists($0))
-               {
-                       %files = $file.ls($file.fixpath($0),f,$1)
-                       if($length(%files))
-                       {
-                               file.mkdir $2
-                               foreach(%file,%files)
-                               {
-                                       $this->%lFiles <+ $str.replace($file.fixpath("$2/%file"),"\\","\\\\")
-                                       file.copy -o $file.fixpath($0/%file) $file.fixpath($2/%file)
-                               }
-                       }
-               }
-       }
-
-       // warning: this function includes files in a substantially random order
-       includeFiles($0 = dir, $1 = file regexp)
-       {
-               if($isempty($0) || !$file.exists($0))
-               {
-                       echo "[Installer] SCRIPT BUG: The first argument to installer_includefiles must be a source directory"
-                       halt
-               }
-       
-               if($1 == "")
-                       %szRe = "*.kvs"
-               else
-                       %szRe = $1
-
-               %files = $file.ls($file.fixpath($0),f,$1)
-               if($length(%files))
-               {
-                       foreach(%file,%files)
-                       {
-                               $this->%lSources <+ $str.replace($file.fixpath("$0/%file"),"\\","\\\\")
-                               include $file.fixpath("$0/%file")
-                       }
-               }
-       }
-               
-       
-       generateUninstallAlias($0 = alias name)
-       {
-               %c  = "alias($0)$lf"
-               %c .= "{$lf"
-               if($isset($this->%lFiles))
-               {
-                       foreach(%file,$this->%lFiles)
-                       {
-                               %file =~ s/"^$file.localdir()/(.*)$"/"\$file.localdir(\\1)"/
-                               %c .= " file.remove -q \"%file\"$lf";
-                       }
-               }
-               if($isset($this->%lSources))
-               {
-                       foreach(%file,$this->%lSources){
-                               foreach(%line,$file.readlines(%file))
-                               if(!$str.isempty(%line)){
-                                       if($str.match("event(*)",%line,e))
-                                               %c .= " event -q ("$str.token(1,"()",%line)"){}$lf"
-                                       else if($str.match("alias(*)",%line,e))
-                                               %aliases<+$str.token(1,"()",%line)
-                                       else if($str.match("defpopup(*)",%line,e))
-                                               %c .= " defpopup("$str.token(1,"()",%line)"){}$lf"
-                                       else if($str.match("toolbar.create * *",%line,e))
-                                               %c .= " toolbar.destroy -q "$str.word(1,%line)"$lf"
-                                       else if($str.match("action.create* (*)",%line,e))
-                                               %c .= " action.destroy -q "$str.replace($str.token(1,"(,)",%line),\",)"$lf"
-                                       else if($str.match("class(*)*",%line,e))
-                                               %c .= " objects.killclass -q "$str.token(1,"(,)",%line)"$lf"
-                               }
-                       }
-                       if($isset(%aliases))
-                               foreach(%alias,%aliases)
-                                       %c .= " alias -q (%alias){}$lf"
-                       %c .= " alias -q ($0){}$lf"
-               }
-               %c .= "}"
-               eval %c
-       }
-}
-
-
-