GErrorize _serialize funcs too, as the writer can fail as well.
[mmediamanager.git] / src / mm-so-category.c
blobd06335ea9c1ac4a6c233a5cbca409dd7bef2c3ec
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>
23 #include "mm-so-category.h"
24 #include "mm-category.h"
25 #include "mm-so-application.h"
26 #include "mm-hit-collection-provider.h"
27 #include "mm-manager.h"
28 #include "mm-module-manager.h"
30 G_DEFINE_TYPE (MMSoCategory, mm_so_category, MM_TYPE_CATEGORY);
32 static MMHitCollection *
33 mm_so_category_get_hits (MMCategory *c,
34 MMFilter *f)
36 MMHitCollectionProvider *provider;
37 MMManager *manager;
39 g_return_val_if_fail (c != NULL, NULL);
40 g_return_val_if_fail (MM_IS_CATEGORY (c), NULL);
41 g_return_val_if_fail (f != NULL, NULL);
42 g_return_val_if_fail (MM_IS_FILTER (f), NULL);
44 manager = mm_manager_get ();
45 provider = mm_module_manager_get_hit_collection_provider_for_application
46 (mm_manager_get_module_manager (manager),
47 mm_application_get_id (mm_category_get_application (c)));
48 return mm_hit_collection_provider_get_hits (provider, c, f);
51 static void
52 mm_so_category_class_init (MMSoCategoryClass *klass)
54 MMCategoryClass *cat_class = MM_CATEGORY_CLASS (klass);
56 cat_class->get_hits = mm_so_category_get_hits;
59 static void
60 mm_so_category_init (MMSoCategory *cat)
62 /* empty */
65 /* public methods */
66 MMCategory *
67 mm_so_category_new (MMSoApplication *app,
68 const char *name,
69 GIcon *icon)
71 MMCategory *category;
73 category = MM_CATEGORY (g_object_new (MM_TYPE_SO_CATEGORY, NULL));
74 mm_category_set_attributes (category, MM_APPLICATION (app), name, icon);
76 return category;