GtkList problem solved
- From: "Faria, Sydney C" <sydney faria pw utc com>
- To: "Gtk app devel list (E-mail)" <gtk-app-devel-list gnome org>
- Subject: GtkList problem solved
- Date: Wed, 7 Sep 2005 08:22:10 -0400
There were a number of typos in the code: 1st GtkCellRendererText should be
GtkCellRenderer and 2nd gtk_list_store_append (...) is followed by 3
gtk_list_store_set(...) calls, but each of these should be preceded by a
gtk_list_store_append(...) call to get the current version of the iterator.
My code ended up as:
static void addToList(GtkWidget *listModel, const gchar *spn ) {
GtkTreeIter iter;
gtk_list_store_append(listModel, &iter);
gtk_list_store_set(listModel, &iter, SPN_COLUMN, spn, -1);
}
in main program code ...
GtkListStore *listModel;
listModel = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING);
addToList(listModel, "1st SPN");
addToList(listModel, "2nd SPN");
GtkWidget *list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(listModel));
GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("SPNs
in new display", renderer,
"text", SPN_COLUMN, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
gtk_widget_show(list);
I then packed the list into a table for formatting, which I found is much
better for formatting than the original vbox!
I still have a couple of question about this widget:
1. I saw some example code creating a cell renderer as follows:
renderer = gtk_cell_renderer_text_new(<!-- -->);
this looks like some sort of formatting or an xml tag or most likely a
typo, if not a typo what is it?
2. I also noticed that the code above creates a single column list with a
column head and the 2 list items inserted as expected; however,
when I typed in some characters a 'edititable box' appeared at the bottom
of the list! What is this and can I eliminate this behaviour?
Sydney
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]