summaryrefslogtreecommitdiffstats
path: root/fortune-ml
diff options
context:
space:
mode:
authorPraveen Arimbrathodiyil <pravi.a@gmail.com>2009-05-20 18:06:11 -0700
committerPraveen Arimbrathodiyil <pravi.a@gmail.com>2009-05-20 18:06:11 -0700
commit83cdafaa88657c95f20c9d493d37ccebd86c1b80 (patch)
treef391004005fbe9a1186bdc11748d4a15c2a39d85 /fortune-ml
parent1e1a97cc8c9fddf411e6b2aca307de0b165dac48 (diff)
parent5a2dfd79178371a529053795d90b48dd96421d88 (diff)
downloadAnjaliOldLipi.git-83cdafaa88657c95f20c9d493d37ccebd86c1b80.tar.gz
AnjaliOldLipi.git-83cdafaa88657c95f20c9d493d37ccebd86c1b80.tar.xz
AnjaliOldLipi.git-83cdafaa88657c95f20c9d493d37ccebd86c1b80.zip
Merge branch 'master' of git://git.savannah.nongnu.org/smc
Diffstat (limited to 'fortune-ml')
-rwxr-xr-xfortune-ml/install.sh4
-rw-r--r--fortune-ml/plasmoid/contents/code/configDialog.py41
-rw-r--r--fortune-ml/plasmoid/contents/code/main.py105
-rwxr-xr-xfortune-ml/plasmoid/install.sh9
-rw-r--r--fortune-ml/plasmoid/metadata.desktop18
5 files changed, 175 insertions, 2 deletions
diff --git a/fortune-ml/install.sh b/fortune-ml/install.sh
index 9bd8e00..14d116b 100755
--- a/fortune-ml/install.sh
+++ b/fortune-ml/install.sh
@@ -3,6 +3,6 @@
echo "Compiling...."
strfile fortune-ml fortune-ml.dat
echo "Installing..."
-cp fortune-ml.dat /usr/share/games/fortunes/
-cp fortune-ml /usr/share/games/fortunes/
+cp fortune-ml.dat /usr/share/games/fortune/
+cp fortune-ml /usr/share/games/fortune/
echo "Done...!"
diff --git a/fortune-ml/plasmoid/contents/code/configDialog.py b/fortune-ml/plasmoid/contents/code/configDialog.py
new file mode 100644
index 0000000..a72867a
--- /dev/null
+++ b/fortune-ml/plasmoid/contents/code/configDialog.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'dialog.ui'
+#
+# Created: Wed Apr 1 15:42:08 2009
+# by: PyQt4 UI code generator 4.4.4
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+class Ui_Dialog(object):
+ def setupUi(self, Dialog):
+ Dialog.setObjectName("Dialog")
+ Dialog.resize(400, 300)
+ self.buttonBox = QtGui.QDialogButtonBox(Dialog)
+ self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
+ self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
+ self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
+ self.buttonBox.setObjectName("buttonBox")
+ self.verticalLayoutWidget = QtGui.QWidget(Dialog)
+ self.verticalLayoutWidget.setGeometry(QtCore.QRect(9, 19, 371, 221))
+ self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
+ self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.gridLayout = QtGui.QGridLayout()
+ self.gridLayout.setObjectName("gridLayout")
+ self.chkOffensive = QtGui.QCheckBox(self.verticalLayoutWidget)
+ self.chkOffensive.setObjectName("chkOffensive")
+ self.gridLayout.addWidget(self.chkOffensive, 0, 0, 1, 1)
+ self.verticalLayout.addLayout(self.gridLayout)
+
+ self.retranslateUi(Dialog)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
+ QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
+ QtCore.QMetaObject.connectSlotsByName(Dialog)
+
+ def retranslateUi(self, Dialog):
+ Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
+ self.chkOffensive.setText(QtGui.QApplication.translate("Dialog", "Offensive on ?", None, QtGui.QApplication.UnicodeUTF8))
+
diff --git a/fortune-ml/plasmoid/contents/code/main.py b/fortune-ml/plasmoid/contents/code/main.py
new file mode 100644
index 0000000..096a9d3
--- /dev/null
+++ b/fortune-ml/plasmoid/contents/code/main.py
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+# Author : Ashik Salahudeen <aashiks@gmail.com>
+# Licensed under :
+# ----------------------------------------------------------------------------
+# "THE CAPPUCHINO LICENSE" (Revision 42):
+# <aashiks@gmail.com> wrote this file. You can do whatever you want with this
+# stuff as long as you retain this notice and as long as you agree to give this
+# stuff to whoever wants it. If we meet some day, and you think
+# this stuff is worth it, you can buy me a cappuchino in return -- Aashik
+# ----------------------------------------------------------------------------
+# fortune configs -o for offensive
+# cookie files : from fortune -f
+# maxlength
+#
+
+#TODO : Create a configuration dialogue to handle various config options.
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+from PyKDE4.plasma import Plasma
+from PyKDE4 import plasmascript
+from PyKDE4.kdecore import KProcess
+
+
+class FortuneCookie(plasmascript.Applet):
+
+ # The all important label : This is the only control in our plasmoid
+ label = Plasma.Label
+ mytimer = QTimer
+ process = KProcess
+ fortunecommand="fortune"
+ fortunecookies="fortune-ml"
+ offensive="-o"
+ #Every half an hour
+ mytimeout = 1800000
+ #process =
+ def __init__(self,parent,args=None):
+ plasmascript.Applet.__init__(self,parent)
+
+ def init(self):
+ #There is no configuration dialogue for this applet
+ self.setHasConfigurationInterface(False)
+
+ #This applet will always retain its Initial aspect ratio
+ self.setAspectRatioMode(Plasma.KeepAspectRatio)
+
+ #Get the current theme and use the default background ("widgets/background") and background hints
+ self.theme = Plasma.Svg(self)
+ self.theme.setImagePath("widgets/background")
+ self.setBackgroundHints(Plasma.Applet.DefaultBackground)
+
+ #The applet layout is horizontal
+ self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet)
+ #Create a new label
+ self.label = Plasma.Label(self.applet)
+
+ # Add the label to the layout so it will be displayed
+ self.layout.addItem(self.label)
+ self.setLayout(self.layout)
+
+ # setup the process
+ self.process=KProcess(self)
+ self.process.setShellCommand(self.fortunecommand + " " + self.fortunecookies)
+ self.process.setOutputChannelMode(KProcess.MergedChannels)
+ # When the command outputs something , get it
+ QObject.connect( self.process, SIGNAL("readyReadStandardOutput()"), self.gotsomeoutput );
+
+ #setup timer
+ self.mytimer=QTimer(self)
+ # We don't want this to timeout all by itself..
+ self.mytimer.setSingleShot(True)
+
+ # When the timer times out, execute this
+ QObject.connect(self.mytimer,SIGNAL("timeout()"), self.TimeOut)
+
+ # start the timer
+ self.process.start()
+ self.mytimer.start(self.mytimeout)
+ # Set the default applet size
+ self.resize(180,130)
+
+ def gotsomeoutput(self):
+ outputstring = str(self.process.readAllStandardOutput())
+ self.label.setText(unicode(outputstring,"utf-8"))
+ self.mytimer.start(self.mytimeout)
+
+ def TimeOut(self):
+ # execute the fortune command and get its output
+ if self.process.state() == QProcess.NotRunning:
+ self.process.start()
+ else:
+ return
+
+ # On mouse click , change the quote
+ def mousePressEvent(self, event):
+ print "Test"
+ self.mytimer.start(0)
+
+
+def GetFortuneCookies():
+ #TODO: Get a list of fortunecookies, if any
+ return ""
+ # Start this applet
+def CreateApplet(parent):
+ return FortuneCookie(parent) \ No newline at end of file
diff --git a/fortune-ml/plasmoid/install.sh b/fortune-ml/plasmoid/install.sh
new file mode 100755
index 0000000..a521195
--- /dev/null
+++ b/fortune-ml/plasmoid/install.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+rm ../FortuneCookie.zip
+zip -r ../FortuneCookie.zip .
+plasmapkg -r fortunecookie
+plasmapkg -i ../FortuneCookie.zip
+
+#--- Uncomment the following lines to see the plasmoid in a test cotainer.
+#echo "invoking Plasmoid Viewer..."
+#plasmoidviewer fortunecookie
diff --git a/fortune-ml/plasmoid/metadata.desktop b/fortune-ml/plasmoid/metadata.desktop
new file mode 100644
index 0000000..79d9085
--- /dev/null
+++ b/fortune-ml/plasmoid/metadata.desktop
@@ -0,0 +1,18 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Fortune Cookie
+Name[ml]=ലാത്തിയടി
+Type=Service
+ServiceTypes=Plasma/Applet
+Icon=chronometer
+X-Plasma-API=python
+X-Plasma-MainScript=code/main.py
+X-KDE-PluginInfo-Author=Ashik Salahudeen
+X-KDE-PluginInfo-Email=aashiks@gmail.com
+X-KDE-PluginInfo-Name=fortunecookie
+X-KDE-PluginInfo-Version=0.1
+X-KDE-PluginInfo-Website=http://plasma.kde.org/
+X-KDE-PluginInfo-Category=Multimedia
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=true \ No newline at end of file