/usr/share/pyshared/libavg/app.py is in python-libavg 1.7.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | # libavg - Media Playback Engine.
# Copyright (C) 2003-2011 Ulrich von Zadow
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Current versions can be found at www.libavg.de
#
# Original author of this file is Martin Heistermann <mh at sponc dot de>
#
from libavg import avg
from appstarter import AppStarter
g_Player = avg.Player.get()
g_Log = avg.Logger.get()
class App(object):
_instances = {}
def __init__(self, parentNode):
'''
Initialization before Player.play()
Use this only when needed, e.g. for
WordsNode.addFontDir(). Do not forget to call
super(YourApp, self).__init__(parentNode)
'''
appname = self.__class__.__name__
if appname in AVGApp._instances:
raise RuntimeError('App %s already setup' % appname)
AVGApp._instances[appname] = self
self.__isRunning = False
self._parentNode = parentNode
self._starter = None
if 'onKey' in dir(self):
raise DeprecationWarning, \
'AVGApp.onKey() has been renamed to AVGApp.onKeyDown().'
@classmethod
def get(cls):
'''
Get the Application instance
Note: this class method has to be called from the top-level app class:
>>> class MyApp(libavg.AVGApp):
... pass
>>> instance = MyApp.get()
'''
return cls._instances.get(cls.__name__, None)
@classmethod
def start(cls, appStarter=AppStarter, **kwargs):
appStarter(appClass=cls, **kwargs)
def init(self):
"""main initialization
build node hierarchy under self.__parentNode."""
pass
def exit(self):
"""Deinitialization
Called after player.play() returns. End of program run."""
pass
def _enter(self):
"""enter the application, internal interface.
override this and start all animations, intervals
etc. here"""
pass
def _leave(self):
"""leave the application, internal interface.
override this and stop all animations, intervals
etc. Take care your application does not use any
non-needed resources after this."""
pass
def enter(self, onLeave = lambda: None):
"""enter the application, external interface.
Do not override this."""
self.__isRunning = True
self._onLeave = onLeave
self._enter()
def leave(self):
"""leave the application, external interface.
Do not override this."""
self.__isRunning = False
self._onLeave()
self._leave()
def onKeyDown(self, event):
"""returns bool indicating if the event was handled
by the application """
return False
def onKeyUp(self, event):
"""returns bool indicating if the event was handled
by the application """
return False
def isRunning(self):
return self.__isRunning
def setStarter(self, starter):
self._starter = starter
def getStarter(self):
return self._starter
class AVGApp(App):
'''Backward compatibility class'''
multitouch = False
fakeFullscreen = False
@classmethod
def start(cls, **kwargs):
# TODO: deprecation warning
if cls.multitouch:
from appstarter import AVGMTAppStarter
starter = AVGMTAppStarter
else:
from appstarter import AVGAppStarter
starter = AVGAppStarter
super(AVGApp, cls).start(appStarter=starter,
fakeFullscreen=cls.fakeFullscreen, **kwargs)
|