Class: Gtk::CssProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/gtk4/css-provider.rb

Instance Method Summary collapse

Instance Method Details

#load(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/gtk4/css-provider.rb', line 19

def load(options)
  string = options[:string]
  bytes = options[:bytes]
  data = options[:data]
  file = options[:file]
  path = options[:path]
  resource_path = options[:resource_path]
  if string
    if Version.or_later?(4, 12, 0)
      load_from_string(string)
    else
      load_from_data(string)
    end
  elsif bytes
    if Version.or_later?(4, 12, 0)
      load_from_bytes(bytes)
    else
      load_from_data(bytes)
    end
  elsif data
    if Version.or_later?(4, 12, 0)
      load_from_bytes(data)
    else
      load_from_data(data)
    end
  elsif file
    load_from_file(file)
  elsif path
    load_from_path(path)
  elsif resource_path
    load_from_resource(resource_path)
  else
    message = "Must specify one of " +
              ":string, :bytes, :data, :file, :path or :resource_path"
    raise ArgumentError, "#{message}: #{options.inspect}"
  end
end

#load_from_data(data) ⇒ Object



59
60
61
62
# File 'lib/gtk4/css-provider.rb', line 59

def load_from_data(data)
  data = data.to_s if data.is_a?(GLib::Bytes)
  load_from_data_raw(data, data.bytesize)
end

#load_from_data_rawObject



57
# File 'lib/gtk4/css-provider.rb', line 57

alias_method :load_from_data_raw, :load_from_data