Skip to content

Instantly share code, notes, and snippets.

@yuntan
Created October 8, 2019 18:09
Show Gist options
  • Save yuntan/bc3064cf6e07887c97bf0077e07e70e6 to your computer and use it in GitHub Desktop.
Save yuntan/bc3064cf6e07887c97bf0077e07e70e6 to your computer and use it in GitHub Desktop.
require 'gtk3'
class MyWidget < Gtk::Widget
type_register
def initialize()
super()
self.has_window = true
self.redraw_on_allocate = true
end
def request_mode
notice 'request_mode'
Gtk::SizeRequestMode::HEIGHT_FOR_WIDTH
end
def preferred_width
notice 'preferred_width'
[100, 250] # minimum, natural
end
def preferred_height
notice 'preferred_height'
h = preferred_height_for_width 250
[h, h]
end
def preferred_height_for_width(width)
notice "preferred_height_for_width(#{width})"
h = 3 * width
[h, h]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment