Extend the MMGtkApplicationStore to handle the right hierarchy:
[mmediamanager.git] / src / mm-so-category.c
blobed14d60a3448f1ed56ce51a073dbeb3fa183d8e3
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"
29 #include "mm-error.h"
31 G_DEFINE_TYPE (MMSoCategory, mm_so_category, MM_TYPE_CATEGORY);
33 static MMHitCollection *
34 mm_so_category_get_hits (MMCategory *c,
35 MMFilter *f,
36 GError **ret_error)
38 MMHitCollectionProvider *provider;
39 MMManager *manager;
40 const char *app_id;
41 MMApplication *app;
43 g_return_val_if_fail (c != NULL, NULL);
44 g_return_val_if_fail (MM_IS_CATEGORY (c), NULL);
45 g_return_val_if_fail (f != NULL, NULL);
46 g_return_val_if_fail (MM_IS_FILTER (f), NULL);
48 manager = mm_manager_get ();
49 app = mm_category_get_application (c);
50 app_id = mm_application_get_id (app);
51 provider = mm_module_manager_get_hit_collection_provider_for_application
52 (mm_manager_get_module_manager (manager), app_id);
53 g_object_unref (app);
54 if (!provider) {
55 g_set_error (ret_error,
56 MM_SO_ERROR_QUARK,
57 MM_SO_ERROR_NULL_PROVIDER,
58 "Unable to get the hit collection provider for application %s",
59 app_id);
60 return NULL;
63 return mm_hit_collection_provider_get_hits (provider, c, f);
66 static void
67 mm_so_category_class_init (MMSoCategoryClass *klass)
69 MMCategoryClass *cat_class = MM_CATEGORY_CLASS (klass);
71 cat_class->get_hits = mm_so_category_get_hits;
74 static void
75 mm_so_category_init (MMSoCategory *cat)
77 /* empty */
80 /* public methods */
81 MMCategory *
82 mm_so_category_new (MMSoApplication *app,
83 const char *name,
84 GIcon *icon)
86 MMCategory *category;
88 category = MM_CATEGORY (g_object_new (MM_TYPE_SO_CATEGORY, NULL));
89 mm_category_set_attributes (category, MM_APPLICATION (app), name, icon);
91 return category;