Back to index

unity-lens-music  6.0.0
musicstore-filter-parser-decade.c
Go to the documentation of this file.
00001 /* musicstore-filter-parser-decade.c generated by valac 0.14.2, the Vala compiler
00002  * generated from musicstore-filter-parser-decade.vala, do not modify */
00003 
00004 /*
00005  * Copyright (C) 2011 Canonical Ltd
00006  *
00007  * This program is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License version 3 as
00009  * published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018  *
00019  * Authored by Alex Launi <alex.launi@canonical.com>
00020  *
00021  */
00022 
00023 #include <glib.h>
00024 #include <glib-object.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #include <unity.h>
00028 
00029 
00030 #define UNITY_MUSIC_LENS_TYPE_FILTER_PARSER (unity_music_lens_filter_parser_get_type ())
00031 #define UNITY_MUSIC_LENS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParser))
00032 #define UNITY_MUSIC_LENS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
00033 #define UNITY_MUSIC_LENS_IS_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
00034 #define UNITY_MUSIC_LENS_IS_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER))
00035 #define UNITY_MUSIC_LENS_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_FILTER_PARSER, UnityMusicLensFilterParserClass))
00036 
00037 typedef struct _UnityMusicLensFilterParser UnityMusicLensFilterParser;
00038 typedef struct _UnityMusicLensFilterParserClass UnityMusicLensFilterParserClass;
00039 typedef struct _UnityMusicLensFilterParserPrivate UnityMusicLensFilterParserPrivate;
00040 
00041 #define UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER (unity_music_lens_decade_filter_parser_get_type ())
00042 #define UNITY_MUSIC_LENS_DECADE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER, UnityMusicLensDecadeFilterParser))
00043 #define UNITY_MUSIC_LENS_DECADE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER, UnityMusicLensDecadeFilterParserClass))
00044 #define UNITY_MUSIC_LENS_IS_DECADE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER))
00045 #define UNITY_MUSIC_LENS_IS_DECADE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER))
00046 #define UNITY_MUSIC_LENS_DECADE_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER, UnityMusicLensDecadeFilterParserClass))
00047 
00048 typedef struct _UnityMusicLensDecadeFilterParser UnityMusicLensDecadeFilterParser;
00049 typedef struct _UnityMusicLensDecadeFilterParserClass UnityMusicLensDecadeFilterParserClass;
00050 typedef struct _UnityMusicLensDecadeFilterParserPrivate UnityMusicLensDecadeFilterParserPrivate;
00051 
00052 #define UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER (unity_music_lens_music_store_filter_parser_get_type ())
00053 #define UNITY_MUSIC_LENS_MUSIC_STORE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, UnityMusicLensMusicStoreFilterParser))
00054 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER))
00055 #define UNITY_MUSIC_LENS_MUSIC_STORE_FILTER_PARSER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, UnityMusicLensMusicStoreFilterParserIface))
00056 
00057 typedef struct _UnityMusicLensMusicStoreFilterParser UnityMusicLensMusicStoreFilterParser;
00058 typedef struct _UnityMusicLensMusicStoreFilterParserIface UnityMusicLensMusicStoreFilterParserIface;
00059 
00060 #define UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER (unity_music_lens_music_store_decade_filter_parser_get_type ())
00061 #define UNITY_MUSIC_LENS_MUSIC_STORE_DECADE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER, UnityMusicLensMusicStoreDecadeFilterParser))
00062 #define UNITY_MUSIC_LENS_MUSIC_STORE_DECADE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER, UnityMusicLensMusicStoreDecadeFilterParserClass))
00063 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_DECADE_FILTER_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER))
00064 #define UNITY_MUSIC_LENS_IS_MUSIC_STORE_DECADE_FILTER_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER))
00065 #define UNITY_MUSIC_LENS_MUSIC_STORE_DECADE_FILTER_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER, UnityMusicLensMusicStoreDecadeFilterParserClass))
00066 
00067 typedef struct _UnityMusicLensMusicStoreDecadeFilterParser UnityMusicLensMusicStoreDecadeFilterParser;
00068 typedef struct _UnityMusicLensMusicStoreDecadeFilterParserClass UnityMusicLensMusicStoreDecadeFilterParserClass;
00069 typedef struct _UnityMusicLensMusicStoreDecadeFilterParserPrivate UnityMusicLensMusicStoreDecadeFilterParserPrivate;
00070 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00071 #define _g_free0(var) (var = (g_free (var), NULL))
00072 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
00073 
00074 struct _UnityMusicLensFilterParser {
00075        GObject parent_instance;
00076        UnityMusicLensFilterParserPrivate * priv;
00077 };
00078 
00079 struct _UnityMusicLensFilterParserClass {
00080        GObjectClass parent_class;
00081        gchar* (*parse) (UnityMusicLensFilterParser* self);
00082        const gchar* (*get_id) (UnityMusicLensFilterParser* self);
00083 };
00084 
00085 struct _UnityMusicLensDecadeFilterParser {
00086        UnityMusicLensFilterParser parent_instance;
00087        UnityMusicLensDecadeFilterParserPrivate * priv;
00088 };
00089 
00090 struct _UnityMusicLensDecadeFilterParserClass {
00091        UnityMusicLensFilterParserClass parent_class;
00092 };
00093 
00094 struct _UnityMusicLensMusicStoreFilterParserIface {
00095        GTypeInterface parent_iface;
00096 };
00097 
00098 struct _UnityMusicLensMusicStoreDecadeFilterParser {
00099        UnityMusicLensDecadeFilterParser parent_instance;
00100        UnityMusicLensMusicStoreDecadeFilterParserPrivate * priv;
00101 };
00102 
00103 struct _UnityMusicLensMusicStoreDecadeFilterParserClass {
00104        UnityMusicLensDecadeFilterParserClass parent_class;
00105 };
00106 
00107 
00108 static gpointer unity_music_lens_music_store_decade_filter_parser_parent_class = NULL;
00109 static UnityMusicLensMusicStoreFilterParserIface* unity_music_lens_music_store_decade_filter_parser_unity_music_lens_music_store_filter_parser_parent_iface = NULL;
00110 
00111 GType unity_music_lens_filter_parser_get_type (void) G_GNUC_CONST;
00112 GType unity_music_lens_decade_filter_parser_get_type (void) G_GNUC_CONST;
00113 GType unity_music_lens_music_store_filter_parser_get_type (void) G_GNUC_CONST;
00114 GType unity_music_lens_music_store_decade_filter_parser_get_type (void) G_GNUC_CONST;
00115 enum  {
00116        UNITY_MUSIC_LENS_MUSIC_STORE_DECADE_FILTER_PARSER_DUMMY_PROPERTY
00117 };
00118 UnityMusicLensMusicStoreDecadeFilterParser* unity_music_lens_music_store_decade_filter_parser_new (UnityMusicLensDecadeFilterParser* parser);
00119 UnityMusicLensMusicStoreDecadeFilterParser* unity_music_lens_music_store_decade_filter_parser_construct (GType object_type, UnityMusicLensDecadeFilterParser* parser);
00120 UnityFilter* unity_music_lens_filter_parser_get_filter (UnityMusicLensFilterParser* self);
00121 UnityMusicLensDecadeFilterParser* unity_music_lens_decade_filter_parser_new (UnityMultiRangeFilter* filter);
00122 UnityMusicLensDecadeFilterParser* unity_music_lens_decade_filter_parser_construct (GType object_type, UnityMultiRangeFilter* filter);
00123 static gchar* unity_music_lens_music_store_decade_filter_parser_real_parse (UnityMusicLensFilterParser* base);
00124 
00125 
00126 UnityMusicLensMusicStoreDecadeFilterParser* unity_music_lens_music_store_decade_filter_parser_construct (GType object_type, UnityMusicLensDecadeFilterParser* parser) {
00127        UnityMusicLensMusicStoreDecadeFilterParser * self = NULL;
00128        UnityMusicLensDecadeFilterParser* _tmp0_;
00129        UnityFilter* _tmp1_;
00130        UnityFilter* _tmp2_;
00131        g_return_val_if_fail (parser != NULL, NULL);
00132        _tmp0_ = parser;
00133        _tmp1_ = unity_music_lens_filter_parser_get_filter ((UnityMusicLensFilterParser*) _tmp0_);
00134        _tmp2_ = _tmp1_;
00135        self = (UnityMusicLensMusicStoreDecadeFilterParser*) unity_music_lens_decade_filter_parser_construct (object_type, UNITY_IS_MULTI_RANGE_FILTER (_tmp2_) ? ((UnityMultiRangeFilter*) _tmp2_) : NULL);
00136        return self;
00137 }
00138 
00139 
00140 UnityMusicLensMusicStoreDecadeFilterParser* unity_music_lens_music_store_decade_filter_parser_new (UnityMusicLensDecadeFilterParser* parser) {
00141        return unity_music_lens_music_store_decade_filter_parser_construct (UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_DECADE_FILTER_PARSER, parser);
00142 }
00143 
00144 
00145 static gpointer _g_object_ref0 (gpointer self) {
00146        return self ? g_object_ref (self) : NULL;
00147 }
00148 
00149 
00150 static gchar* unity_music_lens_music_store_decade_filter_parser_real_parse (UnityMusicLensFilterParser* base) {
00151        UnityMusicLensMusicStoreDecadeFilterParser * self;
00152        gchar* result = NULL;
00153        GString* _tmp0_;
00154        GString* builder;
00155        UnityFilter* _tmp1_;
00156        UnityFilter* _tmp2_;
00157        UnityMultiRangeFilter* _tmp3_;
00158        UnityMultiRangeFilter* range_filter;
00159        UnityMultiRangeFilter* _tmp4_;
00160        UnityFilterOption* _tmp5_ = NULL;
00161        UnityFilterOption* _tmp6_;
00162        const gchar* _tmp7_;
00163        const gchar* _tmp8_;
00164        gchar* _tmp9_;
00165        gchar* _tmp10_;
00166        gchar* start;
00167        UnityMultiRangeFilter* _tmp11_;
00168        UnityFilterOption* _tmp12_ = NULL;
00169        UnityFilterOption* _tmp13_;
00170        const gchar* _tmp14_;
00171        const gchar* _tmp15_;
00172        gchar* _tmp16_;
00173        gchar* _tmp17_;
00174        gchar* end;
00175        const gchar* _tmp18_;
00176        gint _tmp19_ = 0;
00177        gint start_year;
00178        const gchar* _tmp20_;
00179        gint _tmp21_ = 0;
00180        gint end_year;
00181        gint _tmp22_;
00182        gint _tmp23_ = 0;
00183        gint _tmp24_;
00184        gint _tmp25_ = 0;
00185        GString* _tmp33_;
00186        GString* _tmp34_;
00187        gssize _tmp35_;
00188        GString* _tmp36_;
00189        const gchar* _tmp37_;
00190        gchar* _tmp38_;
00191        self = (UnityMusicLensMusicStoreDecadeFilterParser*) base;
00192        _tmp0_ = g_string_new ("&decade=");
00193        builder = _tmp0_;
00194        _tmp1_ = unity_music_lens_filter_parser_get_filter ((UnityMusicLensFilterParser*) self);
00195        _tmp2_ = _tmp1_;
00196        _tmp3_ = _g_object_ref0 (UNITY_IS_MULTI_RANGE_FILTER (_tmp2_) ? ((UnityMultiRangeFilter*) _tmp2_) : NULL);
00197        range_filter = _tmp3_;
00198        _tmp4_ = range_filter;
00199        _tmp5_ = unity_multi_range_filter_get_first_active (_tmp4_);
00200        _tmp6_ = _tmp5_;
00201        _tmp7_ = unity_filter_option_get_id (_tmp6_);
00202        _tmp8_ = _tmp7_;
00203        _tmp9_ = g_strdup (_tmp8_);
00204        _tmp10_ = _tmp9_;
00205        _g_object_unref0 (_tmp6_);
00206        start = _tmp10_;
00207        _tmp11_ = range_filter;
00208        _tmp12_ = unity_multi_range_filter_get_last_active (_tmp11_);
00209        _tmp13_ = _tmp12_;
00210        _tmp14_ = unity_filter_option_get_id (_tmp13_);
00211        _tmp15_ = _tmp14_;
00212        _tmp16_ = g_strdup (_tmp15_);
00213        _tmp17_ = _tmp16_;
00214        _g_object_unref0 (_tmp13_);
00215        end = _tmp17_;
00216        _tmp18_ = start;
00217        _tmp19_ = atoi (_tmp18_);
00218        start_year = _tmp19_;
00219        _tmp20_ = end;
00220        _tmp21_ = atoi (_tmp20_);
00221        end_year = _tmp21_;
00222        _tmp22_ = start_year;
00223        _tmp23_ = CLAMP (_tmp22_, 1900, 2020);
00224        start_year = _tmp23_;
00225        _tmp24_ = end_year;
00226        _tmp25_ = CLAMP (_tmp24_, 1900, 2020);
00227        end_year = _tmp25_;
00228        {
00229               gboolean _tmp26_;
00230               _tmp26_ = TRUE;
00231               while (TRUE) {
00232                      gboolean _tmp27_;
00233                      gint _tmp29_;
00234                      gint _tmp30_;
00235                      GString* _tmp31_;
00236                      gint _tmp32_;
00237                      _tmp27_ = _tmp26_;
00238                      if (!_tmp27_) {
00239                             gint _tmp28_;
00240                             _tmp28_ = start_year;
00241                             start_year = _tmp28_ + 10;
00242                      }
00243                      _tmp26_ = FALSE;
00244                      _tmp29_ = start_year;
00245                      _tmp30_ = end_year;
00246                      if (!(_tmp29_ <= _tmp30_)) {
00247                             break;
00248                      }
00249                      _tmp31_ = builder;
00250                      _tmp32_ = start_year;
00251                      g_string_append_printf (_tmp31_, "%d,", _tmp32_);
00252               }
00253        }
00254        _tmp33_ = builder;
00255        _tmp34_ = builder;
00256        _tmp35_ = _tmp34_->len;
00257        g_string_truncate (_tmp33_, (gsize) (_tmp35_ - 1));
00258        _tmp36_ = builder;
00259        _tmp37_ = _tmp36_->str;
00260        _tmp38_ = g_strdup (_tmp37_);
00261        result = _tmp38_;
00262        _g_free0 (end);
00263        _g_free0 (start);
00264        _g_object_unref0 (range_filter);
00265        _g_string_free0 (builder);
00266        return result;
00267 }
00268 
00269 
00270 static void unity_music_lens_music_store_decade_filter_parser_class_init (UnityMusicLensMusicStoreDecadeFilterParserClass * klass) {
00271        unity_music_lens_music_store_decade_filter_parser_parent_class = g_type_class_peek_parent (klass);
00272        UNITY_MUSIC_LENS_FILTER_PARSER_CLASS (klass)->parse = unity_music_lens_music_store_decade_filter_parser_real_parse;
00273 }
00274 
00275 
00276 static void unity_music_lens_music_store_decade_filter_parser_unity_music_lens_music_store_filter_parser_interface_init (UnityMusicLensMusicStoreFilterParserIface * iface) {
00277        unity_music_lens_music_store_decade_filter_parser_unity_music_lens_music_store_filter_parser_parent_iface = g_type_interface_peek_parent (iface);
00278 }
00279 
00280 
00281 static void unity_music_lens_music_store_decade_filter_parser_instance_init (UnityMusicLensMusicStoreDecadeFilterParser * self) {
00282 }
00283 
00284 
00285 GType unity_music_lens_music_store_decade_filter_parser_get_type (void) {
00286        static volatile gsize unity_music_lens_music_store_decade_filter_parser_type_id__volatile = 0;
00287        if (g_once_init_enter (&unity_music_lens_music_store_decade_filter_parser_type_id__volatile)) {
00288               static const GTypeInfo g_define_type_info = { sizeof (UnityMusicLensMusicStoreDecadeFilterParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_music_lens_music_store_decade_filter_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityMusicLensMusicStoreDecadeFilterParser), 0, (GInstanceInitFunc) unity_music_lens_music_store_decade_filter_parser_instance_init, NULL };
00289               static const GInterfaceInfo unity_music_lens_music_store_filter_parser_info = { (GInterfaceInitFunc) unity_music_lens_music_store_decade_filter_parser_unity_music_lens_music_store_filter_parser_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
00290               GType unity_music_lens_music_store_decade_filter_parser_type_id;
00291               unity_music_lens_music_store_decade_filter_parser_type_id = g_type_register_static (UNITY_MUSIC_LENS_TYPE_DECADE_FILTER_PARSER, "UnityMusicLensMusicStoreDecadeFilterParser", &g_define_type_info, 0);
00292               g_type_add_interface_static (unity_music_lens_music_store_decade_filter_parser_type_id, UNITY_MUSIC_LENS_TYPE_MUSIC_STORE_FILTER_PARSER, &unity_music_lens_music_store_filter_parser_info);
00293               g_once_init_leave (&unity_music_lens_music_store_decade_filter_parser_type_id__volatile, unity_music_lens_music_store_decade_filter_parser_type_id);
00294        }
00295        return unity_music_lens_music_store_decade_filter_parser_type_id__volatile;
00296 }
00297 
00298 
00299