summaryrefslogtreecommitdiff
path: root/timer-applet/src/timerapplet/ui/PulseButton.py
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-30 16:04:57 +0100
committerStefano Karapetsas <[email protected]>2014-01-30 16:04:57 +0100
commit8795f06d464700494234e589020e5e29854aeb8c (patch)
treef2525b646023e533f03d5c80240563b89ab5b152 /timer-applet/src/timerapplet/ui/PulseButton.py
parentc8a85a6aa040c1d2505b957af4cfb4bd39466504 (diff)
parent064212a25bea1fcf8901cd0a1d55aae0899f627c (diff)
downloadmate-applets-8795f06d464700494234e589020e5e29854aeb8c.tar.bz2
mate-applets-8795f06d464700494234e589020e5e29854aeb8c.tar.xz
Merge branch 'dev-timer-applet'
Closes #45 https://github.com/mate-desktop/mate-applets/issues/45
Diffstat (limited to 'timer-applet/src/timerapplet/ui/PulseButton.py')
-rw-r--r--timer-applet/src/timerapplet/ui/PulseButton.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/timer-applet/src/timerapplet/ui/PulseButton.py b/timer-applet/src/timerapplet/ui/PulseButton.py
deleted file mode 100644
index 9694ea48..00000000
--- a/timer-applet/src/timerapplet/ui/PulseButton.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright (C) 2008 Jimmy Do <[email protected]>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import math
-import time
-import gobject
-import gtk
-
-class PulseButton(gtk.Button):
- def __init__(self):
- super(PulseButton, self).__init__()
-
- self._anim_period_seconds = 0.7
- self._start_time = 0.0
- self._factor = 0.0
-
- def start_pulsing(self):
- self._start_time = time.time()
- gobject.timeout_add(10, self._on_timeout)
-
- def stop_pulsing(self):
- self._start_time = 0
-
- def _on_timeout(self, data=None):
- if self._start_time <= 0.0:
- return False
- if self.window != None:
- delta = time.time() - self._start_time
-
- if delta > self._anim_period_seconds:
- delta = self._anim_period_seconds
- self._start_time = time.time()
- fraction = delta/self._anim_period_seconds
- self._factor = math.sin(fraction * math.pi)
-
- self.window.invalidate_rect(self.allocation, True)
- return True
-
- def do_expose_event(self, event):
- gtk.Button.do_expose_event(self, event)
- if self._start_time > 0:
- context = event.window.cairo_create()
- context.rectangle(0, 0, self.allocation.width, self.allocation.height)
-
- #color = self.style.bg[gtk.STATE_SELECTED]
- #color = gtk.gdk.Color(65535, 65535, 65535)
- color = gtk.gdk.Color(0, 0, 0)
- red = color.red / 65535.0
- green = color.green / 65535.0
- blue = color.blue / 65535.0
- context.set_source_rgba(red, green, blue, self._factor * 0.8)
- context.fill()
-
- return False
-
-gobject.type_register(PulseButton)