Use GInitable to define EekXklLayout.

This commit is contained in:
Daiki Ueno
2012-03-16 17:36:20 +09:00
parent 32a1d23c2a
commit a6fe5bd859
9 changed files with 224 additions and 132 deletions

View File

@ -153,6 +153,8 @@ static const GDBusInterfaceVTable interface_vtable =
NULL
};
static Display *display = NULL;
static EekKeyboard *
eekboard_context_service_real_create_keyboard (EekboardContextService *self,
const gchar *keyboard_type)
@ -163,8 +165,19 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
if (g_str_has_prefix (keyboard_type, "xkb:")) {
XklConfigRec *rec =
eekboard_xkl_config_rec_from_string (&keyboard_type[4]);
GError *error;
if (display == NULL)
display = XOpenDisplay (NULL);
error = NULL;
layout = eek_xkl_layout_new (display, &error);
if (layout == NULL) {
g_warning ("can't create keyboard: %s", error->message);
g_error_free (error);
return NULL;
}
layout = eek_xkl_layout_new ();
if (!eek_xkl_layout_set_config (EEK_XKL_LAYOUT(layout), rec)) {
g_object_unref (layout);
return NULL;