Back to index

libunity  5.92.0
unity-lens-search.c
Go to the documentation of this file.
00001 /* unity-lens-search.c generated by valac 0.17.2, the Vala compiler
00002  * generated from unity-lens-search.vala, do not modify */
00003 
00004 /*
00005  * Copyright (C) 2011 Canonical, Ltd.
00006  *
00007  * This library is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU Lesser General Public License
00009  * version 3.0 as published by the Free Software Foundation.
00010  *
00011  * This library 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 Lesser General Public License version 3.0 for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library. If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  *
00020  * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
00021  *
00022  */
00023 
00024 #include <glib.h>
00025 #include <glib-object.h>
00026 #include "unity.h"
00027 #include <stdlib.h>
00028 #include <string.h>
00029 #include <dee.h>
00030 
00031 #define _g_free0(var) (var = (g_free (var), NULL))
00032 #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
00033 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00034 
00035 struct _UnityLensSearchPrivate {
00036        gchar* _search_string;
00037        GHashTable* _hints;
00038        DeeSerializableModel* _results_model;
00039        gboolean got_finished;
00040        GHashTable* _reply_hints;
00041 };
00042 
00043 
00044 static gpointer unity_lens_search_parent_class = NULL;
00045 
00046 #define UNITY_LENS_SEARCH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TYPE_LENS_SEARCH, UnityLensSearchPrivate))
00047 enum  {
00048        UNITY_LENS_SEARCH_DUMMY_PROPERTY,
00049        UNITY_LENS_SEARCH_SEARCH_STRING,
00050        UNITY_LENS_SEARCH_HINTS,
00051        UNITY_LENS_SEARCH_RESULTS_MODEL
00052 };
00053 gboolean unity_lens_search_was_finished (UnityLensSearch* self);
00054 static void _g_free0_ (gpointer var);
00055 static void _g_variant_unref0_ (gpointer var);
00056 GHashTable* unity_lens_search_get_reply_hints (UnityLensSearch* self);
00057 static GObject * unity_lens_search_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
00058 static void _unity_lens_search___lambda3_ (UnityLensSearch* self);
00059 static void __unity_lens_search___lambda3__unity_lens_search_finished (UnityLensSearch* _sender, gpointer self);
00060 static void unity_lens_search_finalize (GObject* obj);
00061 static void _vala_unity_lens_search_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
00062 static void _vala_unity_lens_search_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
00063 
00064 
00065 void unity_lens_search_finished (UnityLensSearch* self) {
00066        g_return_if_fail (self != NULL);
00067        g_signal_emit_by_name (self, "finished");
00068 }
00069 
00070 
00071 UnityLensSearch* unity_lens_search_construct (GType object_type, const gchar* search_string, GHashTable* hints, DeeSerializableModel* results_model) {
00072        UnityLensSearch * self = NULL;
00073        const gchar* _tmp0_;
00074        GHashTable* _tmp1_;
00075        DeeSerializableModel* _tmp2_;
00076        g_return_val_if_fail (search_string != NULL, NULL);
00077        g_return_val_if_fail (hints != NULL, NULL);
00078        g_return_val_if_fail (results_model != NULL, NULL);
00079        _tmp0_ = search_string;
00080        _tmp1_ = hints;
00081        _tmp2_ = results_model;
00082        self = (UnityLensSearch*) g_object_new (object_type, "search-string", _tmp0_, "hints", _tmp1_, "results-model", _tmp2_, NULL);
00083        return self;
00084 }
00085 
00086 
00087 UnityLensSearch* unity_lens_search_new (const gchar* search_string, GHashTable* hints, DeeSerializableModel* results_model) {
00088        return unity_lens_search_construct (UNITY_TYPE_LENS_SEARCH, search_string, hints, results_model);
00089 }
00090 
00091 
00092 gboolean unity_lens_search_was_finished (UnityLensSearch* self) {
00093        gboolean result = FALSE;
00094        gboolean _tmp0_;
00095        g_return_val_if_fail (self != NULL, FALSE);
00096        _tmp0_ = self->priv->got_finished;
00097        result = _tmp0_;
00098        return result;
00099 }
00100 
00101 
00102 gboolean unity_lens_search_equals (UnityLensSearch* self, UnityLensSearch* other) {
00103        gboolean result = FALSE;
00104        gboolean _tmp0_ = FALSE;
00105        UnityLensSearch* _tmp1_;
00106        gboolean _tmp5_;
00107        g_return_val_if_fail (self != NULL, FALSE);
00108        _tmp1_ = other;
00109        if (_tmp1_ == NULL) {
00110               _tmp0_ = TRUE;
00111        } else {
00112               const gchar* _tmp2_;
00113               UnityLensSearch* _tmp3_;
00114               const gchar* _tmp4_;
00115               _tmp2_ = self->priv->_search_string;
00116               _tmp3_ = other;
00117               _tmp4_ = _tmp3_->priv->_search_string;
00118               _tmp0_ = g_strcmp0 (_tmp2_, _tmp4_) != 0;
00119        }
00120        _tmp5_ = _tmp0_;
00121        if (_tmp5_) {
00122               result = FALSE;
00123               return result;
00124        }
00125        result = TRUE;
00126        return result;
00127 }
00128 
00129 
00130 static void _g_free0_ (gpointer var) {
00131        var = (g_free (var), NULL);
00132 }
00133 
00134 
00135 static void _g_variant_unref0_ (gpointer var) {
00136        (var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
00137 }
00138 
00139 
00140 static gpointer _g_variant_ref0 (gpointer self) {
00141        return self ? g_variant_ref (self) : NULL;
00142 }
00143 
00144 
00145 void unity_lens_search_set_reply_hint (UnityLensSearch* self, const gchar* key, GVariant* variant) {
00146        GHashTable* _tmp0_;
00147        GHashTable* _tmp4_;
00148        const gchar* _tmp5_;
00149        gchar* _tmp6_;
00150        GVariant* _tmp7_;
00151        GVariant* _tmp8_;
00152        g_return_if_fail (self != NULL);
00153        g_return_if_fail (key != NULL);
00154        g_return_if_fail (variant != NULL);
00155        _tmp0_ = self->priv->_reply_hints;
00156        if (_tmp0_ == NULL) {
00157               GHashFunc _tmp1_;
00158               GEqualFunc _tmp2_;
00159               GHashTable* _tmp3_;
00160               _tmp1_ = g_str_hash;
00161               _tmp2_ = g_str_equal;
00162               _tmp3_ = g_hash_table_new_full (_tmp1_, _tmp2_, _g_free0_, _g_variant_unref0_);
00163               _g_hash_table_unref0 (self->priv->_reply_hints);
00164               self->priv->_reply_hints = _tmp3_;
00165        }
00166        _tmp4_ = self->priv->_reply_hints;
00167        _tmp5_ = key;
00168        _tmp6_ = g_strdup (_tmp5_);
00169        _tmp7_ = variant;
00170        _tmp8_ = _g_variant_ref0 (_tmp7_);
00171        g_hash_table_insert (_tmp4_, _tmp6_, _tmp8_);
00172 }
00173 
00174 
00175 static gpointer _g_hash_table_ref0 (gpointer self) {
00176        return self ? g_hash_table_ref (self) : NULL;
00177 }
00178 
00179 
00180 GHashTable* unity_lens_search_get_reply_hints (UnityLensSearch* self) {
00181        GHashTable* result = NULL;
00182        GHashTable* _tmp0_;
00183        GHashTable* _tmp1_;
00184        g_return_val_if_fail (self != NULL, NULL);
00185        _tmp0_ = self->priv->_reply_hints;
00186        _tmp1_ = _g_hash_table_ref0 (_tmp0_);
00187        result = _tmp1_;
00188        return result;
00189 }
00190 
00191 
00192 const gchar* unity_lens_search_get_search_string (UnityLensSearch* self) {
00193        const gchar* result;
00194        const gchar* _tmp0_;
00195        g_return_val_if_fail (self != NULL, NULL);
00196        _tmp0_ = self->priv->_search_string;
00197        result = _tmp0_;
00198        return result;
00199 }
00200 
00201 
00202 static void unity_lens_search_set_search_string (UnityLensSearch* self, const gchar* value) {
00203        const gchar* _tmp0_;
00204        gchar* _tmp1_;
00205        g_return_if_fail (self != NULL);
00206        _tmp0_ = value;
00207        _tmp1_ = g_strdup (_tmp0_);
00208        _g_free0 (self->priv->_search_string);
00209        self->priv->_search_string = _tmp1_;
00210        g_object_notify ((GObject *) self, "search-string");
00211 }
00212 
00213 
00214 GHashTable* unity_lens_search_get_hints (UnityLensSearch* self) {
00215        GHashTable* result;
00216        GHashTable* _tmp0_;
00217        g_return_val_if_fail (self != NULL, NULL);
00218        _tmp0_ = self->priv->_hints;
00219        result = _tmp0_;
00220        return result;
00221 }
00222 
00223 
00224 static void unity_lens_search_set_hints (UnityLensSearch* self, GHashTable* value) {
00225        GHashTable* _tmp0_;
00226        GHashTable* _tmp1_;
00227        g_return_if_fail (self != NULL);
00228        _tmp0_ = value;
00229        _tmp1_ = _g_hash_table_ref0 (_tmp0_);
00230        _g_hash_table_unref0 (self->priv->_hints);
00231        self->priv->_hints = _tmp1_;
00232        g_object_notify ((GObject *) self, "hints");
00233 }
00234 
00235 
00236 DeeSerializableModel* unity_lens_search_get_results_model (UnityLensSearch* self) {
00237        DeeSerializableModel* result;
00238        DeeSerializableModel* _tmp0_;
00239        g_return_val_if_fail (self != NULL, NULL);
00240        _tmp0_ = self->priv->_results_model;
00241        result = _tmp0_;
00242        return result;
00243 }
00244 
00245 
00246 static gpointer _g_object_ref0 (gpointer self) {
00247        return self ? g_object_ref (self) : NULL;
00248 }
00249 
00250 
00251 static void unity_lens_search_set_results_model (UnityLensSearch* self, DeeSerializableModel* value) {
00252        DeeSerializableModel* _tmp0_;
00253        DeeSerializableModel* _tmp1_;
00254        g_return_if_fail (self != NULL);
00255        _tmp0_ = value;
00256        _tmp1_ = _g_object_ref0 (_tmp0_);
00257        _g_object_unref0 (self->priv->_results_model);
00258        self->priv->_results_model = _tmp1_;
00259        g_object_notify ((GObject *) self, "results-model");
00260 }
00261 
00262 
00263 static void _unity_lens_search___lambda3_ (UnityLensSearch* self) {
00264        self->priv->got_finished = TRUE;
00265 }
00266 
00267 
00268 static void __unity_lens_search___lambda3__unity_lens_search_finished (UnityLensSearch* _sender, gpointer self) {
00269        _unity_lens_search___lambda3_ (self);
00270 }
00271 
00272 
00273 static GObject * unity_lens_search_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
00274        GObject * obj;
00275        GObjectClass * parent_class;
00276        UnityLensSearch * self;
00277        parent_class = G_OBJECT_CLASS (unity_lens_search_parent_class);
00278        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
00279        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_TYPE_LENS_SEARCH, UnityLensSearch);
00280        g_signal_connect_object (self, "finished", (GCallback) __unity_lens_search___lambda3__unity_lens_search_finished, self, 0);
00281        return obj;
00282 }
00283 
00284 
00285 static void unity_lens_search_class_init (UnityLensSearchClass * klass) {
00286        unity_lens_search_parent_class = g_type_class_peek_parent (klass);
00287        g_type_class_add_private (klass, sizeof (UnityLensSearchPrivate));
00288        G_OBJECT_CLASS (klass)->get_property = _vala_unity_lens_search_get_property;
00289        G_OBJECT_CLASS (klass)->set_property = _vala_unity_lens_search_set_property;
00290        G_OBJECT_CLASS (klass)->constructor = unity_lens_search_constructor;
00291        G_OBJECT_CLASS (klass)->finalize = unity_lens_search_finalize;
00292        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_LENS_SEARCH_SEARCH_STRING, g_param_spec_string ("search-string", "search-string", "search-string", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00293        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_LENS_SEARCH_HINTS, g_param_spec_boxed ("hints", "hints", "hints", G_TYPE_HASH_TABLE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00294        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_LENS_SEARCH_RESULTS_MODEL, g_param_spec_object ("results-model", "results-model", "results-model", dee_serializable_model_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00295        g_signal_new ("finished", UNITY_TYPE_LENS_SEARCH, G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
00296 }
00297 
00298 
00299 static void unity_lens_search_instance_init (UnityLensSearch * self) {
00300        self->priv = UNITY_LENS_SEARCH_GET_PRIVATE (self);
00301        self->priv->got_finished = FALSE;
00302        self->priv->_reply_hints = NULL;
00303 }
00304 
00305 
00306 static void unity_lens_search_finalize (GObject* obj) {
00307        UnityLensSearch * self;
00308        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_TYPE_LENS_SEARCH, UnityLensSearch);
00309        _g_free0 (self->priv->_search_string);
00310        _g_hash_table_unref0 (self->priv->_hints);
00311        _g_object_unref0 (self->priv->_results_model);
00312        _g_hash_table_unref0 (self->priv->_reply_hints);
00313        G_OBJECT_CLASS (unity_lens_search_parent_class)->finalize (obj);
00314 }
00315 
00316 
00317 GType unity_lens_search_get_type (void) {
00318        static volatile gsize unity_lens_search_type_id__volatile = 0;
00319        if (g_once_init_enter (&unity_lens_search_type_id__volatile)) {
00320               static const GTypeInfo g_define_type_info = { sizeof (UnityLensSearchClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_lens_search_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityLensSearch), 0, (GInstanceInitFunc) unity_lens_search_instance_init, NULL };
00321               GType unity_lens_search_type_id;
00322               unity_lens_search_type_id = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "UnityLensSearch", &g_define_type_info, 0);
00323               g_once_init_leave (&unity_lens_search_type_id__volatile, unity_lens_search_type_id);
00324        }
00325        return unity_lens_search_type_id__volatile;
00326 }
00327 
00328 
00329 static void _vala_unity_lens_search_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
00330        UnityLensSearch * self;
00331        self = G_TYPE_CHECK_INSTANCE_CAST (object, UNITY_TYPE_LENS_SEARCH, UnityLensSearch);
00332        switch (property_id) {
00333               case UNITY_LENS_SEARCH_SEARCH_STRING:
00334               g_value_set_string (value, unity_lens_search_get_search_string (self));
00335               break;
00336               case UNITY_LENS_SEARCH_HINTS:
00337               g_value_set_boxed (value, unity_lens_search_get_hints (self));
00338               break;
00339               case UNITY_LENS_SEARCH_RESULTS_MODEL:
00340               g_value_set_object (value, unity_lens_search_get_results_model (self));
00341               break;
00342               default:
00343               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00344               break;
00345        }
00346 }
00347 
00348 
00349 static void _vala_unity_lens_search_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
00350        UnityLensSearch * self;
00351        self = G_TYPE_CHECK_INSTANCE_CAST (object, UNITY_TYPE_LENS_SEARCH, UnityLensSearch);
00352        switch (property_id) {
00353               case UNITY_LENS_SEARCH_SEARCH_STRING:
00354               unity_lens_search_set_search_string (self, g_value_get_string (value));
00355               break;
00356               case UNITY_LENS_SEARCH_HINTS:
00357               unity_lens_search_set_hints (self, g_value_get_boxed (value));
00358               break;
00359               case UNITY_LENS_SEARCH_RESULTS_MODEL:
00360               unity_lens_search_set_results_model (self, g_value_get_object (value));
00361               break;
00362               default:
00363               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00364               break;
00365        }
00366 }
00367 
00368 
00369