3 Module setting user preferences.
6 Copyright (c) 2002-2004 Juri Pakaste
7 Copyright (c) 2005-2007 Straw Contributors
9 __license__
= """ GNU General Public License
11 Straw is free software; you can redistribute it and/or modify it under the
12 terms of the GNU General Public License as published by the Free Software
13 Foundation; either version 2 of the License, or (at your option) any later
16 Straw is distributed in the hope that it will be useful, but WITHOUT ANY
17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22 Place - Suite 330, Boston, MA 02111-1307, USA. """
24 from ConfigOptions
import *
25 from gtk
.glade
import XML
26 from os
.path
import join
33 class PreferencesView(MVP
.GladeView
):
34 def _initialize(self
):
35 self
._window
= self
._widget
.get_widget('preferences')
36 self
._browser
_override
= self
._widget
.get_widget("prefs_browser_setting")
37 self
._browser
_entry
= self
._widget
.get_widget("prefs_browser_setting_entry")
40 poll_frequency
= int(Config
.get(OPTION_POLL_FREQUENCY
) / 60)
41 items_stored
= int(Config
.get(OPTION_ITEMS_STORED
))
43 browser_cmd
= Config
.get(OPTION_BROWSER_CMD
)
46 self
._browser
_override
.set_active(True)
47 self
._browser
_entry
.set_text(browser_cmd
)
48 self
._browser
_entry
.set_sensitive(True)
50 self
._browser
_entry
.set_text(_("Using desktop setting"))
52 self
._widget
.get_widget('poll_frequency_spin').set_value(poll_frequency
)
53 self
._widget
.get_widget('number_of_items_spin').set_value(items_stored
)
54 #self._widget.get_widget('vertical_layout').set_active(Config.get(OPTION_PANE_LAYOUT) == 'vertical')
56 def _apply_settings(self
):
57 a
= self
._widget
.get_widget('number_of_items_spin').get_value_as_int()
58 Config
.set(OPTION_ITEMS_STORED
, a
)
60 def show(self
, *args
):
61 self
._window
.present()
63 def hide(self
, *args
):
65 self
._window
.destroy()
67 def _on_ok_button_clicked(self
, button
):
68 self
._apply
_settings
()
71 def _on_cancel_button_clicked(self
, button
):
74 def _on_apply_button_clicked(self
, button
):
75 self
._apply
_settings
()
77 def on_preferences_delete_event(self
, *args
):
81 def on_close_button_clicked(self
, button
):
84 class PreferencesPresenter(MVP
.BasicPresenter
):
88 gladefile
= XML(os
.path
.join(straw
.defs
.STRAW_DATA_DIR
, "preferences.glade"))
89 dialog
= PreferencesPresenter(view
= PreferencesView(gladefile
))