diff options
author | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-04-03 20:07:37 +0530 |
---|---|---|
committer | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-04-03 20:07:37 +0530 |
commit | 72c573f631823558358128e9133da713e350f44d (patch) | |
tree | 3932c0df7874f1a05996ebd8184b480e57938c7e /fortune-ml | |
parent | 63d858b32fd8f24649f2afda0786f7d380f7d04b (diff) | |
download | Suruma.git-72c573f631823558358128e9133da713e350f44d.tar.gz Suruma.git-72c573f631823558358128e9133da713e350f44d.tar.xz Suruma.git-72c573f631823558358128e9133da713e350f44d.zip |
Fortune Malayalam Plasmoid by Ashik
Diffstat (limited to 'fortune-ml')
-rw-r--r-- | fortune-ml/plasmoid/contents/code/configDialog.py | 41 | ||||
-rw-r--r-- | fortune-ml/plasmoid/contents/code/main.py | 105 | ||||
-rwxr-xr-x | fortune-ml/plasmoid/install.sh | 7 | ||||
-rw-r--r-- | fortune-ml/plasmoid/metadata.desktop | 18 |
4 files changed, 171 insertions, 0 deletions
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..42f4ca5 --- /dev/null +++ b/fortune-ml/plasmoid/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash +rm ../FortuneCookie.zip +zip -r ../FortuneCookie.zip . +plasmapkg -r fortunecookie +plasmapkg -i ../FortuneCookie.zip +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 |