Skip to content

Commit

Permalink
added morning/afternoon timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Kulik committed Apr 8, 2009
1 parent 3990786 commit 52ab7b2
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions contents/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from PyKDE4.kio import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
from editor import Editor
# import os
# from editor import Editor
import random
import dbus

class RubytimeApplet(plasmascript.Applet):
Expand Down Expand Up @@ -65,6 +65,17 @@ def init(self):
self.connect(self.icon, SIGNAL("clicked()"), self.notifyMe)
self.resize(128, 128)

# setup morning notifications
self.morningTimer = QTimer(self)
self.connect(self.morningTimer, SIGNAL("timeout()"), self.morningCheck)
self.morningTimer.start(10000)

# setup morning notifications
self.afternoonTimer = QTimer(self)
self.connect(self.afternoonTimer, SIGNAL("timeout()"), self.afternoonCheck)
self.afternoonTimer.start(20000)
pass

def contextualActions(self):
return []

Expand All @@ -74,6 +85,16 @@ def paintInterface(self, painter, option, rect):
def constraintsEvent(self, constraints):
pass

def morningCheck(self):
self.morningTimer.stop()
self.sendNotification("<html><b>Morning!</b><br/>Did you fill Rubytime for yesterday?</html>")
pass

def afternoonCheck(self):
self.afternoonTimer.stop()
self.sendNotification("<html><b>Good afternoon!</b><br/>Don't forget to add today's activities to Rubytime.</html>")
pass

#def createConfigurationInterface(self, parent):
# self.editor = Editor(self.entries)
# p = parent.addPage(self.editor, ki18n("Rules").toString() )
Expand All @@ -90,11 +111,12 @@ def constraintsEvent(self, constraints):
# dialog.exec_()

def notifyMe(self):
self.sendNotification('Please don\'t forget to add today\'s activities to Rubytime!')
self.sendNotification('Icon clicked, yay!')
pass

def sendNotification(self, body):
self.notifications.Notify('rubytime-plasmoid', 0, 'someid', 'folder-red', 'Rubytime', body, [], [], 0, dbus_interface='org.kde.VisualNotifications')
self.notifications.Notify('rubytime-plasmoid', 0, "someid", 'folder-red', 'Rubytime', body, [], [], 0, dbus_interface='org.kde.VisualNotifications')
#self.notifications.Notify('rubytime-plasmoid', 0, str(random.random() * 10), 'folder-red', 'Rubytime', body, [], [], 0, dbus_interface='org.kde.VisualNotifications')
pass

def mousePressEvent(self, event):
Expand Down

0 comments on commit 52ab7b2

Please sign in to comment.