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-object.h>
24 #include "mm-category.h"
25 #include "mm-hit-collection-provider.h"
26 #include "mm-manager.h"
27 #include "mm-filter.h"
30 #define MM_CATEGORY_GET_PRIVATE(o) \
31 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_CATEGORY, MMCategoryDetails))
33 G_DEFINE_TYPE (MMCategory
, mm_category
, G_TYPE_OBJECT
);
35 struct _MMCategoryDetails
{
38 MMApplication
*application
;
42 mm_category_finalize (GObject
*o
)
44 MMCategoryDetails
*details
= MM_CATEGORY (o
)->details
;
46 g_free (details
->name
);
49 g_object_unref (details
->icon
);
51 if (details
->application
) {
52 g_object_unref (details
->application
);
55 G_OBJECT_CLASS (mm_category_parent_class
)->finalize (o
);
59 mm_category_class_init (MMCategoryClass
*klass
)
61 G_OBJECT_CLASS (klass
)->finalize
= mm_category_finalize
;
63 g_type_class_add_private (klass
, sizeof (MMCategoryDetails
));
67 mm_category_init (MMCategory
*c
)
69 MMCategoryDetails
*details
= c
->details
= MM_CATEGORY_GET_PRIVATE (c
);
73 details
->application
= NULL
;
77 set_attrs (MMCategory
*category
,
82 MMCategoryDetails
*details
= category
->details
;
84 details
->name
= g_strdup (name
);
85 details
->application
= g_object_ref (app
);
87 details
->icon
= g_object_ref (icon
);
94 mm_category_new (MMApplication
*app
,
100 category
= g_object_new (MM_TYPE_CATEGORY
, NULL
);
101 set_attrs (category
, app
, name
, icon
);
107 mm_category_get_icon (MMCategory
*c
)
109 g_return_val_if_fail (c
!= NULL
, NULL
);
110 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
112 return g_object_ref (c
->details
->icon
);
116 mm_category_get_name (MMCategory
*c
)
118 g_return_val_if_fail (c
!= NULL
, NULL
);
119 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
121 return c
->details
->name
;
125 mm_category_get_hits (MMCategory
*c
,
128 MMHitCollectionProvider
*provider
;
131 g_return_val_if_fail (c
!= NULL
, NULL
);
132 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
133 g_return_val_if_fail (f
!= NULL
, NULL
);
134 g_return_val_if_fail (MM_IS_FILTER (f
), NULL
);
136 manager
= mm_manager_get ();
137 provider
= mm_module_manager_get_hit_collection_provider_for_application
138 (mm_manager_get_module_manager (manager
),
139 mm_manager_get_application_provider_for_application (manager
,
140 c
->details
->application
));
141 return mm_hit_collection_provider_get_hits (provider
, c
, f
);