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, MMFilterDetails))
29 struct _MMFilterDetails
{
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 MMFilterDetails
*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 MMFilterDetails
*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 (MMFilterDetails
));
88 return g_object_new (MM_TYPE_FILTER
, NULL
);
92 mm_filter_add_filtering_param (MMFilter
*filter
,
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
,
104 mm_filter_add_filtering_params (MMFilter
*filter
,
107 g_list_foreach (fps
, add_to_filter_params
, filter
);
111 mm_filter_clear (MMFilter
*f
)
114 g_list_free (f
->details
->filter_params
);
115 f
->details
->filter_params
= NULL
;
119 mm_filter_get_filtering_params (MMFilter
*f
)
121 return g_list_reverse (f
->details
->filter_params
);