Esempio n. 1
0
 def __set__(self, instance, value):
     assert hasattr(value,
                    '__iter__'), 'value of ListOption must be iterable'
     gvalues = [gconf.Value(self.list_type) for i in range(len(value))]
     for g, v in map(None, gvalues, value):
         getattr(g, 'set_%s' % self.list_type.value_nick)(v)
     gconf_value = gconf.Value(self.gconf_type)
     gconf_value.set_list_type(self.list_type)
     self.setter(gconf_value, gvalues)
     Option.__set__(self, instance, gconf_value)
Esempio n. 2
0
    def test_config(self):
        '''write new default values to config. 
    TODO: Obvioslsy users will not be expected to edit these values in their gconf tree.
    TODO: Write a config interface.'''
        # Test if alredy exists, don't overwrite!
        if self.client.dir_exists("/apps/librarian") == True:
            print "Creating new config file.\n"

            gvalue_str = gconf.Value(gconf.VALUE_STRING)

            self.client.add_dir("/apps/librarian", gconf.CLIENT_PRELOAD_NONE)
            gvalue_str.set_string('username')
            self.client.set('/apps/librarian/USER', gvalue_str)
            gvalue_str.set_string('password')
            self.client.set('/apps/librarian/PASSWD', gvalue_str)
            gvalue_str.set_string('localhost')
            self.client.set('/apps/librarian/DBHOST', gvalue_str)
            gvalue_str.set_string('books')
            self.client.set('/apps/librarian/DBASE', gvalue_str)
            gvalue_str.set_string('Calibre_Library/metadata.db')
            self.client.set('/apps/librarian/CALIBRE_DB', gvalue_str)
            gvalue_str.set_string('aws_key')
            self.client.set('/apps/librarian/AZKEY', gvalue_str)
            gvalue_str.set_string('az_secret_key')
            self.client.set('/apps/librarian/AZSKEY', gvalue_str)

        if self.client.dir_exists("/apps/librarian") == False:
            print "Cannot create gconf entries!"
            return False
        else:
            return True
Esempio n. 3
0
def _to_gconf(type, value):
    gconf_value = gconf.Value(type)
    if type == gconf.VALUE_STRING:
        gconf_value.set_string(value)
    elif type == gconf.VALUE_BOOL:
        gconf_value.set_bool(value)
    elif type == gconf.VALUE_INT:
        gconf_value.set_int(value)
    return gconf_value
Esempio n. 4
0
 def set (self, key, value):
     """
     Set the given Python object value to the relative key.
     """
     schema = self.client.get_schema ('/schemas'+self.dir+"/"+key)
     gtype = schema.get_type ()
     gvalue = gconf.Value (gtype)
     if gtype == gconf.VALUE_STRING:
         gvalue.set_string (value)
     elif gtype == gconf.VALUE_BOOL:
         gvalue.set_bool (value)
     self.client.set (self.dir+"/"+key, gvalue)
def shortcuts_custom_set(key, key_binding):
    '''
    set the custom keybindings
    @param key: the keybinding's name, a string type
    @param key_binding: a 3-tuple contain action, binding and name
    '''
    client = GCONF_CLIENT
    base_dir = '/desktop/gnome/keybindings'
    v = gconf.Value(gconf.VALUE_STRING)
    v.set_string(key_binding[0])
    client.set("%s/%s/action" % (base_dir, key), v)
    v.set_string(key_binding[1])
    client.set("%s/%s/binding" % (base_dir, key), v)
    v.set_string(key_binding[2])
    client.set("%s/%s/name" % (base_dir, key), v)
Esempio n. 6
0
def gconf_set_bool(key, value):
    v = gconf.Value(gconf.VALUE_BOOL)
    v.set_bool(value)
    gconf.client_get_default().set(key, v)
Esempio n. 7
0
def gconf_set_str(key, value):
    v = gconf.Value(gconf.VALUE_STRING)
    v.set_string(value)
    gconf.client_get_default().set(key, v)
Esempio n. 8
0
 def _set_config_str(self, key, string):
     """ Save a value to a gconf key. """
     key = self._gconf_key_base + key
     value = gconf.Value(gconf.VALUE_STRING)
     value.set_string(string)
     gconf.client_get_default().set(key, value)
Esempio n. 9
0
 def __set__(self, instance, value):
     gconf_value = gconf.Value(self.gconf_type)
     self.setter(gconf_value, value)
     super(SimpleOption, self).__set__(instance, gconf_value)