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
;
78 mm_category_set_attributes (MMCategory
*category
,
83 MMCategoryDetails
*details
= category
->details
;
85 details
->name
= g_strdup (name
);
86 details
->application
= g_object_ref (app
);
88 details
->icon
= g_object_ref (icon
);
93 mm_category_get_icon (MMCategory
*c
)
95 g_return_val_if_fail (c
!= NULL
, NULL
);
96 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
98 return g_object_ref (c
->details
->icon
);
102 mm_category_get_name (MMCategory
*c
)
104 g_return_val_if_fail (c
!= NULL
, NULL
);
105 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
107 return c
->details
->name
;
111 mm_category_get_hits (MMCategory
*c
,
115 g_return_val_if_fail (c
!= NULL
, NULL
);
116 g_return_val_if_fail (f
!= NULL
, NULL
);
117 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
118 g_return_val_if_fail (MM_IS_FILTER (f
), NULL
);
120 /* return NULL if we can't find the method in the subclass */
121 return (MM_CATEGORY_CLASS (G_OBJECT_GET_CLASS (c
))->get_hits
== NULL
) ?
122 NULL
: ((* MM_CATEGORY_CLASS (G_OBJECT_GET_CLASS (c
))->get_hits
) (c
, f
, err
));
126 mm_category_get_application (MMCategory
*c
)
128 g_return_val_if_fail (c
!= NULL
, NULL
);
129 g_return_val_if_fail (MM_IS_CATEGORY (c
), NULL
);
131 return c
->details
->application
;