~ubuntu-branches/ubuntu/trusty/libavg/trusty-proposed

« back to all changes in this revision

Viewing changes to src/python/AVGApp.py

  • Committer: Package Import Robot
  • Author(s): OXullo Intersecans
  • Date: 2011-12-06 22:44:56 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20111206224456-qc7250z3ya1vi8s9
Tags: 1.7.0-0ubuntu1
* New upstream release (LP: #899183)
* Remove patches 0002-libav-0.7.patch, 0003-fglrx-segfault-on-startup.patch
  now merged to upstream
* Remove unnecessary .la files
* Update debian/watch file
* Fix debian/copyright dep-5 compliancy
* Update standards to version 3.9.2
* Add man pages for avg_checktouch, avg_checkvsync, avg_showsvg
* Minor debian/rules enhancement
* Add librsvg2-dev, libgdk-pixbuf2.0-dev to Build-Depends
* Proper transition to dh_python2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# libavg - Media Playback Engine.
2
 
# Copyright (C) 2003-2008 Ulrich von Zadow
3
 
#
4
 
# This library is free software; you can redistribute it and/or
5
 
# modify it under the terms of the GNU Lesser General Public
6
 
# License as published by the Free Software Foundation; either
7
 
# version 2 of the License, or (at your option) any later version.
8
 
#
9
 
# This library is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
# Lesser General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU Lesser General Public
15
 
# License along with this library; if not, write to the Free Software
16
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
#
18
 
# Current versions can be found at www.libavg.de
19
 
#
20
 
# Original author of this file is Martin Heistermann <mh at sponc dot de>
21
 
#
22
 
 
23
 
import os
24
 
from libavg import avg
25
 
g_Player = avg.Player.get()
26
 
g_Log = avg.Logger.get()
27
 
 
28
 
try:
29
 
    from win32gui import *
30
 
    from win32con import *
31
 
    from win32api import *
32
 
    g_WIN32 = True
33
 
except:
34
 
    g_WIN32 = False
35
 
 
36
 
class AVGApp(object):
37
 
    multitouch = False
38
 
    fakeFullscreen = False
39
 
    def __init__(self, parentNode):
40
 
        """initialization before Player.play()
41
 
        Use this only when needed, e.g. for
42
 
        WordsNode.addFontDir(). Do not forget to call
43
 
        super(YourApp, self).__init__(parentNode)"""
44
 
        self.__isRunning = False
45
 
        self._parentNode = parentNode
46
 
        self._starter = None
47
 
        avg.appInstance = self
48
 
 
49
 
        if 'onKey' in dir(self):
50
 
            raise DeprecationWarning, \
51
 
                    'AVGApp.onKey() has been renamed to AVGApp.onKeyDown().'
52
 
 
53
 
    def init(self):
54
 
        """main initialization
55
 
        build node hierarchy under self.__parentNode."""
56
 
        pass
57
 
 
58
 
    def exit(self):
59
 
        """Deinitialization
60
 
        Called after player.play() returns. End of program run."""
61
 
        pass
62
 
 
63
 
    def _enter(self):
64
 
        """enter the application, internal interface.
65
 
        override this and start all animations, intervals
66
 
        etc. here"""
67
 
        pass
68
 
 
69
 
    def _leave(self):
70
 
        """leave the application, internal interface.
71
 
        override this and stop all animations, intervals
72
 
        etc. Take care your application does not use any
73
 
        non-needed resources after this."""
74
 
        pass
75
 
 
76
 
    def enter(self, onLeave = lambda: None):
77
 
        """enter the application, external interface.
78
 
        Do not override this."""
79
 
        self.__isRunning = True
80
 
        self._onLeave = onLeave
81
 
        self._enter()
82
 
 
83
 
    def leave(self):
84
 
        """leave the application, external interface.
85
 
        Do not override this."""
86
 
        self.__isRunning = False
87
 
        self._onLeave()
88
 
        self._leave()
89
 
 
90
 
    def onKeyDown(self, event):
91
 
        """returns bool indicating if the event was handled
92
 
        by the application """
93
 
        return False
94
 
 
95
 
    def onKeyUp(self, event):
96
 
        """returns bool indicating if the event was handled
97
 
        by the application """
98
 
        return False
99
 
 
100
 
    def isRunning(self):
101
 
        return self.__isRunning
102
 
 
103
 
    def setStarter(self, starter):
104
 
        self._starter = starter
105
 
 
106
 
    def getStarter(self):
107
 
        return self._starter
108
 
        
109
 
    @classmethod   
110
 
    def __findWindow(cls, title):
111
 
        def enumWinProc(h, lparams): 
112
 
            lparams.append(h)
113
 
        winList=[]
114
 
        EnumWindows(enumWinProc, winList)
115
 
        for hwnd in winList:
116
 
            curTitle = GetWindowText(hwnd)
117
 
            if IsWindowVisible(hwnd) and title == curTitle:
118
 
                return hwnd
119
 
        return None
120
 
        
121
 
    @classmethod
122
 
    def __fakeFullscreen(cls):
123
 
        hDesk = GetDesktopWindow()
124
 
        (DesktopLeft, DesktopTop, DesktopRight, DesktopBottom) = GetWindowRect(hDesk)
125
 
        w = cls.__findWindow("AVG Renderer")
126
 
        offSetX = 2
127
 
        offSetY = 3
128
 
        SetWindowPos(w, HWND_TOP, -(GetSystemMetrics(SM_CYBORDER)+offSetX), 
129
 
                -(GetSystemMetrics(SM_CYCAPTION)+offSetY), 
130
 
                DesktopRight, DesktopBottom+30, 0)
131
 
        
132
 
    @classmethod
133
 
    def start(cls, *args, **kwargs):
134
 
        from AVGAppStarter import AVGAppStarter
135
 
        from AVGMTAppStarter import AVGMTAppStarter
136
 
        if cls.multitouch:
137
 
            starter = AVGMTAppStarter
138
 
        else:
139
 
            starter = AVGAppStarter
140
 
        cls.avg_deploy = os.getenv("AVG_DEPLOY")
141
 
 
142
 
        if cls.fakeFullscreen and cls.avg_deploy is not None:
143
 
            if g_WIN32:
144
 
                g_Player.setTimeout(1000,cls.__fakeFullscreen)
145
 
            else:
146
 
                g_Log.trace(g_Log.ERROR, 'fakeFullscreen works only on Windows')           
147
 
        starter(appClass = cls, *args, **kwargs)
148