-
-
Save shibafu528/ad5b3a709d2bbbb8616661a5b6cbed86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S vala --pkg gtk+-3.0 | |
using Gtk; | |
// 最小サイズ・自然サイズを両方なかったことにするコンテナ | |
class CondenseContainer : Gtk.Bin { | |
public override void get_preferred_width(out int minimum_width, out int natural_width) { | |
base.get_preferred_width(out minimum_width, out natural_width); | |
print(@"get_preferred_width: minimum = $minimum_width, natural = $natural_width\n"); | |
// この2行をコメントしたりしなかったりすると挙動が変わるよ | |
minimum_width = 0; | |
natural_width = 0; | |
} | |
public override void get_preferred_height(out int minimum_height, out int natural_height) { | |
base.get_preferred_height(out minimum_height, out natural_height); | |
print(@"get_preferred_height: minimum = $minimum_height, natural = $natural_height\n"); | |
// widthのほうとおなじく | |
minimum_height = 0; | |
natural_height = 0; | |
} | |
} | |
int main(string[] args) { | |
Gtk.init(ref args); | |
var window = new Window(); | |
window.title = "box size test"; | |
window.set_size_request(128, 128); | |
window.set_position(Gtk.WindowPosition.CENTER); | |
window.destroy.connect(Gtk.main_quit); | |
var box = new Box(Orientation.VERTICAL, 0); | |
//box.hexpand = false; | |
//box.vexpand = false; | |
//box.valign = Align.START; | |
var button = new Button.with_label("too late"); | |
//button.halign = Align.START; | |
box.pack_start(button); | |
var image = new Image.from_file("/home/shibafu/git/mikutter/core/skin/data/icon.png"); | |
//image.halign = Align.START; | |
box.pack_start(image); | |
var label = new Label("あなたを詐欺罪と器物損壊罪で訴えます!理由はもちろんお分かりですね?あなたが皆をこんなておくれたプラグインで騙し、mikutterを破壊したからです!覚悟の準備をしておいて下さい。ちかいうちに訴えます。裁判も起こします。裁判所にも問答無用できてもらいます。慰謝料の準備もしておいて下さい!貴方は犯罪者です!刑務所にぶち込まれる楽しみにしておいて下さい!いいですね!"); | |
//label.hexpand = false; | |
box.pack_start(label); | |
var outer = new CondenseContainer(); | |
outer.add(box); | |
window.add(outer); | |
window.show_all(); | |
Gtk.main(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment