ComboBox
Gtk が提供する基本は aString
または aのみを処理できます。Pixbuf
しかし、選択範囲の同じ行の近くにテキストと画像が必要でした。
Haskell と Gtk2Hs を使用して以下の結果を取得する方法をしばらく探しました。
期待される結果を得るためのコードは次のとおりです。
pic1 <- pixbufNewFromFile "Picture_1.png"
pic2 <- pixbufNewFromFile "Picture_2.png"
pic3 <- pixbufNewFromFile "Picture_3.png"
let lstsecrep = [
("Picture 1",pic1)
, ("Picture 2",pic2)
, ("Picture 3",pic3)
]
lststorerep <- listStoreNew lstsecrep
customStoreSetColumn lststorerep (makeColumnIdString 0) fst
customStoreSetColumn lststorerep (makeColumnIdPixbuf 1) snd
combo <- comboBoxNewWithModel lststorerep
rendertxt <- cellRendererTextNew
renderpic <- cellRendererPixbufNew
cellLayoutPackStart combo rendertxt False
cellLayoutPackStart combo renderpic True
cellLayoutAddColumnAttribute combo rendertxt cellText $ makeColumnIdString 0
cellLayoutAddColumnAttribute combo renderpic cellPixbuf $ makeColumnIdPixbuf 1
よろしくお願いします。