Re: GtkTreeView: Simple application



On Sat, May 26, 2007 at 03:19:49AM +0300, Felipe Balbi wrote:

my doubt regards this code:

int main(int argc, char *argv[])
{
      GladeXML        *openhset;
      GtkWidget       *main_window, *test_window;
      GtkWidget       *main_window_treeview1;
      GtkWidget       *main_window_ok;

      GtkListStore    *main_window_list;
      GtkTreeIter     iter;

      GtkCellRenderer *renderer;
      GtkTreeViewColumn       *column;

      struct usb_bus  *bus;

      gtk_init(&argc, &argv);

      /* Open the XML File */
      openhset = glade_xml_new (OPENHSET_XML, NULL, NULL);

      /* Get Widgets */
      main_window = glade_xml_get_widget (openhset, "main_window");
      main_window_ok = glade_xml_get_widget (openhset, "main_window_ok");
      main_window_treeview1 = glade_xml_get_widget (openhset,
"main_window_treeview1");

      /* Connect signal handlers */
      glade_xml_signal_autoconnect (openhset);

      /* Create a GtkListStore */
      main_window_list = gtk_list_store_new (1, G_TYPE_STRING);

      /* Populate the GtkListStore */
      gtk_list_store_append (main_window_list, &iter);
      gtk_list_store_set (main_window_list, &iter,
                      0, "TESTING",
                      -1);

      /* Add the GtkListStore to the GtkTreeView */
      gtk_tree_view_set_model (GTK_TREE_VIEW (main_window_treeview1),
GTK_TREE_MODEL (main_window_list));

      /* Renderer and column */
      renderer = gtk_cell_renderer_text_new();
      column = gtk_tree_view_column_new_with_attributes ("USB HCD", renderer,
                      "text", 1, NULL);

Doesn't this print a warning to console?

Your list store has only one column, which therefore gets
number 0, and here you are trying to bind some renderer
attribute to (nonexistent) column 1.

      gtk_tree_view_append_column (GTK_TREE_VIEW (main_window_treeview1), column);

      gtk_main();

      return 0;
}

So... I can't see the result of:

      gtk_list_store_set (main_window_list, &iter,
                      0, "TESTING",
                      -1);

It's not being listed in the treeview after building / running the code.

Probably a consequence of the problem above -- the tree view
has not actually got anything to display.

Yeti

--
http://gwyddion.net/



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