Top | ![]() |
![]() |
![]() |
![]() |
void | filter-changed | Run Last |
void | row-added | Run Last |
void | row-changed | Run Last |
void | row-removed | Run Last |
void | sort-changed | Run Last |
ClutterModel is a generic list model API which can be used to implement the model-view-controller architectural pattern in Clutter.
The ClutterModel class is a list model which can accept most GObject types as a column type.
The example below shows how to create a simple list model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
enum { COLUMN_INT, COLUMN_STRING, N_COLUMNS }; { ClutterModel *model; gint i; model = clutter_list_model_new (N_COLUMNS, // column type, title G_TYPE_INT, "my integers", G_TYPE_STRING, "my strings"); for (i = 0; i < 10; i++) { gchar *string = g_strdup_printf ("String %d", i); clutter_model_append (model, COLUMN_INT, i, COLUMN_STRING, string, -1); g_free (string); } } |
Iterating through the model consists of retrieving a new ClutterModelIter
pointing to the starting row, and calling clutter_model_iter_next()
or
clutter_model_iter_prev()
to move forward or backwards, repectively.
A valid ClutterModelIter represents the position between two rows in the model. For example, the "first" iterator represents the gap immediately before the first row, and the "last" iterator represents the gap immediately after the last row. In an empty sequence, the first and last iterators are the same.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
enum { COLUMN_INT, COLUMN_STRING. N_COLUMNS }; { ClutterModel *model; ClutterModelIter *iter = NULL; // fill the model model = populate_model (); // get the iterator for the first row in the model iter = clutter_model_get_first_iter (model); while (!clutter_model_iter_is_last (iter)) { print_row (iter); iter = clutter_model_iter_next (iter); } // Make sure to unref the iter g_object_unref (iter); } |
ClutterModel is an abstract class. Clutter provides a list model implementation called ClutterListModel which has been optimised for insertion and look up in sorted lists.
ClutterModel is available since Clutter 0.6
ClutterModel defines a custom property "columns" for ClutterScript which allows defining the column names and types. It also defines a custom "rows" property which allows filling the ClutterModel with some data.
The definition below will create a ClutterListModel with three columns: the first one with name "Name" and containing strings; the second one with name "Score" and containing integers; the third one with name "Icon" and containing ClutterTextures. The model is filled with three rows. A row can be defined either with an array that holds all columns of a row, or an object that holds "column-name" : "column-value" pairs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{ "type" : "ClutterListModel", "id" : "teams-model", "columns" : [ [ "Name", "gchararray" ], [ "Score", "gint" ], [ "Icon", "ClutterTexture" ] ], "rows" : [ [ "Team 1", 42, { "type" : "ClutterTexture", "filename" : "team1.png" } ], [ "Team 2", 23, "team2-icon-script-id" ], { "Name" : "Team 3", "Icon" : "team3-icon-script-id" } ] } |
void clutter_model_set_names (ClutterModel *model
,guint n_columns
,const gchar * const names[]
);
clutter_model_set_names
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Assigns a name to the columns of a ClutterModel.
This function is meant primarily for GObjects that inherit from ClutterModel, and should only be used when contructing a ClutterModel. It will not work after the initial creation of the ClutterModel.
model |
||
n_columns |
the number of column names |
|
names |
an array of strings. |
[array length=n_columns] |
Since: 0.6
void clutter_model_set_types (ClutterModel *model
,guint n_columns
,GType *types
);
clutter_model_set_types
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Sets the types of the columns inside a ClutterModel.
This function is meant primarily for GObjects that inherit from ClutterModel, and should only be used when contructing a ClutterModel. It will not work after the initial creation of the ClutterModel.
model |
||
n_columns |
number of columns for the model |
|
types |
an array of GType types. |
[array length=n_columns] |
Since: 0.6
const gchar * clutter_model_get_column_name (ClutterModel *model
,guint column
);
clutter_model_get_column_name
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves the name of the column
the name of the column. The model holds the returned string, and it should not be modified or freed
Since: 0.6
GType clutter_model_get_column_type (ClutterModel *model
,guint column
);
clutter_model_get_column_type
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves the type of the column
.
Since: 0.6
guint
clutter_model_get_n_columns (ClutterModel *model
);
clutter_model_get_n_columns
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves the number of columns inside model
.
Since: 0.6
guint
clutter_model_get_n_rows (ClutterModel *model
);
clutter_model_get_n_rows
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves the number of rows inside model
, eventually taking
into account any filtering function set using clutter_model_set_filter()
.
The length of the model
. If there is a filter set, then
the length of the filtered model
is returned.
Since: 0.6
void clutter_model_append (ClutterModel *model
,...
);
clutter_model_append
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Creates and appends a new row to the ClutterModel, setting the
row values upon creation. For example, to append a new row where
column 0 is type G_TYPE_INT
and column 1 is of type G_TYPE_STRING
:
1 2 3 4 5 |
ClutterModel *model; model = clutter_model_default_new (2, G_TYPE_INT, "Score", G_TYPE_STRING, "Team"); clutter_model_append (model, 0, 42, 1, "Team <GTKDOCLINK HREF="1:CAPS">1</GTKDOCLINK>", -1); |
Since: 0.6
void clutter_model_appendv (ClutterModel *model
,guint n_columns
,guint *columns
,GValue *values
);
clutter_model_appendv
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Creates and appends a new row to the ClutterModel, setting the row
values for the given columns
upon creation.
model |
||
n_columns |
the number of columns and values |
|
columns |
a vector with the columns to set. |
[array length=n_columns] |
values |
a vector with the values. |
[array length=n_columns] |
Since: 0.6
void clutter_model_prepend (ClutterModel *model
,...
);
clutter_model_prepend
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Creates and prepends a new row to the ClutterModel, setting the row
values upon creation. For example, to prepend a new row where column 0
is type G_TYPE_INT
and column 1 is of type G_TYPE_STRING
:
1 2 3 4 5 |
ClutterModel *model; model = clutter_model_default_new (2, G_TYPE_INT, "Score", G_TYPE_STRING, "Team"); clutter_model_prepend (model, 0, 42, 1, "Team <GTKDOCLINK HREF="1:CAPS">1</GTKDOCLINK>", -1); |
Since: 0.6
void clutter_model_prependv (ClutterModel *model
,guint n_columns
,guint *columns
,GValue *values
);
clutter_model_prependv
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Creates and prepends a new row to the ClutterModel, setting the row
values for the given columns
upon creation.
model |
||
n_columns |
the number of columns and values to set |
|
columns |
a vector containing the columns to set. |
[array length=n_columns] |
values |
a vector containing the values for the cells. |
[array length=n_columns] |
Since: 0.6
void clutter_model_insert (ClutterModel *model
,guint row
,...
);
clutter_model_insert
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Inserts a new row to the ClutterModel at row
, setting the row
values upon creation. For example, to insert a new row at index 100,
where column 0 is type G_TYPE_INT
and column 1 is of type
G_TYPE_STRING
:
1 2 3 4 5 |
ClutterModel *model; model = clutter_model_default_new (2, G_TYPE_INT, "Score", G_TYPE_STRING, "Team"); clutter_model_insert (model, 3, 0, 42, 1, "Team <GTKDOCLINK HREF="1:CAPS">1</GTKDOCLINK>", -1); |
model |
||
row |
the position to insert the new row |
|
... |
pairs of column number and value, terminated with -1 |
Since: 0.6
void clutter_model_insertv (ClutterModel *model
,guint row
,guint n_columns
,guint *columns
,GValue *values
);
clutter_model_insertv
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Inserts data at row
into the ClutterModel, setting the row
values for the given columns
upon creation.
model |
||
row |
row index |
|
n_columns |
the number of columns and values to set |
|
columns |
a vector containing the columns to set. |
[array length=n_columns] |
values |
a vector containing the values for the cells. |
[array length=n_columns] |
Since: 0.6
void clutter_model_insert_value (ClutterModel *model
,guint row
,guint column
,const GValue *value
);
clutter_model_insert_value
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Sets the data in the cell specified by iter
and column
. The type of
value
must be convertable to the type of the column. If the row does
not exist then it is created.
model |
||
row |
position of the row to modify |
|
column |
column to modify |
|
value |
new value for the cell |
Since: 0.6
void clutter_model_remove (ClutterModel *model
,guint row
);
clutter_model_remove
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Removes the row at the given position from the model.
Since: 0.6
gboolean (*ClutterModelForeachFunc) (ClutterModel *model
,ClutterModelIter *iter
,gpointer user_data
);
ClutterModelForeachFunc
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel
Iterates on the content of a row in the model
Since: 0.6
void clutter_model_foreach (ClutterModel *model
,ClutterModelForeachFunc func
,gpointer user_data
);
clutter_model_foreach
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Calls func
for each row in the model.
Since: 0.6
void clutter_model_set_sorting_column (ClutterModel *model
,gint column
);
clutter_model_set_sorting_column
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Sets the model to sort by column
. If column
is a negative value
the sorting column will be unset.
Since: 0.6
gint
clutter_model_get_sorting_column (ClutterModel *model
);
clutter_model_get_sorting_column
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves the number of column used for sorting the model
.
Since: 0.6
gint (*ClutterModelSortFunc) (ClutterModel *model
,const GValue *a
,const GValue *b
,gpointer user_data
);
ClutterModelSortFunc
has been deprecated since version 1.24 and should not be used in newly-written code.
Implement sorting using a custom GListModel instead
Compares the content of two rows in the model.
model |
||
a |
a GValue representing the contents of the row |
|
b |
a GValue representing the contents of the second row |
|
user_data |
data passed to |
a positive integer if a
is after b
, a negative integer if
a
is before b
, or 0 if the rows are the same
Since: 0.6
void clutter_model_set_sort (ClutterModel *model
,gint column
,ClutterModelSortFunc func
,gpointer user_data
,GDestroyNotify notify
);
clutter_model_set_sort
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Sorts model
using the given sorting function.
model |
||
column |
the column to sort on |
|
func |
a ClutterModelSortFunc, or NULL. |
[allow-none] |
user_data |
user data to pass to |
|
notify |
destroy notifier of |
Since: 0.6
void
clutter_model_resort (ClutterModel *model
);
clutter_model_resort
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Force a resort on the model
. This function should only be
used by subclasses of ClutterModel.
Since: 0.6
gboolean (*ClutterModelFilterFunc) (ClutterModel *model
,ClutterModelIter *iter
,gpointer user_data
);
ClutterModelFilterFunc
has been deprecated since version 1.24 and should not be used in newly-written code.
Implement filters using a custom GListModel instead
Filters the content of a row in the model.
Since: 0.6
void clutter_model_set_filter (ClutterModel *model
,ClutterModelFilterFunc func
,gpointer user_data
,GDestroyNotify notify
);
clutter_model_set_filter
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Filters the model
using the given filtering function.
model |
||
func |
a ClutterModelFilterFunc, or NULL. |
[allow-none] |
user_data |
user data to pass to |
|
notify |
destroy notifier of |
Since: 0.6
gboolean
clutter_model_get_filter_set (ClutterModel *model
);
clutter_model_get_filter_set
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Returns whether the model
has a filter in place, set
using clutter_model_set_filter()
Since: 1.0
gboolean clutter_model_filter_iter (ClutterModel *model
,ClutterModelIter *iter
);
clutter_model_filter_iter
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Checks whether the row pointer by iter
should be filtered or not using
the filtering function set on model
.
This function should be used only by subclasses of ClutterModel.
Since: 0.6
gboolean clutter_model_filter_row (ClutterModel *model
,guint row
);
clutter_model_filter_row
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Checks whether row
should be filtered or not using the
filtering function set on model
.
This function should be used only by subclasses of ClutterModel.
Since: 0.6
ClutterModelIter *
clutter_model_get_first_iter (ClutterModel *model
);
clutter_model_get_first_iter
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves a ClutterModelIter representing the first non-filtered
row in model
.
Since: 0.6
ClutterModelIter *
clutter_model_get_last_iter (ClutterModel *model
);
clutter_model_get_last_iter
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves a ClutterModelIter representing the last non-filtered
row in model
.
Since: 0.6
ClutterModelIter * clutter_model_get_iter_at_row (ClutterModel *model
,guint row
);
clutter_model_get_iter_at_row
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Retrieves a ClutterModelIter representing the row at the given index.
If a filter function has been set using clutter_model_set_filter()
then the model
implementation will return the first non filtered
row.
A new ClutterModelIter, or NULL
if row
was
out of bounds. When done using the iterator object, call g_object_unref()
to deallocate its resources.
[transfer full]
Since: 0.6
struct ClutterModel;
ClutterModel
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Base class for list models. The ClutterModel structure contains only private data and should be manipulated using the provided API.
Since: 0.6
struct ClutterModelClass { /* vtable */ guint (* get_n_rows) (ClutterModel *model); guint (* get_n_columns) (ClutterModel *model); const gchar * (* get_column_name) (ClutterModel *model, guint column); GType (* get_column_type) (ClutterModel *model, guint column); ClutterModelIter *(* insert_row) (ClutterModel *model, gint index_); void (* remove_row) (ClutterModel *model, guint row); ClutterModelIter *(* get_iter_at_row) (ClutterModel *model, guint row); void (* resort) (ClutterModel *model, ClutterModelSortFunc func, gpointer data); /* signals */ void (* row_added) (ClutterModel *model, ClutterModelIter *iter); void (* row_removed) (ClutterModel *model, ClutterModelIter *iter); void (* row_changed) (ClutterModel *model, ClutterModelIter *iter); void (* sort_changed) (ClutterModel *model); void (* filter_changed) (ClutterModel *model); };
ClutterModelClass
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Class for ClutterModel instances.
virtual function for returning the number of rows of the model |
||
virtual function for retuning the number of columns of the model |
||
virtual function for returning the name of a column |
||
virtual function for returning the type of a column |
||
virtual function for inserting a row at the given index and returning an iterator pointing to it; if the index is a negative integer, the row should be appended to the model |
||
virtual function for removing a row at the given index |
||
virtual function for returning an iterator for the given row |
||
virtual function for sorting the model using the passed sorting function |
||
signal class handler for ClutterModel::row-added |
||
signal class handler for ClutterModel::row-removed |
||
signal class handler for ClutterModel::row-changed |
||
signal class handler for ClutterModel::sort-changed |
||
signal class handler for ClutterModel::filter-changed |
Since: 0.6
“filter-set”
property “filter-set” gboolean
Whether the ClutterModel has a filter set
This property is set to TRUE
if a filter function has been
set using clutter_model_set_filter()
ClutterModel:filter-set
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
Flags: Read
Default value: FALSE
Since: 1.0
“filter-changed”
signalvoid user_function (ClutterModel *model, gpointer user_data)
The ::filter-changed signal is emitted when a new filter has been applied
ClutterModel::filter-changed
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
model |
the ClutterModel on which the signal is emitted |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 0.6
“row-added”
signalvoid user_function (ClutterModel *model, ClutterModelIter *iter, gpointer user_data)
The ::row-added signal is emitted when a new row has been added. The data on the row has already been set when the ::row-added signal has been emitted.
ClutterModel::row-added
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
model |
the ClutterModel on which the signal is emitted |
|
iter |
a ClutterModelIter pointing to the new row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 0.6
“row-changed”
signalvoid user_function (ClutterModel *model, ClutterModelIter *iter, gpointer user_data)
The ::row-removed signal is emitted when a row has been changed. The data on the row has already been updated when the ::row-changed signal has been emitted.
ClutterModel::row-changed
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
model |
the ClutterModel on which the signal is emitted |
|
iter |
a ClutterModelIter pointing to the changed row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 0.6
“row-removed”
signalvoid user_function (ClutterModel *model, ClutterModelIter *iter, gpointer user_data)
The ::row-removed signal is emitted when a row has been removed. The data on the row pointed by the passed iterator is still valid when the ::row-removed signal has been emitted.
ClutterModel::row-removed
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
model |
the ClutterModel on which the signal is emitted |
|
iter |
a ClutterModelIter pointing to the removed row |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 0.6
“sort-changed”
signalvoid user_function (ClutterModel *model, gpointer user_data)
The ::sort-changed signal is emitted after the model has been sorted
ClutterModel::sort-changed
has been deprecated since version 1.24 and should not be used in newly-written code.
Use GListModel instead
model |
the ClutterModel on which the signal is emitted |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
Since: 0.6