diff --git a/eek/eek-clutter-drawing-context.c b/eek/eek-clutter-drawing-context.c index 8283cb7f..984f8e1e 100644 --- a/eek/eek-clutter-drawing-context.c +++ b/eek/eek-clutter-drawing-context.c @@ -72,6 +72,7 @@ eek_clutter_drawing_context_class_init (EekClutterDrawingContextClass *klass) sizeof (EekClutterDrawingContextPrivate)); gobject_class->finalize = eek_clutter_drawing_context_finalize; + gobject_class->dispose = eek_clutter_drawing_context_dispose; } static void diff --git a/eek/eek-clutter-keyboard.c b/eek/eek-clutter-keyboard.c index b6dfcc5b..1e45ad65 100644 --- a/eek/eek-clutter-keyboard.c +++ b/eek/eek-clutter-keyboard.c @@ -31,6 +31,7 @@ #include "eek-clutter-keyboard.h" #include "eek-clutter-drawing-context.h" #include "eek-keyboard.h" +#include "eek-drawing.h" G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, EEK_TYPE_KEYBOARD); @@ -266,7 +267,9 @@ update_category_fonts (EekClutterKeyboard *keyboard) base_font = pango_font_description_from_string ("Sans"); pango_layout_set_font_description (layout, base_font); pango_font_description_free (base_font); - eek_get_fonts (EEK_KEYBOARD(keyboard), layout, &fonts); + eek_get_fonts (EEK_KEYBOARD(keyboard), + layout, + (PangoFontDescription **)&fonts); for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++) { eek_clutter_drawing_context_set_category_font (priv->context, i, diff --git a/eek/eek-container.h b/eek/eek-container.h index dbd9ac83..ed9cdc70 100644 --- a/eek/eek-container.h +++ b/eek/eek-container.h @@ -74,7 +74,7 @@ struct _EekContainerClass GType eek_container_get_type (void) G_GNUC_CONST; -void eek_container_foreach_child (EekContainer *self, +void eek_container_foreach_child (EekContainer *container, EekCallback callback, gpointer user_data); EekElement *eek_container_find (EekContainer *container, diff --git a/eek/eek-key.c b/eek/eek-key.c index 0a45e211..f117ab38 100644 --- a/eek/eek-key.c +++ b/eek/eek-key.c @@ -201,7 +201,9 @@ eek_key_real_set_keysym_index (EekKey *self, g_return_if_fail (0 <= group); if (group >= priv->keysyms.num_groups) group = 0; - g_return_if_fail (0 <= level && level < priv->keysyms.num_levels); + g_return_if_fail (0 <= level); + if (level >= priv->keysyms.num_levels) + level = 0; priv->group = group; priv->level = level; } diff --git a/eek/eek-keyboard.c b/eek/eek-keyboard.c index 584c317d..aaff2c1f 100644 --- a/eek/eek-keyboard.c +++ b/eek/eek-keyboard.c @@ -430,8 +430,6 @@ eek_keyboard_get_keysym_index (EekKeyboard *keyboard, /** * eek_keyboard_create_section: * @keyboard: an #EekKeyboard - * @name: name of the section - * @bounds: bounding box of the section * * Create an #EekSection instance and append it to @keyboard. This * function is rarely called by application but called by #EekLayout diff --git a/eek/eek-keyboard.h b/eek/eek-keyboard.h index feff731a..1601dc4e 100644 --- a/eek/eek-keyboard.h +++ b/eek/eek-keyboard.h @@ -69,10 +69,10 @@ struct _EekKeyboardClass GType eek_keyboard_get_type (void) G_GNUC_CONST; -void eek_keyboard_set_keysym_index (EekKeyboard *self, +void eek_keyboard_set_keysym_index (EekKeyboard *keyboard, gint group, gint level); -void eek_keyboard_get_keysym_index (EekKeyboard *self, +void eek_keyboard_get_keysym_index (EekKeyboard *keyboard, gint *group, gint *level); @@ -80,7 +80,7 @@ EekSection *eek_keyboard_create_section (EekKeyboard *keyboard); void eek_keyboard_set_layout (EekKeyboard *keyboard, EekLayout *layout); -void eek_keyboard_realize (EekKeyboard *keyboard); +void eek_keyboard_realize (EekKeyboard *keyboard); EekKey *eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard, guint keycode); diff --git a/eek/eek-section.h b/eek/eek-section.h index ac8501a0..56d71595 100644 --- a/eek/eek-section.h +++ b/eek/eek-section.h @@ -90,7 +90,7 @@ EekKey *eek_section_create_key (EekSection *section, gint column, gint row); -EekKey *eek_section_find_key_by_keycode (EekSection *self, +EekKey *eek_section_find_key_by_keycode (EekSection *section, guint keycode); G_END_DECLS diff --git a/eek/eek-types.h b/eek/eek-types.h index 122692b8..b3c0282e 100644 --- a/eek/eek-types.h +++ b/eek/eek-types.h @@ -24,6 +24,15 @@ G_BEGIN_DECLS +/** + * EekOrientation: + * @EEK_ORIENTATION_VERTICAL: the elements will be arranged vertically + * @EEK_ORIENTATION_HORIZONTAL: the elements will be arranged horizontally + * @EEK_ORIENTATION_INVALID: used for error reporting + * + * Orientation of rows in sections. Elements in a row will be + * arranged with the specified orientation. + */ typedef enum { EEK_ORIENTATION_VERTICAL, EEK_ORIENTATION_HORIZONTAL, diff --git a/eek/eek-xkb-layout.c b/eek/eek-xkb-layout.c index 4794c4b3..c093b528 100644 --- a/eek/eek-xkb-layout.c +++ b/eek/eek-xkb-layout.c @@ -338,38 +338,6 @@ compare_component_name (gchar *name0, gchar *name1) 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); - - /* keycodes */ - if (compare_component_name (names->keycodes, priv->names.keycodes) != 0) - is_changed = TRUE; - g_free (priv->names.keycodes); - priv->names.keycodes = g_strdup (names->keycodes); - - /* geometry */ - if (compare_component_name (names->geometry, priv->names.geometry) != 0) - is_changed = TRUE; - g_free (priv->names.geometry); - priv->names.geometry = g_strdup (names->geometry); - - /* symbols */ - if (compare_component_name (names->symbols, priv->names.symbols) != 0) - is_changed = TRUE; - 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 eek_xkb_layout_finalize (GObject *object) { @@ -469,7 +437,6 @@ eek_xkb_layout_class_init (EekXkbLayoutClass *klass) g_type_class_add_private (gobject_class, sizeof (EekXkbLayoutPrivate)); - klass->set_names = eek_xkb_layout_real_set_names; gobject_class->finalize = eek_xkb_layout_finalize; gobject_class->set_property = eek_xkb_layout_set_property; gobject_class->get_property = eek_xkb_layout_get_property; @@ -609,29 +576,68 @@ eek_xkb_layout_new (const gchar *keycodes, return EEK_LAYOUT(layout); } +/** + * eek_xkb_layout_set_names: + * @layout: an #EekXkbLayout + * @names: XKB component names + * + * Set the XKB component names to @layout. + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean +eek_xkb_layout_set_names (EekXkbLayout *layout, XkbComponentNamesRec *names) +{ + EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout); + gboolean is_changed; + + g_return_val_if_fail (priv, FALSE); + + /* keycodes */ + if (compare_component_name (names->keycodes, priv->names.keycodes) != 0) + is_changed = TRUE; + g_free (priv->names.keycodes); + priv->names.keycodes = g_strdup (names->keycodes); + + /* geometry */ + if (compare_component_name (names->geometry, priv->names.geometry) != 0) + is_changed = TRUE; + g_free (priv->names.geometry); + priv->names.geometry = g_strdup (names->geometry); + + /* symbols */ + if (compare_component_name (names->symbols, priv->names.symbols) != 0) + is_changed = TRUE; + g_free (priv->names.symbols); + priv->names.symbols = g_strdup (names->symbols); + + get_keyboard (layout); + if (!priv->xkb) + return FALSE; + + if (is_changed) + g_signal_emit_by_name (layout, "changed"); + + return TRUE; +} + /** * eek_xkb_layout_set_keycodes: * @layout: an #EekXkbLayout * @keycodes: component name for keycodes * * Set the keycodes component (in the XKB terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise */ -void +gboolean eek_xkb_layout_set_keycodes (EekXkbLayout *layout, const gchar *keycodes) { EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout); - gboolean is_changed = TRUE; + XkbComponentNamesRec names; - 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"); + g_return_val_if_fail (priv, FALSE); + memcpy (&names, &priv->names, sizeof names); + names.keycodes = (gchar *)keycodes; + return eek_xkb_layout_set_names (layout, &names); } /** @@ -639,24 +645,18 @@ eek_xkb_layout_set_keycodes (EekXkbLayout *layout, const gchar *keycodes) * @layout: an #EekXkbLayout * @geometry: component name for geometry * - * Set the keycodes component (in the XKB terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise */ -void +gboolean eek_xkb_layout_set_geometry (EekXkbLayout *layout, const gchar *geometry) { EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout); - gboolean is_changed = TRUE; + XkbComponentNamesRec names; - 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"); + g_return_val_if_fail (priv, FALSE); + memcpy (&names, &priv->names, sizeof names); + names.geometry = (gchar *)geometry; + return eek_xkb_layout_set_names (layout, &names); } /** @@ -665,23 +665,18 @@ eek_xkb_layout_set_geometry (EekXkbLayout *layout, const gchar *geometry) * @symbols: component name for symbols * * Set the symbols component (in the XKB terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise */ -void +gboolean eek_xkb_layout_set_symbols (EekXkbLayout *layout, const gchar *symbols) { EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout); - gboolean is_changed = TRUE; + XkbComponentNamesRec names; - 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"); + g_return_val_if_fail (priv, FALSE); + memcpy (&names, &priv->names, sizeof names); + names.symbols = (gchar *)symbols; + return eek_xkb_layout_set_names (layout, &names); } /** diff --git a/eek/eek-xkb-layout.h b/eek/eek-xkb-layout.h index 52f73510..2d249fe0 100644 --- a/eek/eek-xkb-layout.h +++ b/eek/eek-xkb-layout.h @@ -49,27 +49,33 @@ struct _EekXkbLayoutClass { /*< private >*/ GInitiallyUnownedClass parent_class; - - void (* set_names) (EekXkbLayout *self, - XkbComponentNamesRec *names); }; -GType eek_xkb_layout_get_type (void) G_GNUC_CONST; +GType eek_xkb_layout_get_type (void) G_GNUC_CONST; -EekLayout *eek_xkb_layout_new (const gchar *keycodes, - const gchar *geometry, - const gchar *symbols); +EekLayout *eek_xkb_layout_new (const gchar *keycodes, + const gchar *geometry, + const gchar *symbols); -void eek_xkb_layout_set_keycodes (EekXkbLayout *layout, - const gchar *keycodes); -void eek_xkb_layout_set_geometry (EekXkbLayout *layout, - const gchar *geometry); -void eek_xkb_layout_set_symbols (EekXkbLayout *layout, - const gchar *symbols); -G_CONST_RETURN gchar *eek_xkb_layout_get_keycodes (EekXkbLayout *layout); -G_CONST_RETURN gchar *eek_xkb_layout_get_geometry (EekXkbLayout *layout); -G_CONST_RETURN gchar *eek_xkb_layout_get_symbols (EekXkbLayout *layout); +gboolean eek_xkb_layout_set_names (EekXkbLayout *layout, + XkbComponentNamesRec *names); +gboolean eek_xkb_layout_set_keycodes + (EekXkbLayout *layout, + const gchar *keycodes); +gboolean eek_xkb_layout_set_geometry + (EekXkbLayout *layout, + const gchar *geometry); +gboolean eek_xkb_layout_set_symbols + (EekXkbLayout *layout, + const gchar *symbols); + +G_CONST_RETURN gchar *eek_xkb_layout_get_keycodes + (EekXkbLayout *layout); +G_CONST_RETURN gchar *eek_xkb_layout_get_geometry + (EekXkbLayout *layout); +G_CONST_RETURN gchar *eek_xkb_layout_get_symbols + (EekXkbLayout *layout); G_END_DECLS #endif /* #ifndef EEK_XKB_LAYOUT_H */ diff --git a/eek/eek-xkl-layout.c b/eek/eek-xkl-layout.c index 21072b9a..4c697689 100644 --- a/eek/eek-xkl-layout.c +++ b/eek/eek-xkl-layout.c @@ -50,6 +50,7 @@ G_DEFINE_TYPE_WITH_CODE (EekXklLayout, eek_xkl_layout, EEK_TYPE_XKB_LAYOUT, enum { PROP_0, + PROP_MODEL, PROP_LAYOUTS, PROP_VARIANTS, PROP_OPTIONS, @@ -75,7 +76,8 @@ extern void xkl_xkb_config_native_cleanup (XklEngine * engine, XkbComponentNamesPtr component_names); -static void get_xkb_component_names (EekXklLayout *layout); +static gboolean set_xkb_component_names (EekXklLayout *layout, + XklConfigRec *config); static gint eek_xkl_layout_real_get_group (EekLayout *self) @@ -121,6 +123,10 @@ eek_xkl_layout_set_property (GObject *object, { switch (prop_id) { + case PROP_MODEL: + eek_xkl_layout_set_model (EEK_XKL_LAYOUT(object), + g_value_get_string (value)); + break; case PROP_LAYOUTS: eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object), g_value_get_boxed (value)); @@ -149,6 +155,11 @@ eek_xkl_layout_get_property (GObject *object, { switch (prop_id) { + case PROP_MODEL: + g_value_set_string + (value, + eek_xkl_layout_get_model (EEK_XKL_LAYOUT(object))); + break; case PROP_LAYOUTS: g_value_set_boxed (value, @@ -184,6 +195,23 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass) gobject_class->set_property = eek_xkl_layout_set_property; gobject_class->get_property = eek_xkl_layout_get_property; + /** + * EekXklLayout:model: + * + * The libxklavier model name of #EekXklLayout. + */ + pspec = g_param_spec_string ("model", + "Model", + "Libxklavier model", + NULL, + G_PARAM_READWRITE); + g_object_class_install_property (gobject_class, PROP_MODEL, pspec); + + /** + * EekXklLayout:layouts: + * + * The libxklavier layout names of #EekXklLayout. + */ pspec = g_param_spec_boxed ("layouts", "Layouts", "Libxklavier layouts", @@ -191,6 +219,11 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass) G_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_LAYOUTS, pspec); + /** + * EekXklLayout:variants: + * + * The libxklavier variant names of #EekXklLayout. + */ pspec = g_param_spec_boxed ("variants", "Variants", "Libxklavier variants", @@ -198,6 +231,11 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass) G_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_VARIANTS, pspec); + /** + * EekXklLayout:options: + * + * The libxklavier option names of #EekXklLayout. + */ pspec = g_param_spec_boxed ("options", "Options", "Libxklavier options", @@ -206,6 +244,8 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass) g_object_class_install_property (gobject_class, PROP_OPTIONS, pspec); } +/* Disabled since the current EekXklLayout implementation does not + change the server setting. */ #if 0 static void on_state_changed (XklEngine *xklengine, @@ -234,103 +274,179 @@ eek_xkl_layout_init (EekXklLayout *self) g_return_if_fail (display); priv->engine = xkl_engine_get_instance (display); + /* Disabled since the current EekXklLayout implementation does not + change the server setting. */ #if 0 g_signal_connect (priv->engine, "X-state-changed", G_CALLBACK(on_state_changed), self); xkl_engine_start_listen (priv->engine, XKLL_TRACK_KEYBOARD_STATE); #endif xkl_config_rec_get_from_server (priv->config, priv->engine); - get_xkb_component_names (self); + set_xkb_component_names (self, priv->config); } +/** + * eek_xkl_layout_new: + * + * Create a new #EekXklLayout. + */ EekLayout * eek_xkl_layout_new (void) { return g_object_new (EEK_TYPE_XKL_LAYOUT, NULL); } -void +G_INLINE_FUNC void +merge_xkl_config_rec (XklConfigRec *dst, XklConfigRec *src) +{ + if (src->model) { + g_free (dst->model); + dst->model = g_strdup (src->model); + } + if (src->layouts) { + g_strfreev (dst->layouts); + dst->layouts = g_strdupv (src->layouts); + } + if (src->variants) { + g_strfreev (dst->variants); + dst->variants = g_strdupv (src->variants); + } + if (src->options) { + g_strfreev (dst->options); + dst->options = g_strdupv (src->options); + } +} + +/** + * eek_xkl_layout_set_config: + * @layout: an #EekXklLayout + * @config: Libxklavier configuration + * + * Reconfigure @layout with @config. + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean eek_xkl_layout_set_config (EekXklLayout *layout, XklConfigRec *config) { EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout); + XklConfigRec *c; - g_return_if_fail (priv); - if (config->model) { - g_free (priv->config->model); - priv->config->model = g_strdup (config->model); + g_return_val_if_fail (priv, FALSE); + c = xkl_config_rec_new (); + merge_xkl_config_rec (c, priv->config); + merge_xkl_config_rec (c, config); + if (set_xkb_component_names (layout, c)) { + g_object_unref (c); + merge_xkl_config_rec (priv->config, config); + return TRUE; } - if (config->layouts) { - g_strfreev (priv->config->layouts); - priv->config->layouts = g_strdupv (config->layouts); - } - if (config->variants) { - g_strfreev (priv->config->variants); - priv->config->variants = g_strdupv (config->variants); - } - if (config->options) { - g_strfreev (priv->config->options); - priv->config->options = g_strdupv (config->options); - } - get_xkb_component_names (layout); + g_object_unref (c); + return FALSE; } -void +/** + * eek_xkl_layout_set_model: + * @layout: an #EekXklLayout + * @model: model name + * + * Set the model name of @layout configuration (in the Libxklavier terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean eek_xkl_layout_set_model (EekXklLayout *layout, - gchar *model) + const gchar *model) { EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout); XklConfigRec *config; + gboolean success; - g_return_if_fail (priv); + g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); - config->model = model; - eek_xkl_layout_set_config (layout, config); + config->model = (gchar *)model; + success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); + return success; } -void +/** + * eek_xkl_layout_set_layouts: + * @layout: an #EekXklLayout + * @layouts: layout names + * + * Set the layout names of @layout (in the Libxklavier terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean eek_xkl_layout_set_layouts (EekXklLayout *layout, gchar **layouts) { EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout); XklConfigRec *config; + gboolean success; - g_return_if_fail (priv); + g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); config->layouts = layouts; - eek_xkl_layout_set_config (layout, config); + success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); + return success; } -void +/** + * eek_xkl_layout_set_variants: + * @layout: an #EekXklLayout + * @variants: variant names + * + * Set the variant names of @layout (in the Libxklavier terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean eek_xkl_layout_set_variants (EekXklLayout *layout, gchar **variants) { EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout); XklConfigRec *config; + gboolean success; - g_return_if_fail (priv); + g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); config->variants = variants; - eek_xkl_layout_set_config (layout, config); + success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); + return success; } -void +/** + * eek_xkl_layout_set_options: + * @layout: an #EekXklLayout + * @options: option names + * + * Set the option names of @layout (in the Libxklavier terminology). + * Returns: %TRUE if the component name is successfully set, %FALSE otherwise + */ +gboolean eek_xkl_layout_set_options (EekXklLayout *layout, gchar **options) { EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout); XklConfigRec *config; + gboolean success; - g_return_if_fail (priv); + g_return_val_if_fail (priv, FALSE); config = xkl_config_rec_new (); config->options = options; - eek_xkl_layout_set_config (layout, config); + success = eek_xkl_layout_set_config (layout, config); g_object_unref (config); + return success; } +/** + * eek_xkl_layout_get_model: + * @layout: an #EekXklLayout + * + * Get the model name of @layout configuration (in the Libxklavier terminology). + */ gchar * eek_xkl_layout_get_model (EekXklLayout *layout) { @@ -340,6 +456,13 @@ eek_xkl_layout_get_model (EekXklLayout *layout) return priv->config->model; } +/** + * eek_xkl_layout_get_layouts: + * @layout: an #EekXklLayout + * + * Get the layout names of @layout configuration (in the Libxklavier + * terminology). + */ gchar ** eek_xkl_layout_get_layouts (EekXklLayout *layout) { @@ -349,6 +472,13 @@ eek_xkl_layout_get_layouts (EekXklLayout *layout) return priv->config->layouts; } +/** + * eek_xkl_layout_get_variants: + * @layout: an #EekXklLayout + * + * Get the variant names of @layout configuration (in the Libxklavier + * terminology). + */ gchar ** eek_xkl_layout_get_variants (EekXklLayout *layout) { @@ -358,6 +488,13 @@ eek_xkl_layout_get_variants (EekXklLayout *layout) return priv->config->variants; } +/** + * eek_xkl_layout_get_options: + * @layout: an #EekXklLayout + * + * Get the option names of @layout configuration (in the Libxklavier + * terminology). + */ gchar ** eek_xkl_layout_get_options (EekXklLayout *layout) { @@ -367,15 +504,21 @@ eek_xkl_layout_get_options (EekXklLayout *layout) return priv->config->options; } -static void -get_xkb_component_names (EekXklLayout *layout) +static gboolean +set_xkb_component_names (EekXklLayout *layout, XklConfigRec *config) { EekXklLayoutPrivate *priv = layout->priv; XkbComponentNamesRec names; + gboolean success = FALSE; - if (xkl_xkb_config_native_prepare (priv->engine, priv->config, &names)) { - EEK_XKB_LAYOUT_GET_CLASS (layout)-> - set_names (EEK_XKB_LAYOUT(layout), &names); + /* Disabled since the current EekXklLayout implementation does not + change the server setting. */ +#if 0 + xkl_config_rec_activate (priv->engine, config); +#endif + if (xkl_xkb_config_native_prepare (priv->engine, config, &names)) { + success = eek_xkb_layout_set_names (EEK_XKB_LAYOUT(layout), &names); xkl_xkb_config_native_cleanup (priv->engine, &names); } + return success; } diff --git a/eek/eek-xkl-layout.h b/eek/eek-xkl-layout.h index 409d47e4..a647520c 100644 --- a/eek/eek-xkl-layout.h +++ b/eek/eek-xkl-layout.h @@ -53,16 +53,16 @@ GType eek_xkl_layout_get_type (void) G_GNUC_CONST; EekLayout *eek_xkl_layout_new (void); -void eek_xkl_layout_set_config (EekXklLayout *layout, +gboolean eek_xkl_layout_set_config (EekXklLayout *layout, XklConfigRec *config); -void eek_xkl_layout_set_model (EekXklLayout *layout, - gchar *model); -void eek_xkl_layout_set_layouts (EekXklLayout *layout, +gboolean eek_xkl_layout_set_model (EekXklLayout *layout, + const gchar *model); +gboolean eek_xkl_layout_set_layouts (EekXklLayout *layout, gchar **layouts); -void eek_xkl_layout_set_variants (EekXklLayout *layout, +gboolean eek_xkl_layout_set_variants (EekXklLayout *layout, gchar **variants); -void eek_xkl_layout_set_options (EekXklLayout *layout, +gboolean eek_xkl_layout_set_options (EekXklLayout *layout, gchar **options); gchar *eek_xkl_layout_get_model (EekXklLayout *layout); diff --git a/src/eekboard-gtk.c b/src/eekboard-gtk.c index ce2d618b..e431335f 100644 --- a/src/eekboard-gtk.c +++ b/src/eekboard-gtk.c @@ -462,7 +462,7 @@ main (int argc, char *argv[]) bounds.width = CSW; bounds.height = CSH; eekboard.keyboard = eek_gtk_keyboard_new (); - eek_element_set_bounds (eekboard.keyboard, &bounds); + eek_element_set_bounds (EEK_ELEMENT(eekboard.keyboard), &bounds); eek_keyboard_set_layout (eekboard.keyboard, eekboard.layout); embed = eek_gtk_keyboard_get_widget (EEK_GTK_KEYBOARD (eekboard.keyboard));