Hi,

In order to fully implement the new Etk_Tree in Etk-Perl, I need to be able
to set the fields of each model individually because I cannot manipulate
va_lists in the xs code.
Here's a patch that introduces two functions to set the fields of the model.

--
Chady 'Leviathan' Kassouf
http://chady.net/
? diff
Index: etk_tree.c
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.c,v
retrieving revision 1.82
diff -u -r1.82 etk_tree.c
--- etk_tree.c  17 Jan 2007 04:57:05 -0000      1.82
+++ etk_tree.c  25 Jan 2007 02:03:34 -0000
@@ -530,6 +530,7 @@
    col->models[col->num_models] = model;
    model->tree = col->tree;
    model->col = col;
+   model->index = col->num_models;
    col->num_models++;
 }
 
@@ -1059,6 +1060,28 @@
 }
 
 /**
+ * @brief Sets the values of a model of the cells of the row
+ * @param row a row of the tree
+ * @param emit_signal whether or not the "cell_value_changed" signal should be 
emitted on the modified columns.
+ * Most of the time, the signal don't need to be emitted (so @a emit_signal 
should be ETK_FALSE), except if you have
+ * callback connected on this signal
+ * @param ... an "Etk_Tree_Col *" followed by the "Etk_Tree_Model *", followed 
by the value of the cell,
+ * then any number of "Etk_Tree_Col *"/"Etk_Tree_Model *"/Value pairs, and 
terminated by NULL.
+ * Note that, according to the models used by the column, a cell value can use 
several parameters
+ */
+void etk_tree_row_model_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, 
...)
+{
+   va_list args;
+   
+   if (!row)
+      return;
+   
+   va_start(args, emit_signal);
+   etk_tree_row_model_fields_set_valist(row, emit_signal, args);
+   va_end(args);
+}
+
+/**
  * @brief Sets the values of the cells of the row
  * @param row a row of the tree
  * @param emit_signal whether or not the "cell_value_changed" signal should be 
emitted on the modified columns.
@@ -1085,6 +1108,43 @@
          if (col->models[i]->cell_data_set)
             col->models[i]->cell_data_set(col->models[i], 
row->cells_data[col->id][i], &args2);
       }
+      if (emit_signal)
+         
etk_signal_emit(_etk_tree_col_signals[ETK_TREE_COL_CELL_VALUE_CHANGED], 
ETK_OBJECT(col), NULL, row);
+   }
+   va_end(args2);
+   
+   if (!row->tree->frozen)
+      etk_widget_redraw_queue(ETK_WIDGET(row->tree));
+}
+
+/**
+ * @brief Sets the values of a model of the cells of the row
+ * @param row a row of the tree
+ * @param emit_signal whether or not the "cell_value_changed" signal should be 
emitted on the modified columns.
+ * Most of the time, the signal don't need to be emitted (so @a emit_signal 
should be ETK_FALSE), except if you have
+ * callback connected on this signal
+ * @param ... an "Etk_Tree_Col *" followed by the "Etk_Tree_Model *", followed 
by the value of the cell,
+ * then any number of "Etk_Tree_Col *"/"Etk_Tree_Model *"/Value pairs, and 
terminated by NULL.
+ * Note that, according to the models used by the column, a cell value can use 
several parameters
+ */
+void etk_tree_row_model_fields_set_valist(Etk_Tree_Row *row, Etk_Bool 
emit_signal, va_list args)
+{
+   Etk_Tree_Col *col;
+   va_list args2;
+   int i;
+   
+   if (!row)
+      return;
+   
+   va_copy(args2, args);
+   while ((col = va_arg(args2, Etk_Tree_Col *)))
+   {
+      Etk_Tree_Model *model;
+      model = va_arg(args2, Etk_Tree_Model *);
+      i = model->index;
+
+      if (col->models[i]->cell_data_set)
+         col->models[i]->cell_data_set(col->models[i], 
row->cells_data[col->id][i], &args2);
       if (emit_signal)
          
etk_signal_emit(_etk_tree_col_signals[ETK_TREE_COL_CELL_VALUE_CHANGED], 
ETK_OBJECT(col), NULL, row);
    }
Index: etk_tree.h
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree.h,v
retrieving revision 1.28
diff -u -r1.28 etk_tree.h
--- etk_tree.h  17 Jan 2007 04:57:05 -0000      1.28
+++ etk_tree.h  25 Jan 2007 02:03:34 -0000
@@ -204,6 +204,8 @@
 
 void etk_tree_row_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, ...);
 void etk_tree_row_fields_set_valist(Etk_Tree_Row *row, Etk_Bool emit_signal, 
va_list args);
+void etk_tree_row_model_fields_set(Etk_Tree_Row *row, Etk_Bool emit_signal, 
...);
+void etk_tree_row_model_fields_set_valist(Etk_Tree_Row *row, Etk_Bool 
emit_signal, va_list args);
 void etk_tree_row_fields_get(Etk_Tree_Row *row, ...);
 void etk_tree_row_fields_get_valist(Etk_Tree_Row *row, va_list args);
 
Index: etk_tree_model.c
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree_model.c,v
retrieving revision 1.12
diff -u -r1.12 etk_tree_model.c
--- etk_tree_model.c    16 Jan 2007 23:49:26 -0000      1.12
+++ etk_tree_model.c    25 Jan 2007 02:03:34 -0000
@@ -111,6 +111,7 @@
    model->objects_create = _text_objects_create;
    model->render = _text_render;
    model->width_get = _text_width_get;
+   model->index = 0;
    
    return model;
 }
@@ -133,6 +134,7 @@
    model->objects_create = _text_objects_create;
    model->render = _int_render;
    model->width_get = _text_width_get;
+   model->index = 0;
    
    return model;
 }
@@ -155,6 +157,7 @@
    model->objects_create = _text_objects_create;
    model->render = _double_render;
    model->width_get = _text_width_get;
+   model->index = 0;
    
    return model;
 }
@@ -181,6 +184,7 @@
    model->objects_cache = _image_objects_cache;
    model->render = _image_render;
    model->width_get = _image_width_get;
+   model->index = 0;
    
    image_model->width = 0;
    image_model->halign = 0.0;
@@ -207,6 +211,7 @@
    model->objects_create = _checkbox_objects_create;
    model->render = _checkbox_render;
    model->width_get = _checkbox_width_get;
+   model->index = 0;
    
    return model;
 }
@@ -230,6 +235,7 @@
    model->objects_create = _progress_bar_objects_create;
    model->render = _progress_bar_render;
    model->width_get = _progress_bar_width_get;
+   model->index = 0;
    
    return model;
 }
Index: etk_tree_model.h
===================================================================
RCS file: /cvs/e/e17/libs/etk/src/lib/etk_tree_model.h,v
retrieving revision 1.8
diff -u -r1.8 etk_tree_model.h
--- etk_tree_model.h    17 Jan 2007 04:57:05 -0000      1.8
+++ etk_tree_model.h    25 Jan 2007 02:03:34 -0000
@@ -22,6 +22,7 @@
    Etk_Tree *tree;
    Etk_Tree_Col *col;
    int cell_data_size;
+   int index;
    
    void (*model_free)(Etk_Tree_Model *model);
    void (*cell_data_init)(Etk_Tree_Model *model, void *cell_data);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to