How to use the gconf.VALUE_INVALID function in gconf

To help you get started, we’ve selected a few gconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gmate / gmate / plugins / gconfoptions.py View on Github external
return value

    def __set__(self, instance, value):
        key = self.get_key(instance.gconfDir)
        instance.client.set(key, value)

    def __delete__(self, instance):
        instance.client.unset(self.get_key(instance.gconfDir))


class SimpleOption(Option):
    """
            Base class for all types in gconf.
    """
    gconf_type = gconf.VALUE_INVALID

    def __init__(self, *args, **kwargs):
        self.getter = getattr(gconf.Value, 'get_%s' % self.gconf_type.value_nick)
        self.setter = getattr(gconf.Value, 'set_%s' % self.gconf_type.value_nick)
        super(SimpleOption, self).__init__(*args, **kwargs)

    def __get__(self, instance, owner=None):
        gconf_value = super(SimpleOption, self).__get__(instance, owner)
        if gconf_value is None:
            return None
        return self.getter(gconf_value)

    def __set__(self, instance, value):
        gconf_value = gconf.Value(self.gconf_type)
        self.setter(gconf_value, value)
        super(SimpleOption, self).__set__(instance, gconf_value)
github gmate / gmate / plugins / gedit2 / completion / lib / sgconf / __init__.py View on Github external
return value

    def __set__(self, instance, value):
        key = self.get_key(self._base_uri)
        self._storage_client.set(key, value)

    def __delete__(self, instance):
        self._storage_client.unset(self.get_key(self._base_uri))


class SimpleOption(Option):
    """
        Base class for all types in gconf.
        Define setters and getters only
    """
    gconf_type = gconf.VALUE_INVALID

    def __init__(self, *args, **kwargs):
        self.getter = getattr(gconf.Value, 'get_%s' % self.gconf_type.value_nick)
        self.setter = getattr(gconf.Value, 'set_%s' % self.gconf_type.value_nick)
        super(SimpleOption, self).__init__(*args, **kwargs)

    def __get__(self, instance, owner=None):
        gconf_value = super(SimpleOption, self).__get__(instance, owner)
        if gconf_value is None:
            return None
        return self.getter(gconf_value)

    def __set__(self, instance, value):
        gconf_value = gconf.Value(self.gconf_type)
        self.setter(gconf_value, value)
        super(SimpleOption, self).__set__(instance, gconf_value)