class Gio::Settings - gio2-3.2.9 Documentation

# class Gio::Settings

### Public Class Methods

new(*args) click to toggle source

    # File lib/gio2/settings.rb, line 21
    def initialize(*args)
      if args.size == 1
        if args[0].is_a?(String)
          initialize_raw(args[0])
        else
          initialize_with_hash_args(args[0])
        end
      elsif args.size == 2
        schema_id = args[0]
        options = args[1]
        path = options[:path] || nil
        backend = options[:backend] || nil
        if path && backend
          initialize_new_with_backend_and_path(schema_id, backend, path)
        elsif path
          initialize_new_with_path(schema_id, path)
        elsif backend
          initialize_new_with_backend(schema_id, backend)
        end
      elsif args.size == 3
        initialize_new_full(*args)
      else
        message =
          "must specify one of the following combinations: " +
          "schema_id, " +
          "options, " +
          "schema_id and options, " +
          "schema and backend and path " +
          "instead of: #{args.inspect}"
        raise ArgumentError, message
      end
    end

Also aliased as: initialize_raw

### Public Instance Methods

[]=(key, value)
Alias for: set_value
initialize_raw(*args)
Alias for: new
initialize_with_hash_args(options) click to toggle source

    # File lib/gio2/settings.rb, line 54
    def initialize_with_hash_args(options)
      path = options[:path] || nil
      schema_id = options[:schema_id] || nil
      backend = options[:backend] || nil
      schema = options[:schema] || nil
      if schema_id
        if path && backend
          initialize_new_with_backend_and_path(schema_id, backend, path)
        elsif path
          initialize_new_with_path(schema_id, path)
        elsif backend
          initialize_new_with_backend(schema_id, backend)
        else
          initialize_raw(schema_id)
        end
      elsif schema
        initialize_new_full(schema, backend, path)
      else
        message =
          "must specify one of the following combinations: " +
          ":schema_id, " +
          ":schema_id and :path, " +
          ":schema_id and :backend, " +
          ":schema_id and :backend and :path, " +
          ":schema, " +
          ":schema and :path, " +
          ":schema and :backend, " +
          "or :schema and :backend and :path " +
          "instead of: #{options.inspect}"
        raise ArgumentError, message
      end
    end

set_value(key, value) click to toggle source

    # File lib/gio2/settings.rb, line 88
    def set_value(key, value)
      schema_key = settings_schema.get_key(key)
      variant_value = GLib::Variant.new(value, schema_key.value_type)
      set_value_raw(key, variant_value)
    end

Also aliased as: set_value_raw, []=
set_value_raw(key, value)
Alias for: set_value