ui/gtk/model.c

changeset 140
c03c338a7dcf
parent 129
5babf09f5f19
child 142
46448d38885c
--- a/ui/gtk/model.c	Tue Jan 24 18:46:47 2017 +0100
+++ b/ui/gtk/model.c	Fri Nov 10 17:17:14 2017 +0100
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright 2014 Olaf Wintermann. All rights reserved.
+ * Copyright 2017 Olaf Wintermann. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -92,7 +92,7 @@
 
 static void list_model_init(UiListModel *instance, GObjectClass *cl) {
     instance->columntypes = NULL;
-    instance->list = NULL;
+    instance->var = NULL;
     instance->numcolumns = 0;
     instance->stamp = g_random_int();
 }
@@ -122,10 +122,10 @@
     value->g_type = G_TYPE_INVALID; 
 }
 
-UiListModel* ui_list_model_new(UiListPtr *list, UiModelInfo *info) {
+UiListModel* ui_list_model_new(UiVar *var, UiModelInfo *info) {
     UiListModel *model = g_object_new(list_model_type, NULL);
     model->info = info;
-    model->list = list;
+    model->var = var;
     model->columntypes = calloc(sizeof(GType), 2 * info->columns);
     int ncol = 0;
     for(int i=0;i<info->columns;i++) {
@@ -168,7 +168,7 @@
 {
     g_assert(IS_UI_LIST_MODEL(tree_model));
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
+    UiList *list = model->var->value;
     
     // check the depth of the path
     // a list must have a depth of 1
@@ -215,7 +215,6 @@
     g_return_val_if_fail(iter->user_data != NULL, NULL);
     
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
     
     GtkTreePath *path = gtk_tree_path_new();
     gtk_tree_path_append_index(path, (int)(intptr_t)iter->user_data2); // list->index
@@ -234,7 +233,7 @@
     g_return_if_fail(iter->user_data != NULL);
     
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
+    UiList *list = model->var->value;
     
     g_return_if_fail(column < model->numcolumns);
     
@@ -261,7 +260,7 @@
     g_return_val_if_fail(iter->user_data != NULL, FALSE);
     
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
+    UiList *list = model->var->value;
     list->iter = iter->user_data;
     //list->index = (int)(intptr_t)iter->user_data2;
     void *val = list->next(list);
@@ -282,7 +281,7 @@
     g_return_val_if_fail(IS_UI_LIST_MODEL(tree_model), FALSE);
     
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
+    UiList *list = model->var->value;
     
     if(parent) {
         return FALSE;
@@ -317,7 +316,7 @@
     if(!iter) {
         // return number of rows
         UiListModel *model = UI_LIST_MODEL(tree_model);
-        UiList *list = model->list->list;
+        UiList *list = model->var->value;
         return list->count(list);
     }
     
@@ -337,7 +336,7 @@
     }
     
     UiListModel *model = UI_LIST_MODEL(tree_model);
-    UiList *list = model->list->list;
+    UiList *list = model->var->value;
     
     // check n
     if(n == 0) {

mercurial