EekKey#set_keysym_index(): fallback to level 0 when level exceeds num_levels
This commit is contained in:
		@ -72,6 +72,7 @@ eek_clutter_drawing_context_class_init (EekClutterDrawingContextClass *klass)
 | 
				
			|||||||
                              sizeof (EekClutterDrawingContextPrivate));
 | 
					                              sizeof (EekClutterDrawingContextPrivate));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    gobject_class->finalize = eek_clutter_drawing_context_finalize;
 | 
					    gobject_class->finalize = eek_clutter_drawing_context_finalize;
 | 
				
			||||||
 | 
					    gobject_class->dispose = eek_clutter_drawing_context_dispose;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@
 | 
				
			|||||||
#include "eek-clutter-keyboard.h"
 | 
					#include "eek-clutter-keyboard.h"
 | 
				
			||||||
#include "eek-clutter-drawing-context.h"
 | 
					#include "eek-clutter-drawing-context.h"
 | 
				
			||||||
#include "eek-keyboard.h"
 | 
					#include "eek-keyboard.h"
 | 
				
			||||||
 | 
					#include "eek-drawing.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, EEK_TYPE_KEYBOARD);
 | 
					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");
 | 
					    base_font = pango_font_description_from_string ("Sans");
 | 
				
			||||||
    pango_layout_set_font_description (layout, base_font);
 | 
					    pango_layout_set_font_description (layout, base_font);
 | 
				
			||||||
    pango_font_description_free (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++) {
 | 
					    for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++) {
 | 
				
			||||||
        eek_clutter_drawing_context_set_category_font (priv->context,
 | 
					        eek_clutter_drawing_context_set_category_font (priv->context,
 | 
				
			||||||
                                                       i,
 | 
					                                                       i,
 | 
				
			||||||
 | 
				
			|||||||
@ -74,7 +74,7 @@ struct _EekContainerClass
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
GType       eek_container_get_type      (void) G_GNUC_CONST;
 | 
					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,
 | 
					                                         EekCallback    callback,
 | 
				
			||||||
                                         gpointer       user_data);
 | 
					                                         gpointer       user_data);
 | 
				
			||||||
EekElement *eek_container_find          (EekContainer  *container,
 | 
					EekElement *eek_container_find          (EekContainer  *container,
 | 
				
			||||||
 | 
				
			|||||||
@ -201,7 +201,9 @@ eek_key_real_set_keysym_index (EekKey *self,
 | 
				
			|||||||
    g_return_if_fail (0 <= group);
 | 
					    g_return_if_fail (0 <= group);
 | 
				
			||||||
    if (group >= priv->keysyms.num_groups)
 | 
					    if (group >= priv->keysyms.num_groups)
 | 
				
			||||||
        group = 0;
 | 
					        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->group = group;
 | 
				
			||||||
    priv->level = level;
 | 
					    priv->level = level;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -430,8 +430,6 @@ eek_keyboard_get_keysym_index (EekKeyboard *keyboard,
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * eek_keyboard_create_section:
 | 
					 * eek_keyboard_create_section:
 | 
				
			||||||
 * @keyboard: an #EekKeyboard
 | 
					 * @keyboard: an #EekKeyboard
 | 
				
			||||||
 * @name: name of the section
 | 
					 | 
				
			||||||
 * @bounds: bounding box of the section
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Create an #EekSection instance and append it to @keyboard.  This
 | 
					 * Create an #EekSection instance and append it to @keyboard.  This
 | 
				
			||||||
 * function is rarely called by application but called by #EekLayout
 | 
					 * function is rarely called by application but called by #EekLayout
 | 
				
			||||||
 | 
				
			|||||||
@ -69,10 +69,10 @@ struct _EekKeyboardClass
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
GType       eek_keyboard_get_type            (void) G_GNUC_CONST;
 | 
					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         group,
 | 
				
			||||||
                                              gint         level);
 | 
					                                              gint         level);
 | 
				
			||||||
void        eek_keyboard_get_keysym_index    (EekKeyboard *self,
 | 
					void        eek_keyboard_get_keysym_index    (EekKeyboard *keyboard,
 | 
				
			||||||
                                              gint        *group,
 | 
					                                              gint        *group,
 | 
				
			||||||
                                              gint        *level);
 | 
					                                              gint        *level);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -80,7 +80,7 @@ EekSection *eek_keyboard_create_section      (EekKeyboard *keyboard);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void        eek_keyboard_set_layout          (EekKeyboard *keyboard,
 | 
					void        eek_keyboard_set_layout          (EekKeyboard *keyboard,
 | 
				
			||||||
                                              EekLayout   *layout);
 | 
					                                              EekLayout   *layout);
 | 
				
			||||||
void        eek_keyboard_realize          (EekKeyboard *keyboard);
 | 
					void        eek_keyboard_realize             (EekKeyboard *keyboard);
 | 
				
			||||||
EekKey     *eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard,
 | 
					EekKey     *eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard,
 | 
				
			||||||
                                              guint        keycode);
 | 
					                                              guint        keycode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -90,7 +90,7 @@ EekKey *eek_section_create_key          (EekSection     *section,
 | 
				
			|||||||
                                         gint            column,
 | 
					                                         gint            column,
 | 
				
			||||||
                                         gint            row);
 | 
					                                         gint            row);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EekKey *eek_section_find_key_by_keycode (EekSection     *self,
 | 
					EekKey *eek_section_find_key_by_keycode (EekSection     *section,
 | 
				
			||||||
                                         guint           keycode);
 | 
					                                         guint           keycode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
G_END_DECLS
 | 
					G_END_DECLS
 | 
				
			||||||
 | 
				
			|||||||
@ -24,6 +24,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
G_BEGIN_DECLS
 | 
					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 {
 | 
					typedef enum {
 | 
				
			||||||
    EEK_ORIENTATION_VERTICAL,
 | 
					    EEK_ORIENTATION_VERTICAL,
 | 
				
			||||||
    EEK_ORIENTATION_HORIZONTAL,
 | 
					    EEK_ORIENTATION_HORIZONTAL,
 | 
				
			||||||
 | 
				
			|||||||
@ -338,38 +338,6 @@ compare_component_name (gchar *name0, gchar *name1)
 | 
				
			|||||||
        return 0;
 | 
					        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
 | 
					static void
 | 
				
			||||||
eek_xkb_layout_finalize (GObject *object)
 | 
					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));
 | 
					    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->finalize = eek_xkb_layout_finalize;
 | 
				
			||||||
    gobject_class->set_property = eek_xkb_layout_set_property;
 | 
					    gobject_class->set_property = eek_xkb_layout_set_property;
 | 
				
			||||||
    gobject_class->get_property = eek_xkb_layout_get_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);
 | 
					    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:
 | 
					 * eek_xkb_layout_set_keycodes:
 | 
				
			||||||
 * @layout: an #EekXkbLayout
 | 
					 * @layout: an #EekXkbLayout
 | 
				
			||||||
 * @keycodes: component name for keycodes
 | 
					 * @keycodes: component name for keycodes
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Set the keycodes component (in the XKB terminology).
 | 
					 * 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)
 | 
					eek_xkb_layout_set_keycodes (EekXkbLayout *layout, const gchar *keycodes)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    gboolean is_changed = TRUE;
 | 
					    XkbComponentNamesRec names;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    if (keycodes && priv->names.keycodes)
 | 
					    memcpy (&names, &priv->names, sizeof names);
 | 
				
			||||||
        is_changed = g_strcmp0 (keycodes, priv->names.keycodes) != 0;
 | 
					    names.keycodes = (gchar *)keycodes;
 | 
				
			||||||
    else if (keycodes == NULL && priv->names.keycodes == NULL)
 | 
					    return eek_xkb_layout_set_names (layout, &names);
 | 
				
			||||||
        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");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -639,24 +645,18 @@ eek_xkb_layout_set_keycodes (EekXkbLayout *layout, const gchar *keycodes)
 | 
				
			|||||||
 * @layout: an #EekXkbLayout
 | 
					 * @layout: an #EekXkbLayout
 | 
				
			||||||
 * @geometry: component name for geometry
 | 
					 * @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)
 | 
					eek_xkb_layout_set_geometry (EekXkbLayout *layout, const gchar *geometry)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    gboolean is_changed = TRUE;
 | 
					    XkbComponentNamesRec names;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    if (geometry && priv->names.geometry)
 | 
					    memcpy (&names, &priv->names, sizeof names);
 | 
				
			||||||
        is_changed = g_strcmp0 (geometry, priv->names.geometry) != 0;
 | 
					    names.geometry = (gchar *)geometry;
 | 
				
			||||||
    else if (geometry == NULL && priv->names.geometry == NULL)
 | 
					    return eek_xkb_layout_set_names (layout, &names);
 | 
				
			||||||
        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");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -665,23 +665,18 @@ eek_xkb_layout_set_geometry (EekXkbLayout *layout, const gchar *geometry)
 | 
				
			|||||||
 * @symbols: component name for symbols
 | 
					 * @symbols: component name for symbols
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Set the symbols component (in the XKB terminology).
 | 
					 * 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)
 | 
					eek_xkb_layout_set_symbols (EekXkbLayout *layout, const gchar *symbols)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    gboolean is_changed = TRUE;
 | 
					    XkbComponentNamesRec names;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    if (symbols && priv->names.symbols)
 | 
					    memcpy (&names, &priv->names, sizeof names);
 | 
				
			||||||
        is_changed = g_strcmp0 (symbols, priv->names.symbols) != 0;
 | 
					    names.symbols = (gchar *)symbols;
 | 
				
			||||||
    else if (symbols == NULL && priv->names.symbols == NULL)
 | 
					    return eek_xkb_layout_set_names (layout, &names);
 | 
				
			||||||
        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");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
				
			|||||||
