~ricmm/+junk/unity-lens_music-sc

« back to all changes in this revision

Viewing changes to tests/unit/filter-parser-genre.c

  • Committer: Ricardo Mendoza
  • Date: 2012-09-05 14:20:15 UTC
  • Revision ID: ricardo.mendoza@canonical.com-20120905142015-prem6hiyfshwgm8q
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* filter-parser-genre.c generated by valac 0.16.1, the Vala compiler
 
2
 * generated from filter-parser-genre.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2011 Canonical Ltd
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License version 3 as
 
9
 * published by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 * Authored by Alex Launi <alex.launi@canonical.com>
 
20
 *
 
21
 */
 
22
 
 
23
#include <glib.h>
 
24
#include <glib-object.h>
 
25
#include <stdlib.h>
 
26
#include <string.h>
 
27
#include <unity.h>
 
28
 
 
29
 
 
30
#define UNITY_MUSIC_LENS_TYPE_FILTER_PARSER (unity_music_lens_filter_parser_get_type ())
 
31
#define UNITY_MUSIC_LENS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParser))
 
32
#define UNITY_MUSIC_LENS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
33
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
34
#define UNITY_MUSIC_LENS_IS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
 
35
#define UNITY_MUSIC_LENS_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
 
36
 
 
37
typedef struct _UnityMusicLensFilterParser UnityMusicLensFilterParser;
 
38
typedef struct _UnityMusicLensFilterParserClass UnityMusicLensFilterParserClass;
 
39
typedef struct _UnityMusicLensFilterParserPrivate UnityMusicLensFilterParserPrivate;
 
40
 
 
41
#define UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER (unity_music_lens_genre_filter_parser_get_type ())
 
42
#define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParser))
 
43
#define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParserClass))
 
44
#define UNITY_MUSIC_LENS_IS_GENRE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER))
 
45
#define UNITY_MUSIC_LENS_IS_GENRE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER))
 
46
#define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParserClass))
 
47
 
 
48
typedef struct _UnityMusicLensGenreFilterParser UnityMusicLensGenreFilterParser;
 
49
typedef struct _UnityMusicLensGenreFilterParserClass UnityMusicLensGenreFilterParserClass;
 
50
typedef struct _UnityMusicLensGenreFilterParserPrivate UnityMusicLensGenreFilterParserPrivate;
 
51
 
 
52
#define UNITY_MUSIC_LENS_TYPE_GENRE (unity_music_lens_genre_get_type ())
 
53
#define UNITY_MUSIC_LENS_GENRE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenre))
 
54
#define UNITY_MUSIC_LENS_GENRE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenreClass))
 
55
#define UNITY_MUSIC_LENS_IS_GENRE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_GENRE))
 
56
#define UNITY_MUSIC_LENS_IS_GENRE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_GENRE))
 
57
#define UNITY_MUSIC_LENS_GENRE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_GENRE, UnityMusicLensGenreClass))
 
58
 
 
59
typedef struct _UnityMusicLensGenre UnityMusicLensGenre;
 
60
typedef struct _UnityMusicLensGenreClass UnityMusicLensGenreClass;
 
61
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
62
#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
 
63
 
 
64
struct _UnityMusicLensFilterParser {
 
65
        GObject parent_instance;
 
66
        UnityMusicLensFilterParserPrivate * priv;
 
67
};
 
68
 
 
69
struct _UnityMusicLensFilterParserClass {
 
70
        GObjectClass parent_class;
 
71
        gchar* (*parse) (UnityMusicLensFilterParser* self);
 
72
        const gchar* (*get_id) (UnityMusicLensFilterParser* self);
 
73
};
 
74
 
 
75
struct _UnityMusicLensGenreFilterParser {
 
76
        UnityMusicLensFilterParser parent_instance;
 
77
        UnityMusicLensGenreFilterParserPrivate * priv;
 
78
};
 
79
 
 
80
struct _UnityMusicLensGenreFilterParserClass {
 
81
        UnityMusicLensFilterParserClass parent_class;
 
82
};
 
83
 
 
84
struct _UnityMusicLensGenreFilterParserPrivate {
 
85
        UnityMusicLensGenre* _map;
 
86
};
 
87
 
 
88
 
 
89
static gpointer unity_music_lens_genre_filter_parser_parent_class = NULL;
 
