![]() |
![]() |
![]() |
Gcr Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
struct GcrCollectionModel; struct GcrCollectionModelClass; enum GcrCollectionModelMode; GcrCollectionModel * gcr_collection_model_new (GcrCollection *collection
,GcrCollectionModelMode mode
,...
); GcrCollectionModel * gcr_collection_model_new_full (GcrCollection *collection
,GcrCollectionModelMode mode
,const GcrColumn *columns
); guint gcr_collection_model_set_columns (GcrCollectionModel *self
,const GcrColumn *columns
); GcrCollection * gcr_collection_model_get_collection (GcrCollectionModel *self
); void gcr_collection_model_set_collection (GcrCollectionModel *self
,GcrCollection *collection
); gboolean gcr_collection_model_iter_for_object (GcrCollectionModel *self
,GObject *object
,GtkTreeIter *iter
); GObject * gcr_collection_model_object_for_iter (GcrCollectionModel *self
,const GtkTreeIter *iter
); gboolean gcr_collection_model_is_selected (GcrCollectionModel *self
,GtkTreeIter *iter
); void gcr_collection_model_change_selected (GcrCollectionModel *self
,GtkTreeIter *iter
,gboolean selected
); void gcr_collection_model_toggle_selected (GcrCollectionModel *self
,GtkTreeIter *iter
); GList * gcr_collection_model_get_selected_objects (GcrCollectionModel *self
); void gcr_collection_model_set_selected_objects (GcrCollectionModel *self
,GList *selected
); gint gcr_collection_model_column_for_selected (GcrCollectionModel *self
);
"collection" GcrCollection* : Read / Write "columns" gpointer : Read / Write / Construct Only "mode" GcrCollectionModelMode : Read / Write / Construct Only
This is an implementation of GtkTreeModel which represents the objects in the a GcrCollection. As objects are added or removed from the collection, rows are added and removed from this model.
The row values come from the properties of the objects in the collection. Use
gcr_collection_model_new()
to create a new collection model. To have more
control over the values use a set of GcrColumn structures to define the
columns. This can be done with gcr_collection_model_new_full()
or
gcr_collection_model_set_columns()
.
Each row can have a selected state, which is represented by a boolean column.
The selected state can be toggled with gcr_collection_model_toggle_selected()
or set with gcr_collection_model_set_selected_objects()
and retrieved with
gcr_collection_model_get_selected_objects()
.
To determine which object a row represents and vice versa, use the
gcr_collection_model_iter_for_object()
or gcr_collection_model_object_for_iter()
functions.
struct GcrCollectionModel;
A GtkTreeModel which contains a row for each object in a GcrCollection.
struct GcrCollectionModelClass { GObjectClass parent_class; };
The class for GcrCollectionModel.
GObjectClass |
The parent class |
typedef enum { GCR_COLLECTION_MODEL_LIST = 0, GCR_COLLECTION_MODEL_TREE } GcrCollectionModelMode;
If set GcrCollectionModel is created with a mode of GCR_COLLECTION_MODEL_TREE
,
then any included objects that are themselves a GcrCollection, will have all child
objects include as child rows in a tree form.
GcrCollectionModel * gcr_collection_model_new (GcrCollection *collection
,GcrCollectionModelMode mode
,...
);
Create a new GcrCollectionModel. The variable argument list should contain
pairs of property names, and GType values. The variable argument list should
be terminated with NULL
.
|
the collection to represent |
|
whether list or tree mode |
|
the column names and types |
Returns : |
a newly allocated model, which should be released
with g_object_unref() . [transfer full]
|
GcrCollectionModel * gcr_collection_model_new_full (GcrCollection *collection
,GcrCollectionModelMode mode
,const GcrColumn *columns
);
Create a new GcrCollectionModel.
|
the collection to represent |
|
whether list or tree mode |
|
the columns the model should contain |
Returns : |
a newly allocated model, which should be released
with g_object_unref() . [transfer full]
|
guint gcr_collection_model_set_columns (GcrCollectionModel *self
,const GcrColumn *columns
);
Set the columns that the model should contain. columns
is an array of
GcrColumn structures, with the last one containing NULL
for all values.
This function can only be called once, and only if the model was not created without a set of columns. This function cannot be called after the model has been added to a view.
The columns are accessed as static data. They should continue to remain in memory for longer than the GcrCollectionModel object.
|
The model |
|
The columns the model should contain |
Returns : |
The number of columns |
GcrCollection * gcr_collection_model_get_collection (GcrCollectionModel *self
);
Get the collection which this model represents
|
a collection model |
Returns : |
the collection, owned by the model. [transfer none] |
void gcr_collection_model_set_collection (GcrCollectionModel *self
,GcrCollection *collection
);
gboolean gcr_collection_model_iter_for_object (GcrCollectionModel *self
,GObject *object
,GtkTreeIter *iter
);
Set iter
to the row for the given object. If the object is not in this
model, then FALSE
will be returned.
|
The model |
|
The object |
|
The row for the object |
Returns : |
TRUE if the object was present. |
GObject * gcr_collection_model_object_for_iter (GcrCollectionModel *self
,const GtkTreeIter *iter
);
Get the object that is represented by the given row in the model.
|
The model |
|
The row |
Returns : |
The object, owned by the model. [transfer none] |
gboolean gcr_collection_model_is_selected (GcrCollectionModel *self
,GtkTreeIter *iter
);
Check whether a given row has been toggled as selected.
|
The model |
|
The row |
Returns : |
Whether the row has been selected. |
void gcr_collection_model_change_selected (GcrCollectionModel *self
,GtkTreeIter *iter
,gboolean selected
);
Set whether a given row is toggled selected or not.
|
The model |
|
The row |
|
Whether the row should be selected or not. |
void gcr_collection_model_toggle_selected (GcrCollectionModel *self
,GtkTreeIter *iter
);
Toggle the selected state of a given row.
|
The model |
|
The row |
GList * gcr_collection_model_get_selected_objects
(GcrCollectionModel *self
);
Get a list of checked/selected objects.
|
the collection model |
Returns : |
a list of selected
objects, which should be freed with g_list_free() . [transfer container][element-type GLib.Object]
|
void gcr_collection_model_set_selected_objects (GcrCollectionModel *self
,GList *selected
);
Set the checked/selected objects.
|
the collection model |
|
a list of objects to select. [element-type GLib.Object] |
gint gcr_collection_model_column_for_selected
(GcrCollectionModel *self
);
Get the column identifier for the column that contains the values of the selected state.
|
The model |
Returns : |
The column identifier. |
"collection"
property"collection" GcrCollection* : Read / Write
Collection to get objects from.
"mode"
property"mode" GcrCollectionModelMode : Read / Write / Construct Only
Tree or list mode.
Default value: GCR_COLLECTION_MODEL_TREE