Class: Gtk::Widget
- Inherits:
-
Object
- Object
- Gtk::Widget
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk3/widget.rb,
lib/gtk3/deprecated.rb
Class Method Summary collapse
- .have_template? ⇒ Boolean
- .set_connect_func(&block) ⇒ Object
- .set_connect_func_raw ⇒ Object
- .template_children ⇒ Object
Instance Method Summary collapse
- #add_events(new_events) ⇒ Object
- #add_events_raw ⇒ Object
- #bind_template_child(name, options = {}) ⇒ Object
- #drag_dest_set(flags, targets, actions) ⇒ Object
- #drag_dest_set_raw ⇒ Object
- #drag_source_set(flags, targets, actions) ⇒ Object
- #drag_source_set_raw ⇒ Object
- #events ⇒ Object
- #events_raw ⇒ Object
- #insert_action_group(name, group) ⇒ Object
- #insert_action_group_raw ⇒ Object
- #render_icon_pixbuf(stock_id, size) ⇒ Object
- #render_icon_pixbuf_raw ⇒ Object
- #set_allocation(*args) ⇒ Object
- #set_events(new_events) ⇒ Object (also: #events=)
- #set_events_raw ⇒ Object
- #set_size_request(*args) ⇒ Object
- #set_size_request_raw ⇒ Object
- #set_template(template) ⇒ Object
- #set_template_raw ⇒ Object
- #style_context ⇒ Object
- #style_context_raw ⇒ Object
- #style_get_property(name) ⇒ Object
- #style_get_property_raw ⇒ Object
- #translate_coordinates(widget, x, y) ⇒ Object
- #translate_coordinates_raw ⇒ Object
Class Method Details
.have_template? ⇒ Boolean
20 21 22 |
# File 'lib/gtk3/widget.rb', line 20 def have_template? @have_template ||= false end |
.set_connect_func(&block) ⇒ Object
51 52 53 54 55 |
# File 'lib/gtk3/widget.rb', line 51 def set_connect_func(&block) set_connect_func_raw do |*args| Builder.connect_signal(*args, &block) end end |
.set_connect_func_raw ⇒ Object
50 |
# File 'lib/gtk3/widget.rb', line 50 alias_method :set_connect_func_raw, :set_connect_func |
.template_children ⇒ Object
24 25 26 |
# File 'lib/gtk3/widget.rb', line 24 def template_children @template_children ||= [] end |
Instance Method Details
#add_events(new_events) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/gtk3/widget.rb', line 64 def add_events(new_events) unless new_events.is_a?(Gdk::EventMask) new_events = Gdk::EventMask.new(new_events) end add_events_raw(new_events.to_i) end |
#add_events_raw ⇒ Object
63 |
# File 'lib/gtk3/widget.rb', line 63 alias_method :add_events_raw, :add_events |
#bind_template_child(name, options = {}) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gtk3/widget.rb', line 41 def bind_template_child(name, ={}) internal_child = [:internal_child] internal_child = false if internal_child.nil? bind_template_child_full(name, internal_child, 0) template_children << name attr_reader(name) end |
#drag_dest_set(flags, targets, actions) ⇒ Object
107 108 109 110 |
# File 'lib/gtk3/widget.rb', line 107 def drag_dest_set(flags, targets, actions) targets = ensure_drag_targets(targets) drag_dest_set_raw(flags, targets, actions) end |
#drag_dest_set_raw ⇒ Object
106 |
# File 'lib/gtk3/widget.rb', line 106 alias_method :drag_dest_set_raw, :drag_dest_set |
#drag_source_set(flags, targets, actions) ⇒ Object
101 102 103 104 |
# File 'lib/gtk3/widget.rb', line 101 def drag_source_set(flags, targets, actions) targets = ensure_drag_targets(targets) drag_source_set_raw(flags, targets, actions) end |
#drag_source_set_raw ⇒ Object
100 |
# File 'lib/gtk3/widget.rb', line 100 alias_method :drag_source_set_raw, :drag_source_set |
#events ⇒ Object
59 60 61 |
# File 'lib/gtk3/widget.rb', line 59 def events Gdk::EventMask.new(events_raw) end |
#events_raw ⇒ Object
58 |
# File 'lib/gtk3/widget.rb', line 58 alias_method :events_raw, :events |
#insert_action_group(name, group) ⇒ Object
145 146 147 148 149 150 151 152 153 |
# File 'lib/gtk3/widget.rb', line 145 def insert_action_group(name, group) insert_action_group_raw(name, group) @action_groups ||= {} if group.nil? @action_groups.delete(name) else @action_groups[name] = group end end |
#insert_action_group_raw ⇒ Object
144 |
# File 'lib/gtk3/widget.rb', line 144 alias_method :insert_action_group_raw, :insert_action_group |
#render_icon_pixbuf(stock_id, size) ⇒ Object
124 125 126 127 |
# File 'lib/gtk3/widget.rb', line 124 def render_icon_pixbuf(stock_id, size) size = IconSize.new(size) unless size.is_a?(IconSize) render_icon_pixbuf_raw(stock_id, size) end |
#render_icon_pixbuf_raw ⇒ Object
123 |
# File 'lib/gtk3/widget.rb', line 123 alias_method :render_icon_pixbuf_raw, :render_icon_pixbuf |
#set_allocation(*args) ⇒ Object
1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
# File 'lib/gtk3/deprecated.rb', line 1084 def set_allocation(*args) case args.size when 1 __set_allocation__(args.first) when 4 warn "#{caller[0]}: '#{self.class}#set_allocation(x, y, width, height)' style has been deprecated. Use '#{self.class}#set_allocation(alloc)' style." __set_allocation__(Gtk::Allocation.new(*args)) else raise ArgumentError.new("need 1 or 4 arguments.") end end |
#set_events(new_events) ⇒ Object Also known as: events=
72 73 74 75 76 77 |
# File 'lib/gtk3/widget.rb', line 72 def set_events(new_events) unless new_events.is_a?(Gdk::EventMask) new_events = Gdk::EventMask.new(new_events) end set_events_raw(new_events.to_i) end |
#set_events_raw ⇒ Object
71 |
# File 'lib/gtk3/widget.rb', line 71 alias_method :set_events_raw, :set_events |
#set_size_request(*args) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/gtk3/widget.rb', line 83 def set_size_request(*args) case args.size when 1 = args[0] raise ArgumentError, ":width is missing" unless .key?(:width) width = [:width] raise ArgumentError, ":height is missing" unless .key?(:height) height = [:height] when 2 width, height = args else = "wrong number of arguments (given #{args.size}, expected 1..2)" raise ArgumentError, end set_size_request_raw(width, height) end |
#set_size_request_raw ⇒ Object
82 |
# File 'lib/gtk3/widget.rb', line 82 alias_method :set_size_request_raw, :set_size_request |
#set_template(template) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gtk3/widget.rb', line 30 def set_template(template) resource = template[:resource] data = template[:data] if resource set_template_from_resource(resource) else set_template_raw(data) end @have_template = true end |
#set_template_raw ⇒ Object
29 |
# File 'lib/gtk3/widget.rb', line 29 alias_method :set_template_raw, :set_template |
#style_context ⇒ Object
140 141 142 |
# File 'lib/gtk3/widget.rb', line 140 def style_context @style_context ||= style_context_raw end |
#style_context_raw ⇒ Object
139 |
# File 'lib/gtk3/widget.rb', line 139 alias_method :style_context_raw, :style_context |
#style_get_property(name) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/gtk3/widget.rb', line 113 def style_get_property(name) property = self.class.find_style_property(name) if property.nil? raise ArgumentError, "unknown style: #{name.inspect}" end value = GLib::Value.new(property.value_type) style_get_property_raw(name, value) value.value end |
#style_get_property_raw ⇒ Object
112 |
# File 'lib/gtk3/widget.rb', line 112 alias_method :style_get_property_raw, :style_get_property |
#translate_coordinates(widget, x, y) ⇒ Object
130 131 132 133 134 135 136 137 |
# File 'lib/gtk3/widget.rb', line 130 def translate_coordinates(, x, y) translated, x, y = translate_coordinates_raw(, x, y) if translated [x, y] else nil end end |
#translate_coordinates_raw ⇒ Object
129 |
# File 'lib/gtk3/widget.rb', line 129 alias_method :translate_coordinates_raw, :translate_coordinates |