90
 
 
91
GType unity_music_lens_filter_parser_get_type (void) G_GNUC_CONST;
 
92
GType unity_music_lens_genre_filter_parser_get_type (void) G_GNUC_CONST;
 
93
GType unity_music_lens_genre_get_type (void) G_GNUC_CONST;
 
94
#define UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, UnityMusicLensGenreFilterParserPrivate))
 
95
enum  {
 
96
        UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_DUMMY_PROPERTY,
 
97
        UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_ID,
 
98
        UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_MAP
 
99
};
 
100
UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_new (UnityCheckOptionFilterCompact* filter);
 
101
UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_construct (GType object_type, UnityCheckOptionFilterCompact* filter);
 
102
UnityMusicLensFilterParser* unity_music_lens_filter_parser_construct (GType object_type, UnityFilter* filter);
 
103
UnityMusicLensGenre* unity_music_lens_genre_new (void);
 
104
UnityMusicLensGenre* unity_music_lens_genre_construct (GType object_type);
 
105
static void unity_music_lens_genre_filter_parser_set_map (UnityMusicLensGenreFilterParser* self, UnityMusicLensGenre* value);
 
106
static gchar* unity_music_lens_genre_filter_parser_real_parse (UnityMusicLensFilterParser* base);
 
107
GList* unity_music_lens_genre_filter_parser_get_all_selected_genres (UnityMusicLensGenreFilterParser* self);
 
108
UnityFilter* unity_music_lens_filter_parser_get_filter (UnityMusicLensFilterParser* self);
 
109
static void _g_object_unref0_ (gpointer var);
 
110
static void _g_list_free__g_object_unref0_ (GList* self);
 
111
UnityMusicLensGenre* unity_music_lens_genre_filter_parser_get_map (UnityMusicLensGenreFilterParser* self);
 
112
static void unity_music_lens_genre_filter_parser_finalize (GObject* obj);
 
113
const gchar* unity_music_lens_filter_parser_get_id (UnityMusicLensFilterParser* self);
 
114
static void _vala_unity_music_lens_genre_filter_parser_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
 
115
static void _vala_unity_music_lens_genre_filter_parser_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
 
116
 
 
117
 
 
118
UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_construct (GType object_type, UnityCheckOptionFilterCompact* filter) {
 
119
        UnityMusicLensGenreFilterParser * self = NULL;
 
120
        UnityCheckOptionFilterCompact* _tmp0_;
 
121
        UnityMusicLensGenre* _tmp1_;
 
122
        UnityMusicLensGenre* _tmp2_;
 
123
        g_return_val_if_fail (filter != NULL, NULL);
 
124
        _tmp0_ = filter;
 
125
        self = (UnityMusicLensGenreFilterParser*) unity_music_lens_filter_parser_construct (object_type, (UnityFilter*) _tmp0_);
 
126
        _tmp1_ = unity_music_lens_genre_new ();
 
127
        _tmp2_ = _tmp1_;
 
128
        unity_music_lens_genre_filter_parser_set_map (self, _tmp2_);
 
129
        _g_object_unref0 (_tmp2_);
 
130
        return self;
 
131
}
 
132
 
 
133
 
 
134
UnityMusicLensGenreFilterParser* unity_music_lens_genre_filter_parser_new (UnityCheckOptionFilterCompact* filter) {
 
135
        return unity_music_lens_genre_filter_parser_construct (UNITY_MUSIC_LENS_TYPE_GENRE_FILTER_PARSER, filter);
 
136
}
 
137
 
 
138
 
 
139
static gchar* unity_music_lens_genre_filter_parser_real_parse (UnityMusicLensFilterParser* base) {
 
140
        UnityMusicLensGenreFilterParser * self;
 
141
        gchar* result = NULL;
 
142
        gchar* _tmp0_;
 
143
        self = (UnityMusicLensGenreFilterParser*) base;
 
144
        _tmp0_ = g_strdup ("");
 
145
        result = _tmp0_;
 
146
        return result;
 
147
}
 
148
 
 
149
 
 
150
static gpointer _g_object_ref0 (gpointer self) {
 
151
        return self ? g_object_ref (self) : NULL;
 
152
}
 
