mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
[model] Add :filter-set
Currently, there is no way for implementations of the ClutterModel abstract class to know whether there is a filter in place. Since subclasses might implement some optimization in case there is no filter present, we need a simple (and public) API to ask the model itself.
This commit is contained in:
parent
9fdc9ca583
commit
44fefa2afe
@ -133,9 +133,15 @@
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-debug.h"
|
||||
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (ClutterModel, clutter_model, G_TYPE_OBJECT);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_FILTER_SET
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ROW_ADDED,
|
||||
@ -249,11 +255,33 @@ clutter_model_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (clutter_model_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_model_get_property (GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
ClutterModelPrivate *priv = CLUTTER_MODEL (gobject)->priv;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_FILTER_SET:
|
||||
g_value_set_boolean (value, priv->filter_func != NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_model_class_init (ClutterModelClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
gobject_class->get_property = clutter_model_get_property;
|
||||
gobject_class->finalize = clutter_model_finalize;
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (ClutterModelPrivate));
|
||||
@ -263,6 +291,23 @@ clutter_model_class_init (ClutterModelClass *klass)
|
||||
klass->get_n_columns = clutter_model_real_get_n_columns;
|
||||
klass->get_n_rows = clutter_model_real_get_n_rows;
|
||||
|
||||
/**
|
||||
* ClutterModel:filter-set:
|
||||
*
|
||||
* 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()
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
pspec = g_param_spec_boolean ("filter-set",
|
||||
"Filter Set",
|
||||
"Whether the model has a filter",
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READABLE);
|
||||
g_object_class_install_property (gobject_class, PROP_FILTER_SET, pspec);
|
||||
|
||||
/**
|
||||
* ClutterModel::row-added:
|
||||
* @model: the #ClutterModel on which the signal is emitted
|
||||
@ -1356,6 +1401,26 @@ clutter_model_set_filter (ClutterModel *model,
|
||||
priv->filter_notify = notify;
|
||||
|
||||
g_signal_emit (model, model_signals[FILTER_CHANGED], 0);
|
||||
g_object_notify (G_OBJECT (model), "filter-set");
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_model_get_filter_set:
|
||||
* @model: a #ClutterModel
|
||||
*
|
||||
* Returns whether the @model has a filter in place, set
|
||||
* using clutter_model_set_filter()
|
||||
*
|
||||
* Return value: %TRUE if a filter is set
|
||||
*
|
||||
* Since: 1.0
|
||||
*/
|
||||
gboolean
|
||||
clutter_model_get_filter_set (ClutterModel *model)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_MODEL (model), FALSE);
|
||||
|
||||
return model->priv->filter_func != NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -248,6 +248,7 @@ void clutter_model_set_filter (ClutterModel *model,
|
||||
ClutterModelFilterFunc func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
gboolean clutter_model_get_filter_set (ClutterModel *model);
|
||||
|
||||
void clutter_model_resort (ClutterModel *model);
|
||||
gboolean clutter_model_filter_row (ClutterModel *model,
|
||||
|
Loading…
Reference in New Issue
Block a user