summaryrefslogtreecommitdiff
path: root/invest-applet/invest/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'invest-applet/invest/__init__.py')
-rw-r--r--invest-applet/invest/__init__.py63
1 files changed, 24 insertions, 39 deletions
diff --git a/invest-applet/invest/__init__.py b/invest-applet/invest/__init__.py
index 101881f5..beb299c1 100644
--- a/invest-applet/invest/__init__.py
+++ b/invest-applet/invest/__init__.py
@@ -3,7 +3,13 @@ from os.path import join, exists, isdir, isfile, dirname, abspath, expanduser
from types import ListType
import datetime
-import gtk, gtk.gdk, mateconf, gobject
+import gi
+gi.require_version("Gtk", "2.0")
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
+from gi.repository import Gio
+
import cPickle
import networkmanager
@@ -54,19 +60,6 @@ if not exists(USER_INVEST_DIR):
# when presenting save/open dialogs
os.chdir(expanduser("~"))
-#Gconf client
-MATECONF_CLIENT = mateconf.client_get_default()
-
-# MateConf directory for invest in window mode and shared settings
-MATECONF_DIR = "/apps/invest"
-
-# MateConf key for list of enabled handlers, when uninstalled, use a debug key to not conflict
-# with development version
-#MATECONF_ENABLED_HANDLERS = MATECONF_DIR + "/enabled_handlers"
-
-# Preload mateconf directories
-#MATECONF_CLIENT.add_dir(MATECONF_DIR, mateconf.CLIENT_PRELOAD_RECURSIVE)
-
# tests whether the given stocks are in the old labelless format
def labelless_stock_format(stocks):
if len(stocks) == 0:
@@ -161,32 +154,30 @@ PROXY = None
# borrowed from Ross Burton
# http://burtonini.com/blog/computers/postr
# extended by exception handling and retry scheduling
-def get_mate_proxy(client):
- sleep = 10 # sleep between attempts for 10 seconds
- attempts = 3 # try to get configuration from mateconf at most three times
- get_mate_proxy_retry(client, attempts, sleep)
-
-def get_mate_proxy_retry(client, attempts, sleep):
- # decrease attempts counter
- attempts -= 1
+def get_gnome_proxy():
# sanity check if we still need to look for proxy configuration
global PROXY
if PROXY != None:
return
- # try to get config from mateconfd
+ # try to get config from gsettings
try:
- if client.get_bool("/system/http_proxy/use_http_proxy"):
- host = client.get_string("/system/http_proxy/host")
- port = client.get_int("/system/http_proxy/port")
+ proxy_settings = Gio.Settings.new("org.gnome.system.proxy")
+ proxy_http_settings = Gio.Settings.new("org.gnome.system.proxy.http")
+
+ proxy_mode = proxy_settings.get_enum("mode")
+
+ if proxy_mode == 1:
+ host = proxy_http_settings.get_string("host")
+ port = proxy_http_settings.get_int("port")
if host is None or host == "" or port == 0:
- # mate proxy is not valid, stop here
+ # system proxy is not valid, stop here
return
- if client.get_bool("/system/http_proxy/use_authentication"):
- user = client.get_string("/system/http_proxy/authentication_user")
- password = client.get_string("/system/http_proxy/authentication_password")
+ if proxy_http_settings.get_boolean("use-authentication"):
+ user = proxy_http_settings.get_string("authentication-user")
+ password = proxy_http_settings.get_string("authentication-password")
if user and user != "":
url = "http://%s:%s@%s:%d" % (user, password, host, port)
else:
@@ -198,15 +189,9 @@ def get_mate_proxy_retry(client, attempts, sleep):
PROXY = {'http': url}
except Exception, msg:
- error("Failed to get proxy configuration from MateConfd:\n%s" % msg)
- # we did not succeed, schedule retry
- if attempts > 0:
- error("Retrying to contact MateConfd in %d seconds" % sleep)
- gobject.timeout_add(sleep * 1000, get_mate_proxy_retry, client, attempts, sleep)
-
-# use mateconf to get proxy config
-client = mateconf.client_get_default()
-get_mate_proxy(client)
+ error("Failed to get proxy configuration from GSettings:\n%s" % msg)
+
+get_gnome_proxy()
# connect to Network Manager to identify current network connectivity