Class: Gtk::Builder
- Inherits:
- 
      Object
      
        - Object
- Gtk::Builder
 
- Defined in:
- lib/gtk4/builder.rb
Instance Method Summary collapse
- #<<(target) ⇒ Object
- #add(target_or_options = {}) ⇒ Object
- #add_from_string(string) ⇒ Object
- #add_from_string_raw ⇒ Object
- #add_objects_from_string(string, object_ids) ⇒ Object
- #add_objects_from_string_raw ⇒ Object
- 
  
    
      #initialize(options = {})  ⇒ Builder 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Builder. 
- #initialize_raw ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Builder
Returns a new instance of Builder.
| 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # File 'lib/gtk4/builder.rb', line 22 def initialize(={}) object = [:object] path = [:path] || [:file] resource = [:resource] string = [:string] initialize_new set_current_object(object) if object set_scope(RubyBuilderScope.new) if path path = path.to_path if path.respond_to?(:to_path) add_from_file(path) elsif resource add_from_resource(resource) elsif string add_from_string(string) end end | 
Instance Method Details
#<<(target) ⇒ Object
| 103 104 105 106 | # File 'lib/gtk4/builder.rb', line 103 def <<(target) add(target) self end | 
#add(target_or_options = {}) ⇒ Object
| 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | # File 'lib/gtk4/builder.rb', line 54 def add(={}) if .is_a?(Hash) = else target = = {} if target.respond_to?(:to_path) [:path] = target.to_path elsif target.start_with?("<") or target.start_with?(" ") [:string] = target elsif File.exist?(target) [:path] = target else [:resource] = target end end string = [:string] path = [:path] || [:file] resource = [:resource] object_ids = [:object_ids] if path path = path.to_path if path.respond_to?(:to_path) if object_ids add_objects_from_file(path, object_ids) else add_from_file(path) end elsif resource if object_ids add_objects_from_resource(resource, object_ids) else add_from_resource(resource) end elsif string if object_ids add_objects_from_string(string, object_ids) else add_from_string(string) end else = ":path (:file), :resource or :string " + "must be specified: #{.inspect}" raise InvalidArgument, end end | 
#add_from_string(string) ⇒ Object
| 45 46 47 | # File 'lib/gtk4/builder.rb', line 45 def add_from_string(string) add_from_string_raw(string, string.bytesize) end | 
#add_from_string_raw ⇒ Object
| 44 | # File 'lib/gtk4/builder.rb', line 44 alias_method :add_from_string_raw, :add_from_string | 
#add_objects_from_string(string, object_ids) ⇒ Object
| 50 51 52 | # File 'lib/gtk4/builder.rb', line 50 def add_objects_from_string(string, object_ids) add_objects_from_string_raw(string, string.bytesize, object_ids) end | 
#add_objects_from_string_raw ⇒ Object
| 49 | # File 'lib/gtk4/builder.rb', line 49 alias_method :add_objects_from_string_raw, :add_objects_from_string | 
#initialize_raw ⇒ Object
| 21 | # File 'lib/gtk4/builder.rb', line 21 alias_method :initialize_raw, :initialize |