@ -49,27 +49,33 @@ struct _EekXkbLayoutClass
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    /*< private >*/
 | 
					    /*< private >*/
 | 
				
			||||||
    GInitiallyUnownedClass parent_class;
 | 
					    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,
 | 
					EekLayout            *eek_xkb_layout_new       (const gchar          *keycodes,
 | 
				
			||||||
                                                   const gchar  *geometry,
 | 
					                                                const gchar          *geometry,
 | 
				
			||||||
                                                   const gchar  *symbols);
 | 
					                                                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);
 | 
					gboolean              eek_xkb_layout_set_names (EekXkbLayout         *layout,
 | 
				
			||||||
G_CONST_RETURN gchar *eek_xkb_layout_get_geometry (EekXkbLayout *layout);
 | 
					                                                XkbComponentNamesRec *names);
 | 
				
			||||||
G_CONST_RETURN gchar *eek_xkb_layout_get_symbols  (EekXkbLayout *layout);
 | 
					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
 | 
					G_END_DECLS
 | 
				
			||||||
#endif				/* #ifndef EEK_XKB_LAYOUT_H */
 | 
					#endif				/* #ifndef EEK_XKB_LAYOUT_H */
 | 
				
			||||||
 | 
				
			|||||||
@ -50,6 +50,7 @@ G_DEFINE_TYPE_WITH_CODE (EekXklLayout, eek_xkl_layout, EEK_TYPE_XKB_LAYOUT,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
enum {
 | 
					enum {
 | 
				
			||||||
    PROP_0,
 | 
					    PROP_0,
 | 
				
			||||||
 | 
					    PROP_MODEL,
 | 
				
			||||||
    PROP_LAYOUTS,
 | 
					    PROP_LAYOUTS,
 | 
				
			||||||
    PROP_VARIANTS,
 | 
					    PROP_VARIANTS,
 | 
				
			||||||
    PROP_OPTIONS,
 | 
					    PROP_OPTIONS,
 | 
				
			||||||
@ -75,7 +76,8 @@ extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
 | 
				
			|||||||
					   XkbComponentNamesPtr
 | 
										   XkbComponentNamesPtr
 | 
				
			||||||
					   component_names);
 | 
										   component_names);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void get_xkb_component_names (EekXklLayout *layout);
 | 
					static gboolean set_xkb_component_names (EekXklLayout *layout,
 | 
				
			||||||
 | 
					                                         XklConfigRec *config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static gint
 | 
					static gint
 | 
				
			||||||
eek_xkl_layout_real_get_group (EekLayout *self)
 | 
					eek_xkl_layout_real_get_group (EekLayout *self)
 | 
				
			||||||
@ -121,6 +123,10 @@ eek_xkl_layout_set_property (GObject      *object,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    switch (prop_id) 
 | 
					    switch (prop_id) 
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					        case PROP_MODEL:
 | 
				
			||||||
 | 
					            eek_xkl_layout_set_model (EEK_XKL_LAYOUT(object),
 | 
				
			||||||
 | 
					                                      g_value_get_string (value));
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        case PROP_LAYOUTS:
 | 
					        case PROP_LAYOUTS:
 | 
				
			||||||
            eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object),
 | 
					            eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object),
 | 
				
			||||||
                                        g_value_get_boxed (value));
 | 
					                                        g_value_get_boxed (value));
 | 
				
			||||||
