|
|
|
@ -387,7 +387,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
settings_action = gtk.Action('Settings', '_Settings', |
|
|
|
|
'Settings', gtk.STOCK_PREFERENCES) |
|
|
|
|
#settings_action.connect('activate', self.show_settings) |
|
|
|
|
settings_action.connect('activate', self._show_settings) |
|
|
|
|
action_group.add_action(settings_action) |
|
|
|
|
|
|
|
|
|
# Message actions |
|
|
|
@ -807,6 +807,90 @@ class Interface(object):
|
|
|
|
|
message) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _show_settings(self, widget, user_data=None): |
|
|
|
|
"""Display the settings window.""" |
|
|
|
|
settings_window = gtk.Dialog(title='Settings', |
|
|
|
|
parent=self._main_window, |
|
|
|
|
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, |
|
|
|
|
buttons=(gtk.STOCK_OK, 0)) |
|
|
|
|
|
|
|
|
|
# the tabs |
|
|
|
|
tabs = gtk.Notebook() |
|
|
|
|
|
|
|
|
|
# first page is the interface settings |
|
|
|
|
self._refresh_interval_field = gtk.SpinButton() |
|
|
|
|
self._refresh_interval_field.set_range(1, 99) |
|
|
|
|
self._refresh_interval_field.set_numeric(True) |
|
|
|
|
self._refresh_interval_field.set_value( |
|
|
|
|
self._options[self.NAMESPACE]['refresh_interval']) |
|
|
|
|
self._refresh_interval_field.set_increments(1, 5) |
|
|
|
|
|
|
|
|
|
interface_box = gtk.Table(rows=1, columns=2, homogeneous=False) |
|
|
|
|
interface_box.attach(gtk.Label('Refresh interval (minutes):'), |
|
|
|
|
0, 1, 0, 1) |
|
|
|
|
interface_box.attach(self._refresh_interval_field, 0, 1, 1, 2) |
|
|
|
|
interface_box.show_all() |
|
|
|
|
|
|
|
|
|
tabs.insert_page(interface_box, gtk.Label('Interface')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# We store the fields in a dictionary, inside dictionaries for each |
|
|
|
|
# NAMESPACE. To set the values, we just run the dictionaries setting |
|
|
|
|
# self._options. |
|
|
|
|
self._fields = {self.NAMESPACE: {'refresh_interval': |
|
|
|
|
self._refresh_interval_field}} |
|
|
|
|
|
|
|
|
|
# next pages are each network settings |
|
|
|
|
net_options = self._connection.settings() |
|
|
|
|
for network in net_options: |
|
|
|
|
network_name = network['name'] |
|
|
|
|
|
|
|
|
|
rows = len(network['options']) |
|
|
|
|
net_box = gtk.Table(rows=rows, columns=2, homogeneous=False) |
|
|
|
|
|
|
|
|
|
self._fields[network_name] = {} |
|
|
|
|
row = 0 |
|
|
|
|
for option in network['options']: |
|
|
|
|
option_name = option['name'] |
|
|
|
|
option_value = '' |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
option_value = self._options[network_name][option_name] |
|
|
|
|
except KeyError: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
new_field = gtk.Entry() |
|
|
|
|
new_field.set_text(option_value) |
|
|
|
|
# Ony "str" and "passwd" are valid type and both use Entry() |
|
|
|
|
if option['type'] == 'passwd': |
|
|
|
|
new_field.set_visibility(False) |
|
|
|
|
|
|
|
|
|
net_box.attach(gtk.Label(option_name), row, row+1, 0, 1) |
|
|
|
|
net_box.attach(new_field, row, row+1, 1, 2) |
|
|
|
|
|
|
|
|
|
row += 1 |
|
|
|
|
|
|
|
|
|
self._fields[network_name][option_name] = new_field |
|
|
|
|
|
|
|
|
|
net_box.show_all() |
|
|
|
|
tabs.insert_page(net_box, gtk.Label(network_name)) |
|
|
|
|
|
|
|
|
|
tabs.show_all() |
|
|
|
|
settings_window.vbox.pack_start(tabs, True, True, 0) |
|
|
|
|
settings_window.connect('response', self._update_settings) |
|
|
|
|
settings_window.run() |
|
|
|
|
settings_window.hide() |
|
|
|
|
|
|
|
|
|
def _update_settings(self, widget, response_id=0, user_data=None): |
|
|
|
|
"""Update the interface settings.""" |
|
|
|
|
for namespace in self._fields: |
|
|
|
|
for option in self._fields[namespace]: |
|
|
|
|
field = self._fields[namespace][option] |
|
|
|
|
value = field.get_text() |
|
|
|
|
self._options[namespace][option] = value |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Network related functions |
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|