Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def python_type_to_gconf_type(self, type):
"""
Convert a Python type (bool, int, str, ...) to GConf type
"""
if type == bool:
return gconf.VALUE_BOOL
elif type == str:
return gconf.VALUE_STRING
elif type == int:
return gconf.VALUE_INT
def getShowHidden(self):
return self._readSetting('show_hidden', gconf.VALUE_BOOL, False)
client.set_bool(fullkey, value)
elif isinstance(value, int):
client.set_int(fullkey, value)
elif isinstance(value, float):
client.set_float(fullkey, value)
elif isinstance(value, list):
# this is lame, but there isn't enough information to
# figure it out another way
if len(value) == 0 or isinstance(value[0], str):
list_type = gconf.VALUE_STRING
elif isinstance(value[0], int):
list_type = gconf.VALUE_INT
elif isinstance(value[0], float):
list_type = gconf.VALUE_FLOAT
elif isinstance(value[0], bool):
list_type = gconf.VALUE_BOOL
else:
raise TypeError("unknown gconf type %s" % type(value[0]))
client.set_list(fullkey, list_type, value)
else:
raise TypeError()
finally:
gconf_lock.release()
def _writeSetting(self, name, gconfType, value):
base = '/apps/gedit-2/plugins/gotofile/'
if gconfType == gconf.VALUE_STRING:
self._gconf.set_string(base + name, value)
elif gconfType == gconf.VALUE_INT:
self._gconf.set_int(base + name, value)
elif gconfType == gconf.VALUE_BOOL:
self._gconf.set_bool(base + name, value)
else:
raise "Not supported"
client.set_bool(fullkey, value)
elif isinstance(value, int):
client.set_int(fullkey, value)
elif isinstance(value, float):
client.set_float(fullkey, value)
elif isinstance(value, list):
# this is lame, but there isn't enough information to
# figure it out another way
if len(value) == 0 or isinstance(value[0], str):
list_type = gconf.VALUE_STRING
elif isinstance(value[0], int):
list_type = gconf.VALUE_INT
elif isinstance(value[0], float):
list_type = gconf.VALUE_FLOAT
elif isinstance(value[0], bool):
list_type = gconf.VALUE_BOOL
else:
raise TypeError("unknown gconf type %s" % type(value[0]))
client.set_list(fullkey, list_type, value)
else:
raise TypeError()
finally:
gconf_lock.release()
def get (key):
key = normpath(GDIR+key)
value = c.get(key)
if value.type == gconf.VALUE_BOOL:
return value.get_bool()
if value.type == gconf.VALUE_FLOAT:
return value.get_float()
if value.type == gconf.VALUE_INT:
return value.get_int()
if value.type == gconf.VALUE_STRING:
return value.get_string()
def _writeSetting(self, name, gconfType, value):
base = '/apps/gedit-2/plugins/gotofile/'
if gconfType == gconf.VALUE_STRING:
self._gconf.set_string(base + name, value)
elif gconfType == gconf.VALUE_INT:
self._gconf.set_int(base + name, value)
elif gconfType == gconf.VALUE_BOOL:
self._gconf.set_bool(base + name, value)
else:
raise "Not supported"
value = client.get(data)
if value.type == gconf.VALUE_INT:
client.set_int(data, 1)
client.set_string("/apps/compiz/plugins/wobbly/screen0/options/map_window_match","Splash | DropdownMenu | PopupMenu | Tooltip | Notification | Combo | Dnd | Unknown")
elif value.type == gconf.VALUE_BOOL:
client.set_bool(data, True)
elif value.type == gconf.VALUE_STRING:
client.set_string(data, "Toolbar | Menu | Utility | Dialog | Normal | Unknown")
else:
self.__set_active("wobbly", False)
value = client.get(data)
if value.type == gconf.VALUE_INT:
client.set_int(data, 0)
elif value.type == gconf.VALUE_BOOL:
client.set_bool(data, False)
elif value.type == gconf.VALUE_STRING:
client.set_string(data, "")
def get_value(self, value):
"""Gets the value of ``value``"""
if value.type == gconf.VALUE_STRING:
return value.get_string()
elif value.type == gconf.VALUE_INT:
return value.get_int()
elif value.type == gconf.VALUE_FLOAT:
return value.get_float()
elif value.type == gconf.VALUE_BOOL:
return value.get_bool()
elif value.type == gconf.VALUE_LIST:
_list = value.get_list()
return [self.get_value(v) for v in _list]
else:
msg = "Unsupported type %s for %s"
raise TypeError(msg % (type(value), value))
def gconf_get_bool(key, default = False):
val = gconf.client_get_default().get(key)
if val is not None and val.type == gconf.VALUE_BOOL:
return val.get_bool()
else:
return default