Commit 4b7f2440 authored by Daiki Ueno's avatar Daiki Ueno

Add a standalone application.

parent 174b1b3f
......@@ -17,4 +17,4 @@
# 02110-1301 USA
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = eek examples tests docs
SUBDIRS = eek src examples tests docs
......@@ -34,12 +34,16 @@ 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], ,
[AC_MSG_ERROR([XKB support not found])])
PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier x11], ,
[AC_MSG_ERROR([Libxklavier not found])])
PKG_CHECK_MODULES([LIBFAKEKEY], [libfakekey], ,
[AC_MSG_ERROR([libfakekey not found])])
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
......@@ -51,6 +55,7 @@ AC_CHECK_PROGS([PYTHON], [python])
AC_CONFIG_HEADERS([eek/config.h])
AC_CONFIG_FILES([Makefile
eek/Makefile
src/Makefile
examples/Makefile
tests/Makefile
docs/Makefile
......
......@@ -154,6 +154,18 @@ eek_keyboard_real_create_section (EekKeyboard *self)
return section;
}
static void
on_group_changed (EekLayout *layout,
gint new_group,
gpointer user_data)
{
EekKeyboard *keyboard = user_data;
gint group, level;
eek_keyboard_get_keysym_index (keyboard, &group, &level);
eek_keyboard_set_keysym_index (keyboard, new_group, level);
}
static void
eek_keyboard_real_set_layout (EekKeyboard *self,
EekLayout *layout)
......@@ -163,6 +175,8 @@ eek_keyboard_real_set_layout (EekKeyboard *self,
g_return_if_fail (EEK_IS_LAYOUT(layout));
priv->layout = layout;
g_object_ref_sink (priv->layout);
g_signal_connect (priv->layout, "group_changed",
G_CALLBACK(on_group_changed), self);
}
static void
......@@ -173,6 +187,8 @@ eek_keyboard_real_realize (EekKeyboard *self)
g_return_if_fail (priv->layout);
g_return_if_fail (!priv->is_realized);
EEK_LAYOUT_GET_IFACE(priv->layout)->apply (priv->layout, self);
/* apply the initial group setting */
on_group_changed (priv->layout, eek_layout_get_group (priv->layout), self);
priv->is_realized = TRUE;
}
......
......@@ -33,13 +33,39 @@
#include "eek-layout.h"
#include "eek-keyboard.h"
enum {
GROUP_CHANGED,
CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0, };
static void
eek_layout_base_init (gpointer gobject_class)
{
static gboolean is_initialized = FALSE;
if (!is_initialized) {
/* TODO: signals */
signals[GROUP_CHANGED] =
g_signal_new ("group-changed",
G_TYPE_FROM_INTERFACE(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(EekLayoutIface, group_changed),
NULL,
NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1,
G_TYPE_INT);
signals[CHANGED] =
g_signal_new ("changed",
G_TYPE_FROM_INTERFACE(gobject_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(EekLayoutIface, changed),
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
is_initialized = TRUE;
}
}
......@@ -69,3 +95,9 @@ eek_layout_apply (EekLayout *layout,
EEK_LAYOUT_GET_IFACE(layout)->apply (layout, keyboard);
}
gint
eek_layout_get_group (EekLayout *layout)
{
g_return_val_if_fail (EEK_IS_LAYOUT(layout), -1);
return EEK_LAYOUT_GET_IFACE(layout)->get_group (layout);
}
......@@ -39,13 +39,21 @@ struct _EekLayoutIface
/*< private >*/
GTypeInterface parent_iface;
void (*apply) (EekLayout *self,
EekKeyboard *keyboard);
/*< public >*/
void (* apply) (EekLayout *self,
EekKeyboard *keyboard);
gint (* get_group) (EekLayout *self);
/* signals */
void (* group_changed) (EekLayout *self,
gint group);
void (* changed) (EekLayout *self);
};
GType eek_layout_get_type (void) G_GNUC_CONST;
void eek_layout_apply (EekLayout *layout,
EekKeyboard *keyboard);
GType eek_layout_get_type (void) G_GNUC_CONST;
void eek_layout_apply (EekLayout *layout,
EekKeyboard *keyboard);
gint eek_layout_get_group (EekLayout *layout);
G_END_DECLS
#endif /* EEK_LAYOUT_H */
......@@ -27,14 +27,15 @@
* elements using XKB.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <gdk/gdkx.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBgeom.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-xkb-layout.h"
#include "eek-keyboard.h"
#include "eek-section.h"
......@@ -308,19 +309,41 @@ eek_xkb_layout_real_apply (EekLayout *layout, EekKeyboard *keyboard)
create_keyboard (EEK_XKB_LAYOUT(layout), keyboard);
}
static gint
compare_component_names (gchar *name0, gchar *name1)
{
if (name0 && name1)
return g_strcmp0 (name0, name1);
else if (!name0 && name1)
return -1;
else if (name0 && !name1)
return 1;
else
return 0;
}
static void
eek_xkb_layout_real_set_names (EekXkbLayout *self, XkbComponentNamesRec *names)
{
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (self);
gboolean is_changed;
g_return_if_fail (priv);
is_changed =
compare_component_names (names->keycodes, priv->names.keycodes) != 0;
g_free (priv->names.keycodes);
priv->names.keycodes = g_strdup (names->keycodes);
is_changed =
compare_component_names (names->geometry, priv->names.geometry) != 0;
g_free (priv->names.geometry);
priv->names.geometry = g_strdup (names->geometry);
is_changed =
compare_component_names (names->symbols, priv->names.symbols) != 0;
g_free (priv->names.symbols);
priv->names.symbols = g_strdup (names->symbols);
get_keyboard (self);
if (is_changed)
g_signal_emit_by_name (self, "changed");
}
static void
......@@ -574,11 +597,18 @@ void
eek_xkb_layout_set_keycodes (EekXkbLayout *layout, const gchar *keycodes)
{
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
gboolean is_changed = TRUE;
g_return_if_fail (priv);
if (keycodes && priv->names.keycodes)
is_changed = g_strcmp0 (keycodes, priv->names.keycodes) != 0;
else if (keycodes == NULL && priv->names.keycodes == NULL)
is_changed = FALSE;
g_free (priv->names.keycodes);
priv->names.keycodes = g_strdup (keycodes);
get_keyboard (layout);
if (is_changed)
g_signal_emit_by_name (layout, "changed");
}
/**
......@@ -592,11 +622,18 @@ void
eek_xkb_layout_set_geometry (EekXkbLayout *layout, const gchar *geometry)
{
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
gboolean is_changed = TRUE;
g_return_if_fail (priv);
if (geometry && priv->names.geometry)
is_changed = g_strcmp0 (geometry, priv->names.geometry) != 0;
else if (geometry == NULL && priv->names.geometry == NULL)
is_changed = FALSE;
g_free (priv->names.geometry);
priv->names.geometry = g_strdup (geometry);
get_keyboard (layout);
if (is_changed)
g_signal_emit_by_name (layout, "changed");
}
/**
......@@ -610,11 +647,18 @@ void
eek_xkb_layout_set_symbols (EekXkbLayout *layout, const gchar *symbols)
{
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
gboolean is_changed = TRUE;
g_return_if_fail (priv);
if (symbols && priv->names.symbols)
is_changed = g_strcmp0 (symbols, priv->names.symbols) != 0;
else if (symbols == NULL && priv->names.symbols == NULL)
is_changed = FALSE;
g_free (priv->names.symbols);
priv->names.symbols = g_strdup (symbols);
get_keyboard (layout);
if (is_changed)
g_signal_emit_by_name (layout, "changed");
}
/**
......
......@@ -38,7 +38,12 @@
#define noKBDRAW_DEBUG
G_DEFINE_TYPE (EekXklLayout, eek_xkl_layout, EEK_TYPE_XKB_LAYOUT);
static void eek_layout_iface_init (EekLayoutIface *iface);
static EekLayoutIface *parent_layout_iface;
G_DEFINE_TYPE_WITH_CODE (EekXklLayout, eek_xkl_layout, EEK_TYPE_XKB_LAYOUT,
G_IMPLEMENT_INTERFACE(EEK_TYPE_LAYOUT,
eek_layout_iface_init));
#define EEK_XKL_LAYOUT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_XKL_LAYOUT, EekXklLayoutPrivate))
......@@ -72,6 +77,26 @@ extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
static void get_xkb_component_names (EekXklLayout *layout);
static gint
eek_xkl_layout_real_get_group (EekLayout *self)
{
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (self);
XklState *state;
state = xkl_engine_get_current_state (priv->engine);
g_return_val_if_fail (state, -1);
return state->group;
}
static void
eek_layout_iface_init (EekLayoutIface *iface)
{
parent_layout_iface = g_type_interface_peek_parent (iface);
if (!parent_layout_iface)
parent_layout_iface = g_type_default_interface_peek (EEK_TYPE_LAYOUT);
iface->get_group = eek_xkl_layout_real_get_group;
}
static void
eek_xkl_layout_finalize (GObject *object)
{
......@@ -145,12 +170,12 @@ eek_xkl_layout_get_property (GObject *object,
static void
eek_xkl_layout_class_init (EekXklLayoutClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
g_type_class_add_private (gobject_class, sizeof (EekXklLayoutPrivate));
gobject_class->finalize = eek_xkl_layout_finalize;
gobject_class->finalize = eek_xkl_layout_finalize;
gobject_class->set_property = eek_xkl_layout_set_property;
gobject_class->get_property = eek_xkl_layout_get_property;
......@@ -176,6 +201,19 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass)
g_object_class_install_property (gobject_class, PROP_OPTIONS, pspec);
}
static void
on_state_changed (XklEngine *xklengine,
XklEngineStateChange type,
gint value,
gboolean restore,
gpointer user_data)
{
EekLayout *layout = user_data;
if (type == GROUP_CHANGED)
g_signal_emit_by_name (layout, "group_changed", value);
}
static void
eek_xkl_layout_init (EekXklLayout *self)
{
......@@ -189,18 +227,37 @@ eek_xkl_layout_init (EekXklLayout *self)
g_return_if_fail (display);
priv->engine = xkl_engine_get_instance (display);
g_signal_connect (priv->engine, "X-state-changed",
G_CALLBACK(on_state_changed), self);
xkl_config_rec_get_from_server (&priv->config, priv->engine);
get_xkb_component_names (self);
xkl_engine_start_listen (priv->engine, XKLL_TRACK_KEYBOARD_STATE);
}
EekLayout *
eek_xkl_layout_new (gchar **layouts,
gchar **variants,
gchar **options)
eek_xkl_layout_new (void)
{
return g_object_new (EEK_TYPE_XKL_LAYOUT, NULL);
}
void
eek_xkl_layout_set_config (EekXklLayout *layout,
gchar **layouts,
gchar **variants,
gchar **options)
{
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
g_return_if_fail (priv);
g_strfreev (priv->config.layouts);
priv->config.layouts = g_strdupv (layouts);
g_strfreev (priv->config.variants);
priv->config.variants = g_strdupv (variants);
g_strfreev (priv->config.options);
priv->config.options = g_strdupv (options);
get_xkb_component_names (layout);
}
void
eek_xkl_layout_set_layouts (EekXklLayout *layout, gchar **layouts)
{
......@@ -268,6 +325,7 @@ get_xkb_component_names (EekXklLayout *layout)
XkbComponentNamesRec names;
if (xkl_xkb_config_native_prepare (priv->engine, &priv->config, &names)) {
g_debug ("symbols = \"%s\"", names.symbols);
EEK_XKB_LAYOUT_GET_CLASS (layout)->
set_names (EEK_XKB_LAYOUT(layout), &names);
xkl_xkb_config_native_cleanup (priv->engine, &names);
......
......@@ -51,7 +51,10 @@ struct _EekXklLayoutClass
GType eek_xkl_layout_get_type (void) G_GNUC_CONST;
EekLayout *eek_xkl_layout_new (gchar **layouts,
EekLayout *eek_xkl_layout_new (void);
void eek_xkl_layout_set_config (EekXklLayout *layout,
gchar **layouts,
gchar **variants,
gchar **options);
......@@ -63,7 +66,8 @@ void eek_xkl_layout_set_options (EekXklLayout *layout,
gchar **options);
gchar **eek_xkl_layout_get_layouts (EekXklLayout *layout);
gchar **eek_xkl_layout_get_variants (EekXklLayout *layout);
gchar **eek_xkl_layout_get_variants
(EekXklLayout *layout);
gchar **eek_xkl_layout_get_options (EekXklLayout *layout);
G_END_DECLS
......
#include "eek/eek-clutter.h"
#include "eek/eek-xkb.h"
#include <gtk/gtk.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek/eek-clutter.h"
#include "eek/eek-xkb.h"
#define CSW 640
#define CSH 480
......
# 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
bin_PROGRAMS = eekboard
eekboard_CFLAGS = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(CLUTTER_CFLAGS) $(CLUTTER_GTK_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS) $(LIBXKLAVIER_CFLAGS) $(LIBFAKEKEY_CFLAGS)
eekboard_LDFLAGS = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkl.la $(top_builddir)/eek/libeek-clutter.la $(GOBJECT2_LIBS) $(CLUTTER_LIBS) $(CLUTTER_GTK_LIBS) $(GTK2_CFLAGS) $(XKB_LIBS) $(LIBXKLAVIER_LIBS) $(LIBFAKEKEY_LIBS)
This diff is collapsed.
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