|
|
@ -35,6 +35,8 @@ from mitterlib.ui.helpers.gtk_messagegrid import MessageGrid |
|
|
|
from mitterlib.ui.helpers.gdk_avatarcache import AvatarCache |
|
|
|
from mitterlib.ui.helpers.gdk_avatarcache import AvatarCache |
|
|
|
from mitterlib.constants import gpl_3, version |
|
|
|
from mitterlib.constants import gpl_3, version |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from mitterlib.network import NetworksNoNetworkSetupError |
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
# Constants |
|
|
|
# Constants |
|
|
|
# ---------------------------------------------------------------------- |
|
|
|
# ---------------------------------------------------------------------- |
|
|
@ -657,42 +659,12 @@ class Interface(object): |
|
|
|
# the tabs |
|
|
|
# the tabs |
|
|
|
tabs = gtk.Notebook() |
|
|
|
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=2, columns=1, 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'))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# second page is the network manager settings |
|
|
|
|
|
|
|
self._proxy_field = gtk.Entry() |
|
|
|
|
|
|
|
if self._options['NetworkManager']['proxy']: |
|
|
|
|
|
|
|
self._proxy_field.set_text( |
|
|
|
|
|
|
|
self._options['NetworkManager']['proxy']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
manager_box = gtk.Table(rows=1, columns=2, homogeneous=False) |
|
|
|
|
|
|
|
manager_box.attach(gtk.Label(_('Proxy:')), 0, 1, 0, 1) |
|
|
|
|
|
|
|
manager_box.attach(self._proxy_field, 0, 1, 1, 2) |
|
|
|
|
|
|
|
manager_box.show_all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabs.insert_page(manager_box, gtk.Label(_('Networks'))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# We store the fields in a dictionary, inside dictionaries for each |
|
|
|
# We store the fields in a dictionary, inside dictionaries for each |
|
|
|
# NAMESPACE. To set the values, we just run the dictionaries setting |
|
|
|
# NAMESPACE. To set the values, we just run the dictionaries setting |
|
|
|
# self._options. |
|
|
|
# self._options. |
|
|
|
self._fields = {self.NAMESPACE: {'refresh_interval': |
|
|
|
self._fields = {} |
|
|
|
(self._refresh_interval_field, 'int')}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# next pages are each network settings |
|
|
|
# each network settings |
|
|
|
net_options = self._connection.settings() |
|
|
|
net_options = self._connection.settings() |
|
|
|
for network in net_options: |
|
|
|
for network in net_options: |
|
|
|
network_name = network['name'] |
|
|
|
network_name = network['name'] |
|
|
@ -730,6 +702,37 @@ class Interface(object): |
|
|
|
net_box.show_all() |
|
|
|
net_box.show_all() |
|
|
|
tabs.insert_page(net_box, gtk.Label(network_name)) |
|
|
|
tabs.insert_page(net_box, gtk.Label(network_name)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# second to last page is the network manager settings |
|
|
|
|
|
|
|
self._proxy_field = gtk.Entry() |
|
|
|
|
|
|
|
if self._options['NetworkManager']['proxy']: |
|
|
|
|
|
|
|
self._proxy_field.set_text( |
|
|
|
|
|
|
|
self._options['NetworkManager']['proxy']) |
|
|
|
|
|
|
|
manager_box = gtk.Table(rows=1, columns=2, homogeneous=False) |
|
|
|
|
|
|
|
manager_box.attach(gtk.Label(_('Proxy:')), 0, 1, 0, 1) |
|
|
|
|
|
|
|
manager_box.attach(self._proxy_field, 0, 1, 1, 2) |
|
|
|
|
|
|
|
manager_box.show_all() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabs.insert_page(manager_box, gtk.Label(_('Networks'))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# last 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=2, columns=1, 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() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._fields[self.NAMESPACE] = { |
|
|
|
|
|
|
|
'refresh_interval': (self._refresh_interval_field, 'int')} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tabs.insert_page(interface_box, gtk.Label(_('Interface'))) |
|
|
|
|
|
|
|
|
|
|
|
tabs.show_all() |
|
|
|
tabs.show_all() |
|
|
|
settings_window.vbox.pack_start(tabs, True, True, 0) |
|
|
|
settings_window.vbox.pack_start(tabs, True, True, 0) |
|
|
|
settings_window.connect('response', self._update_settings) |
|
|
|
settings_window.connect('response', self._update_settings) |
|
|
@ -738,15 +741,25 @@ class Interface(object): |
|
|
|
|
|
|
|
|
|
|
|
def _update_settings(self, widget, response_id=0, user_data=None): |
|
|
|
def _update_settings(self, widget, response_id=0, user_data=None): |
|
|
|
"""Update the interface settings.""" |
|
|
|
"""Update the interface settings.""" |
|
|
|
|
|
|
|
need_refresh = False |
|
|
|
|
|
|
|
_log.debug('Saving options') |
|
|
|
for namespace in self._fields: |
|
|
|
for namespace in self._fields: |
|
|
|
for option in self._fields[namespace]: |
|
|
|
for option in self._fields[namespace]: |
|
|
|
(field, field_type) = self._fields[namespace][option] |
|
|
|
(field, field_type) = self._fields[namespace][option] |
|
|
|
value = field.get_text() |
|
|
|
value = field.get_text() |
|
|
|
if field_type == 'int': |
|
|
|
if field_type == 'int': |
|
|
|
value = int(value) |
|
|
|
value = int(value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if any of the options change, do another refresh |
|
|
|
|
|
|
|
if (namespace != self.NAMESPACE and |
|
|
|
|
|
|
|
self._options[namespace][option] != value): |
|
|
|
|
|
|
|
need_refresh = True |
|
|
|
self._options[namespace][option] = value |
|
|
|
self._options[namespace][option] = value |
|
|
|
|
|
|
|
|
|
|
|
self._options.save() |
|
|
|
self._options.save() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if need_refresh: |
|
|
|
|
|
|
|
self._refresh() |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
def _change_tab(self, widget, user_data=None): |
|
|
|
def _change_tab(self, widget, user_data=None): |
|
|
@ -802,11 +815,21 @@ class Interface(object): |
|
|
|
"""Function called if the retrival of current messages returns an |
|
|
|
"""Function called if the retrival of current messages returns an |
|
|
|
exception.""" |
|
|
|
exception.""" |
|
|
|
_log.debug(str(exception)) |
|
|
|
_log.debug(str(exception)) |
|
|
|
message = _('%s\nAuto-refresh is now disabled. Use the "refresh" ' \ |
|
|
|
|
|
|
|
|
|
|
|
# if we get a NetworksNoNetworkSetupError, we need to show the |
|
|
|
|
|
|
|
# settings window |
|
|
|
|
|
|
|
if isinstance(exception, NetworksNoNetworkSetupError): |
|
|
|
|
|
|
|
self._statusbar.pop(self._statusbar_context) |
|
|
|
|
|
|
|
self._show_settings(None) |
|
|
|
|
|
|
|
# don't enable the refresh yet, the settings should take care of |
|
|
|
|
|
|
|
# that once the user set a new config. |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message = _('%s\n\nAuto-refresh is now disabled. Use the "refresh" ' \ |
|
|
|
'option to re-enable it.') % (str(exception)) |
|
|
|
'option to re-enable it.') % (str(exception)) |
|
|
|
error_win = gtk.MessageDialog(parent=self._main_window, |
|
|
|
error_win = gtk.MessageDialog(parent=self._main_window, |
|
|
|
type=gtk.MESSAGE_ERROR, |
|
|
|
type=gtk.MESSAGE_ERROR, |
|
|
|
message_format=_message, |
|
|
|
message_format=message, |
|
|
|
buttons=gtk.BUTTONS_OK) |
|
|
|
buttons=gtk.BUTTONS_OK) |
|
|
|
error_win.run() |
|
|
|
error_win.run() |
|
|
|
error_win.hide() |
|
|
|
error_win.hide() |
|
|
@ -1043,11 +1066,16 @@ class Interface(object): |
|
|
|
self._main_window.show() |
|
|
|
self._main_window.show() |
|
|
|
|
|
|
|
|
|
|
|
# get a user avatar. We need that for the updatebox. |
|
|
|
# get a user avatar. We need that for the updatebox. |
|
|
|
|
|
|
|
try: |
|
|
|
user = self._connection.user() |
|
|
|
user = self._connection.user() |
|
|
|
self._threads.add_work(self._post_avatar_pic, |
|
|
|
self._threads.add_work(self._post_avatar_pic, |
|
|
|
self._exception_download_pic, |
|
|
|
self._exception_download_pic, |
|
|
|
self._download_pic, |
|
|
|
self._download_pic, |
|
|
|
user.avatar) |
|
|
|
user.avatar) |
|
|
|
|
|
|
|
except NetworksNoNetworkSetupError: |
|
|
|
|
|
|
|
# on the first run, the user won't have an avatar 'cause, well, |
|
|
|
|
|
|
|
# there are no networks set up. |
|
|
|
|
|
|
|
pass # and the user gets the default avatar. |
|
|
|
|
|
|
|
|
|
|
|
# queue the first fetch |
|
|
|
# queue the first fetch |
|
|
|
self._refresh_id = None # The auto-refresh manager. |
|
|
|
self._refresh_id = None # The auto-refresh manager. |
|
|
|