Back to index

libunity  5.92.0
unity-lens-category.c
Go to the documentation of this file.
00001 /* unity-lens-category.c generated by valac 0.17.2, the Vala compiler
00002  * generated from unity-lens-category.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 <gio/gio.h>
00030 
00031 #define _g_free0(var) (var = (g_free (var), NULL))
00032 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
00033 #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
00034 
00035 struct _UnityCategoryPrivate {
00036        gchar* _name;
00037        GIcon* _icon_hint;
00038        UnityCategoryRenderer _default_renderer;
00039        GHashTable* _hints;
00040 };
00041 
00042 
00043 static gpointer unity_category_parent_class = NULL;
00044 
00045 #define UNITY_CATEGORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UNITY_TYPE_CATEGORY, UnityCategoryPrivate))
00046 enum  {
00047        UNITY_CATEGORY_DUMMY_PROPERTY,
00048        UNITY_CATEGORY_NAME,
00049        UNITY_CATEGORY_ICON_HINT,
00050        UNITY_CATEGORY_DEFAULT_RENDERER,
00051        UNITY_CATEGORY_RENDERER,
00052        UNITY_CATEGORY_HINTS
00053 };
00054 const gchar* unity_category_get_renderer (UnityCategory* self);
00055 GHashTable* unity_category_get_hints (UnityCategory* self);
00056 void unity_category_set_hints (UnityCategory* self, GHashTable* value);
00057 static GObject * unity_category_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
00058 static void _g_free0_ (gpointer var);
00059 static void _g_variant_unref0_ (gpointer var);
00060 static void unity_category_finalize (GObject* obj);
00061 static void _vala_unity_category_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
00062 static void _vala_unity_category_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
00063 
00064 
00065 GType unity_category_renderer_get_type (void) {
00066        static volatile gsize unity_category_renderer_type_id__volatile = 0;
00067        if (g_once_init_enter (&unity_category_renderer_type_id__volatile)) {
00068               static const GEnumValue values[] = {{UNITY_CATEGORY_RENDERER_VERTICAL_TILE, "UNITY_CATEGORY_RENDERER_VERTICAL_TILE", "vertical-tile"}, {UNITY_CATEGORY_RENDERER_HORIZONTAL_TILE, "UNITY_CATEGORY_RENDERER_HORIZONTAL_TILE", "horizontal-tile"}, {UNITY_CATEGORY_RENDERER_LIST_TILE, "UNITY_CATEGORY_RENDERER_LIST_TILE", "list-tile"}, {UNITY_CATEGORY_RENDERER_FLOW, "UNITY_CATEGORY_RENDERER_FLOW", "flow"}, {0, NULL, NULL}};
00069               GType unity_category_renderer_type_id;
00070               unity_category_renderer_type_id = g_enum_register_static ("UnityCategoryRenderer", values);
00071               g_once_init_leave (&unity_category_renderer_type_id__volatile, unity_category_renderer_type_id);
00072        }
00073        return unity_category_renderer_type_id__volatile;
00074 }
00075 
00076 
00077 UnityCategory* unity_category_construct (GType object_type, const gchar* name, GIcon* icon_hint, UnityCategoryRenderer renderer) {
00078        UnityCategory * self = NULL;
00079        const gchar* _tmp0_;
00080        GIcon* _tmp1_;
00081        UnityCategoryRenderer _tmp2_;
00082        g_return_val_if_fail (name != NULL, NULL);
00083        g_return_val_if_fail (icon_hint != NULL, NULL);
00084        _tmp0_ = name;
00085        _tmp1_ = icon_hint;
00086        _tmp2_ = renderer;
00087        self = (UnityCategory*) g_object_new (object_type, "name", _tmp0_, "icon-hint", _tmp1_, "default-renderer", _tmp2_, NULL);
00088        return self;
00089 }
00090 
00091 
00092 UnityCategory* unity_category_new (const gchar* name, GIcon* icon_hint, UnityCategoryRenderer renderer) {
00093        return unity_category_construct (UNITY_TYPE_CATEGORY, name, icon_hint, renderer);
00094 }
00095 
00096 
00097 const gchar* unity_category_get_name (UnityCategory* self) {
00098        const gchar* result;
00099        const gchar* _tmp0_;
00100        g_return_val_if_fail (self != NULL, NULL);
00101        _tmp0_ = self->priv->_name;
00102        result = _tmp0_;
00103        return result;
00104 }
00105 
00106 
00107 static void unity_category_set_name (UnityCategory* self, const gchar* value) {
00108        const gchar* _tmp0_;
00109        gchar* _tmp1_;
00110        g_return_if_fail (self != NULL);
00111        _tmp0_ = value;
00112        _tmp1_ = g_strdup (_tmp0_);
00113        _g_free0 (self->priv->_name);
00114        self->priv->_name = _tmp1_;
00115        g_object_notify ((GObject *) self, "name");
00116 }
00117 
00118 
00119 GIcon* unity_category_get_icon_hint (UnityCategory* self) {
00120        GIcon* result;
00121        GIcon* _tmp0_;
00122        g_return_val_if_fail (self != NULL, NULL);
00123        _tmp0_ = self->priv->_icon_hint;
00124        result = _tmp0_;
00125        return result;
00126 }
00127 
00128 
00129 static gpointer _g_object_ref0 (gpointer self) {
00130        return self ? g_object_ref (self) : NULL;
00131 }
00132 
00133 
00134 static void unity_category_set_icon_hint (UnityCategory* self, GIcon* value) {
00135        GIcon* _tmp0_;
00136        GIcon* _tmp1_;
00137        g_return_if_fail (self != NULL);
00138        _tmp0_ = value;
00139        _tmp1_ = _g_object_ref0 (_tmp0_);
00140        _g_object_unref0 (self->priv->_icon_hint);
00141        self->priv->_icon_hint = _tmp1_;
00142        g_object_notify ((GObject *) self, "icon-hint");
00143 }
00144 
00145 
00146 UnityCategoryRenderer unity_category_get_default_renderer (UnityCategory* self) {
00147        UnityCategoryRenderer result;
00148        UnityCategoryRenderer _tmp0_;
00149        g_return_val_if_fail (self != NULL, 0);
00150        _tmp0_ = self->priv->_default_renderer;
00151        result = _tmp0_;
00152        return result;
00153 }
00154 
00155 
00156 static void unity_category_set_default_renderer (UnityCategory* self, UnityCategoryRenderer value) {
00157        UnityCategoryRenderer _tmp0_;
00158        g_return_if_fail (self != NULL);
00159        _tmp0_ = value;
00160        self->priv->_default_renderer = _tmp0_;
00161        g_object_notify ((GObject *) self, "default-renderer");
00162 }
00163 
00164 
00165 const gchar* unity_category_get_renderer (UnityCategory* self) {
00166        const gchar* result;
00167        UnityCategoryRenderer _tmp0_;
00168        g_return_val_if_fail (self != NULL, NULL);
00169        _tmp0_ = self->priv->_default_renderer;
00170        switch (_tmp0_) {
00171               case UNITY_CATEGORY_RENDERER_VERTICAL_TILE:
00172               {
00173                      result = "tile-vertical";
00174                      return result;
00175               }
00176               case UNITY_CATEGORY_RENDERER_HORIZONTAL_TILE:
00177               {
00178                      result = "tile-horizontal";
00179                      return result;
00180               }
00181               case UNITY_CATEGORY_RENDERER_LIST_TILE:
00182               {
00183                      result = "tile-list";
00184                      return result;
00185               }
00186               case UNITY_CATEGORY_RENDERER_FLOW:
00187               {
00188                      result = "flow";
00189                      return result;
00190               }
00191               default:
00192               {
00193                      result = "tile-vertical";
00194                      return result;
00195               }
00196        }
00197 }
00198 
00199 
00200 GHashTable* unity_category_get_hints (UnityCategory* self) {
00201        GHashTable* result;
00202        GHashTable* _tmp0_;
00203        g_return_val_if_fail (self != NULL, NULL);
00204        _tmp0_ = self->priv->_hints;
00205        result = _tmp0_;
00206        return result;
00207 }
00208 
00209 
00210 static gpointer _g_hash_table_ref0 (gpointer self) {
00211        return self ? g_hash_table_ref (self) : NULL;
00212 }
00213 
00214 
00215 void unity_category_set_hints (UnityCategory* self, GHashTable* value) {
00216        GHashTable* _tmp0_;
00217        GHashTable* _tmp1_;
00218        g_return_if_fail (self != NULL);
00219        _tmp0_ = value;
00220        _tmp1_ = _g_hash_table_ref0 (_tmp0_);
00221        _g_hash_table_unref0 (self->priv->_hints);
00222        self->priv->_hints = _tmp1_;
00223        g_object_notify ((GObject *) self, "hints");
00224 }
00225 
00226 
00227 static void _g_free0_ (gpointer var) {
00228        var = (g_free (var), NULL);
00229 }
00230 
00231 
00232 static void _g_variant_unref0_ (gpointer var) {
00233        (var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
00234 }
00235 
00236 
00237 static GObject * unity_category_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
00238        GObject * obj;
00239        GObjectClass * parent_class;
00240        UnityCategory * self;
00241        GHashTable* _tmp0_;
00242        GHashTable* _tmp1_;
00243        parent_class = G_OBJECT_CLASS (unity_category_parent_class);
00244        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
00245        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_TYPE_CATEGORY, UnityCategory);
00246        _tmp0_ = g_hash_table_new_full (NULL, NULL, _g_free0_, _g_variant_unref0_);
00247        _tmp1_ = _tmp0_;
00248        unity_category_set_hints (self, _tmp1_);
00249        _g_hash_table_unref0 (_tmp1_);
00250        return obj;
00251 }
00252 
00253 
00254 static void unity_category_class_init (UnityCategoryClass * klass) {
00255        unity_category_parent_class = g_type_class_peek_parent (klass);
00256        g_type_class_add_private (klass, sizeof (UnityCategoryPrivate));
00257        G_OBJECT_CLASS (klass)->get_property = _vala_unity_category_get_property;
00258        G_OBJECT_CLASS (klass)->set_property = _vala_unity_category_set_property;
00259        G_OBJECT_CLASS (klass)->constructor = unity_category_constructor;
00260        G_OBJECT_CLASS (klass)->finalize = unity_category_finalize;
00261        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_CATEGORY_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00262        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_CATEGORY_ICON_HINT, g_param_spec_object ("icon-hint", "icon-hint", "icon-hint", G_TYPE_ICON, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00263        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_CATEGORY_DEFAULT_RENDERER, g_param_spec_enum ("default-renderer", "default-renderer", "default-renderer", UNITY_TYPE_CATEGORY_RENDERER, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
00264        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_CATEGORY_RENDERER, g_param_spec_string ("renderer", "renderer", "renderer", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
00265        g_object_class_install_property (G_OBJECT_CLASS (klass), UNITY_CATEGORY_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));
00266 }
00267 
00268 
00269 static void unity_category_instance_init (UnityCategory * self) {
00270        self->priv = UNITY_CATEGORY_GET_PRIVATE (self);
00271 }
00272 
00273 
00274 static void unity_category_finalize (GObject* obj) {
00275        UnityCategory * self;
00276        self = G_TYPE_CHECK_INSTANCE_CAST (obj, UNITY_TYPE_CATEGORY, UnityCategory);
00277        _g_free0 (self->priv->_name);
00278        _g_object_unref0 (self->priv->_icon_hint);
00279        _g_hash_table_unref0 (self->priv->_hints);
00280        G_OBJECT_CLASS (unity_category_parent_class)->finalize (obj);
00281 }
00282 
00283 
00284 GType unity_category_get_type (void) {
00285        static volatile gsize unity_category_type_id__volatile = 0;
00286        if (g_once_init_enter (&unity_category_type_id__volatile)) {
00287               static const GTypeInfo g_define_type_info = { sizeof (UnityCategoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) unity_category_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UnityCategory), 0, (GInstanceInitFunc) unity_category_instance_init, NULL };
00288               GType unity_category_type_id;
00289               unity_category_type_id = g_type_register_static (G_TYPE_OBJECT, "UnityCategory", &g_define_type_info, 0);
00290               g_once_init_leave (&unity_category_type_id__volatile, unity_category_type_id);
00291        }
00292        return unity_category_type_id__volatile;
00293 }
00294 
00295 
00296 static void _vala_unity_category_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
00297        UnityCategory * self;
00298        self = G_TYPE_CHECK_INSTANCE_CAST (object, UNITY_TYPE_CATEGORY, UnityCategory);
00299        switch (property_id) {
00300               case UNITY_CATEGORY_NAME:
00301               g_value_set_string (value, unity_category_get_name (self));
00302               break;
00303               case UNITY_CATEGORY_ICON_HINT:
00304               g_value_set_object (value, unity_category_get_icon_hint (self));
00305               break;
00306               case UNITY_CATEGORY_DEFAULT_RENDERER:
00307               g_value_set_enum (value, unity_category_get_default_renderer (self));
00308               break;
00309               case UNITY_CATEGORY_RENDERER:
00310               g_value_set_string (value, unity_category_get_renderer (self));
00311               break;
00312               case UNITY_CATEGORY_HINTS:
00313               g_value_set_boxed (value, unity_category_get_hints (self));
00314               break;
00315               default:
00316               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00317               break;
00318        }
00319 }
00320 
00321 
00322 static void _vala_unity_category_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
00323        UnityCategory * self;
00324        self = G_TYPE_CHECK_INSTANCE_CAST (object, UNITY_TYPE_CATEGORY, UnityCategory);
00325        switch (property_id) {
00326               case UNITY_CATEGORY_NAME:
00327               unity_category_set_name (self, g_value_get_string (value));
00328               break;
00329               case UNITY_CATEGORY_ICON_HINT:
00330               unity_category_set_icon_hint (self, g_value_get_object (value));
00331               break;
00332               case UNITY_CATEGORY_DEFAULT_RENDERER:
00333               unity_category_set_default_renderer (self, g_value_get_enum (value));
00334               break;
00335               case UNITY_CATEGORY_HINTS:
00336               unity_category_set_hints (self, g_value_get_boxed (value));
00337               break;
00338               default:
00339               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
00340               break;
00341        }
00342 }
00343 
00344 
00345