Question

I have an dialog window with Gtk::TreeView. This dialod shows main filesystem tree and provides option to select folders on the disk. When user selects some folder, I am adding an Gtk::Stock image to the row that represents that folder.

To do this, I have created an Gtk::CellRendererPixbuf associated with the last column of my tree:

//appending columns
directory_tree.append_column("Folder List", dir_columns.name);
Gtk::TreeViewColumn *column = directory_tree.get_column(0);
if(column) column->set_expand(true);
Gtk::CellRendererPixbuf *cell = Gtk::manage(new Gtk::CellRendererPixbuf);
directory_tree.append_column("", *cell);
column = directory_tree.get_column(1);
if(column) column->add_attribute(cell->property_stock_id(), dir_columns.stock_id);

Link to this bit of code: https://github.com/mc-suchecki/Imagine/blob/master/gui/dialogs.cpp#L47

Gtk::CellRendererPixbuf 'translates' Gtk::StockId found in 'dir_columns.stock_id' to an image located in tree. When I add image to row like this:

//selecting folder
(*folder)[fs_columns.stock_id] = Gtk::StockID(Gtk::Stock::FIND).get_string();
(*folder)[fs_columns.included] = true;

everything is ok, but when I try to delete the image this way:

//unselecting folder
(*folder)[fs_columns.stock_id] = "";
(*folder)[fs_columns.included] = false;

the image correctly disappears, but there are some errors in command line like this (this is not the exact message, I will post it when I will be able to launch my application):

(imagine:9376): Gtk-WARNING **: Gtk StockId not found 

Of course the reason of the warning is obvious (there is no StockId item associated with blank name), however my question is: Is there a way to delete an image from Gtk::TreeView row which would not generate any Gtk warnings?

Code where i deselect folder is here: https://github.com/mc-suchecki/Imagine/blob/master/core/core.cpp#L207

Thank you very much in advance and sorry for my English.

Était-ce utile?

La solution

Change the visible property to false if you want to get rid of the image, instead of the stock-id property.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top