@ -149,6 +155,11 @@ eek_xkl_layout_get_property (GObject    *object,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    switch (prop_id) 
 | 
					    switch (prop_id) 
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					        case PROP_MODEL:
 | 
				
			||||||
 | 
					            g_value_set_string
 | 
				
			||||||
 | 
					                (value,
 | 
				
			||||||
 | 
					                 eek_xkl_layout_get_model (EEK_XKL_LAYOUT(object)));
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        case PROP_LAYOUTS:
 | 
					        case PROP_LAYOUTS:
 | 
				
			||||||
            g_value_set_boxed
 | 
					            g_value_set_boxed
 | 
				
			||||||
                (value,
 | 
					                (value,
 | 
				
			||||||
@ -184,6 +195,23 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass)
 | 
				
			|||||||
    gobject_class->set_property = eek_xkl_layout_set_property;
 | 
					    gobject_class->set_property = eek_xkl_layout_set_property;
 | 
				
			||||||
    gobject_class->get_property = eek_xkl_layout_get_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",
 | 
					    pspec = g_param_spec_boxed ("layouts",
 | 
				
			||||||
                                "Layouts",
 | 
					                                "Layouts",
 | 
				
			||||||
                                "Libxklavier layouts",
 | 
					                                "Libxklavier layouts",
 | 
				
			||||||
@ -191,6 +219,11 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass)
 | 
				
			|||||||
                                G_PARAM_READWRITE);
 | 
					                                G_PARAM_READWRITE);
 | 
				
			||||||
    g_object_class_install_property (gobject_class, PROP_LAYOUTS, pspec);
 | 
					    g_object_class_install_property (gobject_class, PROP_LAYOUTS, pspec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * EekXklLayout:variants:
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * The libxklavier variant names of #EekXklLayout.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    pspec = g_param_spec_boxed ("variants",
 | 
					    pspec = g_param_spec_boxed ("variants",
 | 
				
			||||||
                                "Variants",
 | 
					                                "Variants",
 | 
				
			||||||
                                "Libxklavier variants",
 | 
					                                "Libxklavier variants",
 | 
				
			||||||
@ -198,6 +231,11 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass)
 | 
				
			|||||||
                                G_PARAM_READWRITE);
 | 
					                                G_PARAM_READWRITE);
 | 
				
			||||||
    g_object_class_install_property (gobject_class, PROP_VARIANTS, pspec);
 | 
					    g_object_class_install_property (gobject_class, PROP_VARIANTS, pspec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * EekXklLayout:options:
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * The libxklavier option names of #EekXklLayout.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
    pspec = g_param_spec_boxed ("options",
 | 
					    pspec = g_param_spec_boxed ("options",
 | 
				
			||||||
                                "Options",
 | 
					                                "Options",
 | 
				
			||||||
                                "Libxklavier options",
 | 
					                                "Libxklavier options",
 | 
				
			||||||
@ -206,6 +244,8 @@ eek_xkl_layout_class_init (EekXklLayoutClass *klass)
 | 
				
			|||||||
    g_object_class_install_property (gobject_class, PROP_OPTIONS, pspec);
 | 
					    g_object_class_install_property (gobject_class, PROP_OPTIONS, pspec);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Disabled since the current EekXklLayout implementation does not
 | 
				
			||||||
 | 
					   change the server setting. */
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_state_changed (XklEngine           *xklengine,
 | 
					on_state_changed (XklEngine           *xklengine,
 | 
				
			||||||
@ -234,103 +274,179 @@ eek_xkl_layout_init (EekXklLayout *self)
 | 
				
			|||||||
    g_return_if_fail (display);
 | 
					    g_return_if_fail (display);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    priv->engine = xkl_engine_get_instance (display);
 | 
					    priv->engine = xkl_engine_get_instance (display);
 | 
				
			||||||
 | 
					    /* Disabled since the current EekXklLayout implementation does not
 | 
				
			||||||
 | 
					       change the server setting. */
 | 
				
			||||||
#if 0
 | 
					#if 0
 | 
				
			||||||
    g_signal_connect (priv->engine, "X-state-changed",
 | 
					    g_signal_connect (priv->engine, "X-state-changed",
 | 
				
			||||||
                      G_CALLBACK(on_state_changed), self);
 | 
					                      G_CALLBACK(on_state_changed), self);
 | 
				
			||||||
    xkl_engine_start_listen (priv->engine, XKLL_TRACK_KEYBOARD_STATE);
 | 
					    xkl_engine_start_listen (priv->engine, XKLL_TRACK_KEYBOARD_STATE);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    xkl_config_rec_get_from_server (priv->config, priv->engine);
 | 
					    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 *
 | 
					EekLayout *
 | 
				
			||||||
eek_xkl_layout_new (void)
 | 
					eek_xkl_layout_new (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return g_object_new (EEK_TYPE_XKL_LAYOUT, NULL);
 | 
					    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,
 | 
					eek_xkl_layout_set_config (EekXklLayout *layout,
 | 
				
			||||||
                           XklConfigRec *config)
 | 
					                           XklConfigRec *config)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
 | 
					    XklConfigRec *c;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    if (config->model) {
 | 
					    c = xkl_config_rec_new ();
 | 
				
			||||||
        g_free (priv->config->model);
 | 
					    merge_xkl_config_rec (c, priv->config);
 | 
				
			||||||
        priv->config->model = g_strdup (config->model);
 | 
					    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_object_unref (c);
 | 
				
			||||||
        g_strfreev (priv->config->layouts);
 | 
					    return FALSE;
 | 
				
			||||||
        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);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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,
 | 
					eek_xkl_layout_set_model (EekXklLayout *layout,
 | 
				
			||||||
                          gchar        *model)
 | 
					                          const gchar  *model)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    XklConfigRec *config;
 | 
					    XklConfigRec *config;
 | 
				
			||||||
 | 
					    gboolean success;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    config = xkl_config_rec_new ();
 | 
					    config = xkl_config_rec_new ();
 | 
				
			||||||
    config->model = model;
 | 
					    config->model = (gchar *)model;
 | 
				
			||||||
    eek_xkl_layout_set_config (layout, config);
 | 
					    success = eek_xkl_layout_set_config (layout, config);
 | 
				
			||||||
    g_object_unref (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,
 | 
					eek_xkl_layout_set_layouts (EekXklLayout *layout,
 | 
				
			||||||
                            gchar       **layouts)
 | 
					                            gchar       **layouts)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    XklConfigRec *config;
 | 
					    XklConfigRec *config;
 | 
				
			||||||
 | 
					    gboolean success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    config = xkl_config_rec_new ();
 | 
					    config = xkl_config_rec_new ();
 | 
				
			||||||
    config->layouts = layouts;
 | 
					    config->layouts = layouts;
 | 
				
			||||||
    eek_xkl_layout_set_config (layout, config);
 | 
					    success = eek_xkl_layout_set_config (layout, config);
 | 
				
			||||||
    g_object_unref (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,
 | 
					eek_xkl_layout_set_variants (EekXklLayout *layout,
 | 
				
			||||||
                             gchar       **variants)
 | 
					                             gchar       **variants)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    XklConfigRec *config;
 | 
					    XklConfigRec *config;
 | 
				
			||||||
 | 
					    gboolean success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    config = xkl_config_rec_new ();
 | 
					    config = xkl_config_rec_new ();
 | 
				
			||||||
    config->variants = variants;
 | 
					    config->variants = variants;
 | 
				
			||||||
    eek_xkl_layout_set_config (layout, config);
 | 
					    success = eek_xkl_layout_set_config (layout, config);
 | 
				
			||||||
    g_object_unref (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,
 | 
					eek_xkl_layout_set_options (EekXklLayout *layout,
 | 
				
			||||||
                            gchar       **options)
 | 
					                            gchar       **options)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
					    EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
 | 
				
			||||||
    XklConfigRec *config;
 | 
					    XklConfigRec *config;
 | 
				
			||||||
 | 
					    gboolean success;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    g_return_if_fail (priv);
 | 
					    g_return_val_if_fail (priv, FALSE);
 | 
				
			||||||
    config = xkl_config_rec_new ();
 | 
					    config = xkl_config_rec_new ();
 | 
				
			||||||
    config->options = options;
 | 
					    config->options = options;
 | 
				
			||||||
    eek_xkl_layout_set_config (layout, config);
 | 
					    success = eek_xkl_layout_set_config (layout, config);
 | 
				
			||||||
    g_object_unref (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 *
 | 
					gchar *
 | 
				
			||||||
eek_xkl_layout_get_model (EekXklLayout *layout)
 | 
					eek_xkl_layout_get_model (EekXklLayout *layout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -340,6 +456,13 @@ eek_xkl_layout_get_model (EekXklLayout *layout)
 | 
				
			|||||||
    return priv->config->model;
 | 
					    return priv->config->model;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * eek_xkl_layout_get_layouts:
 | 
				
			||||||
 | 
					 * @layout: an #EekXklLayout
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Get the layout names of @layout configuration (in the Libxklavier
 | 
				
			||||||
 | 
					 * terminology).
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
gchar **
 | 
					gchar **
 | 
				
			||||||
eek_xkl_layout_get_layouts (EekXklLayout *layout)
 | 
					eek_xkl_layout_get_layouts (EekXklLayout *layout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -349,6 +472,13 @@ eek_xkl_layout_get_layouts (EekXklLayout *layout)
 | 
				
			|||||||
    return priv->config->layouts;
 | 
					    return priv->config->layouts;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * eek_xkl_layout_get_variants:
 | 
				
			||||||
 | 
					 * @layout: an #EekXklLayout
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Get the variant names of @layout configuration (in the Libxklavier
 | 
				
			||||||
 | 
					 * terminology).
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
gchar **
 | 
					gchar **
 | 
				
			||||||
eek_xkl_layout_get_variants (EekXklLayout *layout)
 | 
					eek_xkl_layout_get_variants (EekXklLayout *layout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -358,6 +488,13 @@ eek_xkl_layout_get_variants (EekXklLayout *layout)
 | 
				
			|||||||
    return priv->config->variants;
 | 
					    return priv->config->variants;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * eek_xkl_layout_get_options:
 | 
				
			||||||
 | 
					 * @layout: an #EekXklLayout
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Get the option names of @layout configuration (in the Libxklavier
 | 
				
			||||||
 | 
					 * terminology).
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
gchar **
 | 
					gchar **
 | 
				
			||||||
eek_xkl_layout_get_options (EekXklLayout *layout)
 | 
					eek_xkl_layout_get_options (EekXklLayout *layout)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -367,15 +504,21 @@ eek_xkl_layout_get_options (EekXklLayout *layout)
 | 
				
			|||||||
    return priv->config->options;
 | 
					    return priv->config->options;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static gboolean
 | 
				
			||||||
get_xkb_component_names (EekXklLayout *layout)
 | 
					set_xkb_component_names (EekXklLayout *layout, XklConfigRec *config)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekXklLayoutPrivate *priv = layout->priv;
 | 
					    EekXklLayoutPrivate *priv = layout->priv;
 | 
				
			||||||
    XkbComponentNamesRec names;
 | 
					    XkbComponentNamesRec names;
 | 
				
			||||||
 | 
					    gboolean success = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (xkl_xkb_config_native_prepare (priv->engine, priv->config, &names)) {
 | 
					    /* Disabled since the current EekXklLayout implementation does not
 | 
				
			||||||
        EEK_XKB_LAYOUT_GET_CLASS (layout)->
 | 
					       change the server setting. */
 | 
				
			||||||
            set_names (EEK_XKB_LAYOUT(layout), &names);
 | 
					#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);
 | 
					        xkl_xkb_config_native_cleanup (priv->engine, &names);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return success;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -53,16 +53,16 @@ GType      eek_xkl_layout_get_type     (void) G_GNUC_CONST;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
EekLayout *eek_xkl_layout_new          (void);
 | 
					EekLayout *eek_xkl_layout_new          (void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void       eek_xkl_layout_set_config   (EekXklLayout *layout,
 | 
					gboolean   eek_xkl_layout_set_config   (EekXklLayout *layout,
 | 
				
			||||||
                                        XklConfigRec *config);
 | 
					                                        XklConfigRec *config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void       eek_xkl_layout_set_model    (EekXklLayout *layout,
 | 
					gboolean   eek_xkl_layout_set_model    (EekXklLayout *layout,
 | 
				
			||||||
                                        gchar        *model);
 | 
					                                        const gchar  *model);
 | 
				
			||||||
void       eek_xkl_layout_set_layouts  (EekXklLayout *layout,
 | 
					gboolean   eek_xkl_layout_set_layouts  (EekXklLayout *layout,
 | 
				
			||||||
                                        gchar       **layouts);
 | 
					                                        gchar       **layouts);
 | 
				
			||||||
void       eek_xkl_layout_set_variants (EekXklLayout *layout,
 | 
					gboolean   eek_xkl_layout_set_variants (EekXklLayout *layout,
 | 
				
			||||||
                                        gchar       **variants);
 | 
					                                        gchar       **variants);
 | 
				
			||||||
void       eek_xkl_layout_set_options  (EekXklLayout *layout,
 | 
					gboolean   eek_xkl_layout_set_options  (EekXklLayout *layout,
 | 
				
			||||||
                                        gchar       **options);
 | 
					                                        gchar       **options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gchar     *eek_xkl_layout_get_model    (EekXklLayout *layout);
 | 
					gchar     *eek_xkl_layout_get_model    (EekXklLayout *layout);
 | 
				
			||||||
 | 
				
			|||||||
@ -462,7 +462,7 @@ main (int argc, char *argv[])
 | 
				
			|||||||
    bounds.width = CSW;
 | 
					    bounds.width = CSW;
 | 
				
			||||||
    bounds.height = CSH;
 | 
					    bounds.height = CSH;
 | 
				
			||||||
    eekboard.keyboard = eek_gtk_keyboard_new ();
 | 
					    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);
 | 
					    eek_keyboard_set_layout (eekboard.keyboard, eekboard.layout);
 | 
				
			||||||
    embed = eek_gtk_keyboard_get_widget (EEK_GTK_KEYBOARD (eekboard.keyboard));
 | 
					    embed = eek_gtk_keyboard_get_widget (EEK_GTK_KEYBOARD (eekboard.keyboard));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user