Class: MittensUi::Image
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes inherited from Core
Instance Method Summary collapse
- #click ⇒ Object
-
#initialize(path, options = {}) ⇒ Image
constructor
A new instance of Image.
- #render ⇒ Object
Methods inherited from Core
#hidden?, #hide, #remove, #show
Methods included from Helpers
#icon_map, #list_system_icons, #set_margin_from_opts_for
Constructor Details
#initialize(path, options = {}) ⇒ Image
Returns a new instance of Image.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mittens_ui/image.rb', line 7 def initialize(path, = {}) @path = File.join(path.strip) tooltip_text = [:tooltip_text].nil? ? "" : [:tooltip_text] width = [:width].nil? ? 80 : [:width] height = [:height].nil? ? 80 : [:height] pixbuf = nil args_to_send = {} if path.include?(".gif") pixbuf = GdkPixbuf::PixbufAnimation.new(@path) args_to_send[:animation] = pixbuf else pixbuf = GdkPixbuf::Pixbuf.new(file: @path, width: width, height: height) args_to_send[:pixbuf] = pixbuf end @image = Gtk::Image.new(args_to_send) @image.tooltip_text = tooltip_text @event_box = Gtk::EventBox.new.add_child(@image) super(@image, ) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/mittens_ui/image.rb', line 5 def path @path end |
Instance Method Details
#click ⇒ Object
34 35 36 37 38 |
# File 'lib/mittens_ui/image.rb', line 34 def click @event_box.signal_connect("button_press_event") do yield end end |
#render ⇒ Object
40 41 42 43 |
# File 'lib/mittens_ui/image.rb', line 40 def render $vertical_box.pack_start(@event_box) return self end |