Using a 2-column layout in a ComboBox



Althought this has already been discussed in this list, I still can't get
my code to work. I have a ComboBox and I want it to have 2 columns, one
with an image, and another one with a string.

This is the relevant part of my code:


The model for the column (header file):

	class StatusComboModelColumns :
	public Gtk::TreeModelColumnRecord {
		public:
			StatusComboModelColumns();

			Gtk::TreeModelColumn<
				Glib::RefPtr<Gdk::Pixbuf> >
					m_col_status_icon;

			Gtk::TreeModelColumn<Glib::ustring>
				m_col_status_string;
	};

The model for the columns (source file):

	StatusComboModelColumns::StatusComboModelColumns() {
		add(m_col_status_icon);
		add(m_col_status_string);
	}

The widget (derived from ComboBox):

	StatusComboWidget::StatusComboWidget(
		BaseObjectType* cobject,
		const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
	{
		m_model_statuses = Gtk::ListStore::create(m_model_columns);
		this->set_model(m_model_statuses);

		Gtk::TreeModel::Row row;
		// available
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconAvailable();
		row[m_model_columns.m_col_status_string] = gettext("Available");
		// chatty
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconChatty();
		row[m_model_columns.m_col_status_string] = gettext("Chatty");
		// away
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconAway();
		row[m_model_columns.m_col_status_string] = gettext("Away");
		// extended away
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconXAway();
		row[m_model_columns.m_col_status_string] = gettext("Extended away");
		// do not disturb
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconDND();
		row[m_model_columns.m_col_status_string] = gettext("Do Not Disturb");
		// offline
		row = *(m_model_statuses->append());
		row[m_model_columns.m_col_status_icon] = this->getIconOffline();
		row[m_model_columns.m_col_status_string] = gettext("Offline");

		this->pack_start(m_model_columns.m_col_status_icon);
		this->pack_start(m_model_columns.m_col_status_string);
	}

I really don't understand what's wrong. The ComboBox appears as empty.
Please let me know if you find anything wrong in my code.

Thank you very much in advance!

-- 
Salvatore Iovene
+358404181646
Movial Oy



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