[Gtk-sharp-list] Gtk.ComboBoxEntry issues with setting text...

Dennis Craven dcraven at gmail.com
Fri Mar 28 18:55:23 EDT 2008


Hi list,

I'm trying to use a ComboBoxEntry to show a list of strings. The model
is of type ListStore. Once realized, the associated menu of available
text
selections drops down as expected, but when one is chosen, the given
text does not appear in the ComboBoxEntry.Entry and the following
assertion appears in the console:

    Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed

The relevant (I think) code goes like this:

         // projectStore is a valid ListStore, containing custom objects
         // of type Project. These have a Name property that is of type string.
         ListStore projectStore = db.GetListStore();

         projectComboBoxEntry = new ComboBoxEntry ();
         CellRendererText projectCellRenderer = new CellRendererText ();
         projectComboBoxEntry.PackStart (projectCellRenderer, true);

         projectComboBoxEntry.SetCellDataFunc (projectCellRenderer,
               new Gtk.CellLayoutDataFunc (ProjectComboBoxEntryDataFunc));
         projectComboBoxEntry.Model = projectStore;

         projectComboBoxEntry.Show ();

      // This is the CellDataFunc
      void ProjectComboBoxEntryDataFunc (CellLayout layout,
            CellRenderer renderer, TreeModel model, TreeIter iter)
      {
         Gtk.CellRendererText crt = renderer as Gtk.CellRendererText;
         Project project = model.GetValue (iter, 0) as Project;

         crt.Text = string.Format ("{0}", project.Name);
      }

I don't see what the problem with this code could be. If I use a ComboBox with
identical code, it works fine.

Any pointers will be appreciated.
~djc


More information about the Gtk-sharp-list mailing list