| 410 if(attributes != listview->current_row_attributes) { |
410 if(attributes != listview->current_row_attributes) { |
| 411 pango_attr_list_unref(attributes); |
411 pango_attr_list_unref(attributes); |
| 412 } |
412 } |
| 413 } |
413 } |
| 414 |
414 |
| 415 static void column_factory_unbind(GtkSignalListItemFactory *self, GtkListItem *item, UiColData *col) { |
415 static void column_factory_unbind(GtkSignalListItemFactory *self, GtkListItem *item, UiColData *col) { |
| 416 ObjWrapper *obj = gtk_list_item_get_item(item); |
416 ObjWrapper *obj = gtk_list_item_get_item(item); |
| 417 UiListView *listview = col->listview; |
417 UiListView *listview = col->listview; |
| 418 CxHashKey row_key = cx_hash_key(&obj->i, sizeof(int)); |
418 CxHashKey row_key = cx_hash_key(&obj->i, sizeof(int)); |
| 419 UiRowItems *row = cxMapGet(listview->bound_rows, row_key); |
419 UiRowItems *row = cxMapGet(listview->bound_rows, row_key); |
| 420 if(row) { |
420 if(row) { |
| 471 listview->bound_rows->collection.simple_destructor = (cx_destructor_func)free; |
471 listview->bound_rows->collection.simple_destructor = (cx_destructor_func)free; |
| 472 |
472 |
| 473 GtkListItemFactory *factory = gtk_signal_list_item_factory_new(); |
473 GtkListItemFactory *factory = gtk_signal_list_item_factory_new(); |
| 474 g_signal_connect(factory, "setup", G_CALLBACK(column_factory_setup), &listview->coldata); |
474 g_signal_connect(factory, "setup", G_CALLBACK(column_factory_setup), &listview->coldata); |
| 475 g_signal_connect(factory, "bind", G_CALLBACK(column_factory_bind), &listview->coldata); |
475 g_signal_connect(factory, "bind", G_CALLBACK(column_factory_bind), &listview->coldata); |
| |
476 g_signal_connect(factory, "unbind", G_CALLBACK(column_factory_unbind), &listview->coldata); |
| 476 |
477 |
| 477 GtkSelectionModel *selection_model = create_selection_model(listview, ls, args->multiselection); |
478 GtkSelectionModel *selection_model = create_selection_model(listview, ls, args->multiselection); |
| 478 GtkWidget *view = gtk_list_view_new(GTK_SELECTION_MODEL(selection_model), factory); |
479 GtkWidget *view = gtk_list_view_new(GTK_SELECTION_MODEL(selection_model), factory); |
| 479 |
480 |
| 480 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST); |
481 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST); |
| 755 listview->numcolumns = insert_index+1; |
756 listview->numcolumns = insert_index+1; |
| 756 listview->columns = realloc(listview->columns, listview->numcolumns * sizeof(UiColData)); |
757 listview->columns = realloc(listview->columns, listview->numcolumns * sizeof(UiColData)); |
| 757 } |
758 } |
| 758 |
759 |
| 759 gtk_column_view_set_model(GTK_COLUMN_VIEW(listview->widget), NULL); |
760 gtk_column_view_set_model(GTK_COLUMN_VIEW(listview->widget), NULL); |
| |
761 cxMapClear(listview->bound_rows); |
| 760 |
762 |
| 761 if(insert_index) { |
763 if(insert_index) { |
| 762 listview->columns[insert_index] = insert_index; |
764 int prev = 0; |
| |
765 if(insert_index > 0) { |
| |
766 prev = listview->columns[insert_index-1]; |
| |
767 } |
| |
768 listview->columns[insert_index] = prev+1; |
| 763 add_column(listview, insert_index); |
769 add_column(listview, insert_index); |
| 764 // TODO: adjust data_column if insert_index < numcolumns |
770 |
| |
771 if(insert_index+1 < listview->numcolumns) { |
| |
772 // the data index of trailing columns must be adjusted |
| |
773 UiModelType type = model->types[insert_index]; |
| |
774 int add = 1; |
| |
775 if(type == UI_ICON_TEXT || type == UI_ICON_TEXT_FREE) { |
| |
776 add++; |
| |
777 } |
| |
778 for(int i=insert_index+1;i<listview->numcolumns;i++) { |
| |
779 listview->columns[i] += add; |
| |
780 } |
| |
781 } |
| 765 } // TODO: delete_index |
782 } // TODO: delete_index |
| 766 |
783 |
| 767 GListStore *ls = g_list_store_new(G_TYPE_OBJECT); |
784 GListStore *ls = g_list_store_new(G_TYPE_OBJECT); |
| 768 GtkSelectionModel *selection_model = create_selection_model(listview, ls, listview->multiselection); |
785 GtkSelectionModel *selection_model = create_selection_model(listview, ls, listview->multiselection); |
| 769 gtk_column_view_set_model(GTK_COLUMN_VIEW(listview->widget), selection_model); |
786 gtk_column_view_set_model(GTK_COLUMN_VIEW(listview->widget), selection_model); |
| 902 |
919 |
| 903 void ui_listview_update2(UiList *list, int i) { |
920 void ui_listview_update2(UiList *list, int i) { |
| 904 UiListView *view = list->obj; |
921 UiListView *view = list->obj; |
| 905 view->current_row = -1; |
922 view->current_row = -1; |
| 906 if(i < 0) { |
923 if(i < 0) { |
| |
924 cxMapClear(view->bound_rows); |
| 907 ui_update_liststore(view->liststore, list); |
925 ui_update_liststore(view->liststore, list); |
| 908 } else { |
926 } else { |
| 909 void *value = list->get(list, i); |
927 void *value = list->get(list, i); |
| 910 if(value) { |
928 if(value) { |
| 911 ObjWrapper *obj = g_list_model_get_item(G_LIST_MODEL(view->liststore), i); |
929 ObjWrapper *obj = g_list_model_get_item(G_LIST_MODEL(view->liststore), i); |