TreeModelFilter as model for IconView.
- From: "Jorge Cardona" <jorgeecardona gmail com>
- To: gtk-app-devel-list gnome org
- Subject: TreeModelFilter as model for IconView.
- Date: Wed, 15 Oct 2008 11:26:36 -0500
Greetings.
I'm building an application and i use a global TreeStore to store some
elements.I have in a window a Gtk::TreeView and a Gtk::IconView, i
create then two TreeModelFilter, because I want to show just some
elements from my global TreeStore in my Gtk::TreeView and others in
the Gtk::IconView, i can set the Filter to the Gtk::TreeView without
problems, but when i used the same procedure to set the Gtk::IconView
model, well it compile, but in runtime i got this error:
(gtkmodelica:25279): Gtk-CRITICAL **: gtk_icon_view_set_model:
assertion `gtk_tree_model_get_flags (model) &
GTK_TREE_MODEL_LIST_ONLY' failed
I assume that i just can pass to an iconview a list as a model, but
there is a way to create a list model from a filter??
Some code from my application:
Here i set the TreeView model:
blocks = new Blocks();
packages_tree_store = Gtk::TreeModelFilter::create(blocks->tree_store);
packages_tree_store->set_visible_func(sigc::mem_fun(*blocks,
&Blocks::on_package));
treeview_packages->set_model(packages_tree_store);
treeview_packages->append_column("Categoria",blocks->model_record->name);
My global TreeStore is a tree, but when generate the TreeModelFilter
for the iconview i created in base to a node at the last path, so, it
could be used as a list, but i don't know how to tell to gtk that
treat this TreeModelFilter as a list.
void Gui::on_treeview_packages_cursor_changed()
{
Glib::RefPtr<Gtk::TreeSelection> tree_selection =
treeview_packages->get_selection();
Gtk::TreeModel::iterator iter = tree_selection->get_selected();
if (iter)
{
Gtk::TreeModel::Row row = *iter;
label_description->set_label(row[blocks->model_record->description]);
Gtk::TreePath tree_path = Gtk::TreePath(iter);
blocks_list_store =
Gtk::TreeModelFilter::create(blocks->tree_store,tree_path);
blocks_list_store->set_visible_func(sigc::mem_fun(*blocks,
&Blocks::on_block));
iconview_blocks->set_model(blocks_list_store);
iconview_blocks->set_text_column(blocks->model_record->name);
}
}
And the definition of block class:
class Blocks
{
public:
Blocks();
class Model_Record : public Gtk::TreeModelColumnRecord
{
public:
Model_Record()
{add(name); add(path); add(description); add(icon);
add(is_block);}
Gtk::TreeModelColumn< Glib::ustring >
name;
Gtk::TreeModelColumn< Glib::ustring >
path;
Gtk::TreeModelColumn< Glib::ustring >
description;
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > icon;
Gtk::TreeModelColumn< bool >
is_block;
};
Model_Record *model_record;
Glib::RefPtr< Gtk::TreeStore > tree_store;
bool on_package(const Gtk::TreeModel::const_iterator& iter)
{ return not ((*iter)[model_record->is_block]); }
bool on_block(const Gtk::TreeModel::const_iterator& iter)
{ return (*iter)[model_record->is_block]; }
protected:
private:
gint16 read_blocks(std::vector<Glib::ustring> filename,
Gtk::TreeNodeChildren parent);
};
Can i create a TreeModelFilter to be used in an iconview? or i got to
create a new liststore?
Thanks.
--
Jorge Eduardo Cardona
jorgeecardona gmail com
jorgeecardona.blogspot.com
------------------------------------------------
Linux registered user #391186
Registered machine #291871
------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]