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. """
27 class OfflineView(MVP
.WidgetView
):
29 Model: Config instance
30 Presenter: OfflinePresenter instance
32 def _initialize(self
):
33 self
._tooltips
= gtk
.Tooltips()
34 self
._tooltips
.enable()
36 def _on_offline_toggle_toggled(self
, *args
):
37 status
= self
._widget
.get_active()
38 if status
!= self
._model
.offline
:
39 self
._model
.offline
= status
41 def set_status(self
, active
):
42 self
._widget
.set_active(active
)
44 def set_text(self
, text
):
45 self
._tooltips
.set_tip(self
._widget
, text
, text
)
47 def set_icon(self
, icon
):
48 image
= self
._widget
.get_child()
49 image
.set_from_stock(icon
, gtk
.ICON_SIZE_BUTTON
)
51 class OfflinePresenter(MVP
.BasicPresenter
):
53 Model: Config instance
54 View: OfflineView instance
57 def _initialize(self
):
58 self
._attribs
= {'online': (gtk
.STOCK_CONNECT
, _("Straw is currently online. Click to go offline.")),
59 'offline': (gtk
.STOCK_DISCONNECT
, _("Straw is currently offline. Click to go online."))}
61 self
._model
.connect('offline-mode-changed', self
._config
_offline
_changed
)
62 if self
._model
.offline
:
63 self
._config
_offline
_changed
(None)
65 def _config_offline_changed(self
, config
):
66 offline
= self
._model
.offline
68 icon
, tip
= self
._attribs
.get('offline')
70 icon
, tip
= self
._attribs
.get('online')
71 self
._view
.set_status(offline
)
72 self
._view
.set_text(tip
)
73 self
._view
.set_icon(icon
)
76 def __init__(self
, widget
):
77 config
= Config
.get_instance()
78 oview
= OfflineView(widget
, model
=config
)
79 self
._presenter
= OfflinePresenter(model
=config
, view
=oview
)