

This does not work with the SUN Forte compiler: If((id.length() >= prefix_length) & (id.compare(0, prefix_length, prefix) = 0)) Glib::ustring::const_iterator id_pos = id.begin() Glib::ustring Example_StockBrowser::id_to_symbol(const Gtk::StockID& stockid)Ĭonst size_t prefix_length = sizeof(prefix) - 1 Ĭonst Glib::ustring id = stockid.get_string() Row = render_icon(stockid, Gtk::ICON_SIZE_MENU) Row = Gtk::AccelGroup::name(keyval, item.get_modifier()) If(const unsigned int keyval = item.get_keyval()) Populate Accel column, if the stock item has an accelerator key. Gtk::TreeModel::Row row = *(refStore->append()) iterate through them, populating the ListStore as appropriateįor(type_vecIDs::const_iterator iterIDs = vecIDs.begin() iterIDs != vecIDs.end() ++iterIDs) Type_vecIDs vecIDs = Gtk::Stock::get_ids() RefStore->set_sort_column(m_columns.id, Gtk::SORT_ASCENDING) Glib::RefPtr refStore = Gtk::ListStore::create(m_columns) Glib::RefPtr Example_StockBrowser::create_model()

Sigc::mem_fun(*this, &Example_StockBrowser::on_selection_changed)) Įxample_StockBrowser::~Example_StockBrowser() M_refTreeSelection->signal_changed().connect( M_refTreeSelection->set_mode(Gtk::SELECTION_SINGLE) M_refTreeSelection = m_TreeView.get_selection() M_VBox.pack_start(m_Label_ID, Gtk::PACK_SHRINK) M_VBox.pack_start(m_Label_Symbol, Gtk::PACK_SHRINK) M_VBox.pack_start(m_Label_Accel, Gtk::PACK_SHRINK) M_VBox.pack_start(m_Image, Gtk::PACK_SHRINK) M_VBox.pack_start(m_Label_Type, Gtk::PACK_SHRINK) M_TreeView.append_column("ID", m_columns.id) //Defaults to CellRendererText for a string model column. M_TreeView.append_column("Accelerator", m_columns.accel) //Defaults to CellRendererText for a string model column. M_TreeView.append_column("Label", m_columns.label) //Defaults to CellRendererText for a string model column. PColumn->pack_start(m_columns.icon, false) m_columns.icon and m_columns.symbol are columns in the model. The icon/symbol column uses two CellRenderers: Here we see why Gtk::TreeView is so good Gtk::TreeView::Column* pColumn = Gtk::manage( new Gtk::TreeView::Column("Symbol") ) //We specify the renderer(s) after construction. add columns to the TreeView, mapping model Columns to TreeView m_columns::

create the TreeView, associate the TreeModel with it create the TreeModel with all the stock item data in it M_HBox.pack_start(m_ScrolledWindow, Gtk::PACK_SHRINK) M_t_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC) ModelColumns() Įxample_StockBrowser::Example_StockBrowser() Struct ModelColumns : public Gtk::TreeModel::ColumnRecord Static Glib::ustring id_to_symbol(const Gtk::StockID& stockid) // convert StockID to Gtk::Stock symbol * stock items probably won't be useful for the vast majorityĬlass Example_StockBrowser: public Gtk::Window
#Gtkmm stock icons code
The code for retrieving and displaying all * renderers into one column and using Gtk::CellRendererPixbuf * things not seen in other demos, such as packing multiple * for the use of Gtk::TreeView, as it demonstrates a few * The source code for this demo is only really useful Entweder du gibst den Icons eine eigene Spalte oder du machst es wie in der demo anwendung (Abschnitt Stockicon Browser) /* Stock Item and Icon Browser Du kannst mit Hilfe von Gtk::CellRendererPixbuf Icons davor anzeigen.
