Commit e0c93193 authored by Daiki Ueno's avatar Daiki Ueno

Make clutter optional for build.

parent 04150043
......@@ -4,48 +4,26 @@ eekboard is a virtual keyboard software package which ships with a
standalone virtual keyboard application ("eekboard"), and a library to
create keyboard-like UI ("libeek").
*NOTE* eekboard is still under heavy development. The code has still a
lot of bugs and lacks documentation.
* Requirements
* GLib2, GTK2, Cairo, Pango, Libxklavier...
* Clutter (optional)
* Clutter-Gtk (optional)
* How to test
$ sudo apt-get install libclutter-gtk-0.10-dev libxklavier-dev \
libfakekey-dev python
If you build from git repo:
$ git clone git://github.com/ueno/eekboard.git
$ cd eekboard
$ ./autogen.sh --prefix=/usr --enable-gtk-doc
Otherwise start from here:
$ ./configure
$ make
$ sudo make install
$ eekboard
* libeek API (not fixed)
Since libeek is designed as simple as possible, it provides only two
kinds of objects. One is "keyboard element" and another is "keyboard
layout engine". A keyboard element represents either a keyboard, a
section, or a key. Each element implements the Builder pattern[1] so
that it can be converted into a UI widget (ClutterActor,
GtkDrawingArea, ...). A layout engine arranges keyboard elements
using information from external configuration mechanisms (libxklavier,
XKB, matchbox-keyboard layouts in XML, ...)
Here is a sample code which utilizes Clutter keyboard elements
and libxklavier layout engine:
1: EekKeyboard *keyboard;
2: EekLayout *layout;
3:
4: /* Create a keyboard layout using libxklavier configuration. */
5: layout = eek_xkl_layout_new ();
6:
7: /* Create a keyboard implemented as ClutterActor. */
8: keyboard = eek_clutter_keyboard_new (640, 480);
9:
10: /* Apply the layout to the keyboard. */
11: eek_keyboard_set_layout (keyboard, layout);
12:
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
*NOTE* some version combination of Clutter & Clutter-Gtk does not
cooperate well. Try "EEKBOARD_DISABLE_CLUTTER=1 eekboard"
......@@ -32,10 +32,6 @@ PKG_CHECK_MODULES([CAIRO], [cairo], ,
[AC_MSG_ERROR([Cairo not found])])
PKG_CHECK_MODULES([PANGO], [pango], ,
[AC_MSG_ERROR([Pango not found])])
PKG_CHECK_MODULES([CLUTTER], [clutter-1.0], ,
[AC_MSG_ERROR([Clutter not found])])
PKG_CHECK_MODULES([CLUTTER_GTK], [clutter-gtk-0.10], ,
[AC_MSG_ERROR([clutter-gtk not found])])
PKG_CHECK_MODULES([GTK2], [gtk+-2.0 gdk-2.0], ,
[AC_MSG_ERROR([GTK2 not found])])
PKG_CHECK_MODULES([XKB], [x11], ,
......@@ -47,6 +43,31 @@ PKG_CHECK_MODULES([LIBFAKEKEY], [libfakekey], ,
PKG_CHECK_MODULES([ATK], [atk], ,
[AC_MSG_ERROR([ATK not found])])
AC_MSG_CHECKING([whether you enable Clutter])
AC_ARG_ENABLE(clutter,
AS_HELP_STRING([--enable-clutter=no/yes],
[Enable Clutter user interface default=yes]),,
enable_clutter=yes)
AC_MSG_RESULT($enable_clutter)
if test x$enable_clutter = xyes; then
PKG_CHECK_MODULES([CLUTTER], [clutter-1.0], ,
[AC_MSG_ERROR([Clutter not found])])
AC_DEFINE([HAVE_CLUTTER], [1], [Define if Clutter is found])
enable_clutter_gtk=no
PKG_CHECK_MODULES([CLUTTER_GTK], [clutter-gtk-0.90],
[enable_clutter_gtk=yes])
if test x$enable_clutter_gtk = xno; then
PKG_CHECK_MODULES([CLUTTER_GTK], [clutter-gtk-0.10],
[enable_clutter_gtk=yes])
fi
if test x$enable_clutter_gtk = xyes; then
AC_DEFINE([HAVE_CLUTTER_GTK], [1], [Define if Clutter-Gtk is found])
fi
fi
AM_CONDITIONAL(HAVE_CLUTTER, [test x$enable_clutter = xyes])
AM_CONDITIONAL(HAVE_CLUTTER_GTK, [test x$enable_clutter_gtk = xyes])
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
EEK_API_VERSION=0.1
......
......@@ -90,12 +90,12 @@ HTML_IMAGES=
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
content_files=
content_files=eek-overview.xml
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
# These files must be listed here *and* in content_files
# e.g. expand_content_files=running.sgml
expand_content_files=
expand_content_files=eek-overview.xml
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
......@@ -104,14 +104,16 @@ expand_content_files=
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS = $(GOBJECT2_CFLAGS)
GTKDOC_LIBS = $(top_srcdir)/eek/libeek.la \
$(top_srcdir)/eek/libeek-clutter.la \
$(top_srcdir)/eek/libeek-gtk.la \
$(top_srcdir)/eek/libeek-xkb.la \
$(top_srcdir)/eek/libeek-xkl.la \
$(GOBJECT2_LIBS) \
$(CLUTTER_LIBS) \
$(XKB_LIBS)
if HAVE_CLUTTER
GTKDOC_LIBS += $(top_srcdir)/eek/libeek-clutter.la $(CLUTTER_LIBS)
endif
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make
......
......@@ -18,11 +18,14 @@
lib_LTLIBRARIES = \
libeek.la \
libeek-clutter.la \
libeek-gtk.la \
libeek-xkb.la \
libeek-xkl.la
if HAVE_CLUTTER
lib_LTLIBRARIES += libeek-clutter.la
endif
libeek_la_SOURCES = \
eek-layout.c \
eek-layout.h \
......@@ -47,6 +50,7 @@ libeek_la_SOURCES = \
libeek_la_CFLAGS = $(GOBJECT2_CFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS)
libeek_la_LIBADD = $(GOBJECT2_LIBS) $(CAIRO_LIBS) $(PANGO_LIBS)
if HAVE_CLUTTER
libeek_clutter_la_SOURCES = \
eek-clutter-keyboard.c \
eek-clutter-keyboard.h \
......@@ -64,6 +68,7 @@ libeek_clutter_la_SOURCES = \
libeek_clutter_la_CFLAGS = $(CLUTTER_CFLAGS)
libeek_clutter_la_LIBADD = libeek.la $(CLUTTER_LIBS)
endif
libeek_gtk_la_SOURCES = \
eek-gtk-keyboard.c \
......
......@@ -17,9 +17,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
/**
* SECTION:eek-keysym
* @short_description: Keysym conversion utilities
*/
#include <glib.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-keysym.h"
struct eek_keysym_label {
......
......@@ -17,5 +17,15 @@
# 02110-1301 USA
bin_PROGRAMS = eekboard
eekboard_CFLAGS = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(CLUTTER_CFLAGS) $(CLUTTER_GTK_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS) $(LIBXKLAVIER_CFLAGS) $(LIBFAKEKEY_CFLAGS) $(ATK_CFLAGS)
eekboard_LDFLAGS = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkl.la $(top_builddir)/eek/libeek-clutter.la $(top_builddir)/eek/libeek-gtk.la $(GOBJECT2_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(GTK2_CFLAGS) $(XKB_LIBS) $(LIBXKLAVIER_LIBS) $(LIBFAKEKEY_LIBS) $(ATK_LIBS)
eekboard_CFLAGS = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS) $(LIBXKLAVIER_CFLAGS) $(LIBFAKEKEY_CFLAGS) $(ATK_CFLAGS)
eekboard_LDFLAGS = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkl.la $(top_builddir)/eek/libeek-gtk.la $(GOBJECT2_LIBS) $(GTK2_CFLAGS) $(XKB_LIBS) $(LIBXKLAVIER_LIBS) $(LIBFAKEKEY_LIBS) $(ATK_LIBS)
if HAVE_CLUTTER
eekboard_CFLAGS += $(CLUTTER_CFLAGS)
eekboard_LDFLAGS += $(CLUTTER_LIBS)
endif
if HAVE_CLUTTER_GTK
eekboard_CFLAGS += $(CLUTTER_GTK_CFLAGS)
eekboard_LDFLAGS += $(top_builddir)/eek/libeek-clutter.la $(CLUTTER_GTK_LIBS)
endif
\ No newline at end of file
......@@ -16,7 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_CLUTTER_GTK
#include <clutter-gtk/clutter-gtk.h>
#endif
#include <fakekey/fakekey.h>
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
......@@ -32,13 +35,22 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
#if HAVE_CLUTTER_GTK
#include "eek/eek-clutter.h"
#endif
#include "eek/eek-gtk.h"
#include "eek/eek-xkl.h"
#define CSW 640
#define CSH 480
#if HAVE_CLUTTER_GTK
#define USE_CLUTTER TRUE
#else
#define USE_CLUTTER FALSE
#endif
#define LICENSE \
"This program is free software: you can redistribute it and/or modify " \
"it under the terms of the GNU General Public License as published by " \
......@@ -58,7 +70,7 @@ struct _Eekboard {
Display *display;
FakeKey *fakekey;
GtkWidget *widget;
gfloat width, height;
gint width, height;
guint key_event_listener;
EekKeyboard *keyboard;
......@@ -87,8 +99,15 @@ static void on_monitor_key_event_toggled
(GtkToggleAction *action,
GtkWidget *window);
static GtkWidget *create_widget (Eekboard *eekboard,
gfloat initial_width,
gfloat initial_height);
gint initial_width,
gint initial_height);
static GtkWidget *create_widget_gtk (Eekboard *eekboard,
gint initial_width,
gint initial_height);
#if !HAVE_CLUTTER_GTK
#define create_widget create_widget_gtk
#endif
static const char ui_description[] =
"<ui>"
......@@ -371,6 +390,7 @@ create_menus (Eekboard *eekboard,
create_layouts_menu (eekboard, ui_manager);
}
#if HAVE_CLUTTER_GTK
static GtkWidget *
create_widget_clutter (Eekboard *eekboard,
gint initial_width,
......@@ -404,6 +424,7 @@ create_widget_clutter (Eekboard *eekboard,
clutter_actor_set_size (stage, eekboard->width, eekboard->height);
return eekboard->widget;
}
#endif
static GtkWidget *
create_widget_gtk (Eekboard *eekboard,
......@@ -432,16 +453,18 @@ create_widget_gtk (Eekboard *eekboard,
return eekboard->widget;
}
#if HAVE_CLUTTER_GTK
static GtkWidget *
create_widget (Eekboard *eekboard,
gfloat initial_width,
gfloat initial_height)
gint initial_width,
gint initial_height)
{
if (eekboard->use_clutter)
return create_widget_clutter (eekboard, initial_width, initial_height);
else
return create_widget_gtk (eekboard, initial_width, initial_height);
}
#endif
Eekboard *
eekboard_new (gboolean use_clutter)
......@@ -482,7 +505,7 @@ int
main (int argc, char *argv[])
{
const gchar *env;
gboolean use_clutter = TRUE;
gboolean use_clutter = USE_CLUTTER;
Eekboard *eekboard;
GtkWidget *widget, *vbox, *menubar, *window;
GtkUIManager *ui_manager;
......@@ -491,11 +514,13 @@ main (int argc, char *argv[])
if (env && g_strcmp0 (env, "1") == 0)
use_clutter = FALSE;
#if HAVE_CLUTTER_GTK
if (use_clutter &&
gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) {
g_warning ("Can't init Clutter-Gtk...fallback to GTK");
use_clutter = FALSE;
}
#endif
if (!use_clutter && !gtk_init_check (&argc, &argv)) {
g_warning ("Can't init GTK");
......
......@@ -16,13 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
INCLUDES = -I$(top_srcdir) $(CLUTTER_CFLAGS) $(GOBJECT2_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS)
INCLUDES = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS)
TESTS = eek-simple-test eek-xkb-test
noinst_PROGRAMS = $(TESTS)
eek_simple_test_SOURCES = eek-simple-test.c
eek_simple_test_LDADD = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-clutter.la
eek_simple_test_LDADD = $(top_builddir)/eek/libeek.la
eek_xkb_test_SOURCES = eek-xkb-test.c
eek_xkb_test_LDADD = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkb.la
......@@ -18,7 +18,6 @@
* 02110-1301 USA
*/
#include "eek.h"
#include "eek-clutter.h"
static void
test_create (void)
......@@ -37,38 +36,11 @@ test_create (void)
g_assert (EEK_IS_KEY(key1));
}
#if 0
static void
test_create_clutter (void)
{
EekKeyboard *keyboard;
EekSection *section;
EekKey *key0, *key1;
ClutterActor *actor;
keyboard = eek_clutter_keyboard_new (640.0, 480.0);
section = eek_keyboard_create_section (keyboard);
g_assert (EEK_IS_SECTION(section));
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
key0 = eek_section_create_key (section, 0, 0);
g_assert (EEK_IS_KEY(key0));
key1 = eek_section_create_key (section, 1, 0);
g_assert (EEK_IS_KEY(key1));
actor = eek_clutter_keyboard_get_actor (EEK_CLUTTER_KEYBOARD(keyboard));
g_assert (CLUTTER_IS_ACTOR(actor));
g_object_unref (keyboard);
}
#endif
int
main (int argc, char **argv)
{
g_type_init ();
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/eek-simple-test/create", test_create);
#if 0
clutter_init (&argc, &argv);
g_test_add_func ("/eek-simple-test/create-clutter", test_create_clutter);
#endif
return g_test_run ();
}
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