153
 
 
154
 
 
155
static void _g_object_unref0_ (gpointer var) {
 
156
        (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
 
157
}
 
158
 
 
159
 
 
160
static void _g_list_free__g_object_unref0_ (GList* self) {
 
161
        g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
 
162
        g_list_free (self);
 
163
}
 
164
 
 
165
 
 
166
GList* unity_music_lens_genre_filter_parser_get_all_selected_genres (UnityMusicLensGenreFilterParser* self) {
 
167
        GList* result = NULL;
 
168
        UnityFilter* _tmp0_;
 
169
        UnityFilter* _tmp1_;
 
170
        GList* _tmp2_;
 
171
        GList* options;
 
172
        GList* active;
 
173
        GList* _tmp3_;
 
174
        g_return_val_if_fail (self != NULL, NULL);
 
175
        _tmp0_ = unity_music_lens_filter_parser_get_filter ((UnityMusicLensFilterParser*) self);
 
176
        _tmp1_ = _tmp0_;
 
177
        _tmp2_ = ((UnityOptionsFilter*) (UNITY_IS_CHECK_OPTION_FILTER_COMPACT (_tmp1_) ? ((UnityCheckOptionFilterCompact*) _tmp1_) : NULL))->options;
 
178
        options = _tmp2_;
 
179
        active = NULL;
 
180
        _tmp3_ = options;
 
181
        {
 
182
                GList* option_collection = NULL;
 
183
                GList* option_it = NULL;
 
184
                option_collection = _tmp3_;
 
185
                for (option_it = option_collection; option_it != NULL; option_it = option_it->next) {
 
186
                        UnityFilterOption* _tmp4_;
 
187
                        UnityFilterOption* option = NULL;
 
188
                        _tmp4_ = _g_object_ref0 ((UnityFilterOption*) option_it->data);
 
189
                        option = _tmp4_;
 
190
                        {
 
191
                                UnityFilterOption* _tmp5_;
 
192
                                gboolean _tmp6_;
 
193
                                gboolean _tmp7_;
 
194
                                _tmp5_ = option;
 
195
                                _tmp6_ = unity_filter_option_get_active (_tmp5_);
 
196
                                _tmp7_ = _tmp6_;
 
197
                                if (_tmp7_) {
 
198
                                        UnityFilterOption* _tmp8_;
 
199
                                        UnityFilterOption* _tmp9_;
 
200
                                        _tmp8_ = option;
 
201
                                        _tmp9_ = _g_object_ref0 (_tmp8_);
 
202
                                        active = g_list_append (active, _tmp9_);
 
203
                                }
 
204
                                _g_object_unref0 (option);
 
205
                        }
 
206
                }
 
207
        }
 
208
        result = active;
 
209
        return result;
 
210
}
 
211
 
 
212
 
 
213
static const gchar* unity_music_lens_genre_filter_parser_real_get_id (UnityMusicLensFilterParser* base) {
 
214
        const gchar* result;
 
215
        UnityMusicLensGenreFilterParser* self;
 
216
        self = (UnityMusicLensGenreFilterParser*) base;
 
217
        result = "genre";
 
218
        return result;
 
219
}
 
220
 
 
221
 
 
222
UnityMusicLensGenre* unity_music_lens_genre_filter_parser_get_map (UnityMusicLensGenreFilterParser* self) {
 
223
        UnityMusicLensGenre* result;
 
224
        UnityMusicLensGenre* _tmp0_;
 
225
        g_return_val_if_fail (self != NULL, NULL);
 
226
        _tmp0_ = self->priv->_map;
 
227
        result = _tmp0_;
 
228
        return result;
 
229
}
 
230
 
 
231
 
 
232
static void unity_music_lens_genre_filter_parser_set_map (UnityMusicLensGenreFilterParser* self, UnityMusicLensGenre* value) {
 
233
        UnityMusicLensGenre* _tmp0_;
 
234
        UnityMusicLensGenre* _tmp1_;
 
235
        g_return_if_fail (self != NULL);
 
236
        _tmp0_ = value;
 
237
        _tmp1_ = _g_object_ref0 (_tmp0_);
 
238
        _g_object_unref0 (self->priv->_map);
 
239
        self->priv->_map = _tmp1_;
 
240
        g_object_notify ((GObject *) self, "map");
 
241
}
 
242
 
 
243
 
 
244
static void unity_music_lens_genre_filter_parser_class_init (UnityMusicLensGenreFilterParserClass * klass) {
 
245
        unity_music_lens_genre_filter_parser_parent_class = g_type_class_peek_parent (klass);
 
246
        g_type_class_add_private (klass, sizeof (UnityMusicLensGenreFilterParserPrivate));
 
247
        UNITY_MUSIC_LENS_FILTER_PARSER_CLASS (klass)->parse = unity_music_lens_genre_filter_parser_real_parse;
 
248
        UNITY_MUSIC_LENS_FILTER_PARSER_CLASS (klass)->get_id = unity_music_lens_genre_filter_parser_real_get_id;
 
249
        G_OBJECT_CLASS (klass)->get_property = _vala_unity_music_lens_genre_filter_parser_get_property;
 
250
        G_OBJECT_CLASS (klass)->set_property = _vala_unity_music_lens_genre_filter_parser_set_property;
 
251
        G_OBJECT_CLASS (klass)->finalize = unity_music_lens_genre_filter_parser_finalize;
 
252
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_ID, g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
253
        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_MAP, g_param_spec_object ("map", "map", "map", UNITY_MUSIC_LENS_TYPE_GENRE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
 
254
}
 
255
 
 
256
 
 
257
static void unity_music_lens_genre_filter_parser_instance_init (UnityMusicLensGenreFilterParser * self) {
 
258
        self->priv = UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_GET_PRIVATE (self);
 
259
}
 
260
 
 
261
 
 
262
static void unity_music_lens_genre_filter_parser_finalize (GObject* obj) {
 
263
        UnityMusicLensGenreFilterParser * self;
 
264
        self = UNITY_MUSIC_LENS_GENRE_FILTER_PARSER (obj);
 
265
        _g_object_unref0 (self->priv->_map);
 
266
        G_OBJECT_CLASS (unity_music_lens_genre_filter_parser_parent_class)->finalize (obj);
 
267
}
 
268
 
 
269
 
 
270
GType unity_music_lens_genre_filter_parser_get_type (void) {
 
271
        static volatile gsize unity_music_lens_genre_filter_parser_type_id__volatile = 0;
 
272
        if (g_once_init_enter (&unity_music_lens_genre_filter_parser_type_id__volatile)) {
 
273
                static const GTypeInfo g_define_type_info = { sizeof (UnityMusicLensGenreFilterParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_music_lens_genre_filter_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMusicLensGenreFilterParser), 0, (GInstanceInitFunc) unity_music_lens_genre_filter_parser_instance_init, NULL };
 
274
                GType unity_music_lens_genre_filter_parser_type_id;
 
275
                unity_music_lens_genre_filter_parser_type_id = g_type_register_static (UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, "UnityMusicLensGenreFilterParser", &g_define_type_info, 0);
 
276
                g_once_init_leave (&unity_music_lens_genre_filter_parser_type_id__volatile, unity_music_lens_genre_filter_parser_type_id);
 
277
        }
 
278
        return unity_music_lens_genre_filter_parser_type_id__volatile;
 
279
}
 
280
 
 
281
 
 
282
static void _vala_unity_music_lens_genre_filter_parser_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
 
283
        UnityMusicLensGenreFilterParser * self;
 
284
        self = UNITY_MUSIC_LENS_GENRE_FILTER_PARSER (object);
 
285
        switch (property_id) {
 
286
                case UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_ID:
 
287
                g_value_set_string (value, unity_music_lens_filter_parser_get_id ((UnityMusicLensFilterParser*) self));
 
288
                break;
 
289
                case UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_MAP:
 
290
                g_value_set_object (value, unity_music_lens_genre_filter_parser_get_map (self));
 
291
                break;
 
292
                default:
 
293
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
294
                break;
 
295
        }
 
296
}
 
297
 
 
298
 
 
299
static void _vala_unity_music_lens_genre_filter_parser_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
 
300
        UnityMusicLensGenreFilterParser * self;
 
301
        self = UNITY_MUSIC_LENS_GENRE_FILTER_PARSER (object);
 
302
        switch (property_id) {
 
303
                case UNITY_MUSIC_LENS_GENRE_FILTER_PARSER_MAP:
 
304
                unity_music_lens_genre_filter_parser_set_map (self, g_value_get_object (value));
 
305
                break;
 
306
                default:
 
307
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
308
                break;
 
309
        }
 
310
}
 
311
 
 
312
 
 
313