Simplify codebase.

* Drop clutter support.
* Unify eek-xkb into eek-xkl.
* Generate vapi from gir instead of gi.
This commit is contained in:
Daiki Ueno
2012-03-16 16:21:02 +09:00
parent 06644945cf
commit 32a1d23c2a
55 changed files with 540 additions and 3970 deletions

View File

@ -19,13 +19,8 @@
lib_LTLIBRARIES = \
libeek.la \
libeek-gtk.la \
libeek-xkb.la \
libeek-xkl.la
if ENABLE_CLUTTER
lib_LTLIBRARIES += libeek-clutter.la
endif
libeek_public_headers = \
$(srcdir)/eek-layout.h \
$(srcdir)/eek-element.h \
@ -102,27 +97,6 @@ libeek_la_SOURCES = \
libeek_la_CFLAGS = -DEEK_COMPILATION=1 $(GIO2_CFLAGS) $(PANGOCAIRO_CFLAGS) $(LIBCROCO_CFLAGS)
libeek_la_LIBADD = $(GIO2_LIBS) $(PANGOCAIRO_LIBS) $(LIBCROCO_LIBS) -lm
if ENABLE_CLUTTER
libeek_clutter_public_headers = \
$(srcdir)/eek-clutter-keyboard.h \
$(srcdir)/eek-clutter.h
libeek_clutter_private_headers = \
$(srcdir)/eek-clutter-section.h \
$(srcdir)/eek-clutter-key.h \
$(srcdir)/eek-clutter-renderer.h
libeek_clutter_sources = \
$(srcdir)/eek-clutter-keyboard.c \
$(srcdir)/eek-clutter-section.c \
$(srcdir)/eek-clutter-key.c \
$(srcdir)/eek-clutter-renderer.c
libeek_clutter_la_SOURCES = $(libeek_clutter_sources)
libeek_clutter_la_CFLAGS = -DEEK_COMPILATION=1 $(CLUTTER_CFLAGS)
libeek_clutter_la_LIBADD = libeek.la $(CLUTTER_LIBS)
endif
libeek_gtk_public_headers = \
$(srcdir)/eek-gtk-keyboard.h \
$(srcdir)/eek-gtk.h
@ -136,42 +110,30 @@ libeek_gtk_la_SOURCES = $(libeek_gtk_sources)
libeek_gtk_la_CFLAGS = -DEEK_COMPILATION=1 $(GTK_CFLAGS) $(LIBCANBERRA_CFLAGS)
libeek_gtk_la_LIBADD = libeek.la $(GTK_LIBS) $(LIBCANBERRA_LIBS)
libeek_xkb_public_headers = \
libeek_xkl_public_headers = \
$(srcdir)/eek-xkl-layout.h \
$(srcdir)/eek-xkl.h \
$(srcdir)/eek-xkb-layout.h \
$(srcdir)/eek-xkb.h
libeek_xkb_sources = \
$(srcdir)/eek-xkb-layout.c
libeek_xkb_la_SOURCES = $(libeek_xkb_sources)
libeek_xkb_la_CFLAGS = -DEEK_COMPILATION=1 $(XKB_CFLAGS) $(GTK_CFLAGS)
libeek_xkb_la_LIBADD = libeek.la $(XKB_LIBS) $(GTK_LIBS)
libeek_xkl_public_headers = \
$(srcdir)/eek-xkl-layout.h \
$(srcdir)/eek-xkl.h
libeek_xkl_sources = \
$(srcdir)/eek-xkb-layout.c \
$(srcdir)/eek-xkl-layout.c
libeek_xkl_la_SOURCES = $(libeek_xkl_sources)
libeek_xkl_la_CFLAGS = -DEEK_COMPILATION=1 $(LIBXKLAVIER_CFLAGS) $(GTK_CFLAGS)
libeek_xkl_la_LIBADD = libeek-xkb.la $(LIBXKLAVIER_LIBS) $(GTK_LIBS)
libeek_xkl_la_LIBADD = libeek.la $(LIBXKLAVIER_LIBS) $(GTK_LIBS)
eekdir = $(includedir)/eek-$(EEK_API_VERSION)/eek
eek_HEADERS = \
$(libeek_public_headers) \
$(srcdir)/eek-enumtypes.h \
$(libeek_clutter_public_headers) \
$(libeek_gtk_public_headers) \
$(libeek_xkb_public_headers) \
$(libeek_xkl_public_headers)
noinst_HEADERS = \
$(libeek_private_headers) \
$(libeek_clutter_private_headers) \
$(libeek_gtk_private_headers) \
$(libeek_xkb_private_headers) \
$(libeek_xkl_private_headers)
eek-special-keysym-entries.h: special-keysym-entries.txt
@ -208,13 +170,8 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
eek-$(EEK_API_VERSION).pc \
eek-gtk-$(EEK_API_VERSION).pc \
eek-xkb-$(EEK_API_VERSION).pc \
eek-xkl-$(EEK_API_VERSION).pc
if ENABLE_CLUTTER
pkgconfig_DATA += eek-clutter-$(EEK_API_VERSION).pc
endif
CLEANFILES =
DISTCLEANFILES = \
@ -238,34 +195,21 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
if HAVE_INTROSPECTION
Eek@EEK_LIBRARY_SUFFIX@.gir: libeek.la
Eek@EEK_LIBRARY_SUFFIX_U@_gir_SCANNERFLAGS = --strip-prefix=Eek --pkg=glib-2.0
Eek@EEK_LIBRARY_SUFFIX_U@_gir_SCANNERFLAGS = --strip-prefix=Eek --pkg=glib-2.0 --pkg-export=eek-$(EEK_API_VERSION)
Eek@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0
Eek@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeek_la_CFLAGS)
Eek@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeek.la
Eek@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_sources) $(libeek_public_headers) $(srcdir)/eek-enumtypes.h
EekGtk@EEK_LIBRARY_SUFFIX@.gir: libeek-gtk.la Eek@EEK_LIBRARY_SUFFIX@.gir
EekGtk@EEK_LIBRARY_SUFFIX_U@_gir_SCANNERFLAGS = --pkg-export=eek-gtk-$(EEK_API_VERSION)
EekGtk@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GObject-2.0 Gtk-@GTK_API_VERSION@ Eek@EEK_LIBRARY_SUFFIX@
EekGtk@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeek_gtk_la_CFLAGS)
EekGtk@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeek-gtk.la
EekGtk@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_gtk_sources) $(libeek_gtk_public_headers)
if ENABLE_CLUTTER
EekClutter@EEK_LIBRARY_SUFFIX@.gir: libeek-clutter.la Eek@EEK_LIBRARY_SUFFIX@.gir
EekClutter@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GObject-2.0 Clutter-1.0 Eek@EEK_LIBRARY_SUFFIX@
EekClutter@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeek_clutter_la_CFLAGS)
EekClutter@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeek-clutter.la
EekClutter@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_clutter_sources) $(libeek_clutter_public_headers)
endif
EekXkb@EEK_LIBRARY_SUFFIX@.gir: libeek-xkb.la Eek@EEK_LIBRARY_SUFFIX@.gir
EekXkb@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GObject-2.0 Eek@EEK_LIBRARY_SUFFIX@
EekXkb@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeek_xkb_la_CFLAGS)
EekXkb@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeek-xkb.la
EekXkb@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_xkb_sources) $(libeek_xkb_public_headers)
EekXkl@EEK_LIBRARY_SUFFIX@.gir: libeek-xkl.la EekXkb@EEK_LIBRARY_SUFFIX@.gir
EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GObject-2.0 EekXkb@EEK_LIBRARY_SUFFIX@
EekXkl@EEK_LIBRARY_SUFFIX@.gir: libeek-xkl.la Eek@EEK_LIBRARY_SUFFIX@.gir
EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_INCLUDES = GObject-2.0 Eek@EEK_LIBRARY_SUFFIX@
EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_CFLAGS = $(libeek_xkl_la_CFLAGS)
EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_LIBS = libeek-xkl.la
EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_xkl_sources) $(libeek_xkl_public_headers)
@ -273,14 +217,8 @@ EekXkl@EEK_LIBRARY_SUFFIX_U@_gir_FILES = $(libeek_xkl_sources) $(libeek_xkl_publ
INTROSPECTION_GIRS += \
Eek@EEK_LIBRARY_SUFFIX@.gir \
EekGtk@EEK_LIBRARY_SUFFIX@.gir \
EekXkb@EEK_LIBRARY_SUFFIX@.gir \
EekXkl@EEK_LIBRARY_SUFFIX@.gir
if ENABLE_CLUTTER
INTROSPECTION_GIRS += \
EekClutter@EEK_LIBRARY_SUFFIX@.gir
endif
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)

