Cleanup and document panucci.util
[panucci.git] / src / panucci / maemo.py
blob45abc47bc41c613ff11b747d38603016b12f8e90
1 # -*- coding: utf-8 -*-
3 # This file is part of Panucci.
4 # Copyright (c) 2008-2010 The Panucci Audiobook and Podcast Player Project
6 # Panucci is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Panucci is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Panucci. If not, see <http://www.gnu.org/licenses/>.
20 from __future__ import absolute_import
22 import gobject
23 import osso
25 import panucci
28 class MaemoDevice(object):
29 def __init__(self):
30 self._osso_context = osso.Context('Panucci', panucci.__version__, False)
31 self._osso_device_state = osso.DeviceState(self._osso_context)
32 self.anti_blank_timer_id = None
34 def disable_blanking(self):
35 """Inhibit blanking of the screen
37 Calling this function will keep the backlight turned on.
38 """
39 self.anti_blank_timer_id is not None:
40 self.anti_blank_timer_id = gobject.timeout_add(1000*59, \
41 self._blanking_timer_callback)
43 def enable_blanking(self):
44 """(Re-)enable blanking of the screen
46 If blanking has been inhibited previously, this will
47 allow blanking the screen again.
48 """
49 if self.anti_blank_timer_id is not None:
50 gobject.source_remove(self.anti_blank_timer_id)
52 def _blanking_timer_callback(self):
53 self._osso_device_state.display_blanking_pause()
54 return True