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. """
26 from gtk
.glade
import XML
29 from os
.path
import join
37 config
= Config
.get_instance()
38 self
._glade
= XML(join(straw
.STRAW_DATA_DIR
,'preferences.glade'))
39 self
._window
= self
._glade
.get_widget('preferences')
40 self
._browser
_override
= self
._glade
.get_widget("prefs_browser_setting")
41 self
._browser
_entry
= self
._glade
.get_widget("prefs_browser_setting_entry")
44 config
= Config
.get_instance()
45 poll_frequency
= int(config
.poll_frequency
/self
.SEC_PER_MINUTE
)
46 items_stored
= int(config
.number_of_items_stored
)
48 browser_cmd
= config
.browser_cmd
50 self
._browser
_override
.set_active(True)
51 self
._browser
_entry
.set_text (browser_cmd
)
52 self
._browser
_entry
.set_sensitive (True)
54 self
._browser
_entry
.set_text (_("Using desktop setting"))
56 self
._glade
.get_widget('poll_frequency_spin').set_value(poll_frequency
)
57 self
._glade
.get_widget('number_of_items_spin').set_value(items_stored
)
58 self
._glade
.get_widget(['item_order_oldest',
59 'item_order_newest'][config
.item_order
]).set_active(1)
60 self
._glade
.get_widget('vertical_layout').set_active(config
.pane_layout
== 'vertical')
63 for key
in dir(self
.__class
__):
65 nameFuncMap
[key
] = getattr(self
, key
)
66 self
._glade
.signal_autoconnect(nameFuncMap
)
68 def show(self
, *args
):
69 self
._window
.present()
71 def hide(self
, *args
):
74 def on_preferences_delete_event(self
, *args
):
78 def on_close_button_clicked(self
, button
):
82 def on_poll_frequency_spin_value_changed(self
, spin
):
83 Config
.get_instance().poll_frequency
= int(spin
.get_value() * self
.SEC_PER_MINUTE
)
85 def on_number_of_items_spin_value_changed(self
, spin
):
86 Config
.get_instance().number_of_items_stored
= int(spin
.get_value())
88 def on_item_order_newest_toggled(self
, radio
):
89 config
= Config
.get_instance()
90 config
.item_order
= not config
.item_order
92 def on_item_order_oldest_toggled(self
, radio
):
95 def on_prefs_browser_setting_toggled(self
, button
):
96 active
= button
.get_active()
98 config
= Config
.get_instance()
99 config
.browser_cmd
= ""
100 self
._browser
_entry
.set_sensitive(active
)
102 def on_prefs_browser_setting_entry_focus_out_event(self
, entry
, *args
):
103 config
= Config
.get_instance()
104 config
.browser_cmd
= entry
.get_text()
106 def on_vertical_layout_clicked(self
, *args
):
108 config
= Config
.get_instance()
109 config
.pane_layout
= 'vertical'
111 def on_horizontal_layout_clicked(self
, *args
):
112 print 'orintal clicked'
113 config
= Config
.get_instance()
114 config
.pane_layout
= 'horizontal'
118 def preferences_show():
121 _dialog
= Preferences()