1 /* MManager - a Desktop wide manager for multimedia applications.
3 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #include <glib-object.h>
24 #include "mm-filter.h"
26 #define MM_FILTER_GET_PRIVATE(o) \
27 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_FILTER, MMFilterPrivate))
29 struct _MMFilterPrivate
{
33 G_DEFINE_TYPE (MMFilter
, mm_filter
, G_TYPE_OBJECT
);
36 unref_obj (gpointer data
,
39 g_object_unref (data
);
43 unref_all_fps (MMFilter
*f
)
45 MMFilterPrivate
*details
= f
->details
;
46 g_list_foreach (details
->filter_params
, unref_obj
, NULL
);
50 add_to_filter_params (gpointer _fp
,
53 MMFilter
*filter
= _filter
;
54 MMFilterParam
*fp
= _fp
;
56 mm_filter_add_filtering_param (filter
, fp
);
60 mm_filter_finalize (GObject
*o
)
62 unref_all_fps (MM_FILTER (o
));
63 g_list_free (MM_FILTER (o
)->details
->filter_params
);
65 G_OBJECT_CLASS (mm_filter_parent_class
)->finalize (o
);
69 mm_filter_init (MMFilter
*f
)
71 MMFilterPrivate
*details
= f
->details
= MM_FILTER_GET_PRIVATE (f
);
72 details
->filter_params
= NULL
;
76 mm_filter_class_init (MMFilterClass
*klass
)
78 G_OBJECT_CLASS (klass
)->finalize
= mm_filter_finalize
;
80 g_type_class_add_private (klass
, sizeof (MMFilterPrivate
));
88 * Builds an empty #MMFilter object.
90 * Return value: an empty #MMFilter.
96 return g_object_new (MM_TYPE_FILTER
, NULL
);
100 * mm_filter_add_filtering_param:
101 * @filter: a #MMFilter
102 * @fp: a #MMFilterParam
104 * Adds @fp to @filter. @filter will keep a reference to @fp.
108 mm_filter_add_filtering_param (MMFilter
*filter
,
111 MMFilterPrivate
*details
= filter
->details
;
113 g_return_if_fail (MM_IS_FILTER_PARAM (fp
));
115 details
->filter_params
= g_list_prepend (details
->filter_params
,
120 * mm_filter_add_filtering_params:
121 * @filter: a #MMFilter.
122 * @fps: a #GList of #MMFilterParam objects.
124 * Adds the #MMFilterParam objects inside the list to @filter. @filter
125 * will keep a reference to all the #MMFilterParam objects.
129 mm_filter_add_filtering_params (MMFilter
*filter
,
132 g_list_foreach (fps
, add_to_filter_params
, filter
);
137 * @filter: a #MMFilter.
139 * Clears all the #MMFilterParam<!-- -->s from @filter.
143 mm_filter_clear (MMFilter
*filter
)
145 unref_all_fps (filter
);
146 g_list_free (filter
->details
->filter_params
);
147 filter
->details
->filter_params
= NULL
;
151 * mm_filter_get_filtering_params:
152 * @filter: a #MMFilter.
154 * Gets a #GList of all the #MMFilterParam<!-- -->s added to @filter.
156 * Return value: a #GList of #MMFilterParam objects. Use #g_list_free when done
161 mm_filter_get_filtering_params (MMFilter
*filter
)
163 return g_list_reverse (filter
->details
->filter_params
);