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. """
28 class OfflineView(MVP
.WidgetView
):
30 Model: Config instance
31 Presenter: OfflinePresenter instance
33 def _initialize(self
):
34 self
._tooltips
= gtk
.Tooltips()
35 self
._tooltips
.enable()
37 def _on_offline_toggle_toggled(self
, *args
):
38 status
= self
._widget
.get_active()
39 if status
!= self
._model
.offline
:
40 self
._model
.offline
= status
42 def set_status(self
, active
):
43 self
._widget
.set_active(active
)
45 def set_text(self
, text
):
46 self
._tooltips
.set_tip(self
._widget
, text
, text
)
48 def set_icon(self
, icon
):
49 image
= self
._widget
.get_child()
50 image
.set_from_stock(icon
, gtk
.ICON_SIZE_BUTTON
)
52 class OfflinePresenter(MVP
.BasicPresenter
):
54 Model: Config instance
55 View: OfflineView instance
58 def _initialize(self
):
59 self
._attribs
= {'online': (gtk
.STOCK_CONNECT
, _("Straw is currently online. Click to go offline.")),
60 'offline': (gtk
.STOCK_DISCONNECT
, _("Straw is currently offline. Click to go online."))}
62 self
._model
.connect('offline-mode-changed', self
._config
_offline
_changed
)
63 if self
._model
.offline
:
64 self
._config
_offline
_changed
(None)
66 def _config_offline_changed(self
, config
):
67 offline
= self
._model
.offline
69 icon
, tip
= self
._attribs
.get('offline')
71 icon
, tip
= self
._attribs
.get('online')
72 self
._view
.set_status(offline
)
73 self
._view
.set_text(tip
)
74 self
._view
.set_icon(icon
)
77 def __init__(self
, widget
):
78 config
= Config
.get_instance()
79 oview
= OfflineView(widget
, model
=config
)
80 self
._presenter
= OfflinePresenter(model
=config
, view
=oview
)