grim/gobjects-101
Clone
Summary
Browse
Changes
Graph
Move to macros add a subclass and instance method
draft
2021-06-23, Gary Kramlich
e21f4ddf7902
Move to macros add a subclass and instance method
#include
<stdio.h>
#include
"mountain_bike.h"
struct
_GobjectsMountainBike
{
GobjectsBicycle
parent
;
};
G_DEFINE_TYPE
(
GobjectsMountainBike
,
gobjects_mountain_bike
,
GOBJECTS_TYPE_BICYCLE
)
/*******************************************************************************
* Overrides
******************************************************************************/
static
void
gobjects_mountain_bike_ring_bell
(
GobjectsBicycle
*
bicycle
)
{
printf
(
"Mountain bikes don't have bells...
\n
"
);
}
/*******************************************************************************
* GObject Implementation
******************************************************************************/
static
void
gobjects_mountain_bike_init
(
GobjectsMountainBike
*
mountain_bike
)
{
}
static
void
gobjects_mountain_bike_class_init
(
GobjectsMountainBikeClass
*
klass
)
{
GobjectsBicycleClass
*
bicycle_class
=
GOBJECTS_BICYCLE_CLASS
(
klass
);
bicycle_class
->
ring_bell
=
gobjects_mountain_bike_ring_bell
;
}
/*******************************************************************************
* Public API
******************************************************************************/
GobjectsBicycle
*
gobjects_mountain_bike_new
(
void
)
{
return
g_object_new
(
GOBJECTS_TYPE_MOUNTAIN_BIKE
,
NULL
);
}