Commit 048fccd6 authored by Daiki Ueno's avatar Daiki Ueno

Use GEnumTypes.

parent 638d41e0
......@@ -88,10 +88,12 @@ libeek_marshalers_sources = \
BUILT_SOURCES = \
$(libeek_keysym_sources) \
$(libeek_enumtypes_sources) \
$(libeek_marshalers_sources)
libeek_la_SOURCES = \
$(libeek_sources) \
$(srcdir)/eek-enumtypes.c \
$(srcdir)/eek-marshalers.c
libeek_la_CFLAGS = $(GIO2_CFLAGS) $(PANGOCAIRO_CFLAGS) $(LIBCROCO_CFLAGS)
......@@ -175,6 +177,16 @@ eek-unicode-keysym-entries.h: unicode-keysym-entries.txt
eek-xkeysym-keysym-entries.h: xkeysym-keysym-entries.txt
$(PYTHON) ./gen-keysym-entries.py xkeysym_keysym_entries < $< > $@
eek-enumtypes.h: $(libeek_public_headers) eek-enumtypes.h.template
$(AM_V_GEN) $(GLIB_MKENUMS) --template eek-enumtypes.h.template \
$(libeek_public_headers) > eek-enumtypes.h.tmp && \
mv eek-enumtypes.h.tmp eek-enumtypes.h
eek-enumtypes.c: $(libeek_public_headers) eek-enumtypes.c.template
$(AM_V_GEN) $(GLIB_MKENUMS) --template eek-enumtypes.c.template \
$(libeek_public_headers) > eek-enumtypes.c.tmp && \
mv eek-enumtypes.c.tmp eek-enumtypes.c
# gen marshal
eek-marshalers.h: eek-marshalers.list
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_eek_marshal $(srcdir)/eek-marshalers.list --header --internal > $@.tmp && \
......@@ -207,6 +219,8 @@ EXTRA_DIST = \
special-keysym-entries.txt \
unicode-keysym-entries.txt \
xkeysym-keysym-entries.txt \
eek-enumtypes.h.template \
eek-enumtypes.c.template \
eek-marshalers.list
-include $(INTROSPECTION_MAKEFILE)
......
/*** BEGIN file-header ***/
#include "eek.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter (&g_define_type_id__volatile))
{
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_define_type_id =
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/*** END value-tail ***/
/*** BEGIN file-header ***/
#ifndef __EEK_ENUMTYPES_H__
#define __EEK_ENUMTYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __EEK_ENUMTYPES_H__ */
/*** END file-tail ***/
......@@ -36,6 +36,7 @@
#include "eek-key.h"
#include "eek-symbol.h"
#include "eek-serializable.h"
#include "eek-enumtypes.h"
enum {
PROP_0,
......@@ -274,7 +275,7 @@ eek_keyboard_set_property (GObject *object,
break;
case PROP_MODIFIER_BEHAVIOR:
eek_keyboard_set_modifier_behavior (EEK_KEYBOARD(object),
g_value_get_int (value));
g_value_get_enum (value));
break;
default:
g_object_set_property (object,
......@@ -297,8 +298,8 @@ eek_keyboard_get_property (GObject *object,
g_value_set_object (value, priv->layout);
break;
case PROP_MODIFIER_BEHAVIOR:
g_value_set_int (value,
eek_keyboard_get_modifier_behavior (EEK_KEYBOARD(object)));
g_value_set_enum (value,
eek_keyboard_get_modifier_behavior (EEK_KEYBOARD(object)));
break;
default:
g_object_get_property (object,
......@@ -465,11 +466,12 @@ eek_keyboard_class_init (EekKeyboardClass *klass)
*
* The modifier handling mode of #EekKeyboard.
*/
pspec = g_param_spec_int ("modifier-behavior",
"Modifier behavior",
"Modifier handling mode of the keyboard",
0, G_MAXINT, EEK_MODIFIER_BEHAVIOR_NONE,
G_PARAM_READWRITE);
pspec = g_param_spec_enum ("modifier-behavior",
"Modifier behavior",
"Modifier handling mode of the keyboard",
EEK_TYPE_MODIFIER_BEHAVIOR,
EEK_MODIFIER_BEHAVIOR_NONE,
G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_MODIFIER_BEHAVIOR,
pspec);
......
......@@ -31,6 +31,7 @@
#include "eek-symbol.h"
#include "eek-serializable.h"
#include "eek-enumtypes.h"
enum {
PROP_0,
......@@ -110,11 +111,11 @@ eek_symbol_set_property (GObject *object,
eek_symbol_set_label (EEK_SYMBOL(object), g_value_get_string (value));
break;
case PROP_CATEGORY:
eek_symbol_set_category (EEK_SYMBOL(object), g_value_get_uint (value));
eek_symbol_set_category (EEK_SYMBOL(object), g_value_get_enum (value));
break;
case PROP_MODIFIER_MASK:
eek_symbol_set_modifier_mask (EEK_SYMBOL(object),
g_value_get_uint (value));
g_value_get_flags (value));
break;
case PROP_ICON_NAME:
eek_symbol_set_icon_name (EEK_SYMBOL(object),
......@@ -142,11 +143,11 @@ eek_symbol_get_property (GObject *object,
g_value_set_string (value, eek_symbol_get_label (EEK_SYMBOL(object)));
break;
case PROP_CATEGORY:
g_value_set_uint (value, eek_symbol_get_category (EEK_SYMBOL(object)));
g_value_set_enum (value, eek_symbol_get_category (EEK_SYMBOL(object)));
break;
case PROP_MODIFIER_MASK:
g_value_set_uint (value,
eek_symbol_get_modifier_mask (EEK_SYMBOL(object)));
g_value_set_flags (value,
eek_symbol_get_modifier_mask (EEK_SYMBOL(object)));
break;
case PROP_ICON_NAME:
g_value_set_string (value,
......@@ -197,18 +198,20 @@ eek_symbol_class_init (EekSymbolClass *klass)
G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_LABEL, pspec);
pspec = g_param_spec_uint ("category",
pspec = g_param_spec_enum ("category",
"Category",
"Category of the symbol",
0, G_MAXUINT, 0,
EEK_TYPE_SYMBOL_CATEGORY,
EEK_SYMBOL_CATEGORY_UNKNOWN,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_CATEGORY, pspec);
pspec = g_param_spec_uint ("modifier-mask",
"Modifier mask",
"Modifier mask of the symbol",
0, G_MAXUINT, 0,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
pspec = g_param_spec_flags ("modifier-mask",
"Modifier mask",
"Modifier mask of the symbol",
EEK_TYPE_MODIFIER_TYPE,
0,
G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_MODIFIER_MASK, pspec);
pspec = g_param_spec_string ("icon-name",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment