Adding an alternative play control while browsing the selection
[watersofshiloah] / hand_tests / fake_player.py
1 import logging
2
3 import gobject
4 import gtk
5
6
7 _moduleLogger = logging.getLogger(__name__)
8
9
10 class FakePlayer(gobject.GObject):
11
12         __gsignals__ = {
13                 'state_change' : (
14                         gobject.SIGNAL_RUN_LAST,
15                         gobject.TYPE_NONE,
16                         (gobject.TYPE_PYOBJECT, ),
17                 ),
18                 'navigate_change' : (
19                         gobject.SIGNAL_RUN_LAST,
20                         gobject.TYPE_NONE,
21                         (gobject.TYPE_PYOBJECT, ),
22                 ),
23                 'title_change' : (
24                         gobject.SIGNAL_RUN_LAST,
25                         gobject.TYPE_NONE,
26                         (gobject.TYPE_PYOBJECT, ),
27                 ),
28         }
29
30         def __init__(self):
31                 gobject.GObject.__init__(self)
32
33                 self._title = gtk.Entry()
34                 self._title.connect("activate", self._title_change)
35
36                 self._playButton = gtk.RadioButton(label="Play")
37                 self._playButton.connect("clicked", self._state_change, "play")
38                 self._pauseButton = gtk.RadioButton(group=self._playButton, label="Pause")
39                 self._pauseButton.connect("clicked", self._state_change, "pause")
40                 self._stopButton = gtk.RadioButton(group=self._playButton, label="stop")
41                 self._stopButton.connect("clicked", self._state_change, "stop")
42
43                 self._canNavigate = gtk.CheckButton("Can Navigate?")
44                 self._canNavigate.connect("clicked", self._navigate_change)
45
46                 self._layout = gtk.VBox()
47                 self._layout.pack_start(self._title)
48                 self._layout.pack_start(self._playButton)
49                 self._layout.pack_start(self._pauseButton)
50                 self._layout.pack_start(self._stopButton)
51                 self._layout.pack_start(self._canNavigate)
52
53                 self._state = "stop"
54
55         @property
56         def toplevel(self):
57                 return self._layout
58
59         @property
60         def node(self):
61                 return None
62
63         @property
64         def title(self):
65                 return self._title.get_text()
66
67         @property
68         def can_navigate(self):
69                 return self._canNavigate.get_active()
70
71         @property
72         def state(self):
73                 return self._state
74
75         def _state_change(self, widget, state):
76                 _moduleLogger.info("User changed state")
77                 self.emit("state_change", state)
78                 self._state = state
79
80         def _navigate_change(self, widget):
81                 _moduleLogger.info("User changed nav")
82                 self.emit("navigate_change", self._canNavigate.get_active())
83
84         def _title_change(self, widget):
85                 _moduleLogger.info("User changed title")
86                 self.emit("title_change", self._title.get_text())
87
88         def play(self):
89                 _moduleLogger.info("play")
90
91         def pause(self):
92                 _moduleLogger.info("pause")
93
94         def stop(self):
95                 _moduleLogger.info("stop")
96
97         def back(self):
98                 _moduleLogger.info("back")
99
100         def next(self):
101                 _moduleLogger.info("next")
102
103
104 gobject.type_register(FakePlayer)