LCOV - code coverage report
Current view: top level - gui/source - gui_type_resource.c (source / functions) Coverage Total Hit
Test: crystal-facet-uml_v1.63.2_covts Lines: 0.0 % 55 0
Test Date: 2025-05-01 10:10:14 Functions: 0.0 % 8 0

            Line data    Source code
       1              : /* File: gui_type_resource.c; Copyright and License: see below */
       2              : 
       3              : #include "gui_type_resource.h"
       4              : #include "u8/u8_trace.h"
       5              : #include <assert.h>
       6              : 
       7            0 : G_DEFINE_TYPE (GuiTypeResource, gui_type_resource, G_TYPE_OBJECT)
       8              : 
       9              : typedef enum
      10              : {
      11              :   GUI_TYPE_RESOURCE_PROP_NAME = 1,
      12              :   GUI_TYPE_RESOURCE_PROP_ICON,
      13              :   GUI_TYPE_RESOURCE_PROP_MAX
      14              : } GuiTypeResourceProperty;
      15              : 
      16              : static GParamSpec *gui_type_resource_properties[GUI_TYPE_RESOURCE_PROP_MAX] = { NULL, };
      17              : 
      18              : static void
      19            0 : gui_type_resource_set_property( GObject      *object,
      20              :                                 guint         property_id,
      21              :                                 const GValue *value,
      22              :                                 GParamSpec   *pspec )
      23              : {
      24            0 :     U8_TRACE_BEGIN();
      25            0 :     GuiTypeResource *self = GUI_TYPE_RESOURCE (object);
      26              : 
      27            0 :     switch ((GuiTypeResourceProperty) property_id)
      28              :     {
      29            0 :         case GUI_TYPE_RESOURCE_PROP_NAME:
      30              :         {
      31              :             /* this object is read only */
      32            0 :             self->name = g_value_get_string( value );
      33              :         }
      34            0 :         break;
      35              : 
      36            0 :         case GUI_TYPE_RESOURCE_PROP_ICON:
      37              :         {
      38              :             /* this object is read only */
      39            0 :             if ( self->icon != NULL )
      40              :             {
      41            0 :                 g_object_unref( self->icon );
      42              :             }
      43            0 :             self->icon = g_value_get_object( value );
      44              :         }
      45            0 :         break;
      46              : 
      47            0 :         default:
      48              :         {
      49              :             /* We don't have any other property... */
      50            0 :             G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, pspec );
      51              :         }
      52            0 :         break;
      53              :     }
      54              : 
      55            0 :     U8_TRACE_END();
      56            0 : }
      57              : 
      58              : static void
      59            0 : gui_type_resource_get_property( GObject    *object,
      60              :                                 guint       property_id,
      61              :                                 GValue     *value,
      62              :                                 GParamSpec *pspec )
      63              : {
      64            0 :     U8_TRACE_BEGIN();
      65            0 :     GuiTypeResource *self = GUI_TYPE_RESOURCE (object);
      66              : 
      67            0 :     switch ((GuiTypeResourceProperty) property_id)
      68              :     {
      69            0 :         case GUI_TYPE_RESOURCE_PROP_NAME:
      70              :         {
      71            0 :             g_value_set_static_string( value, self->name );
      72              :         }
      73            0 :         break;
      74              : 
      75            0 :         case GUI_TYPE_RESOURCE_PROP_ICON:
      76              :         {
      77            0 :             g_value_set_object( value, self->icon );
      78              :         }
      79            0 :         break;
      80              : 
      81            0 :         default:
      82              :         {
      83              :             /* We don't have any other property... */
      84            0 :             G_OBJECT_WARN_INVALID_PROPERTY_ID( object, property_id, pspec );
      85              :         }
      86            0 :         break;
      87              :     }
      88              : 
      89            0 :     U8_TRACE_END();
      90            0 : }
      91              : 
      92              : static void
      93            0 : gui_type_resource_class_init( GuiTypeResourceClass *klass )
      94              : {
      95            0 :     U8_TRACE_BEGIN();
      96            0 :     GObjectClass *object_class = G_OBJECT_CLASS ( klass );
      97              : 
      98            0 :     object_class->set_property = gui_type_resource_set_property;
      99            0 :     object_class->get_property = gui_type_resource_get_property;
     100              : 
     101            0 :     gui_type_resource_properties[GUI_TYPE_RESOURCE_PROP_NAME] =
     102            0 :     g_param_spec_string( "name",
     103              :                          "Name",
     104              :                          "Name of the represented element type.",
     105              :                          NULL  /* default value */,
     106              :                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
     107              :                        );
     108              : 
     109            0 :     gui_type_resource_properties[GUI_TYPE_RESOURCE_PROP_ICON] =
     110            0 :     g_param_spec_object( "icon",
     111              :                          "Icon",
     112              :                          "Icon of the represented element type.",
     113              :                          gdk_texture_get_type(),
     114              :                          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE
     115              :                        );
     116              : 
     117            0 :     g_object_class_install_properties( object_class,
     118              :                                        GUI_TYPE_RESOURCE_PROP_MAX,
     119              :                                        gui_type_resource_properties
     120              :                                      );
     121            0 :     U8_TRACE_END();
     122            0 : }
     123              : 
     124              : static void
     125            0 : gui_type_resource_init (GuiTypeResource *self)
     126              : {
     127            0 :     data_type_init_void( &((*self).type_id) );
     128            0 :     (*self).name = NULL;
     129            0 :     (*self).icon = NULL;
     130            0 : }
     131              : 
     132            0 : gboolean gui_type_resource_equal( const gui_type_resource_t *this_, const gui_type_resource_t *that )
     133              : {
     134            0 :     U8_TRACE_BEGIN();
     135            0 :     const gboolean result = ( data_type_equals( &((*this_).type_id), &((*that).type_id) ) );
     136            0 :     U8_TRACE_END();
     137            0 :     return result;
     138              : }
     139              : 
     140              : 
     141              : /*
     142              : Copyright 2024-2025 Andreas Warnke
     143              : 
     144              : Licensed under the Apache License, Version 2.0 (the "License");
     145              : you may not use this file except in compliance with the License.
     146              : You may obtain a copy of the License at
     147              : 
     148              :     http://www.apache.org/licenses/LICENSE-2.0
     149              : 
     150              : Unless required by applicable law or agreed to in writing, software
     151              : distributed under the License is distributed on an "AS IS" BASIS,
     152              : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     153              : See the License for the specific language governing permissions and
     154              : limitations under the License.
     155              : */
        

Generated by: LCOV version 2.0-1