Fix object finalization.

Add XKL wrapper (not ready).
This commit is contained in:
Daiki Ueno
2010-06-10 17:52:44 +09:00
parent 9011a7309b
commit 43fdb5e960
26 changed files with 923 additions and 265 deletions

View File

@ -17,5 +17,5 @@
# 02110-1301 USA
noinst_PROGRAMS = eek-clutter-xkb-test
eek_clutter_xkb_test_CFLAGS = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(CLUTTER_CFLAGS) $(XKB_CFLAGS)
eek_clutter_xkb_test_LDFLAGS = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkb.la $(top_builddir)/eek/libeek-clutter.la $(GOBJECT2_LIBS) $(CLUTTER_LIBS) $(XKB_LIBS)
eek_clutter_xkb_test_CFLAGS = -I$(top_srcdir) $(GOBJECT2_CFLAGS) $(CLUTTER_CFLAGS) $(GTK2_CFLAGS) $(XKB_CFLAGS)
eek_clutter_xkb_test_LDFLAGS = $(top_builddir)/eek/libeek.la $(top_builddir)/eek/libeek-xkb.la $(top_builddir)/eek/libeek-clutter.la $(GOBJECT2_LIBS) $(CLUTTER_LIBS) $(GTK2_CFLAGS) $(XKB_LIBS)

View File

@ -1,5 +1,6 @@
#include "eek/eek-clutter.h"
#include "eek/eek-xkb.h"
#include <gtk/gtk.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -31,31 +32,6 @@ static const GOptionEntry options[] = {
gfloat stage_width, stage_height;
static gboolean
on_event (ClutterStage *stage,
ClutterEvent *event,
gpointer user_data)
{
if (event->type == CLUTTER_BUTTON_PRESS) {
ClutterActor *actor = clutter_event_get_source (event);
if (EEK_IS_KEY(actor)) {
guint keysym;
const gchar *label = NULL;
keysym = eek_key_get_keysym (EEK_KEY(actor));
if (keysym != EEK_INVALID_KEYSYM)
label = eek_keysym_to_string (keysym);
if (label) {
printf ("%s", label);
fflush (stdout);
}
}
return TRUE;
}
return FALSE;
}
static void
on_resize (GObject *object,
GParamSpec *param_spec,
@ -107,7 +83,6 @@ main (int argc, char *argv[])
g_option_context_free (context);
clutter_init (&argc, &argv);
gtk_init (&argc, &argv);
layout = eek_xkb_layout_new (keycodes, geometry, symbols);
@ -115,7 +90,6 @@ main (int argc, char *argv[])
fprintf (stderr, "Failed to create layout\n");
exit(1);
}
g_object_ref_sink (layout);
keyboard = eek_clutter_keyboard_new (CSW, CSH);
if (keyboard == NULL) {
@ -123,11 +97,13 @@ main (int argc, char *argv[])
fprintf (stderr, "Failed to create keyboard\n");
exit(1);
}
g_object_ref_sink (keyboard);
g_signal_connect (keyboard, "key-pressed", G_CALLBACK(key_pressed_event), NULL);
g_signal_connect (keyboard, "key-pressed",
G_CALLBACK(key_pressed_event), NULL);
eek_keyboard_set_layout (keyboard, layout);
actor = eek_clutter_keyboard_get_actor (EEK_CLUTTER_KEYBOARD(keyboard));
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE(stage), &stage_color);

View File

@ -1,70 +0,0 @@
#include "eek/eek-gtk.h"
#include "eek/eek-xkb.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
static gchar *symbols = NULL;
static gchar *keycodes = NULL;
static gchar *geometry = NULL;
static const GOptionEntry options[] = {
{"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
"Symbols component of the keyboard. If you omit this option, it is "
"obtained from the X server; that is, the keyboard that is currently "
"configured is drawn. Examples: --symbols=us or "
"--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL},
{"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
"Keycodes component of the keyboard. If you omit this option, it is "
"obtained from the X server; that is, the keyboard that is currently"
" configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
NULL},
{"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
"Geometry xkb component. If you omit this option, it is obtained from the"
" X server; that is, the keyboard that is currently configured is drawn. "
"Example: --geometry=kinesis", NULL},
{NULL},
};
gfloat window_width, window_height;
int
main (int argc, char *argv[])
{
EekKeyboard *keyboard;
EekLayout *layout;
GtkWidget *window;
GOptionContext *context;
context = g_option_context_new ("test-xkb-gtk");
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, NULL);
g_option_context_free (context);
gtk_init (&argc, &argv);
layout = eek_xkb_layout_new (keycodes, geometry, symbols);
if (layout == NULL) {
fprintf (stderr, "Failed to create layout\n");
exit(1);
}
g_object_ref_sink (layout);
keyboard = eek_gtk_keyboard_new ();
if (keyboard == NULL) {
g_object_unref (layout);
fprintf (stderr, "Failed to create keyboard\n");
exit(1);
}
g_object_ref_sink (keyboard);
eek_keyboard_set_layout (keyboard, layout);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add (GTK_CONTAINER(window), GTK_WIDGET(keyboard));
gtk_widget_show_all (window);
gtk_main ();
return 0;
}