Make it compile with new files.
[mmediamanager.git] / src / mm-filter.c
blob5d92a68b90a0e5e62f04cba9afa79aa9e34323a4
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.
21 #include <glib.h>
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, MMFilterDetails))
29 struct _MMFilterDetails {
30 GList *filter_params;
33 G_DEFINE_TYPE (MMFilter, mm_filter, G_TYPE_OBJECT);
35 static void
36 unref_obj (gpointer data,
37 gpointer _unused)
39 g_object_unref (data);
42 static void
43 unref_all_fps (MMFilter *f)
45 MMFilterDetails *details = f->details;
46 g_list_foreach (details->filter_params, unref_obj, NULL);
49 static void
50 add_to_filter_params (gpointer _fp,
51 gpointer _filter)
53 MMFilter *filter = _filter;
54 MMFilterParam *fp = _fp;
56 mm_filter_add_filtering_param (filter, fp);
59 static void
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);
68 static void
69 mm_filter_init (MMFilter *f)
71 MMFilterDetails *details = f->details = MM_FILTER_GET_PRIVATE (f);
72 details->filter_params = NULL;
75 static void
76 mm_filter_class_init (MMFilterClass *klass)
78 G_OBJECT_CLASS (klass)->finalize = mm_filter_finalize;
80 g_type_class_add_private (klass, sizeof (MMFilterDetails));
83 /* public methods */
85 MMFilter *
86 mm_filter_new (void)
88 return g_object_new (MM_TYPE_FILTER, NULL);
91 void
92 mm_filter_add_filtering_param (MMFilter *filter,
93 MMFilterParam *fp)
95 MMFilterDetails *details = filter->details;
97 g_return_if_fail (MM_IS_FILTER_PARAM (fp));
99 details->filter_params = g_list_prepend (details->filter_params,
100 g_object_ref (fp));
103 void
104 mm_filter_add_filtering_params (MMFilter *filter,
105 GList *fps)
107 g_list_foreach (fps, add_to_filter_params, filter);
110 void
111 mm_filter_clear (MMFilter *f)
113 unref_all_fps (f);
114 g_list_free (f->details->filter_params);
115 f->details->filter_params = NULL;
118 GList *
119 mm_filter_get_filtering_params (MMFilter *f)
121 return g_list_reverse (f->details->filter_params);