Creates a new GtkIconView instance. To make it actually display something, you need to add a data model (e.g. a GtkListStore) and some scroll bars.
Example 74. GtkIconView filled with stock icons
<?php //GtkIconView example $wnd = new GtkWindow(); $wnd->set_title('GtkIconView'); $wnd->set_default_size(400, 400); $wnd->connect_simple('destroy', array('Gtk', 'main_quit')); $iv = new GtkIconView(); $model = new GtkListStore(GdkPixbuf::gtype, Gtk::TYPE_STRING); $iv->set_model($model); //fill the model with some nice icons $ids = Gtk::stock_list_ids(); sort($ids); foreach ($ids as $id) { $pixbuf = $iv->render_icon($id, Gtk::ICON_SIZE_DIALOG); $model->set($model->append(), 0, $pixbuf, 1, $id); } $iv->set_pixbuf_column(0); $iv->set_text_column(1); //number of columns in view, not model $iv->set_columns(0); $iv->set_item_width(100); //make it scrollable $scrollwin = new GtkScrolledWindow(); $scrollwin->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); $scrollwin->add($iv); $wnd->add($scrollwin); $wnd->show_all(); Gtk::main(); ?> |