Skip to content
Snippets Groups Projects
Commit 816cc31c authored by Adrien Plazas's avatar Adrien Plazas Committed by Guido Gunther
Browse files

Add HdyEnumValueObject

This will be used in the next commit to use enumeration values in a
GListModel.
parent a4c60847
No related branches found
No related tags found
1 merge request!176Add many rows widgets
......@@ -42,6 +42,7 @@
<xi:include href="xml/hdy-dialer.xml"/>
<xi:include href="xml/hdy-dialer-button.xml"/>
<xi:include href="xml/hdy-dialer-cycle-button.xml"/>
<xi:include href="xml/hdy-enum-value-object.xml"/>
<xi:include href="xml/hdy-expander-row.xml"/>
<xi:include href="xml/hdy-header-group.xml"/>
<xi:include href="xml/hdy-leaflet.xml"/>
......
......@@ -31,6 +31,7 @@ G_BEGIN_DECLS
#include "hdy-dialer-button.h"
#include "hdy-dialer-cycle-button.h"
#include "hdy-dialer.h"
#include "hdy-enum-value-object.h"
#include "hdy-expander-row.h"
#include "hdy-fold.h"
#include "hdy-header-group.h"
......
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#include "hdy-enum-value-object.h"
/**
* SECTION:hdy-enum-value-object
* @short_description: An object representing a #GEnumValue.
* @Title: HdyEnumValueObject
*
* The #HdyEnumValueObject object represents a #GEnumValue, allowing it to be
* used with #GListModel.
*/
struct _HdyEnumValueObject
{
GObject parent_instance;
GEnumValue enum_value;
};
G_DEFINE_TYPE (HdyEnumValueObject, hdy_enum_value_object, G_TYPE_OBJECT)
HdyEnumValueObject *
hdy_enum_value_object_new (GEnumValue *enum_value)
{
HdyEnumValueObject *self = g_object_new (HDY_TYPE_ENUM_VALUE_OBJECT, NULL);
self->enum_value = *enum_value;
return self;
}
static void
hdy_enum_value_object_class_init (HdyEnumValueObjectClass *klass)
{
}
static void
hdy_enum_value_object_init (HdyEnumValueObject *self)
{
}
gint
hdy_enum_value_object_get_value (HdyEnumValueObject *self)
{
g_return_val_if_fail (HDY_IS_ENUM_VALUE_OBJECT (self), 0);
return self->enum_value.value;
}
const gchar *
hdy_enum_value_object_get_name (HdyEnumValueObject *self)
{
g_return_val_if_fail (HDY_IS_ENUM_VALUE_OBJECT (self), NULL);
return self->enum_value.value_name;
}
const gchar *
hdy_enum_value_object_get_nick (HdyEnumValueObject *self)
{
g_return_val_if_fail (HDY_IS_ENUM_VALUE_OBJECT (self), NULL);
return self->enum_value.value_nick;
}
/*
* Copyright (C) 2018 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#if !defined(_HANDY_INSIDE) && !defined(HANDY_COMPILATION)
#error "Only <handy.h> can be included directly."
#endif
#include <gio/gio.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define HDY_TYPE_ENUM_VALUE_OBJECT (hdy_enum_value_object_get_type())
G_DECLARE_FINAL_TYPE (HdyEnumValueObject, hdy_enum_value_object, HDY, ENUM_VALUE_OBJECT, GObject)
HdyEnumValueObject *hdy_enum_value_object_new (GEnumValue *enum_value);
gint hdy_enum_value_object_get_value (HdyEnumValueObject *self);
const gchar *hdy_enum_value_object_get_name (HdyEnumValueObject *self);
const gchar *hdy_enum_value_object_get_nick (HdyEnumValueObject *self);
G_END_DECLS
......@@ -54,6 +54,7 @@ src_headers = [
'hdy-dialer-button.h',
'hdy-dialer-cycle-button.h',
'hdy-dialer.h',
'hdy-enum-value-object.h',
'hdy-expander-row.h',
'hdy-fold.h',
'hdy-header-group.h',
......@@ -83,6 +84,7 @@ src_sources = [
'hdy-dialer-button.c',
'hdy-dialer-cycle-button.c',
'hdy-dialer.c',
'hdy-enum-value-object.c',
'hdy-expander-row.c',
'hdy-fold.c',
'hdy-header-group.c',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment