ComboBox and TreeStore



Hello,

I need to display the content of a TreeStore into a ComboBox,
but the following problems happen:
1. When the user expands a node, the children of it
are not displayed. You have to pop up the combo box again
for the children to be drawn ( this happens when MS Windows
theme is used )
2. If a child node is activated, then popping up the combo box
first time will display only the root elements. Popping up second time,
children are displayed correctly, but the root element is selected,
not the active node.

Are these GTK bugs? I'm using gtkmm-2.10.11-1. If they are bugs,
have they been solved in a later version? I couldn't find a document
with changes of GTK.

Below is an example application where you can see the behavior of (1).

Thank you

-----------------------------------------------------------------------

#include <gtkmm.h>

class ExampleWindow : public Gtk::Window
{
public:
   ExampleWindow();
   virtual ~ExampleWindow() {}

protected:
   class ModelColumns : public Gtk::TreeModel::ColumnRecord
   {
   public:
       ModelColumns() { add(x); }
       Gtk::TreeModelColumn<Glib::ustring> x;
   };

   Gtk::ComboBox combo;
   ModelColumns columns;
   Glib::RefPtr<Gtk::TreeStore> treeModel;
};


ExampleWindow::ExampleWindow()
{
   set_title("ComboBox example");
   set_border_width(5);
   set_default_size(400, 0);
   add(combo);

   treeModel = Gtk::TreeStore::create(columns);
   Gtk::TreeIter i;
   i = treeModel->append(); (*i)[columns.x] = "A";
   i = treeModel->append(i->children()); (*i)[columns.x] = "A.1";

   combo.set_model(treeModel);
   combo.pack_start(columns.x);

   show_all_children();
}


int main(int argc, char *argv[])
{
   Gtk::Main kit(argc, argv);

   ExampleWindow window;
   Gtk::Main::run(window);

   return 0;
}



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