Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _convert_gconf_value(value):
if value.type == gconf.VALUE_STRING:
return value.get_string()
if value.type == gconf.VALUE_INT:
return value.get_int()
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_LIST:
return [_convert_gconf_value(v) for v in value.get_list()]
raise TypeError("unknown gconf type %s" % value.type)
def create_profile(profile):
profile_list = conf_client.get_list("/apps/gnome15/profile_list", gconf.VALUE_INT)
if profile_list == None:
profile_list = []
if profile.id == -1:
profile.id = int(time.time())
dir_key = "/apps/gnome15/profiles/" + str(profile.id)
conf_client.add_dir(dir_key, gconf.CLIENT_PRELOAD_NONE)
profile_list.append(profile.id)
conf_client.set_list("/apps/gnome15/profile_list", gconf.VALUE_INT, profile_list)
conf_client.set_string(dir_key + "/name", profile.name)
def get_value (self, key):
'''returns the value of key `key' ''' #'
#if '/' in key:
# raise 'ConfError', 'key must not contain /'
value = self._gconf_client.get (self._domain + key)
value_type = value.type
if value_type == VALUE_BOOL:
return value.get_bool ()
elif value_type == VALUE_INT:
return value.get_int ()
elif value_type == VALUE_STRING:
return value.get_string ()
elif value_type == VALUE_FLOAT:
return value.get_float ()
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 create_profile(profile):
profile_list = conf_client.get_list("/apps/gnome15/profile_list", gconf.VALUE_INT)
if profile_list == None:
profile_list = []
if profile.id == -1:
profile.id = int(time.time())
dir_key = "/apps/gnome15/profiles/" + str(profile.id)
conf_client.add_dir(dir_key, gconf.CLIENT_PRELOAD_NONE)
profile_list.append(profile.id)
conf_client.set_list("/apps/gnome15/profile_list", gconf.VALUE_INT, profile_list)
conf_client.set_string(dir_key + "/name", profile.name)
def __get_active_opacity(self, type):
client = gconf.client_get_default()
if type == "matches":
return client.get_list("/apps/compiz/general/screen0/options/opacity_matches", gconf.VALUE_STRING)
if type == "values":
return client.get_list("/apps/compiz/general/screen0/options/opacity_values", gconf.VALUE_INT)
def _readSetting(self, name, gconfType, default):
base = '/apps/gedit-2/plugins/gotofile/'
val = self._gconf.get(base + name)
if val:
if gconfType == gconf.VALUE_INT:
return val.get_int()
elif gconfType == gconf.VALUE_STRING:
return val.get_string()
elif gconfType == gconf.VALUE_BOOL:
return val.get_bool()
return default
def gconf_get_int(key, default = 0):
val = gconf_client.get(key)
if val is not None and val.type == gconf.VALUE_INT:
return val.get_int()
else:
return default
conf_client.get_int('/apps/compiz/general/%s/options/hsize' % screen) *
conf_client.get_int('/apps/compiz/general/%s/options/vsize' % screen))
# Get the current list of wallpapers on this screen
wallpapers = conf_client.get_list(
'/apps/compiz/plugins/wallpaper/%s/options/bg_image' % screen,
gconf.VALUE_STRING)
# If list of wallpapers is too short, populate it to the correct length
if len(wallpapers) < number_of_faces:
wallpapers.extend([filename] * (number_of_faces - len(wallpapers)))
prefix = '/apps/compiz/plugins/wallpaper/%s/options/' % screen
settings = {
'bg_color1' : (gconf.VALUE_STRING, '#000000ff'),
'bg_color2' : (gconf.VALUE_STRING, '#000000ff'),
'bg_fill_type': (gconf.VALUE_INT, 0),
'bg_image_pos': (gconf.VALUE_INT, 0),
}
for key, value in settings.items():
ext_list = conf_client.get_list(prefix + key, value[0])
ext_list.extend([value[1]] * (number_of_faces - len(ext_list)))
conf_client.set_list(prefix + key, value[0], ext_list)
# Correct face if invalid
if face >= number_of_faces or face < 0:
face = 0
# Set wallpaper
wallpapers[face] = filename
conf_client.set_list(
'/apps/compiz/plugins/wallpaper/%s/options/bg_image' % screen,
gconf.VALUE_STRING,