1
# Copyright (C) 2008-2010 LottaNZB Development Team
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; version 3.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16
from lottanzb.core.component import depends_on
17
from lottanzb.core.environ import _
18
from lottanzb.util.signalmanager import SignalManager
19
from lottanzb.gui.framework import SlaveDelegateComponent
20
from lottanzb.backend.hubs.general import GeneralHub
24
class InfoBar(SlaveDelegateComponent):
25
builder_file = "info_bar"
27
depends_on(GeneralHub)
29
def __init__(self, component_manager):
30
SlaveDelegateComponent.__init__(self, component_manager)
32
general_hub = self._component_manager.get(GeneralHub)
34
self._signal_manager = SignalManager()
35
self._signal_manager.connect(general_hub, "notify::speed",
36
self.on_speed_changed)
37
self._signal_manager.connect(general_hub, "notify::size-left",
38
self.on_remaining_changed)
39
self._signal_manager.connect(general_hub, "notify::time-left",
40
self.on_remaining_changed)
42
self.on_speed_changed(general_hub)
43
self.on_remaining_changed(general_hub)
45
def on_speed_changed(self, general_hub, *args):
46
self.speed.set_label(str(general_hub.speed))
48
def on_remaining_changed(self, general_hub, *args):
49
if general_hub.time_left:
50
text = _("{0.size_left} left ({0.time_left.short})")
52
text = _("{0.size_left} left")
54
self.total_remaining.set_text(text.format(general_hub))