4 __copyright__
= "Copyright (c) 2002-2005 Free Software Foundation, Inc."
6 Straw is free software; you can redistribute it and/or modify it under the
7 terms of the GNU General Public License as published by the Free Software
8 Foundation; either version 2 of the License, or (at your option) any later
11 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 Place - Suite 330, Boston, MA 02111-1307, USA. """
29 class OfflineView(MVP
.WidgetView
):
31 Model: Config instance
32 Presenter: OfflinePresenter instance
34 def _initialize(self
):
35 self
._tooltips
= gtk
.Tooltips()
36 self
._tooltips
.enable()
38 def _on_offline_toggle_toggled(self
, *args
):
39 status
= self
._widget
.get_active()
40 if status
!= self
._model
.offline
:
41 self
._model
.offline
= status
43 def set_status(self
, active
):
44 self
._widget
.set_active(active
)
46 def set_text(self
, text
):
47 self
._tooltips
.set_tip(self
._widget
, text
, text
)
49 def set_icon(self
, icon
):
50 image
= self
._widget
.get_child()
51 image
.set_from_stock(icon
, gtk
.ICON_SIZE_BUTTON
)
53 class OfflinePresenter(MVP
.BasicPresenter
):
55 Model: Config instance
56 View: OfflineView instance
59 def _initialize(self
):
60 self
._attribs
= {'online': (gtk
.STOCK_CONNECT
, _("Straw is currently online. Click to go offline.")),
61 'offline': (gtk
.STOCK_DISCONNECT
, _("Straw is currently offline. Click to go online."))}
62 self
._model
.signal_connect(Event
.OfflineModeChangedSignal
,
63 self
._config
_offline
_changed
)
64 if self
._model
.offline
:
65 self
._config
_offline
_changed
(None)
67 def _config_offline_changed(self
, signal
):
68 offline
= self
._model
.offline
70 icon
, tip
= self
._attribs
.get('offline')
72 icon
, tip
= self
._attribs
.get('online')
73 self
._view
.set_status(offline
)
74 self
._view
.set_text(tip
)
75 self
._view
.set_icon(icon
)
78 def __init__(self
, widget
):
79 config
= Config
.get_instance()
80 oview
= OfflineView(widget
, model
=config
)
81 self
._presenter
= OfflinePresenter(model
=config
, view
=oview
)