View File

@ -1,30 +0,0 @@
# Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
# Copyright (C) 2010-2011 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
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libeek-clutter
Description: A Library to Create Keyboard-like UI (Clutter Support)
URL: http://fedorahosted.org/eekboard/
Version: @VERSION@
Requires: eek-@EEK_API_VERSION@ clutter-1.0
Libs: -L${libdir} -leek-clutter
Cflags: -I${includedir}/eek-@EEK_API_VERSION@

View File

@ -1,307 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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-key.h"
enum {
PROP_0,
PROP_KEY,
PROP_RENDERER,
PROP_LAST
};
G_DEFINE_TYPE (EekClutterKey, eek_clutter_key, CLUTTER_TYPE_ACTOR);
#define EEK_CLUTTER_KEY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_KEY, EekClutterKeyPrivate))
struct _EekClutterKeyPrivate
{
EekKey *key;
EekClutterRenderer *renderer;
gulong pressed_handler;
gulong released_handler;
};
static void
on_pressed (EekKey *key, gpointer user_data)
{
ClutterActor *actor = user_data, *parent;
parent = clutter_actor_get_parent (actor);
clutter_actor_raise_top (parent);
clutter_actor_raise_top (actor);
clutter_actor_set_scale_with_gravity (actor,
1.0,
1.0,
CLUTTER_GRAVITY_CENTER);
clutter_actor_animate (actor, CLUTTER_EASE_IN_SINE, 150,
"scale-x", 1.5,
"scale-y", 1.5,
NULL);
}
static void
on_released (EekKey *key, gpointer user_data)
{
ClutterActor *actor = user_data, *parent;
parent = clutter_actor_get_parent (actor);
clutter_actor_raise_top (parent);
clutter_actor_raise_top (actor);
clutter_actor_set_scale_with_gravity (actor,
1.5,
1.5,
CLUTTER_GRAVITY_CENTER);
clutter_actor_animate (actor, CLUTTER_EASE_OUT_SINE, 150,
"scale-x", 1.0,
"scale-y", 1.0,
NULL);
}
static void
set_position (ClutterActor *self)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
clutter_actor_set_position (self, bounds.x * scale, bounds.y * scale);
}
static void
eek_clutter_key_real_realize (ClutterActor *self)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
set_position (self);
clutter_actor_set_reactive (self, TRUE);
priv->pressed_handler =
g_signal_connect (priv->key, "pressed",
G_CALLBACK(on_pressed), self);
priv->released_handler =
g_signal_connect (priv->key, "released",
G_CALLBACK(on_released), self);
}
static void
eek_clutter_key_real_paint (ClutterActor *self)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
set_position (self);
eek_clutter_renderer_render_key (priv->renderer, self, priv->key);
}
static void
eek_clutter_key_real_get_preferred_width (ClutterActor *self,
gfloat for_height,
gfloat *min_width_p,
gfloat *natural_width_p)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
*min_width_p = 0.0f;
*natural_width_p = bounds.width * scale;
}
static void
eek_clutter_key_real_get_preferred_height (ClutterActor *self,
gfloat for_width,
gfloat *min_height_p,
gfloat *natural_height_p)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
*min_height_p = 0.0f;
*natural_height_p = bounds.height * scale;
}
static void
eek_clutter_key_real_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
CLUTTER_ACTOR_CLASS (eek_clutter_key_parent_class)->
allocate (self, box, flags);
}
static gboolean
eek_clutter_key_real_button_press_event (ClutterActor *self,
ClutterButtonEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
g_signal_emit_by_name (priv->key, "pressed");
return TRUE;
}
static gboolean
eek_clutter_key_real_button_release_event (ClutterActor *self,
ClutterButtonEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
g_signal_emit_by_name (priv->key, "released");
return TRUE;
}
static gboolean
eek_clutter_key_real_leave_event (ClutterActor *self,
ClutterCrossingEvent *event)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(self);
if (eek_key_is_pressed (priv->key))
g_signal_emit_by_name (priv->key, "released");
return TRUE;
}
static void
eek_clutter_key_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
switch (prop_id) {
case PROP_KEY:
priv->key = g_value_get_object (value);
g_object_ref (priv->key);
break;
case PROP_RENDERER:
priv->renderer = g_value_get_object (value);
g_object_ref (priv->renderer);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
break;
}
}
static void
eek_clutter_key_dispose (GObject *object)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
if (priv->renderer) {
g_object_unref (priv->renderer);
priv->renderer = NULL;
}
if (priv->key) {
if (g_signal_handler_is_connected (priv->key, priv->pressed_handler))
g_signal_handler_disconnect (priv->key, priv->pressed_handler);
if (g_signal_handler_is_connected (priv->key, priv->released_handler))
g_signal_handler_disconnect (priv->key, priv->released_handler);
g_object_unref (priv->key);
priv->key = NULL;
}
G_OBJECT_CLASS (eek_clutter_key_parent_class)->dispose (object);
}
static void
eek_clutter_key_class_init (EekClutterKeyClass *klass)
{
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
g_type_class_add_private (gobject_class,
sizeof (EekClutterKeyPrivate));
actor_class->realize = eek_clutter_key_real_realize;
actor_class->paint = eek_clutter_key_real_paint;
actor_class->get_preferred_width =
eek_clutter_key_real_get_preferred_width;
actor_class->get_preferred_height =
eek_clutter_key_real_get_preferred_height;
actor_class->allocate = eek_clutter_key_real_allocate;
/* signals */
actor_class->button_press_event =
eek_clutter_key_real_button_press_event;
actor_class->button_release_event =
eek_clutter_key_real_button_release_event;
actor_class->leave_event =
eek_clutter_key_real_leave_event;
gobject_class->set_property = eek_clutter_key_set_property;
gobject_class->dispose = eek_clutter_key_dispose;
pspec = g_param_spec_object ("key",
"Key",
"Key",
EEK_TYPE_KEY,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_KEY,
pspec);
pspec = g_param_spec_object ("renderer",
"Renderer",
"Renderer",
EEK_TYPE_RENDERER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_RENDERER,
pspec);
}
static void
eek_clutter_key_init (EekClutterKey *self)
{
EekClutterKeyPrivate *priv;
priv = self->priv = EEK_CLUTTER_KEY_GET_PRIVATE (self);
priv->key = NULL;
priv->renderer = NULL;
}
ClutterActor *
eek_clutter_key_new (EekKey *key, EekClutterRenderer *renderer)
{
return g_object_new (EEK_TYPE_CLUTTER_KEY,
"key", key,
"renderer", renderer,
NULL);
}

