From 9becd34a377e4dd641f941c2956a9f66f5c04ae4 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 28 Dec 2007 15:33:20 +0000 Subject: [PATCH] 2007-12-28 Emmanuele Bassi * clutter/clutter-model.c: (clutter_model_real_get_n_rows), (clutter_model_class_init), (clutter_model_get_n_rows): Provide a default implementation of the get_n_rows() method, so that subclasses do not strictly need to override it --- ChangeLog | 10 +++++-- clutter/clutter-model.c | 59 ++++++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc6fdb061..7a639fc06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ -2007-12-25 Emmanuele Bassi +2007-12-28 Emmanuele Bassi - reviewed by: + * clutter/clutter-model.c: + (clutter_model_real_get_n_rows), (clutter_model_class_init), + (clutter_model_get_n_rows): Provide a default implementation of + the get_n_rows() method, so that subclasses do not strictly need + to override it + +2007-12-25 Emmanuele Bassi * clutter/clutter-actor.c: (parse_rotation_array): Inline, and get the JsonArray as a parameter diff --git a/clutter/clutter-model.c b/clutter/clutter-model.c index 8f8812603..756fba767 100644 --- a/clutter/clutter-model.c +++ b/clutter/clutter-model.c @@ -202,6 +202,28 @@ clutter_model_real_get_n_columns (ClutterModel *model) return model->priv->n_columns; } +static guint +clutter_model_real_get_n_rows (ClutterModel *model) +{ + ClutterModelIter *iter; + guint n_rows = 0; + + iter = clutter_model_get_first_iter (model); + if (!iter) + return 0; + + while (!clutter_model_iter_is_last (iter)) + { + n_rows += 1; + + clutter_model_iter_next (iter); + } + + g_object_unref (iter); + + return n_rows; +} + static void clutter_model_finalize (GObject *object) { @@ -239,6 +261,7 @@ clutter_model_class_init (ClutterModelClass *klass) klass->get_column_name = clutter_model_real_get_column_name; klass->get_column_type = clutter_model_real_get_column_type; klass->get_n_columns = clutter_model_real_get_n_columns; + klass->get_n_rows = clutter_model_real_get_n_rows; /** * ClutterModel::row-added: @@ -246,6 +269,8 @@ clutter_model_class_init (ClutterModelClass *klass) * @iter: a #ClutterModelIter pointing to the new row * * 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. * * Since: 0.6 */ @@ -264,7 +289,8 @@ clutter_model_class_init (ClutterModelClass *klass) * @iter: a #ClutterModelIter pointing to the removed row * * 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. + * The data on the row pointed by the passed iterator is still valid + * when the ::row-removed signal has been emitted. * * Since: 0.6 */ @@ -282,7 +308,9 @@ clutter_model_class_init (ClutterModelClass *klass) * @model: the #ClutterModel on which the signal is emitted * @iter: a #ClutterModelIter pointing to the changed row * - * The ::row-removed signal is emitted when a row has been changed + * 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. * * Since: 0.6 */ @@ -1172,34 +1200,9 @@ clutter_model_get_last_iter (ClutterModel *model) guint clutter_model_get_n_rows (ClutterModel *model) { - ClutterModelPrivate *priv; - ClutterModelIter *iter; - guint n_rows; - g_return_val_if_fail (CLUTTER_IS_MODEL (model), 0); - priv = model->priv; - - /* if there's no filter set, just get the full number of rows */ - if (!priv->filter_func) - return CLUTTER_MODEL_GET_CLASS (model)->get_n_rows (model); - - iter = clutter_model_get_first_iter (model); - if (!iter) - return 0; - - n_rows = 0; - while (!clutter_model_iter_is_last (iter)) - { - if (clutter_model_filter_iter (model, iter)) - n_rows += 1; - - iter = clutter_model_iter_next (iter); - } - - g_object_unref (iter); - - return n_rows; + return CLUTTER_MODEL_GET_CLASS (model)->get_n_rows (model); }