Class: Gtk::Image
- Inherits:
-
Object
- Object
- Gtk::Image
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gtk3/image.rb,
lib/gtk3/deprecated.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Image
constructor
Creates a Gtk::Image.
- #initialize_raw ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Image
Creates a Gtk::Image. The source of the image depends on the options given.
icon = Gio::Icon.new_for_string 'path/to/the/image.png'
image = Gtk::Image.new :icon => icon, :size => :dialog
pixbuf = GdkPixbuf::Pixbuf.new(:file => 'path/to/the/image.png')
iconSet = Gtk::IconSet.new pixbuf
image = Gtk::Image.new :icon_set => iconSet, :size => :dialog
surface = Cairo::ImageSurface.new :RGB24, 60, 60
context = Cairo::Context.new surface
context.set_source_rgb 0, 1, 0
context.rectangle 10, 10, 40, 40
context.fill.stroke
image = Gtk::Image.new :surface => surface
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/gtk3/image.rb', line 76 def initialize(={}) stock = [:stock] || nil icon_name = [:icon_name] || nil icon_set = [:icon_set] || nil icon = [:icon] || [:gicon] || nil file = [:file] || nil pixbuf = [:pixbuf] || nil animation = [:animation] || nil resource = [:resource] ||nil surface = [:surface] || nil size = [:size] || nil case size when String, Symbol size = IconSize.new(size) else size ||= IconSize::BUTTON end if stock initialize_new_from_stock(stock, size) elsif icon_name initialize_new_from_icon_name(icon_name, size) elsif icon_set initialize_new_from_icon_set(icon_set, size) elsif icon initialize_new_from_gicon(icon, size) elsif file initialize_new_from_file(file) elsif pixbuf initialize_new_from_pixbuf(pixbuf) elsif animation initialize_new_from_animation(animation) elsif resource initialize_new_from_resource(resource) elsif surface initialize_new_from_surface(surface) else initialize_raw end end |
Instance Method Details
#initialize_raw ⇒ Object
19 |
# File 'lib/gtk3/image.rb', line 19 alias_method :initialize_raw, :initialize |