View File

@ -1,63 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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_KEY_H
#define EEK_CLUTTER_KEY_H 1
#include <clutter/clutter.h>
#include "eek-key.h"
#include "eek-clutter-renderer.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_KEY (eek_clutter_key_get_type())
#define EEK_CLUTTER_KEY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_KEY, EekClutterKey))
#define EEK_CLUTTER_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_KEY, EekClutterKeyClass))
#define EEK_IS_CLUTTER_KEY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_KEY))
#define EEK_IS_CLUTTER_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_KEY))
#define EEK_CLUTTER_KEY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_KEY, EekClutterKeyClass))
typedef struct _EekClutterKey EekClutterKey;
typedef struct _EekClutterKeyClass EekClutterKeyClass;
typedef struct _EekClutterKeyPrivate EekClutterKeyPrivate;
struct _EekClutterKey
{
/*< private >*/
ClutterActor parent;
/*< private >*/
EekClutterKeyPrivate *priv;
};
struct _EekClutterKeyClass
{
/*< private >*/
ClutterActorClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_new (EekKey *key,
EekClutterRenderer *renderer);
G_END_DECLS
#endif /* EEK_CLUTTER_KEY_H */

View File

@ -1,272 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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-clutter-keyboard
* @short_description: a #ClutterActor displaying #EekKeyboard
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "eek-clutter-keyboard.h"
#include "eek-clutter-section.h"
#include "eek-clutter-renderer.h"
#include "eek-keyboard.h"
enum {
PROP_0,
PROP_KEYBOARD,
PROP_LAST
};
G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, CLUTTER_TYPE_GROUP);
#define EEK_CLUTTER_KEYBOARD_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_KEYBOARD, EekClutterKeyboardPrivate))
struct _EekClutterKeyboardPrivate
{
EekKeyboard *keyboard;
EekClutterRenderer *renderer;
EekTheme *theme;
};
struct _CreateSectionCallbackData {
ClutterActor *actor;
EekClutterRenderer *renderer;
};
typedef struct _CreateSectionCallbackData CreateSectionCallbackData;
static void
create_section (EekElement *element, gpointer user_data)
{
CreateSectionCallbackData *data = user_data;
ClutterActor *section;
section = eek_clutter_section_new (EEK_SECTION(element), data->renderer);
clutter_container_add_actor (CLUTTER_CONTAINER(data->actor), section);
}
static void
eek_clutter_keyboard_real_realize (ClutterActor *self)
{
EekClutterKeyboardPrivate *priv;
CreateSectionCallbackData data;
EekBounds bounds;
gdouble scale;
priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
if (priv->theme)
eek_renderer_set_theme (EEK_RENDERER(priv->renderer), priv->theme);
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
clutter_actor_set_position (CLUTTER_ACTOR(self),
bounds.x * scale,
bounds.y * scale);
data.actor = CLUTTER_ACTOR(self);
data.renderer = priv->renderer;
eek_container_foreach_child (EEK_CONTAINER(priv->keyboard),
create_section,
&data);
}
static void
eek_clutter_keyboard_real_get_preferred_width (ClutterActor *self,
float for_height,
float *min_width_p,
float *natural_width_p)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
gdouble width;
eek_renderer_get_size (EEK_RENDERER(priv->renderer), &width, NULL);
*min_width_p = 0.0f;
*natural_width_p = width;
}
static void
eek_clutter_keyboard_real_get_preferred_height (ClutterActor *self,
float for_width,
float *min_height_p,
float *natural_height_p)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
gdouble height;
eek_renderer_get_size (EEK_RENDERER(priv->renderer), NULL, &height);
*min_height_p = 0.0f;
*natural_height_p = height;
}
static void
eek_clutter_keyboard_real_allocate (ClutterActor *self,
const ClutterActorBox *box,
ClutterAllocationFlags flags)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
eek_renderer_set_allocation_size (EEK_RENDERER(priv->renderer),
box->x2 - box->x1,
box->y2 - box->y1);
CLUTTER_ACTOR_CLASS (eek_clutter_keyboard_parent_class)->
allocate (self, box, flags);
}
static void
create_renderer (EekClutterKeyboard *self)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
PangoContext *pcontext;
PangoFontDescription *font;
EekBounds bounds;
pcontext = clutter_actor_get_pango_context (CLUTTER_ACTOR(self));
font = pango_font_description_from_string ("Sans 48px");
pango_context_set_font_description (pcontext, font);
pango_font_description_free (font);
priv->renderer = eek_clutter_renderer_new (priv->keyboard, pcontext);
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
eek_renderer_set_allocation_size (EEK_RENDERER(priv->renderer),
bounds.width,
bounds.height);
}
static void
eek_clutter_keyboard_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(object);
switch (prop_id) {
case PROP_KEYBOARD:
priv->keyboard = g_value_get_object (value);
g_object_ref (priv->keyboard);
create_renderer (EEK_CLUTTER_KEYBOARD(object));
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
break;
}
}
static void
eek_clutter_keyboard_dispose (GObject *object)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(object);
if (priv->renderer) {
g_object_unref (G_OBJECT(priv->renderer));
priv->renderer = NULL;
}
if (priv->keyboard) {
g_object_unref (priv->keyboard);
priv->keyboard = NULL;
}
if (priv->theme) {
g_object_unref (priv->theme);
priv->keyboard = NULL;
}
G_OBJECT_CLASS (eek_clutter_keyboard_parent_class)->dispose (object);
}
static void
eek_clutter_keyboard_class_init (EekClutterKeyboardClass *klass)
{
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
g_type_class_add_private (gobject_class,
sizeof (EekClutterKeyboardPrivate));
actor_class->realize =
eek_clutter_keyboard_real_realize;
actor_class->get_preferred_width =
eek_clutter_keyboard_real_get_preferred_width;
actor_class->get_preferred_height =
eek_clutter_keyboard_real_get_preferred_height;
actor_class->allocate = eek_clutter_keyboard_real_allocate;
gobject_class->set_property = eek_clutter_keyboard_set_property;
gobject_class->dispose = eek_clutter_keyboard_dispose;
pspec = g_param_spec_object ("keyboard",
"Keyboard",
"Keyboard",
EEK_TYPE_KEYBOARD,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_KEYBOARD,
pspec);
}
static void
eek_clutter_keyboard_init (EekClutterKeyboard *self)
{
EekClutterKeyboardPrivate *priv;
priv = self->priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
priv->keyboard = NULL;
priv->renderer = NULL;
}
/**
* eek_clutter_keyboard_new:
* @keyboard: an #EekKeyboard
*
* Create a new #ClutterActor displaying @keyboard.
* Returns: a #ClutterActor
*/
ClutterActor *
eek_clutter_keyboard_new (EekKeyboard *keyboard)
{
return g_object_new (EEK_TYPE_CLUTTER_KEYBOARD, "keyboard", keyboard, NULL);
}
void
eek_clutter_keyboard_set_theme (EekClutterKeyboard *keyboard,
EekTheme *theme)
{
EekClutterKeyboardPrivate *priv;
g_return_if_fail (EEK_IS_CLUTTER_KEYBOARD(keyboard));
g_return_if_fail (EEK_IS_THEME(theme));
priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(keyboard);
priv->theme = g_object_ref (theme);
}

