Re: [gtkmm] Combobox usage



On Sun, Aug 22, 2004 at 11:23:25AM +0200, Enrico Zini wrote:

> > How does one attach a column view to a ComboBox in the same way one
> > would for a TreeView? Is this even possible? Shouldn't the ComboBox just
> > be (conceptually) a different view for a list?
> Hello,

I answer myself, after having found some more explanation in the PyGTK
documentation:

    // Editor selection
    editorListModel = Gtk::ListStore::create(editorListModelColumns);
            Gtk::TreeModel::Row row = *(editorListModel->append());
            row[editorListModelColumns.name] = "mutt";
            row[editorListModelColumns.command] = "mutt -f %p";
            row = *(editorListModel->append());
            row[editorListModelColumns.name] = "other";
            row[editorListModelColumns.command] = "sample-mail-editor --folder %p";
    line = Gtk::manage(new Gtk::HBox());
    diavbox->pack_start(*line, false, false);
    line->pack_start(*manage(new Gtk::Label("Mail editor:")), true, true);
    Gtk::ComboBox* cb;
    line->pack_start(*manage(cb = new Gtk::ComboBox(editorListModel)), false, false);
    Gtk::CellRendererText* crt;
    cb->pack_start(*manage(crt = new Gtk::CellRendererText()), true);
    cb->add_attribute(crt->property_text(), editorListModelColumns.name);

ComboBox implements the CellLayout interface which behaves a bit like a Column
in a TreeView; however, there's no append_column method in CellLayout, so one
has to go through the full process of creating the renderer and associating a
property to it.


Ciao,

Enrico

--
GPG key: 1024D/797EBFAB 2000-12-05 Enrico Zini <enrico debian org>

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]