1 """
2 Stores application settings
3
4 Part of this code copied from Gimmie (c) Alex Gravely
5
6 Copyright: John Stowers, 2006
7 License: GPLv2
8 """
9 import gobject
10
11
12
13 TYPE_TO_TYPE_NAME = {
14 int : "int",
15 bool : "bool",
16 str : "string",
17 list : "list"
18 }
19 STRING_TO_TYPE = {
20 "int" : lambda x: int(x),
21 "bool" : lambda x: string_to_bool(x),
22 "string" : lambda x: str(x),
23 "list" : lambda x: string_to_list(x)
24 }
25 TYPE_TO_STRING = {
26 int : lambda x: str(x),
27 bool : lambda x: str(x),
28 str : lambda x: str(x),
29 list : lambda x: list_to_string(x)
30 }
31
33
34 if stringy == "True":
35 return True
36 else:
37 return False
38
40 s = ""
41 if type(listy) is list:
42 s = ",".join(listy)
43 return s
44
46 l = string.split(",")
47 internalTypeName = TYPE_TO_TYPE_NAME[listInternalVtype]
48 for i in range(0, len(l)):
49 l[i] = STRING_TO_TYPE[internalTypeName](l[i])
50 return l
51
53 """
54 Class for storing conduit.GLOBALS.settings. Keys of type str, bool, int,
55 and list of strings supported at this stage.
56
57 Also stores the special proxy settings.
58 """
59 __gsignals__ = {
60 'changed' : (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_DETAILED, gobject.TYPE_NONE, ()),
61 }
62
63
64 DEFAULTS = {
65 'show_splashscreen' : True,
66 'show_dp_description' : False,
67 'show_status_icon' : True,
68 'save_on_exit' : True,
69 'enable_network' : True,
70 'enable_removable_devices' : True,
71 'default_policy_conflict' : "ask",
72 'default_policy_deleted' : "ask",
73 'gui_expanded_rows' : [],
74 'gui_restore_expanded_rows' : True,
75 'gui_hpane_postion' : 250,
76 'gui_window_size' : [],
77 'gui_minimize_to_tray' : False,
78 'gui_initial_canvas_height' : 450,
79 'gui_initial_canvas_width' : 450,
80 'gui_use_rgba_colormap' : False,
81 'gui_show_hints' : True,
82 'web_login_browser' : "gtkmozembed"
83 }
84
95
97 self.emit('changed::%s' % key)
98
100 """
101 Sets values of settings that only exist for this setting, and are
102 never saved, nor updated.
103 """
104 self._impl.set_overrides(**overrides)
105
106 - def get(self, key, **kwargs):
107 """
108 Returns the value of the key or the default value if the key is
109 not yet stored
110 """
111 return self._impl.get(key, **kwargs)
112
113 - def set(self, key, value, **kwargs):
114 """
115 Sets the key to value.
116 """
117 return self._impl.set(key, value, **kwargs)
118
120 """
121 @returns: True if the user has specified a http proxy via
122 the http_proxy environment variable, or in the appropriate settings
123 backend, such as gconf
124 """
125 return self._impl.proxy_enabled()
126
128 """
129 Returns the details of the configured http proxy.
130 The http_proxy environment variable overrides the GNOME setting
131 @returns: host,port,user,password
132 """
133 return self._impl.get_proxy()
134
136 """
137 Performs any necessary tasks to ensure settings are saved between sessions
138 """
139 self._impl.save()
140