ModelList

ModelList — a mutable list of ModelObject instances

Description

ModelList is a mutable list of ModelObject instances (items). Items can be inserted and removed, changing the length and composition of the list.

ModelReference is not used here. The only way to change the value of an item at a particular array index is to remove that item and insert a new one at the same position.

When the list changes, the "changed" signal is emitted. The signal is always emitted from the mainloop; never during the execution of method calls on the model.

Details

ModelList

typedef struct {
  ModelObject parent_instance;
} ModelList;

This is an opaque structure; it may not be accessed directly.


ModelListClass

typedef struct {
  ModelObjectClass parent_class;

  gulong        (*n_children) (ModelList *list);
  ModelObject * (*get_child)  (ModelList *list,
                               gulong     index);
} ModelListClass;

The class structure for ModelList. All virtual functions must be implemented by each subclass.

ModelObjectClass parent_class;

n_children ()

virtual function pointer for model_list_n_children()

get_child ()

virtual function pointer for model_list_get_child()

model_list_n_children ()

gulong              model_list_n_children               (ModelList *list);

Gets the number of items in list.

list :

a ModelList

returns :

the number of items in list

model_list_get_child ()

ModelObject *       model_list_get_child                (ModelList *list,
                                                         gulong index);

Gets the child value at position index of list. index must be a valid index in the array (ie: strictly less than the result of model_list_n_children()).

It is appropriate for the caller to call g_object_unref() on the return value.

list :

a modelList

index :

the index of the child value to get

returns :

the ModelObject for the child value, owned by the caller

model_list_changed ()

void                model_list_changed                  (ModelList *list,
                                                         gulong position,
                                                         gulong removed,
                                                         gulong inserted,
                                                         gboolean more);

Emits the "changed" signal on list.

list :

a ModelList

position :

the position at which the change occurred

removed :

the number of items removed in the change

inserted :

the number of items inserted in the change

more :

TRUE if more changes are coming