サンプルコード
#!/usr/bin/ruby
require 'gtk2'
win = Gtk::Window.new
pxb = Gdk::Pixbuf.new("icon.png")
model = Gtk::ListStore.new(Gdk::Pixbuf, String)
iv = Gtk::IconView.new(model)
iv.pixbuf_column = 0 # Gdk::Pixbufを収納したmodelの添字を指定
iv.text_column = 1 # Stringを収納したmodelの添字を指定
model.set_value(l=model.append(), 0, pxb) # set_value(行, 列, 値)
model.set_value(l, 1, "hoge")
model.set_value(l=model.append(), 0, pxb)
model.set_value(l, 1, "fuga")
win.add(iv)
win.show_all()
Gtk.main()
メンバ
model
データ構造(Gtk::TreeModel).扱えるデータの種類にはアイコン(Gdk::Pixbuf)やアイコンに付けるテキスト(String)などがある.
- model
- modelを取得.
- model=(model)
- set_model(model)
- modelとしてmodelを設定.
selection_mode
アイコンを同時に選択できる数を表すモード(GtkSelectionMode).
- selection_mode
- selection_modeを取得.
- selection_mode=(selection_mode)
- set_selection_mode(selection_mode)
-
selection_modeとしてselection_modeを設定.
SELECTION_NONE 選択不可能. SELECTION_SIMGLE 1つ選択可能. SELECTION_BROWSE 1つ選択必須. SELECTION_MULTIPLE 複数選択可能.
コンストラクタ
- Gtk::IconView.new(model = nil)
- コンストラクタ.modelを設定.
TreeModelとIconView
表示するデータ(Gdk::PixbufやString)は,Gtk::TreeModel(model)によってGtk::IconViewとを関連付けられる.
- Gtk::IconView.set_pixbuf_column(pixbuf_column)
- Gtk::IconView.pixbuf_column=pixbuf_column
- modelが持つGdk::Pixbufの添字(column)番号をpixbuf_columnに設定.
- Gtk::IconView.set_text_column(text_column)
- Gtk::IconView.text_column=text_column
- modelが持つStringの添字(column)番号をtext_columnに設定..
シグナル
シグナル | イベント | 引数 |
---|---|---|
activate-cursor-item |
| |
item-activated |
| |
move-cursor |
| |
select-all |
| |
select-cursor-item |
| |
selection-changed |
| |
set-scroll-adjustments |
| |
toggle-cursor-item |
|