First implementation of a "server side" app to test the module
[mmediamanager.git] / src / mm-hit.c
blob9dfedae388dfb43f71170b151170f415e3776260
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>
24 #include "mm-hit.h"
26 #define MM_HIT_GET_PRIVATE(o) \
27 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_HIT, MMHitDetails))
29 G_DEFINE_TYPE (MMHit, mm_hit, G_TYPE_OBJECT);
31 enum {
32 PROP_0,
33 PROP_URI,
34 PROP_NAME
37 struct _MMHitDetails {
38 char *uri;
39 char *name;
42 static void
43 mm_hit_finalize (GObject *o)
45 MMHitDetails *details = MM_HIT (o)->details;
47 g_free (details->uri);
48 g_free (details->name);
50 G_OBJECT_CLASS (mm_hit_parent_class)->finalize (o);
53 static void
54 mm_hit_set_property (GObject *obj,
55 guint prop_id,
56 const GValue *value,
57 GParamSpec *pspec )
59 MMHitDetails *details = MM_HIT (obj)->details;
61 switch (prop_id) {
62 case PROP_URI:
63 details->uri = g_strdup (g_value_get_string (value));
64 break;
65 case PROP_NAME:
66 details->name = g_strdup (g_value_get_string (value));
67 break;
68 default:
69 break;
73 static void
74 mm_hit_get_property (GObject *obj,
75 guint prop_id,
76 GValue *value,
77 GParamSpec *pspec)
79 MMHitDetails *details = MM_HIT (obj)->details;
81 switch (prop_id) {
82 case PROP_URI:
83 g_value_set_string (value, details->uri);
84 break;
85 case PROP_NAME:
86 g_value_set_string (value, details->name);
87 break;
88 default:
89 break;
93 static void
94 mm_hit_init (MMHit *h)
96 MMHitDetails *details = h->details = MM_HIT_GET_PRIVATE (h);
98 details->uri = NULL;
99 details->name = NULL;
102 static void
103 mm_hit_class_init (MMHitClass *klass)
105 GObjectClass *oclass = G_OBJECT_CLASS (klass);
107 oclass->set_property = mm_hit_set_property;
108 oclass->get_property = mm_hit_get_property;
109 oclass->finalize = mm_hit_finalize;
111 g_object_class_install_property (oclass,
112 PROP_URI,
113 g_param_spec_string ("uri",
114 "Uri",
115 "Uri of the hit",
116 NULL,
117 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
118 g_object_class_install_property (oclass,
119 PROP_NAME,
120 g_param_spec_string ("name",
121 "Name",
122 "Name of the hit",
123 NULL,
124 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
126 g_type_class_add_private (klass, sizeof (MMHitDetails));