2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkListStore.html
28 * strct = GtkListStore
36 * extend = GtkTreeModel
44 * - gtk_list_store_set
53 * - GtkTreeIter* -> TreeIter
59 private import gtk
.gtktypes
;
61 private import lib
.gtk
;
63 private import gtk
.TreeModel
;
64 private import glib
.Str
;
65 private import gtk
.TreeIter
;
66 private import gobject
.Value
;
67 private import glib
.Str
;
71 * The GtkListStore object is a list model for use with a GtkTreeView
72 * widget. It implements the GtkTreeModel interface, and consequentialy,
73 * can use all of the methods available there. It also implements the
74 * GtkTreeSortable interface so it can be sorted by the view.
75 * Finally, it also implements the tree drag and
77 * The GtkListStore can accept most GObject types as a column type, though
78 * it can't accept all custom types. Internally, it will keep a copy of
79 * data passed in (such as a string or a boxed pointer). Columns that
80 * accept GObjects are handled a little differently. The
81 * GtkListStore will keep a reference to the object instead of copying the
82 * value. As a result, if the object is modified, it is up to the
83 * application writer to call gtk_tree_model_row_changed to emit the
84 * "row_changed" signal. This most commonly affects lists with
86 * Example5.Creating a simple list store.
94 * GtkListStore *list_store;
98 * list_store = gtk_list_store_new (N_COLUMNS,
102 * for (i = 0; i < 10; i++)
105 * some_data = get_some_data (i);
106 * /+* Add a new row to the model +/
107 * gtk_list_store_append (list_store, iter);
108 * gtk_list_store_set (list_store, iter,
109 * COLUMN_STRING, some_data,
111 * COLUMN_BOOLEAN, FALSE,
113 * /+* As the store will keep a copy of the string internally, we
116 * g_free (some_data);
118 * /+* Modify a particular row +/
119 * path = gtk_tree_path_new_from_string ("4");
120 * gtk_tree_model_get_iter (GTK_TREE_MODEL (list_store),
123 * gtk_tree_path_free (path);
124 * gtk_list_store_set (list_store, iter,
125 * COLUMN_BOOLEAN, TRUE,
128 * Performance Considerations
129 * Internally, the GtkListStore was implemented with a linked list with a
130 * tail pointer prior to GTK+ 2.6. As a result, it was fast at data
131 * insertion and deletion, and not fast at random data access. The
132 * GtkListStore sets the GTK_TREE_MODEL_ITERS_PERSIST flag, which means
133 * that GtkTreeIters can be cached while the row exists. Thus, if
134 * access to a particular row is needed often and your code is expected to
135 * run on older versions of GTK+, it is worth keeping the iter around.
137 * It is important to note that only the methods gtk_list_store_insert_with_values and
138 * gtk_list_store_insert_with_valuesv are atomic, in the sense that the row is being appended
139 * to the store and the values filled in in a single operation with regard to GtkTreeModel signaling.
140 * In contrast, using e.g. gtk_list_store_append and then gtk_list_store_set will first create a row,
141 * which triggers the "row_inserted" GtkTreeModel signal on GtkListStore. The row, however, is still
142 * empty, and any signal handler connecting to "row_inserted" on this particular store should be prepared
143 * for the situation that the row might be empty.
144 * This is especially important if you are wrapping the GtkListStore inside a GtkTreeModelFilter and are
145 * using a GtkTreeModelFilterVisibleFunc. Using any of the non-atomic operations to append rows to the GtkListStore
146 * will cause the GtkTreeModelFilterVisibleFunc to be visited with an empty row first; the function must be prepared for that.
148 private import gtk
.TreeModel
;
149 public class ListStore
: TreeModel
152 /** the main Gtk struct */
153 protected GtkListStore
* gtkListStore
;
156 public GtkListStore
* getListStoreStruct()
162 /** the main Gtk struct as a void* */
163 protected void* getStruct()
165 return cast(void*)gtkListStore
;
169 * Sets our main struct and passes it to the parent class
171 public this (GtkListStore
* gtkListStore
)
173 super(cast(GtkTreeModel
*)gtkListStore
);
174 this.gtkListStore
= gtkListStore
;
178 * Non-vararg creation function. Used primarily by language bindings.
180 * number of columns in the list store
182 * an array of GType types for the columns, from first to last
186 public this (GType
[] types
)
188 // GtkListStore* gtk_list_store_newv (gint n_columns, GType *types);
189 this(cast(GtkListStore
*)gtk_list_store_newv(types
.length
, cast(GType
*)(types
.ptr
)) );
193 * Creates a top level iteractor.
194 * I don't think lists have but the top level iteractor
196 TreeIter
createIter()
198 GtkTreeIter
* iter
= new GtkTreeIter
;
199 gtk_list_store_append(getListStoreStruct(), iter
);
200 return new TreeIter(iter
);
204 * sets the values for one row
205 * @param iter the row iteractor
206 * @param columns an arrays with the columns to set
207 * @param values an arrays with the values
209 void set(TreeIter iter
, int [] columns
, char*[] values
)
211 for ( int i
=0 ; i
<columns
.length
&& i
<values
.length
; i
++ )
213 //Value v = new Value(values[i]);
214 //gtk_list_store_set(obj(), iter.getIter(), columns[i], v.getV(),-1);
217 iter
.getTreeIterStruct(),
223 void set(TreeIter iter
, int [] columns
, char[][] values
)
225 for ( int i
=0 ; i
<columns
.length
&& i
<values
.length
; i
++ )
227 //Value v = new Value(values[i]);
228 //gtk_list_store_set(obj(), iter.getIter(), columns[i], v.getV(),-1);
231 iter
.getTreeIterStruct(),
233 Str
.toStringz(values
[i
]),-1);
237 void setValue(TreeIter iter
, int column
, char[] value
)
239 Value v
= new Value(value
);
240 gtk_list_store_set_value(gtkListStore
, iter
.getTreeIterStruct(), column
, v
.getValueStruct());
241 //gtk_list_store_set_value(obj(), iter.getIter(), column, (GValue*)cChar(value));
244 void setValue(TreeIter iter
, int column
, int value
)
246 Value v
= new Value(value
);
247 gtk_list_store_set_value(gtkListStore
, iter
.getTreeIterStruct(), column
, v
.getValueStruct());
255 * Creates a new list store as with n_columns columns each of the types passed
256 * in. Note that only types derived from standard GObject fundamental types
258 * As an example, gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,
259 * GDK_TYPE_PIXBUF); will create a new GtkListStore with three columns, of type
260 * int, string and GdkPixbuf respectively.
262 * number of columns in the list store
264 * all GType types for the columns, from first to last
268 public this (int nColumns
, ... )
270 // GtkListStore* gtk_list_store_new (gint n_columns, ...);
271 this(cast(GtkListStore
*)gtk_list_store_new(nColumns
) );
275 * Non-vararg creation function. Used primarily by language bindings.
277 * number of columns in the list store
279 * an array of GType types for the columns, from first to last
283 public this (int nColumns
, GType
* types
)
285 // GtkListStore* gtk_list_store_newv (gint n_columns, GType *types);
286 this(cast(GtkListStore
*)gtk_list_store_newv(nColumns
, types
) );
290 * This function is meant primarily for GObjects that inherit from GtkListStore,
291 * and should only be used when constructing a new GtkListStore. It will not
292 * function after a row has been added, or a method on the GtkTreeModel
293 * interface is called.
297 * Number of columns for the list store
299 * An array length n of GTypes
301 public void setColumnTypes(int nColumns
, GType
* types
)
303 // void gtk_list_store_set_column_types (GtkListStore *list_store, gint n_columns, GType *types);
304 gtk_list_store_set_column_types(gtkListStore
, nColumns
, types
);
309 * See gtk_list_store_set(); this version takes a va_list for use by language
314 * A valid GtkTreeIter for the row being modified
316 * va_list of column/value pairs
318 public void setValist(TreeIter iter
, void* varArgs
)
320 // void gtk_list_store_set_valist (GtkListStore *list_store, GtkTreeIter *iter, va_list var_args);
321 gtk_list_store_set_valist(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), varArgs
);
325 * Sets the data in the cell specified by iter and column.
326 * The type of value must be convertible to the type of the
331 * A valid GtkTreeIter for the row being modified
333 * column number to modify
335 * new value for the cell
337 public void setValue(TreeIter iter
, int column
, Value value
)
339 // void gtk_list_store_set_value (GtkListStore *list_store, GtkTreeIter *iter, gint column, GValue *value);
340 gtk_list_store_set_value(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), column
, (value
is null) ?
null : value
.getValueStruct());
344 * Removes the given row from the list store. After being removed,
345 * iter is set to be the next valid row, or invalidated if it pointed
346 * to the last row in list_store.
350 * A valid GtkTreeIter
352 * TRUE if iter is valid, FALSE if not.
354 public int remove(TreeIter iter
)
356 // gboolean gtk_list_store_remove (GtkListStore *list_store, GtkTreeIter *iter);
357 return gtk_list_store_remove(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct());
361 * Creates a new row at position. iter will be changed to point to this new
362 * row. If position is larger than the number of rows on the list, then the
363 * new row will be appended to the list. The row will be empty after this
364 * function is called. To fill in values, you need to call
365 * gtk_list_store_set() or gtk_list_store_set_value().
369 * An unset GtkTreeIter to set to the new row
371 * position to insert the new row
373 public void insert(TreeIter iter
, int position
)
375 // void gtk_list_store_insert (GtkListStore *list_store, GtkTreeIter *iter, gint position);
376 gtk_list_store_insert(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), position
);
380 * Inserts a new row before sibling. If sibling is NULL, then the row will
381 * be appended to the end of the list. iter will be changed to point to this
382 * new row. The row will be empty after this function is called. To fill in
383 * values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
387 * An unset GtkTreeIter to set to the new row
389 * A valid GtkTreeIter, or NULL
391 public void insertBefore(TreeIter iter
, TreeIter sibling
)
393 // void gtk_list_store_insert_before (GtkListStore *list_store, GtkTreeIter *iter, GtkTreeIter *sibling);
394 gtk_list_store_insert_before(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), (sibling
is null) ?
null : sibling
.getTreeIterStruct());
398 * Inserts a new row after sibling. If sibling is NULL, then the row will be
399 * prepended to the beginning of the list. iter will be changed to point to
400 * this new row. The row will be empty after this function is called. To fill
401 * in values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
405 * An unset GtkTreeIter to set to the new row
407 * A valid GtkTreeIter, or NULL
409 public void insertAfter(TreeIter iter
, TreeIter sibling
)
411 // void gtk_list_store_insert_after (GtkListStore *list_store, GtkTreeIter *iter, GtkTreeIter *sibling);
412 gtk_list_store_insert_after(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), (sibling
is null) ?
null : sibling
.getTreeIterStruct());
416 * Creates a new row at position. iter will be changed to point to this new
417 * row. If position is larger than the number of rows on the list, then the
418 * new row will be appended to the list. The row will be filled with the
419 * values given to this function.
421 * gtk_list_store_insert_with_values(list_store, iter, position...)
422 * has the same effect as calling
423 * gtk_list_store_insert (list_store, iter, position);
424 * gtk_list_store_set (list_store, iter, ...);
425 * with the difference that the former will only emit a row_inserted signal,
426 * while the latter will emit row_inserted, row_changed and, if the list store
427 * is sorted, rows_reordered. Since emitting the rows_reordered signal
428 * repeatedly can affect the performance of the program,
429 * gtk_list_store_insert_with_values() should generally be preferred when
430 * inserting rows in a sorted list store.
434 * An unset GtkTreeIter to set to the new row, or NULL.
436 * position to insert the new row
438 * pairs of column number and value, terminated with -1
441 public void insertWithValues(TreeIter iter
, int position
, ... )
443 // void gtk_list_store_insert_with_values (GtkListStore *list_store, GtkTreeIter *iter, gint position, ...);
444 gtk_list_store_insert_with_values(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), position
);
448 * A variant of gtk_list_store_insert_with_values() which
449 * takes the columns and values as two arrays, instead of
450 * varargs. This function is mainly intended for
455 * An unset GtkTreeIter to set to the new row, or NULL.
457 * position to insert the new row
459 * an array of column numbers
461 * an array of GValues
463 * the length of the columns and values arrays
466 public void insertWithValuesv(TreeIter iter
, int position
, int* columns
, Value values
, int nValues
)
468 // void gtk_list_store_insert_with_valuesv (GtkListStore *list_store, GtkTreeIter *iter, gint position, gint *columns, GValue *values, gint n_values);
469 gtk_list_store_insert_with_valuesv(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), position
, columns
, (values
is null) ?
null : values
.getValueStruct(), nValues
);
473 * Prepends a new row to list_store. iter will be changed to point to this new
474 * row. The row will be empty after this function is called. To fill in
475 * values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
479 * An unset GtkTreeIter to set to the prepend row
481 public void prepend(TreeIter iter
)
483 // void gtk_list_store_prepend (GtkListStore *list_store, GtkTreeIter *iter);
484 gtk_list_store_prepend(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct());
488 * Appends a new row to list_store. iter will be changed to point to this new
489 * row. The row will be empty after this function is called. To fill in
490 * values, you need to call gtk_list_store_set() or gtk_list_store_set_value().
494 * An unset GtkTreeIter to set to the appended row
496 public void append(TreeIter iter
)
498 // void gtk_list_store_append (GtkListStore *list_store, GtkTreeIter *iter);
499 gtk_list_store_append(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct());
503 * Removes all rows from the list store.
509 // void gtk_list_store_clear (GtkListStore *list_store);
510 gtk_list_store_clear(gtkListStore
);
515 * This function is slow. Only use it for debugging and/or testing
517 * Checks if the given iter is a valid iter for this GtkListStore.
523 * TRUE if the iter is valid, FALSE if the iter is invalid.
526 public int iterIsValid(TreeIter iter
)
528 // gboolean gtk_list_store_iter_is_valid (GtkListStore *list_store, GtkTreeIter *iter);
529 return gtk_list_store_iter_is_valid(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct());
533 * Reorders store to follow the order indicated by new_order. Note that
534 * this function only works with unsorted stores.
538 * an array of integers mapping the new position of each child
539 * to its old position before the re-ordering,
540 * i.e. new_order[newpos] = oldpos.
543 public void reorder(int* newOrder
)
545 // void gtk_list_store_reorder (GtkListStore *store, gint *new_order);
546 gtk_list_store_reorder(gtkListStore
, newOrder
);
550 * Swaps a and b in store. Note that this function only works with
557 * Another GtkTreeIter.
560 public void swap(TreeIter a
, TreeIter b
)
562 // void gtk_list_store_swap (GtkListStore *store, GtkTreeIter *a, GtkTreeIter *b);
563 gtk_list_store_swap(gtkListStore
, (a
is null) ?
null : a
.getTreeIterStruct(), (b
is null) ?
null : b
.getTreeIterStruct());
567 * Moves iter in store to the position before position. Note that this
568 * function only works with unsorted stores. If position is NULL, iter
569 * will be moved to the end of the list.
575 * A GtkTreeIter, or NULL.
578 public void moveBefore(TreeIter iter
, TreeIter position
)
580 // void gtk_list_store_move_before (GtkListStore *store, GtkTreeIter *iter, GtkTreeIter *position);
581 gtk_list_store_move_before(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), (position
is null) ?
null : position
.getTreeIterStruct());
585 * Moves iter in store to the position after position. Note that this
586 * function only works with unsorted stores. If position is NULL, iter
587 * will be moved to the start of the list.
593 * A GtkTreeIter or NULL.
596 * GtkTreeModel, GtkTreeStore
598 public void moveAfter(TreeIter iter
, TreeIter position
)
600 // void gtk_list_store_move_after (GtkListStore *store, GtkTreeIter *iter, GtkTreeIter *position);
601 gtk_list_store_move_after(gtkListStore
, (iter
is null) ?
null : iter
.getTreeIterStruct(), (position
is null) ?
null : position
.getTreeIterStruct());