~ubuntu-core-dev/ubuntu-release-upgrader/trunk

« back to all changes in this revision

Viewing changes to UpdateManager/SafeGConfClient.py

  • Committer: Michael Vogt
  • Date: 2011-07-07 16:17:53 UTC
  • mto: This revision was merged to the branch mainline in revision 2148.
  • Revision ID: michael.vogt@ubuntu.com-20110707161753-gpybe06i2gx71gtl
initial port from gconf -> gsettings, this needs some cleanup in the naming still

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from gi.repository import GConf
23
23
from gi.repository import GObject
 
24
from gi.repository import Gio
24
25
 
25
26
class SafeGConfClient(object):
26
27
    """A gconfclient that does not crash if gconf is not avaialble"""
27
28
    def __init__(self):
28
 
        self.gconfclient = GConf.Client.get_default()
 
29
        self.gconfclient = Gio.Settings("com.ubuntu.update-manager")
29
30
 
30
31
    def get_bool(self, key, default=False):
31
32
        try:
32
 
            return self.gconfclient.get_bool(key)
 
33
            return self.gconfclient.get_boolean(key)
33
34
        except GObject.GError, e:
34
35
            return default
35
36
    def get_int(self, key, default=0):
37
38
            return self.gconfclient.get_int(key)
38
39
        except GObject.GError, e:
39
40
            return default
40
 
    def get_pair(self, key, vtype1, vtype2):
41
 
        # FIXME
42
 
        #try:
43
 
        #    return self.gconfclient.get_pair(key, vtype1, vtype2)
44
 
        #except GObject.GError, e:
45
 
        #    return (0, 0)
46
 
        return (0, 0)
47
41
    def get_string(self, key, default=""):
48
42
        try:
49
43
            return self.gconfclient.get_string(key)
56
50
            pass
57
51
    def set_bool(self, key, value):
58
52
        try:
59
 
            self.gconfclient.set_bool(key, value)
60
 
        except GObject.GError, e:
61
 
            pass
62
 
    def set_pair(self, key, vtype1, vtype2, value1, value2):
63
 
        try:
64
 
            self.gconfclient.set_pair(key, vtype1, vtype2, value1, value2)
 
53
            self.gconfclient.set_boolean(key, value)
65
54
        except GObject.GError, e:
66
55
            pass
67
56
    def set_string(self, key, value):