1 | #include "iconbrowsercontext.h" |
2 | |
3 | struct _IbContext |
4 | { |
5 | GObject parent_instance; |
6 | |
7 | char *id; |
8 | char *name; |
9 | char *description; |
10 | }; |
11 | |
12 | struct _IbContextClass |
13 | { |
14 | GObjectClass parent_class; |
15 | }; |
16 | |
17 | enum { |
18 | PROP_ID = 1, |
19 | PROP_NAME, |
20 | PROP_DESCRIPTION, |
21 | PROP_NUM_PROPERTIES |
22 | }; |
23 | |
24 | G_DEFINE_TYPE (IbContext, ib_context, G_TYPE_OBJECT) |
25 | |
26 | static void |
27 | ib_context_init (IbContext *context) |
28 | { |
29 | } |
30 | |
31 | static void |
32 | ib_context_finalize (GObject *object) |
33 | { |
34 | IbContext *context = IB_CONTEXT (ptr: object); |
35 | |
36 | g_free (mem: context->id); |
37 | g_free (mem: context->name); |
38 | g_free (mem: context->description); |
39 | |
40 | G_OBJECT_CLASS (ib_context_parent_class)->finalize (object); |
41 | } |
42 | |
43 | static void |
44 | ib_context_set_property (GObject *object, |
45 | guint property_id, |
46 | const GValue *value, |
47 | GParamSpec *pspec) |
48 | { |
49 | IbContext *context = IB_CONTEXT (ptr: object); |
50 | |
51 | switch (property_id) |
52 | { |
53 | case PROP_ID: |
54 | g_free (mem: context->id); |
55 | context->id = g_value_dup_string (value); |
56 | break; |
57 | |
58 | case PROP_NAME: |
59 | g_free (mem: context->name); |
60 | context->name = g_value_dup_string (value); |
61 | break; |
62 | |
63 | case PROP_DESCRIPTION: |
64 | g_free (mem: context->description); |
65 | context->description = g_value_dup_string (value); |
66 | break; |
67 | |
68 | default: |
69 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
70 | break; |
71 | } |
72 | } |
73 | |
74 | static void |
75 | ib_context_get_property (GObject *object, |
76 | guint property_id, |
77 | GValue *value, |
78 | GParamSpec *pspec) |
79 | { |
80 | IbContext *context = IB_CONTEXT (ptr: object); |
81 | |
82 | switch (property_id) |
83 | { |
84 | case PROP_ID: |
85 | g_value_set_string (value, v_string: context->id); |
86 | break; |
87 | |
88 | case PROP_NAME: |
89 | g_value_set_string (value, v_string: context->name); |
90 | break; |
91 | |
92 | case PROP_DESCRIPTION: |
93 | g_value_set_string (value, v_string: context->description); |
94 | break; |
95 | |
96 | default: |
97 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
98 | break; |
99 | } |
100 | } |
101 | |
102 | static void |
103 | ib_context_class_init (IbContextClass *class) |
104 | { |
105 | GObjectClass *object_class = G_OBJECT_CLASS (class); |
106 | GParamSpec *pspec; |
107 | |
108 | object_class->finalize = ib_context_finalize; |
109 | object_class->set_property = ib_context_set_property; |
110 | object_class->get_property = ib_context_get_property; |
111 | |
112 | pspec = g_param_spec_string (name: "id" , nick: "Id" , blurb: "Id" , |
113 | NULL, |
114 | flags: G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
115 | g_object_class_install_property (oclass: object_class, property_id: PROP_ID, pspec); |
116 | |
117 | pspec = g_param_spec_string (name: "name" , nick: "Name" , blurb: "Name" , |
118 | NULL, |
119 | flags: G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
120 | g_object_class_install_property (oclass: object_class, property_id: PROP_NAME, pspec); |
121 | |
122 | pspec = g_param_spec_string (name: "description" , nick: "Description" , blurb: "Description" , |
123 | NULL, |
124 | flags: G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); |
125 | g_object_class_install_property (oclass: object_class, property_id: PROP_DESCRIPTION, pspec); |
126 | } |
127 | |
128 | IbContext * |
129 | ib_context_new (const char *id, |
130 | const char *name, |
131 | const char *description) |
132 | { |
133 | return g_object_new (IB_TYPE_CONTEXT, |
134 | first_property_name: "id" , id, |
135 | "name" , name, |
136 | "description" , description, |
137 | NULL); |
138 | } |
139 | |
140 | const char * |
141 | ib_context_get_id (IbContext *context) |
142 | { |
143 | return context->id; |
144 | } |
145 | |
146 | const char * |
147 | ib_context_get_name (IbContext *context) |
148 | { |
149 | return context->name; |
150 | } |
151 | |
152 | const char * |
153 | ib_context_get_description (IbContext *context) |
154 | { |
155 | return context->description; |
156 | } |
157 | |