View File

@ -1,67 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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
*/
#if !defined(__EEK_H_INSIDE__) && !defined(EEK_COMPILATION)
#error "Only <eek/eek-clutter.h> can be included directly."
#endif
#ifndef EEK_CLUTTER_KEYBOARD_H
#define EEK_CLUTTER_KEYBOARD_H 1
#include <clutter/clutter.h>
#include "eek-keyboard.h"
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, 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 _EekClutterKeyboardPrivate EekClutterKeyboardPrivate;
struct _EekClutterKeyboard
{
/*< private >*/
ClutterGroup parent;
EekClutterKeyboardPrivate *priv;
};
struct _EekClutterKeyboardClass
{
/*< private >*/
ClutterGroupClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_keyboard_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_keyboard_new (EekKeyboard *keyboard);
void eek_clutter_keyboard_set_theme (EekClutterKeyboard *keyboard,
EekTheme *theme);
G_END_DECLS
#endif /* EEK_CLUTTER_KEYBOARD_H */

View File

@ -1,235 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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 <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cogl/cogl.h>
#include <cogl/cogl-pango.h>
#include <clutter/clutter.h>
#include "eek-clutter-renderer.h"
#include "eek-key.h"
G_DEFINE_TYPE (EekClutterRenderer, eek_clutter_renderer, EEK_TYPE_RENDERER);
#define EEK_CLUTTER_RENDERER_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_RENDERER, EekClutterRendererPrivate))
struct _EekClutterRendererPrivate
{
GHashTable *outline_texture_cache;
};
/* This routine is copied from librsvg:
Copyright © 2005 Dom Lachowicz <cinamod@hotmail.com>
Copyright © 2005 Caleb Moore <c.moore@student.unsw.edu.au>
Copyright © 2005 Red Hat, Inc.
*/
static void
cairo_pixels_to_pixbuf (guint8 *pixels,
int rowstride,
int height)
{
int row;
/* un-premultiply data */
for (row = 0; row < height; row++) {
guint8 *row_data = (pixels + (row * rowstride));
int i;
for (i = 0; i < rowstride; i += 4) {
guint8 *b = &row_data[i];
guint32 pixel;
guint8 alpha;
memcpy (&pixel, b, sizeof (guint32));
alpha = (pixel & 0xff000000) >> 24;
if (alpha == 0) {
b[0] = b[1] = b[2] = b[3] = 0;
} else {
b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
b[1] = (((pixel & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha;
b[2] = (((pixel & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha;
b[3] = alpha;
}
}
}
}
static void
eek_clutter_renderer_finalize (GObject *object)
{
EekClutterRendererPrivate *priv = EEK_CLUTTER_RENDERER_GET_PRIVATE(object);
g_hash_table_destroy (priv->outline_texture_cache);
G_OBJECT_CLASS (eek_clutter_renderer_parent_class)->finalize (object);
}
static void
eek_clutter_renderer_class_init (EekClutterRendererClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class,
sizeof (EekClutterRendererPrivate));
gobject_class->finalize = eek_clutter_renderer_finalize;
}
static void
eek_clutter_renderer_init (EekClutterRenderer *self)
{
EekClutterRendererPrivate *priv;
priv = self->priv = EEK_CLUTTER_RENDERER_GET_PRIVATE(self);
priv->outline_texture_cache =
g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
cogl_handle_unref);
}
void
eek_clutter_renderer_render_key (EekClutterRenderer *renderer,
ClutterActor *actor,
EekKey *key)
{
EekClutterRendererPrivate *priv;
EekOutline *outline;
CoglHandle *outline_texture;
PangoLayout *layout;
PangoRectangle extents = { 0, };
EekColor foreground;
CoglColor color;
ClutterGeometry geom;
gulong oref;
EekKeyboard *keyboard;
g_assert (EEK_IS_CLUTTER_RENDERER(renderer));
g_assert (CLUTTER_IS_ACTOR(actor));
g_assert (EEK_IS_KEY(key));
oref = eek_key_get_oref (key);
g_object_get (renderer, "keyboard", &keyboard, NULL);
outline = eek_keyboard_get_outline (keyboard, oref);
g_object_unref (keyboard);
priv = EEK_CLUTTER_RENDERER_GET_PRIVATE(renderer);
outline_texture = g_hash_table_lookup (priv->outline_texture_cache,
outline);
if (!outline_texture) {
gint rowstride;
guint8 *data;
cairo_surface_t *surface;
cairo_t *cr;
EekBounds bounds;
gdouble scale;
GdkPixbuf *pixbuf;
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
scale = eek_renderer_get_scale (EEK_RENDERER(renderer));
rowstride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32,
bounds.width * scale);
data = g_malloc0 (rowstride * bounds.height);
surface = cairo_image_surface_create_for_data (data,
CAIRO_FORMAT_ARGB32,
bounds.width * scale,
bounds.height * scale,
rowstride);
cr = cairo_create (surface);
eek_renderer_render_key_outline (EEK_RENDERER(renderer),
cr,
key,
1.0,
FALSE);
cairo_destroy (cr);
cairo_surface_destroy (surface);
cairo_pixels_to_pixbuf (data, rowstride, bounds.height * scale);
pixbuf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB,
TRUE,
8,
bounds.width * scale,
bounds.height * scale,
rowstride,
(GdkPixbufDestroyNotify) g_free,
data);
outline_texture =
cogl_texture_new_from_data (gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
COGL_TEXTURE_NONE,
gdk_pixbuf_get_has_alpha (pixbuf)
? COGL_PIXEL_FORMAT_RGBA_8888
: COGL_PIXEL_FORMAT_RGB_888,
COGL_PIXEL_FORMAT_ANY,
gdk_pixbuf_get_rowstride (pixbuf),
gdk_pixbuf_get_pixels (pixbuf));
g_object_unref (pixbuf);
g_hash_table_insert (priv->outline_texture_cache,
outline,
outline_texture);
}
clutter_actor_get_allocation_geometry (actor, &geom);
cogl_set_source_texture (outline_texture);
cogl_rectangle (0.0f, 0.0f, geom.width, geom.height);
layout = eek_renderer_create_pango_layout (EEK_RENDERER(renderer));
eek_renderer_render_key_label (EEK_RENDERER(renderer), layout, key);
pango_layout_get_extents (layout, NULL, &extents);
eek_renderer_get_foreground_color (EEK_RENDERER(renderer),
EEK_ELEMENT(key),
&foreground);
cogl_color_set_from_4f (&color,
foreground.red,
foreground.green,
foreground.blue,
foreground.alpha);
cogl_pango_render_layout (layout,
(geom.width - extents.width / PANGO_SCALE) / 2,
(geom.height - extents.height / PANGO_SCALE) / 2,
&color,
0);
g_object_unref (layout);
}
EekClutterRenderer *
eek_clutter_renderer_new (EekKeyboard *keyboard,
PangoContext *pcontext)
{
EekClutterRenderer *renderer;
renderer = g_object_new (EEK_TYPE_CLUTTER_RENDERER,
"keyboard", keyboard,
"pango-context", pcontext,
NULL);
return renderer;
}

View File

@ -1,64 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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_RENDERER_H
#define EEK_CLUTTER_RENDERER_H 1
#include "eek-renderer.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_RENDERER (eek_clutter_renderer_get_type())
#define EEK_CLUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_RENDERER, EekClutterRenderer))
#define EEK_CLUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_RENDERER, EekClutterRendererClass))
#define EEK_IS_CLUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_RENDERER))
#define EEK_IS_CLUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_RENDERER))
#define EEK_CLUTTER_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_RENDERER, EekClutterRendererClass))
typedef struct _EekClutterRenderer EekClutterRenderer;
typedef struct _EekClutterRendererClass EekClutterRendererClass;
typedef struct _EekClutterRendererPrivate EekClutterRendererPrivate;
struct _EekClutterRenderer {
EekRenderer parent;
EekClutterRendererPrivate *priv;
};
struct _EekClutterRendererClass
{
EekRendererClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_renderer_get_type
(void) G_GNUC_CONST;
EekClutterRenderer *eek_clutter_renderer_new (EekKeyboard *keyboard,
PangoContext *pcontext);
void eek_clutter_renderer_render_key
(EekClutterRenderer *renderer,
ClutterActor *actor,
EekKey *key);
G_END_DECLS
#endif /* EEK_CLUTTER_RENDERER_H */

View File

@ -1,232 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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-section.h"
#include "eek-clutter-key.h"
enum {
PROP_0,
PROP_SECTION,
PROP_RENDERER,
PROP_LAST
};
G_DEFINE_TYPE (EekClutterSection, eek_clutter_section, CLUTTER_TYPE_GROUP);
#define EEK_CLUTTER_SECTION_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_SECTION, EekClutterSectionPrivate))
struct _EekClutterSectionPrivate
{
EekSection *section;
EekClutterRenderer *renderer;
};
struct _CreateKeyCallbackData {
ClutterActor *actor;
EekClutterRenderer *renderer;
};
typedef struct _CreateKeyCallbackData CreateKeyCallbackData;
static void
create_key (EekElement *element, gpointer user_data)
{
CreateKeyCallbackData *data = user_data;
ClutterActor *key;
key = eek_clutter_key_new (EEK_KEY(element), data->renderer);
clutter_container_add_actor (CLUTTER_CONTAINER(data->actor), key);
}
static void
set_position (ClutterActor *self)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
eek_element_get_bounds (EEK_ELEMENT(priv->section), &bounds);
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
clutter_actor_set_position (self, bounds.x * scale, bounds.y * scale);
}
static void
eek_clutter_section_real_realize (ClutterActor *self)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
CreateKeyCallbackData data;
clutter_actor_set_rotation (self,
CLUTTER_Z_AXIS,
eek_section_get_angle (priv->section),
0.0f, 0.0f, 0.0f);
set_position (self);
data.actor = self;
data.renderer = priv->renderer;
eek_container_foreach_child (EEK_CONTAINER(priv->section),
create_key,
&data);
}
static void
eek_clutter_section_real_paint (ClutterActor *self)
{
set_position (self);
CLUTTER_ACTOR_CLASS (eek_clutter_section_parent_class)->
paint (self);
}
static void
eek_clutter_section_real_get_preferred_width (ClutterActor *self,
float for_height,
float *min_width_p,
float *natural_width_p)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->section), &bounds);
*min_width_p = 0.0f;
*natural_width_p = bounds.width * scale;
}
static void
eek_clutter_section_real_get_preferred_height (ClutterActor *self,
float for_width,
float *min_height_p,
float *natural_height_p)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
EekBounds bounds;
gdouble scale;
scale = eek_renderer_get_scale (EEK_RENDERER(priv->renderer));
eek_element_get_bounds (EEK_ELEMENT(priv->section), &bounds);
*min_height_p = 0.0f;
*natural_height_p = bounds.height * scale;
}
static void
eek_clutter_section_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(object);
switch (prop_id) {
case PROP_SECTION:
priv->section = g_value_get_object (value);
g_object_ref (priv->section);
break;
case PROP_RENDERER:
priv->renderer = g_value_get_object (value);
g_object_ref (priv->renderer);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
value);
break;
}
}
static void
eek_clutter_section_dispose (GObject *object)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(object);
if (priv->renderer) {
g_object_unref (priv->renderer);
priv->renderer = NULL;
}
if (priv->section) {
g_object_unref (priv->section);
priv->section = NULL;
}
G_OBJECT_CLASS (eek_clutter_section_parent_class)->dispose (object);
}
static void
eek_clutter_section_class_init (EekClutterSectionClass *klass)
{
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
g_type_class_add_private (gobject_class, sizeof (EekClutterSectionPrivate));
actor_class->realize =
eek_clutter_section_real_realize;
actor_class->paint =
eek_clutter_section_real_paint;
actor_class->get_preferred_width =
eek_clutter_section_real_get_preferred_width;
actor_class->get_preferred_height =
eek_clutter_section_real_get_preferred_height;
gobject_class->set_property = eek_clutter_section_set_property;
gobject_class->dispose = eek_clutter_section_dispose;
pspec = g_param_spec_object ("section",
"Section",
"Section",
EEK_TYPE_SECTION,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_SECTION,
pspec);
pspec = g_param_spec_object ("renderer",
"Renderer",
"Renderer",
EEK_TYPE_RENDERER,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_RENDERER,
pspec);
}
static void
eek_clutter_section_init (EekClutterSection *self)
{
EekClutterSectionPrivate *priv;
priv = self->priv = EEK_CLUTTER_SECTION_GET_PRIVATE (self);
priv->section = NULL;
priv->renderer = NULL;
}
ClutterActor *
eek_clutter_section_new (EekSection *section,
EekClutterRenderer *renderer)
{
return g_object_new (EEK_TYPE_CLUTTER_SECTION,
"section", section,
"renderer", renderer,
NULL);
}

