Commit 662f619b authored by Daiki Ueno's avatar Daiki Ueno

Rewrite.

parent 9e619193
......@@ -40,13 +40,8 @@ and an XKB-based layout engine:
10: /* Apply the layout to the keyboard. */
11: eek_keyboard_set_layout (keyboard, layout);
12:
13: clutter_group_add (CLUTTER_GROUP(stage), CLUTTER_ACTOR(keyboard));
To use GTK+-based keyboard elements instead of Clutter, simply replace
line 8 and 13 with:
8: keyboard = eek_gtk_keyboard_new ();
13: gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(keyboard));
13: clutter_group_add (CLUTTER_GROUP(stage),
14: eek_clutter_keyboard_get_actor (EEK_CLUTTER_KEYBOARD(keyboard)));
Footnotes:
[1] http://en.wikipedia.org/wiki/Builder_pattern
......
......@@ -56,6 +56,5 @@ docs/reference/Makefile
docs/reference/eek/Makefile
eek/eek.pc
eek/eek-clutter.pc
eek/eek-xkb.pc
eek/eek-gtk.pc])
eek/eek-xkb.pc])
AC_OUTPUT
......@@ -77,8 +77,7 @@ EXTRA_HFILES=
# Header files to ignore when scanning. Use base file name, no paths
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h
IGNORE_HFILES= eek-private.h \
eek-clutter-private.h \
eek-keysyms.h \
eek-keysym.h \
$(NULL)
# Images to copy into HTML directory.
......@@ -103,7 +102,6 @@ GTKDOC_CFLAGS = $(GOBJECT2_CFLAGS)
GTKDOC_LIBS = $(top_srcdir)/eek/libeek.la \
$(top_srcdir)/eek/libeek-clutter.la \
$(top_srcdir)/eek/libeek-xkb.la \
$(top_srcdir)/eek/libeek-gtk.la \
$(GOBJECT2_LIBS) \
$(CLUTTER_LIBS) \
$(XKB_LIBS) \
......
......@@ -14,6 +14,8 @@
<chapter>
<title>Base classes and interfaces</title>
<xi:include href="xml/eek-element.xml"/>
<xi:include href="xml/eek-container.xml"/>
<xi:include href="xml/eek-keyboard.xml"/>
<xi:include href="xml/eek-section.xml"/>
<xi:include href="xml/eek-key.xml"/>
......@@ -30,12 +32,6 @@
<title>XKB layout engine</title>
<xi:include href="xml/eek-xkb-layout.xml"/>
</chapter>
<chapter>
<title>GTK keyboard elements</title>
<xi:include href="xml/eek-gtk-keyboard.xml"/>
<xi:include href="xml/eek-gtk-section.xml"/>
<xi:include href="xml/eek-gtk-key.xml"/>
</chapter>
<chapter id="object-tree">
<title>Object Hierarchy</title>
<xi:include href="xml/tree_index.sgml"/>
......
......@@ -16,25 +16,21 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
lib_LTLIBRARIES = libeek.la libeek-clutter.la libeek-xkb.la libeek-gtk.la
lib_LTLIBRARIES = libeek.la libeek-clutter.la libeek-xkb.la
libeek_la_SOURCES = \
eek-layout.c \
eek-layout.h \
eek-element.c \
eek-element.h \
eek-container.c \
eek-container.h \
eek-keyboard.c \
eek-keyboard.h \
eek-section.c \
eek-section.h \
eek-key.c \
eek-key.h \
eek-simple-keyboard.c \
eek-simple-keyboard.h \
eek-simple-section.c \
eek-simple-section.h \
eek-simple-key.c \
eek-simple-key.h \
eek-private.c \
eek-private.h \
eek-types.h \
eek-types.c \
eek-keysym.h \
......@@ -54,8 +50,8 @@ libeek_clutter_la_SOURCES = \
eek-clutter-section.h \
eek-clutter-key.c \
eek-clutter-key.h \
eek-clutter-private.c \
eek-clutter-private.h \
eek-clutter-key-actor.c \
eek-clutter-key-actor.h \
eek-clutter.h \
$(NULL)
......@@ -70,23 +66,10 @@ libeek_xkb_la_SOURCES = \
libeek_xkb_la_CFLAGS = $(GTK2_CFLAGS) $(XKB_CFLAGS)
libeek_xkb_la_LIBADD = libeek.la $(GTK2_LIBS) $(XKB_LIBS)
libeek_gtk_la_SOURCES = \
eek-gtk-keyboard.c \
eek-gtk-keyboard.h \
eek-gtk-section.c \
eek-gtk-section.h \
eek-gtk-key.c \
eek-gtk-key.h \
eek-gtk-private.c \
eek-gtk-private.h \
eek-gtk.h \
$(NULL)
libeek_gtk_la_CFLAGS = $(GTK2_CFLAGS)
libeek_gtk_la_LIBADD = libeek.la $(GTK2_LIBS)
eekdir = $(includedir)/eek-$(EEK_API_VERSION)/eek
eek_HEADERS = \
$(top_srcdir)/eek/eek-element.h \
$(top_srcdir)/eek/eek-container.h \
$(top_srcdir)/eek/eek-keyboard.h \
$(top_srcdir)/eek/eek-section.h \
$(top_srcdir)/eek/eek-key.h \
......@@ -111,7 +94,7 @@ eek-keyname-keysym-labels.h: keyname-keysym-labels.txt
$(PYTHON) ./gen-keysym-labels.py keyname_keysym_labels < $< > $@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = eek.pc eek-clutter.pc eek-xkb.pc eek-gtk.pc
pkgconfig_DATA = eek.pc eek-clutter.pc eek-xkb.pc
DISTCLEANFILES = \
eek-special-keysym-labels.h \
......
......@@ -17,39 +17,44 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_SIMPLE_KEY_H
#define EEK_SIMPLE_KEY_H 1
#ifndef EEK_CLUTTER_KEY_ACTOR_H
#define EEK_CLUTTER_KEY_ACTOR_H 1
#include <clutter/clutter.h>
#include "eek-key.h"
G_BEGIN_DECLS
#define EEK_TYPE_SIMPLE_KEY (eek_simple_key_get_type())
#define EEK_SIMPLE_KEY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_SIMPLE_KEY, EekSimpleKey))
#define EEK_SIMPLE_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_SIMPLE_KEY, EekSimpleKeyClass))
#define EEK_IS_SIMPLE_KEY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_SIMPLE_KEY))
#define EEK_IS_SIMPLE_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_SIMPLE_KEY))
#define EEK_SIMPLE_KEY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_SIMPLE_KEY, EekSimpleKeyClass))
typedef struct _EekSimpleKey EekSimpleKey;
typedef struct _EekSimpleKeyClass EekSimpleKeyClass;
typedef struct _EekSimpleKeyPrivate EekSimpleKeyPrivate;
struct _EekSimpleKey
#define EEK_TYPE_CLUTTER_KEY_ACTOR (eek_clutter_key_actor_get_type())
#define EEK_CLUTTER_KEY_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActor))
#define EEK_CLUTTER_KEY_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActorClass))
#define EEK_IS_CLUTTER_KEY_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR))
#define EEK_IS_CLUTTER_KEY_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_KEY_ACTOR))
#define EEK_CLUTTER_KEY_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_KEY_ACTOR, EekClutterKeyActorClass))
typedef struct _EekClutterKeyActor EekClutterKeyActor;
typedef struct _EekClutterKeyActorClass EekClutterKeyActorClass;
typedef struct _EekClutterKeyActorPrivate EekClutterKeyActorPrivate;
struct _EekClutterKeyActor
{
/*< private >*/
GInitiallyUnowned parent;
ClutterGroup parent;
/*< private >*/
EekSimpleKeyPrivate *priv;
EekClutterKeyActorPrivate *priv;
};
struct _EekSimpleKeyClass
struct _EekClutterKeyActorClass
{
/*< private >*/
GInitiallyUnownedClass parent_class;
ClutterGroupClass parent_class;
/* outline pointer -> ClutterTexture */
GHashTable *outline_textures;
};
GType eek_simple_key_get_type (void) G_GNUC_CONST;
GType eek_clutter_key_actor_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_actor_new (EekKey *key);
G_END_DECLS
#endif /* EEK_SIMPLE_KEY_H */
#endif /* EEK_CLUTTER_KEY_ACTOR_H */
This diff is collapsed.
......@@ -38,7 +38,7 @@ typedef struct _EekClutterKeyPrivate EekClutterKeyPrivate;
struct _EekClutterKey
{
/*< private >*/
ClutterGroup parent;
EekKey parent;
/*< private >*/
EekClutterKeyPrivate *priv;
......@@ -47,14 +47,11 @@ struct _EekClutterKey
struct _EekClutterKeyClass
{
/*< private >*/
ClutterGroupClass parent_class;
EekKeyClass parent_class;
};
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_create_texture (EekClutterKey *key);
void eek_clutter_key_set_texture (EekClutterKey *key,
ClutterActor *texture);
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_get_actor (EekClutterKey *key);
G_END_DECLS
#endif /* EEK_CLUTTER_KEY_H */
This diff is collapsed.
......@@ -25,20 +25,20 @@
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_KEYBOARD (eek_clutter_keyboard_get_type())
#define EEK_CLUTTER_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_KEYBOARD, EekKeyboard))
#define EEK_CLUTTER_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_KEYBOARD, EekClutterKeyboard))
#define EEK_CLUTTER_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_KEYBOARD, EekClutterKeyboardClass))
#define EEK_IS_CLUTTER_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_KEYBOARD))
#define EEK_IS_CLUTTER_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_KEYBOARD))
#define EEK_CLUTTER_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_KEYBOARD, EekClutterKeyboardClass))
typedef struct _EekClutterKeyboard EekClutterKeyboard;
typedef struct _EekClutterKeyboardClass EekClutterKeyboardClass;
typedef struct _EekClutterKeyboard EekClutterKeyboard;
typedef struct _EekClutterKeyboardClass EekClutterKeyboardClass;
typedef struct _EekClutterKeyboardPrivate EekClutterKeyboardPrivate;
struct _EekClutterKeyboard
{
/*< private >*/
ClutterGroup parent;
EekKeyboard parent;
EekClutterKeyboardPrivate *priv;
};
......@@ -46,13 +46,13 @@ struct _EekClutterKeyboard
struct _EekClutterKeyboardClass
{
/*< private >*/
ClutterGroupClass parent_class;
EekKeyboardClass parent_class;
};
GType eek_clutter_keyboard_get_type (void) G_GNUC_CONST;
EekKeyboard *eek_clutter_keyboard_new (gfloat width,
gfloat height);
GType eek_clutter_keyboard_get_type (void) G_GNUC_CONST;
EekKeyboard *eek_clutter_keyboard_new (gfloat width,
gfloat height);
ClutterActor *eek_clutter_keyboard_get_actor (EekClutterKeyboard *keyboard);
G_END_DECLS
#endif /* EEK_CLUTTER_KEYBOARD_H */
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-clutter-private.h"
void
eek_clutter_callback (ClutterActor *actor, gpointer user_data)
{
EekClutterCallbackData *data = user_data;
data->func (actor, data->user_data);
}
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_CLUTTER_PRIVATE_H
#define EEK_CLUTTER_PRIVATE_H 1
#include <glib/gtypes.h>
#include <clutter/clutter.h>
struct _EekClutterCallbackData {
GFunc func;
gpointer user_data;
};
typedef struct _EekClutterCallbackData EekClutterCallbackData;
void eek_clutter_callback (ClutterActor *actor, gpointer user_data);
#endif /* EEK_CLUTTER_PRIVATE_H */
This diff is collapsed.
......@@ -38,19 +38,19 @@ typedef struct _EekClutterSectionPrivate EekClutterSectionPrivate;
struct _EekClutterSection
{
/*< private >*/
ClutterGroup parent;
EekSection parent;
/*< private >*/
EekClutterSectionPrivate *priv;
};
struct _EekClutterSectionClass
{
/*< private >*/
ClutterGroupClass parent_class;
EekSectionClass parent_class;
};
GType eek_clutter_section_get_type (void) G_GNUC_CONST;
GType eek_clutter_section_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_section_get_actor (EekClutterSection *section);
G_END_DECLS
#endif /* EEK_CLUTTER_SECTION_H */
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/**
* SECTION:eek-container
* @short_description: Base class of a keyboard container
*
* The #EekContainerClass class represents a keyboard container, which
* shall be used to implement #EekKeyboard and #EekSection.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-container.h"
enum {
CHILD_ADDED,
CHILD_REMOVED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_ABSTRACT_TYPE (EekContainer, eek_container, EEK_TYPE_ELEMENT);
#define EEK_CONTAINER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CONTAINER, EekContainerPrivate))
struct _EekContainerPrivate
{
GSList *children;
};
static void
eek_container_real_add_child (EekContainer *self,
EekElement *child)
{
EekContainerPrivate *priv = EEK_CONTAINER_GET_PRIVATE(self);
g_return_if_fail (EEK_IS_ELEMENT(child));
g_object_ref (child);
priv->children = g_slist_prepend (priv->children, child);
}
static void
eek_container_real_remove_child (EekContainer *self,
EekElement *child)
{
EekContainerPrivate *priv = EEK_CONTAINER_GET_PRIVATE(self);
GSList *head;
g_return_if_fail (EEK_IS_ELEMENT(child));
head = g_slist_find (priv->children, child);
g_return_if_fail (head);
g_object_unref (child);
priv->children = g_slist_remove_link (priv->children, head);
}
static void
eek_container_real_foreach_child (EekContainer *self,
EekCallback callback,
gpointer user_data)
{
EekContainerPrivate *priv = EEK_CONTAINER_GET_PRIVATE(self);
GSList *head;
for (head = priv->children; head; head = g_slist_next (head))
(*callback) (EEK_ELEMENT(head->data), user_data);
}
static void
eek_container_finalize (GObject *object)
{
EekContainerPrivate *priv = EEK_CONTAINER_GET_PRIVATE(object);
GSList *head;
for (head = priv->children; head; head = g_slist_next (head))
g_object_unref (head->data);
g_slist_free (priv->children);
G_OBJECT_CLASS(eek_container_parent_class)->finalize (object);
}
static void
eek_container_class_init (EekContainerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class,
sizeof (EekContainerPrivate));
klass->add_child = eek_container_real_add_child;
klass->remove_child = eek_container_real_remove_child;
klass->foreach_child = eek_container_real_foreach_child;
gobject_class->finalize = eek_container_finalize;
signals[CHILD_ADDED] =
g_signal_new ("child-added",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(EekContainerClass, child_added),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
EEK_TYPE_ELEMENT);
signals[CHILD_REMOVED] =
g_signal_new ("child-removed",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(EekContainerClass, child_removed),
NULL,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
EEK_TYPE_ELEMENT);
}
static void
eek_container_init (EekContainer *self)
{
EekContainerPrivate *priv;
priv = self->priv = EEK_CONTAINER_GET_PRIVATE(self);
priv->children = NULL;
}
void
eek_container_foreach_child (EekContainer *container,
EekCallback callback,
gpointer user_data)
{
g_return_if_fail (EEK_IS_CONTAINER(container));
EEK_CONTAINER_GET_CLASS(container)->foreach_child (container,
callback,
user_data);
}
......@@ -17,40 +17,63 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_SIMPLE_SECTION_H
#define EEK_SIMPLE_SECTION_H 1
#ifndef EEK_CONTAINER_H
#define EEK_CONTAINER_H 1
#include "eek-simple-key.h"
#include "eek-section.h"
#include "eek-element.h"
G_BEGIN_DECLS
#define EEK_TYPE_SIMPLE_SECTION (eek_simple_section_get_type())
#define EEK_SIMPLE_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_SIMPLE_SECTION, EekSimpleSection))
#define EEK_SIMPLE_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_SIMPLE_SECTION, EekSimpleSectionClass))
#define EEK_IS_SIMPLE_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_SIMPLE_SECTION))
#define EEK_IS_SIMPLE_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_SIMPLE_SECTION))
#define EEK_SIMPLE_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_SIMPLE_SECTION, EekSimpleSectionClass))
typedef struct _EekSimpleSection EekSimpleSection;
typedef struct _EekSimpleSectionClass EekSimpleSectionClass;
typedef struct _EekSimpleSectionPrivate EekSimpleSectionPrivate;
struct _EekSimpleSection
#define EEK_TYPE_CONTAINER (eek_container_get_type())
#define EEK_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CONTAINER, EekContainer))
#define EEK_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CONTAINER, EekContainerClass))
#define EEK_IS_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CONTAINER))
#define EEK_IS_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CONTAINER))
#define EEK_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CONTAINER, EekContainerClass))
typedef struct _EekContainer EekContainer;
typedef struct _EekContainerClass EekContainerClass;
typedef struct _EekContainerPrivate EekContainerPrivate;
typedef void (*EekCallback) (EekElement *element, gpointer user_data);
struct _EekContainer
{
/*< private >*/
GInitiallyUnowned parent;
EekElement parent;
/*< private >*/
EekSimpleSectionPrivate *priv;
/*< public >*/
EekContainerPrivate *priv;
};
struct _EekSimpleSectionClass
struct _EekContainerClass
{
/*< private >*/
GInitiallyUnownedClass parent_class;
EekElementClass parent_class;
void (* add_child) (EekContainer *self,
EekElement *element);
void (* remove_child) (EekContainer *self,
EekElement *element);
/*< public >*/
void (* foreach_child) (EekContainer *self,
EekCallback callback,
gpointer user_data);
/* signals */
void (* child_added) (EekContainer *self,
EekElement *element);
void (* child_removed) (EekContainer *self,
EekElement *element);
};
GType eek_simple_section_get_type (void) G_GNUC_CONST;
GType eek_container_get_type (void) G_GNUC_CONST;
void eek_container_foreach_child (EekContainer *self,
EekCallback callback,
gpointer user_data);
G_END_DECLS
#endif /* EEK_SIMPLE_SECTION_H */
#endif /* EEK_CONTAINER_H */
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/**
* SECTION:eek-element
* @short_description: Base class of a keyboard element
*
* The #EekElementClass class represents a keyboard element, which
* shall be used to implement #EekKeyboard, #EekSection, or #EekKey.
*/
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-element.h"
enum {
PROP_0,
PROP_NAME,
PROP_BOUNDS,
PROP_LAST
};
G_DEFINE_ABSTRACT_TYPE (EekElement, eek_element, G_TYPE_INITIALLY_UNOWNED);
#define EEK_ELEMENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_ELEMENT, EekElementPrivate))
struct _EekElementPrivate
{
gchar *name;
EekBounds bounds;
};
static void
eek_element_real_set_name (EekElement *self,
const gchar *name)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
priv->name = g_strdup (name);
g_object_notify (G_OBJECT(self), "name");
}
static G_CONST_RETURN gchar *
eek_element_real_get_name (EekElement *self)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
return priv->name;
}
static void
eek_element_real_set_bounds (EekElement *self,
EekBounds *bounds)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
priv->bounds = *bounds;
}
static void
eek_element_real_get_bounds (EekElement *self,
EekBounds *bounds)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
g_return_if_fail (bounds);
*bounds = priv->bounds;
g_object_notify (G_OBJECT(self), "bounds");
}
static void
eek_element_finalize (GObject *object)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(object);
g_free (priv->name);
}
static void
eek_element_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
g_return_if_fail (EEK_IS_ELEMENT(object));
switch (prop_id) {
case PROP_NAME:
eek_element_set_name (EEK_ELEMENT(object),
g_value_get_string (value));
break;
case PROP_BOUNDS:
eek_element_set_bounds (EEK_ELEMENT(object),
g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}