Sorting problem
- From: Maulet <llistes_lfs yahoo es>
- To: gtk-app-devel-list gnome org
- Subject: Sorting problem
- Date: Sun, 13 Feb 2005 14:58:12 +0000
Hi again.
First of all thanks for the aid with my GtkTreeModelFilter problem.
But... problems don't come alone! and here's another one:
I'm displaying a tree view with two sortable columns.
When I select a row and sort the tree view by clicking in one column
header, the selected row is always the same (it "follows" the changes in
the tree view). But when I sort the tree view by clicking in the headers
of both columns alternatively... the selected row changes!
Here's the code:
---[ begin code ]---
#include <gtk/gtk.h>
int main(int argc, char* *argv)
{
GtkWidget *window, *view;
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeIter iter;
GtkTreeViewColumn *column;
enum { COL_STRING, COL_INT, N_COLS };
gtk_init(&argc, &argv);
store = gtk_list_store_new(N_COLS, G_TYPE_STRING, G_TYPE_INT);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, COL_STRING, "animal", COL_INT,
2, -1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, COL_STRING, "zoo", COL_INT, 0, -1);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, COL_STRING, "foot", COL_INT, 3,
-1);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("String",
cell, "text",
COL_STRING, NULL);
gtk_tree_view_column_set_sort_column_id(column, COL_STRING);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
cell = gtk_cell_renderer_text_new();
column = gtk_tree_view_column_new_with_attributes("Int", cell,
"text",
COL_INT, NULL);
gtk_tree_view_column_set_sort_column_id(column, COL_INT);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "destroy", gtk_main_quit, NULL);
gtk_container_add(GTK_CONTAINER(window), view);
gtk_widget_show_all(window);
gtk_main();
}
--[ end code ]--
Thanks!
--
David Rosal i Ricart
<drosalri7 fis ub edu>
--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]