View File

@ -1,62 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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_SECTION_H
#define EEK_CLUTTER_SECTION_H 1
#include <clutter/clutter.h>
#include "eek-section.h"
#include "eek-clutter-renderer.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_SECTION (eek_clutter_section_get_type())
#define EEK_CLUTTER_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_SECTION, EekClutterSection))
#define EEK_CLUTTER_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_SECTION, EekClutterSectionClass))
#define EEK_IS_CLUTTER_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_SECTION))
#define EEK_IS_CLUTTER_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_SECTION))
#define EEK_CLUTTER_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_SECTION, EekClutterSectionClass))
typedef struct _EekClutterSection EekClutterSection;
typedef struct _EekClutterSectionClass EekClutterSectionClass;
typedef struct _EekClutterSectionPrivate EekClutterSectionPrivate;
struct _EekClutterSection
{
/*< private >*/
ClutterGroup parent;
EekClutterSectionPrivate *priv;
};
struct _EekClutterSectionClass
{
/*< private >*/
ClutterGroupClass parent_class;
/*< private >*/
/* padding */
gpointer pdummy[24];
};
GType eek_clutter_section_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_section_new (EekSection *section,
EekClutterRenderer *renderer);
G_END_DECLS
#endif /* EEK_CLUTTER_SECTION_H */

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2010-2011 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010-2011 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_H
#define EEK_CLUTTER_H 1
#include "eek.h"
#include "eek-clutter-keyboard.h"
#endif /* EEK_CLUTTER_H */

View File

@ -25,6 +25,6 @@ Name: libeek-xkl
Description: A Library to Create Keyboard-like UI (Libxklavier Support)
URL: http://fedorahosted.org/eekboard/
Version: @VERSION@
Requires: eek-xkb-@EEK_API_VERSION@ libxklavier
Requires: eek-@EEK_API_VERSION@ libxklavier
Libs: -L${libdir} -leek-xkl
Cflags: -I${includedir}/eek-@EEK_API_VERSION@