Fix some mistakes.
This commit is contained in:
@ -488,7 +488,9 @@ eek_element_set_group (EekElement *element,
|
|||||||
g_return_if_fail (EEK_IS_ELEMENT(element));
|
g_return_if_fail (EEK_IS_ELEMENT(element));
|
||||||
if (element->priv->group != group) {
|
if (element->priv->group != group) {
|
||||||
element->priv->group = group;
|
element->priv->group = group;
|
||||||
g_object_notify (element, "group");
|
g_object_notify (G_OBJECT(element), "group");
|
||||||
|
g_signal_emit (element, signals[SYMBOL_INDEX_CHANGED], 0,
|
||||||
|
group, element->priv->level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +511,9 @@ eek_element_set_level (EekElement *element,
|
|||||||
g_return_if_fail (EEK_IS_ELEMENT(element));
|
g_return_if_fail (EEK_IS_ELEMENT(element));
|
||||||
if (element->priv->level != level) {
|
if (element->priv->level != level) {
|
||||||
element->priv->level = level;
|
element->priv->level = level;
|
||||||
g_object_notify (element, "level");
|
g_object_notify (G_OBJECT(element), "level");
|
||||||
|
g_signal_emit (element, signals[SYMBOL_INDEX_CHANGED], 0,
|
||||||
|
element->priv->group, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +529,7 @@ eek_element_set_level (EekElement *element,
|
|||||||
gint
|
gint
|
||||||
eek_element_get_group (EekElement *element)
|
eek_element_get_group (EekElement *element)
|
||||||
{
|
{
|
||||||
g_return_if_fail (EEK_IS_ELEMENT(element));
|
g_return_val_if_fail (EEK_IS_ELEMENT(element), -1);
|
||||||
return element->priv->group;
|
return element->priv->group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,6 +545,6 @@ eek_element_get_group (EekElement *element)
|
|||||||
gint
|
gint
|
||||||
eek_element_get_level (EekElement *element)
|
eek_element_get_level (EekElement *element)
|
||||||
{
|
{
|
||||||
g_return_if_fail (EEK_IS_ELEMENT(element));
|
g_return_val_if_fail (EEK_IS_ELEMENT(element), -1);
|
||||||
return element->priv->level;
|
return element->priv->level;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,12 +97,8 @@ eek_gtk_renderer_new (EekKeyboard *keyboard,
|
|||||||
PangoContext *pcontext,
|
PangoContext *pcontext,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
EekRenderer *renderer;
|
return g_object_new (EEK_TYPE_GTK_RENDERER,
|
||||||
|
"keyboard", keyboard,
|
||||||
renderer = g_object_new (EEK_TYPE_GTK_RENDERER,
|
"pango-context", pcontext,
|
||||||
"keyboard", keyboard,
|
NULL);
|
||||||
"pango-context", pcontext,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return renderer;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -590,11 +590,11 @@ eek_key_set_index (EekKey *key,
|
|||||||
|
|
||||||
if (key->priv->column != column) {
|
if (key->priv->column != column) {
|
||||||
key->priv->column = column;
|
key->priv->column = column;
|
||||||
g_object_notify (key, "column");
|
g_object_notify (G_OBJECT(key), "column");
|
||||||
}
|
}
|
||||||
if (key->priv->row != row) {
|
if (key->priv->row != row) {
|
||||||
key->priv->row = row;
|
key->priv->row = row;
|
||||||
g_object_notify (key, "row");
|
g_object_notify (G_OBJECT(key), "row");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ eek_key_set_oref (EekKey *key,
|
|||||||
g_return_if_fail (EEK_IS_KEY(key));
|
g_return_if_fail (EEK_IS_KEY(key));
|
||||||
if (key->priv->oref != oref) {
|
if (key->priv->oref != oref) {
|
||||||
key->priv->oref = oref;
|
key->priv->oref = oref;
|
||||||
g_object_notify (key, "oref");
|
g_object_notify (G_OBJECT(key), "oref");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ on_key_pressed (EekSection *section,
|
|||||||
EekKey *key,
|
EekKey *key,
|
||||||
EekKeyboard *keyboard)
|
EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (keyboard, "key-pressed", key);
|
g_signal_emit (keyboard, signals[KEY_PRESSED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -87,7 +87,7 @@ on_key_released (EekSection *section,
|
|||||||
EekKey *key,
|
EekKey *key,
|
||||||
EekKeyboard *keyboard)
|
EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (keyboard, "key-released", key);
|
g_signal_emit (keyboard, signals[KEY_RELEASED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -95,7 +95,7 @@ on_key_locked (EekSection *section,
|
|||||||
EekKey *key,
|
EekKey *key,
|
||||||
EekKeyboard *keyboard)
|
EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (keyboard, "key-locked", key);
|
g_signal_emit (keyboard, signals[KEY_LOCKED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -103,7 +103,7 @@ on_key_unlocked (EekSection *section,
|
|||||||
EekKey *key,
|
EekKey *key,
|
||||||
EekKeyboard *keyboard)
|
EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (keyboard, "key-unlocked", key);
|
g_signal_emit (keyboard, signals[KEY_UNLOCKED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -111,7 +111,7 @@ on_key_cancelled (EekSection *section,
|
|||||||
EekKey *key,
|
EekKey *key,
|
||||||
EekKeyboard *keyboard)
|
EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (keyboard, "key-cancelled", key);
|
g_signal_emit (keyboard, signals[KEY_CANCELLED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -558,122 +558,12 @@ eek_keyboard_class_init (EekKeyboardClass *klass)
|
|||||||
static void
|
static void
|
||||||
eek_keyboard_init (EekKeyboard *self)
|
eek_keyboard_init (EekKeyboard *self)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
self->priv = EEK_KEYBOARD_GET_PRIVATE(self);
|
||||||
|
self->priv->modifier_behavior = EEK_MODIFIER_BEHAVIOR_NONE;
|
||||||
priv = self->priv = EEK_KEYBOARD_GET_PRIVATE(self);
|
self->priv->outline_array = g_array_new (FALSE, TRUE, sizeof (EekOutline));
|
||||||
priv->modifier_behavior = EEK_MODIFIER_BEHAVIOR_NONE;
|
|
||||||
priv->outline_array = g_array_new (FALSE, TRUE, sizeof (EekOutline));
|
|
||||||
eek_element_set_symbol_index (EEK_ELEMENT(self), 0, 0);
|
eek_element_set_symbol_index (EEK_ELEMENT(self), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_set_symbol_index:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
* @group: row index of the symbol matrix of keys on @keyboard
|
|
||||||
* @level: column index of the symbol matrix of keys on @keyboard
|
|
||||||
*
|
|
||||||
* Set the default index of the symbol matrices of keys in @keyboard.
|
|
||||||
* To unset, pass -1 as group/level.
|
|
||||||
*
|
|
||||||
* Deprecated: 1.0: Use eek_element_set_symbol_index()
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_keyboard_set_symbol_index (EekKeyboard *keyboard,
|
|
||||||
gint group,
|
|
||||||
gint level)
|
|
||||||
{
|
|
||||||
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
eek_element_set_symbol_index (EEK_ELEMENT(keyboard), group, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_get_symbol_index:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
* @group: a pointer where the group value of the symbol index will be stored
|
|
||||||
* @level: a pointer where the level value of the symbol index will be stored
|
|
||||||
*
|
|
||||||
* Get the default index of the symbol matrices of keys in @keyboard.
|
|
||||||
* If the index is not set, -1 will be returned.
|
|
||||||
*
|
|
||||||
* Deprecated: 1.0: Use eek_element_get_symbol_index()
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_keyboard_get_symbol_index (EekKeyboard *keyboard,
|
|
||||||
gint *group,
|
|
||||||
gint *level)
|
|
||||||
{
|
|
||||||
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
eek_element_get_symbol_index(EEK_ELEMENT(keyboard), group, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_set_group:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
* @group: group index of @keyboard
|
|
||||||
*
|
|
||||||
* Set the group value of the default symbol index of @keyboard. To
|
|
||||||
* unset, pass -1 as @group.
|
|
||||||
*
|
|
||||||
* See also: eek_keyboard_set_symbol_index()
|
|
||||||
* Deprecated: 1.0: Use eek_element_set_group()
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_keyboard_set_group (EekKeyboard *keyboard,
|
|
||||||
gint group)
|
|
||||||
{
|
|
||||||
eek_element_set_group (EEK_ELEMENT(keyboard), group);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_set_level:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
* @level: level index of @keyboard
|
|
||||||
*
|
|
||||||
* Set the level value of the default symbol index of @keyboard. To
|
|
||||||
* unset, pass -1 as @level.
|
|
||||||
*
|
|
||||||
* See also: eek_keyboard_set_symbol_index()
|
|
||||||
* Deprecated: 1.0: Use eek_element_set_level()
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_keyboard_set_level (EekKeyboard *keyboard,
|
|
||||||
gint level)
|
|
||||||
{
|
|
||||||
eek_element_set_level (EEK_ELEMENT(keyboard), level);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_get_group:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
*
|
|
||||||
* Return the group value of the default symbol index of @keyboard.
|
|
||||||
* If the value is not set, -1 will be returned.
|
|
||||||
*
|
|
||||||
* See also: eek_keyboard_get_symbol_index()
|
|
||||||
* Deprecated: 1.0: Use eek_element_get_group()
|
|
||||||
*/
|
|
||||||
gint
|
|
||||||
eek_keyboard_get_group (EekKeyboard *keyboard)
|
|
||||||
{
|
|
||||||
return eek_element_get_group (EEK_ELEMENT(keyboard));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_keyboard_get_level:
|
|
||||||
* @keyboard: an #EekKeyboard
|
|
||||||
*
|
|
||||||
* Return the level value of the default symbol index of @keyboard.
|
|
||||||
* If the value is not set, -1 will be returned.
|
|
||||||
*
|
|
||||||
* See also: eek_keyboard_get_symbol_index()
|
|
||||||
* Deprecated: 1.0: Use eek_element_get_level()
|
|
||||||
*/
|
|
||||||
gint
|
|
||||||
eek_keyboard_get_level (EekKeyboard *keyboard)
|
|
||||||
{
|
|
||||||
return eek_element_get_level (EEK_ELEMENT(keyboard));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eek_keyboard_create_section:
|
* eek_keyboard_create_section:
|
||||||
* @keyboard: an #EekKeyboard
|
* @keyboard: an #EekKeyboard
|
||||||
@ -685,10 +575,8 @@ eek_keyboard_get_level (EekKeyboard *keyboard)
|
|||||||
EekSection *
|
EekSection *
|
||||||
eek_keyboard_create_section (EekKeyboard *keyboard)
|
eek_keyboard_create_section (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekSection *section;
|
|
||||||
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
section = EEK_KEYBOARD_GET_CLASS(keyboard)->create_section (keyboard);
|
return EEK_KEYBOARD_GET_CLASS(keyboard)->create_section (keyboard);
|
||||||
return section;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -703,7 +591,7 @@ EekKey *
|
|||||||
eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard,
|
eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard,
|
||||||
guint keycode)
|
guint keycode)
|
||||||
{
|
{
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
return EEK_KEYBOARD_GET_CLASS(keyboard)->
|
return EEK_KEYBOARD_GET_CLASS(keyboard)->
|
||||||
find_key_by_keycode (keyboard, keycode);
|
find_key_by_keycode (keyboard, keycode);
|
||||||
}
|
}
|
||||||
@ -718,11 +606,8 @@ eek_keyboard_find_key_by_keycode (EekKeyboard *keyboard,
|
|||||||
EekLayout *
|
EekLayout *
|
||||||
eek_keyboard_get_layout (EekKeyboard *keyboard)
|
eek_keyboard_get_layout (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
|
return keyboard->priv->layout;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
return priv->layout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -740,7 +625,6 @@ eek_keyboard_get_size (EekKeyboard *keyboard,
|
|||||||
{
|
{
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
|
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
|
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
|
||||||
*width = bounds.width;
|
*width = bounds.width;
|
||||||
*height = bounds.height;
|
*height = bounds.height;
|
||||||
@ -757,12 +641,8 @@ void
|
|||||||
eek_keyboard_set_modifier_behavior (EekKeyboard *keyboard,
|
eek_keyboard_set_modifier_behavior (EekKeyboard *keyboard,
|
||||||
EekModifierBehavior modifier_behavior)
|
EekModifierBehavior modifier_behavior)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
keyboard->priv->modifier_behavior = modifier_behavior;
|
||||||
|
|
||||||
priv->modifier_behavior = modifier_behavior;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -775,24 +655,16 @@ eek_keyboard_set_modifier_behavior (EekKeyboard *keyboard,
|
|||||||
EekModifierBehavior
|
EekModifierBehavior
|
||||||
eek_keyboard_get_modifier_behavior (EekKeyboard *keyboard)
|
eek_keyboard_get_modifier_behavior (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
|
return keyboard->priv->modifier_behavior;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->modifier_behavior;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eek_keyboard_set_modifiers (EekKeyboard *keyboard,
|
eek_keyboard_set_modifiers (EekKeyboard *keyboard,
|
||||||
EekModifierType modifiers)
|
EekModifierType modifiers)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
||||||
|
keyboard->priv->modifiers = modifiers;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
priv->modifiers = modifiers;
|
|
||||||
set_level_from_modifiers (keyboard);
|
set_level_from_modifiers (keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -806,12 +678,8 @@ eek_keyboard_set_modifiers (EekKeyboard *keyboard,
|
|||||||
EekModifierType
|
EekModifierType
|
||||||
eek_keyboard_get_modifiers (EekKeyboard *keyboard)
|
eek_keyboard_get_modifiers (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
|
return keyboard->priv->modifiers;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->modifiers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -820,46 +688,56 @@ eek_keyboard_get_modifiers (EekKeyboard *keyboard)
|
|||||||
* @outline: an #EekOutline
|
* @outline: an #EekOutline
|
||||||
*
|
*
|
||||||
* Register an outline of @keyboard.
|
* Register an outline of @keyboard.
|
||||||
* Returns: an unsigned long id of the registered outline, for later reference
|
* Returns: an unsigned integer ID of the registered outline, for
|
||||||
|
* later reference
|
||||||
*/
|
*/
|
||||||
gulong
|
guint
|
||||||
eek_keyboard_add_outline (EekKeyboard *keyboard,
|
eek_keyboard_add_outline (EekKeyboard *keyboard,
|
||||||
EekOutline *outline)
|
EekOutline *outline)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
|
||||||
EekOutline *_outline;
|
EekOutline *_outline;
|
||||||
|
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
_outline = eek_outline_copy (outline);
|
_outline = eek_outline_copy (outline);
|
||||||
g_array_append_val (priv->outline_array, *_outline);
|
g_array_append_val (keyboard->priv->outline_array, *_outline);
|
||||||
/* don't use eek_outline_free here, so as to keep _outline->points */
|
/* don't use eek_outline_free here, so as to keep _outline->points */
|
||||||
g_slice_free (EekOutline, _outline);
|
g_slice_free (EekOutline, _outline);
|
||||||
return priv->outline_array->len;
|
return keyboard->priv->outline_array->len - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eek_keyboard_get_outline:
|
* eek_keyboard_get_outline:
|
||||||
* @keyboard: an #EekKeyboard
|
* @keyboard: an #EekKeyboard
|
||||||
* @oref: an unsigned long id
|
* @oref: ID of the outline
|
||||||
*
|
*
|
||||||
* Get an outline associated with @oref in @keyboard.
|
* Get an outline associated with @oref in @keyboard.
|
||||||
* Returns: an #EekOutline, which should not be released
|
* Returns: an #EekOutline, which should not be released
|
||||||
*/
|
*/
|
||||||
EekOutline *
|
EekOutline *
|
||||||
eek_keyboard_get_outline (EekKeyboard *keyboard,
|
eek_keyboard_get_outline (EekKeyboard *keyboard,
|
||||||
gulong oref)
|
guint oref)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
|
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
if (oref > keyboard->priv->outline_array->len)
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
if (oref > priv->outline_array->len)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &g_array_index (priv->outline_array, EekOutline, oref - 1);
|
return &g_array_index (keyboard->priv->outline_array, EekOutline, oref);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eek_keyboard_get_n_outlines:
|
||||||
|
* @keyboard: an #EekKeyboard
|
||||||
|
*
|
||||||
|
* Get the number of outlines defined in @keyboard.
|
||||||
|
* Returns: integer
|
||||||
|
*/
|
||||||
|
gsize
|
||||||
|
eek_keyboard_get_n_outlines (EekKeyboard *keyboard)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
|
return keyboard->priv->outline_array->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -873,12 +751,8 @@ void
|
|||||||
eek_keyboard_set_num_lock_mask (EekKeyboard *keyboard,
|
eek_keyboard_set_num_lock_mask (EekKeyboard *keyboard,
|
||||||
EekModifierType num_lock_mask)
|
EekModifierType num_lock_mask)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
||||||
|
keyboard->priv->num_lock_mask = num_lock_mask;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
priv->num_lock_mask = num_lock_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -891,12 +765,8 @@ eek_keyboard_set_num_lock_mask (EekKeyboard *keyboard,
|
|||||||
EekModifierType
|
EekModifierType
|
||||||
eek_keyboard_get_num_lock_mask (EekKeyboard *keyboard)
|
eek_keyboard_get_num_lock_mask (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
|
return keyboard->priv->num_lock_mask;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->num_lock_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -910,12 +780,8 @@ void
|
|||||||
eek_keyboard_set_alt_gr_mask (EekKeyboard *keyboard,
|
eek_keyboard_set_alt_gr_mask (EekKeyboard *keyboard,
|
||||||
EekModifierType alt_gr_mask)
|
EekModifierType alt_gr_mask)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
|
||||||
|
keyboard->priv->alt_gr_mask = alt_gr_mask;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
priv->alt_gr_mask = alt_gr_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -928,12 +794,8 @@ eek_keyboard_set_alt_gr_mask (EekKeyboard *keyboard,
|
|||||||
EekModifierType
|
EekModifierType
|
||||||
eek_keyboard_get_alt_gr_mask (EekKeyboard *keyboard)
|
eek_keyboard_get_alt_gr_mask (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
|
||||||
|
return keyboard->priv->alt_gr_mask;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->alt_gr_mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -947,12 +809,8 @@ eek_keyboard_get_alt_gr_mask (EekKeyboard *keyboard)
|
|||||||
GList *
|
GList *
|
||||||
eek_keyboard_get_pressed_keys (EekKeyboard *keyboard)
|
eek_keyboard_get_pressed_keys (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
|
return keyboard->priv->pressed_keys;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->pressed_keys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -966,10 +824,6 @@ eek_keyboard_get_pressed_keys (EekKeyboard *keyboard)
|
|||||||
GList *
|
GList *
|
||||||
eek_keyboard_get_locked_keys (EekKeyboard *keyboard)
|
eek_keyboard_get_locked_keys (EekKeyboard *keyboard)
|
||||||
{
|
{
|
||||||
EekKeyboardPrivate *priv;
|
g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), NULL);
|
||||||
|
return keyboard->priv->locked_keys;
|
||||||
g_assert (EEK_IS_KEYBOARD(keyboard));
|
|
||||||
priv = EEK_KEYBOARD_GET_PRIVATE(keyboard);
|
|
||||||
|
|
||||||
return priv->locked_keys;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,13 +156,15 @@ EekKey *eek_keyboard_find_key_by_keycode
|
|||||||
(EekKeyboard *keyboard,
|
(EekKeyboard *keyboard,
|
||||||
guint keycode);
|
guint keycode);
|
||||||
|
|
||||||
gulong eek_keyboard_add_outline
|
guint eek_keyboard_add_outline
|
||||||
(EekKeyboard *keyboard,
|
(EekKeyboard *keyboard,
|
||||||
EekOutline *outline);
|
EekOutline *outline);
|
||||||
|
|
||||||
EekOutline *eek_keyboard_get_outline
|
EekOutline *eek_keyboard_get_outline
|
||||||
(EekKeyboard *keyboard,
|
(EekKeyboard *keyboard,
|
||||||
gulong oref);
|
guint oref);
|
||||||
|
gsize eek_keyboard_get_n_outlines
|
||||||
|
(EekKeyboard *keyboard);
|
||||||
|
|
||||||
void eek_keyboard_set_num_lock_mask
|
void eek_keyboard_set_num_lock_mask
|
||||||
(EekKeyboard *keyboard,
|
(EekKeyboard *keyboard,
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "eek-key.h"
|
#include "eek-key.h"
|
||||||
#include "eek-section.h"
|
#include "eek-section.h"
|
||||||
@ -497,21 +498,25 @@ render_key (EekRenderer *self,
|
|||||||
cairo_surface_t *icon_surface =
|
cairo_surface_t *icon_surface =
|
||||||
eek_renderer_get_icon_surface (self,
|
eek_renderer_get_icon_surface (self,
|
||||||
eek_symbol_get_icon_name (symbol),
|
eek_symbol_get_icon_name (symbol),
|
||||||
MIN(bounds.width, bounds.height));
|
MIN(bounds.width, bounds.height) * 0.7);
|
||||||
if (icon_surface) {
|
if (icon_surface) {
|
||||||
gint width = cairo_image_surface_get_width (icon_surface);
|
gint width = cairo_image_surface_get_width (icon_surface);
|
||||||
gint height = cairo_image_surface_get_height (icon_surface);
|
gint height = cairo_image_surface_get_height (icon_surface);
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
if (height * bounds.width / width <= bounds.height)
|
if (width < bounds.width && height < bounds.height)
|
||||||
scale = bounds.width / width;
|
scale = 1;
|
||||||
else if (width * bounds.height / height <= bounds.width)
|
|
||||||
scale = bounds.height / height;
|
|
||||||
else {
|
else {
|
||||||
if (width * bounds.height < height * bounds.width)
|
if (height * bounds.width / width <= bounds.height)
|
||||||
scale = width / bounds.width;
|
scale = bounds.width / width;
|
||||||
else
|
else if (width * bounds.height / height <= bounds.width)
|
||||||
scale = height / bounds.height;
|
scale = bounds.height / height;
|
||||||
|
else {
|
||||||
|
if (width * bounds.height < height * bounds.width)
|
||||||
|
scale = width / bounds.width;
|
||||||
|
else
|
||||||
|
scale = height / bounds.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
@ -861,17 +866,15 @@ eek_renderer_init (EekRenderer *self)
|
|||||||
static void
|
static void
|
||||||
invalidate (EekRenderer *renderer)
|
invalidate (EekRenderer *renderer)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
if (renderer->priv->outline_surface_cache)
|
||||||
|
g_hash_table_remove_all (renderer->priv->outline_surface_cache);
|
||||||
|
|
||||||
if (priv->outline_surface_cache)
|
if (renderer->priv->active_outline_surface_cache)
|
||||||
g_hash_table_remove_all (priv->outline_surface_cache);
|
g_hash_table_remove_all (renderer->priv->active_outline_surface_cache);
|
||||||
|
|
||||||
if (priv->active_outline_surface_cache)
|
if (renderer->priv->keyboard_surface) {
|
||||||
g_hash_table_remove_all (priv->active_outline_surface_cache);
|
cairo_surface_destroy (renderer->priv->keyboard_surface);
|
||||||
|
renderer->priv->keyboard_surface = NULL;
|
||||||
if (priv->keyboard_surface) {
|
|
||||||
cairo_surface_destroy (priv->keyboard_surface);
|
|
||||||
priv->keyboard_surface = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,14 +892,10 @@ EekRenderer *
|
|||||||
eek_renderer_new (EekKeyboard *keyboard,
|
eek_renderer_new (EekKeyboard *keyboard,
|
||||||
PangoContext *pcontext)
|
PangoContext *pcontext)
|
||||||
{
|
{
|
||||||
EekRenderer *renderer;
|
return g_object_new (EEK_TYPE_RENDERER,
|
||||||
|
"keyboard", keyboard,
|
||||||
renderer = g_object_new (EEK_TYPE_RENDERER,
|
"pango-context", pcontext,
|
||||||
"keyboard", keyboard,
|
NULL);
|
||||||
"pango-context", pcontext,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
return renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -904,19 +903,16 @@ eek_renderer_set_allocation_size (EekRenderer *renderer,
|
|||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height)
|
gdouble height)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
gdouble scale;
|
gdouble scale;
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (width > 0.0 && height > 0.0);
|
g_return_if_fail (width > 0.0 && height > 0.0);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
renderer->priv->allocation_width = width;
|
||||||
|
renderer->priv->allocation_height = height;
|
||||||
|
|
||||||
priv->allocation_width = width;
|
eek_element_get_bounds (EEK_ELEMENT(renderer->priv->keyboard), &bounds);
|
||||||
priv->allocation_height = height;
|
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
|
|
||||||
|
|
||||||
if (bounds.height * width / bounds.width <= height)
|
if (bounds.height * width / bounds.width <= height)
|
||||||
scale = width / bounds.width;
|
scale = width / bounds.width;
|
||||||
@ -929,8 +925,8 @@ eek_renderer_set_allocation_size (EekRenderer *renderer,
|
|||||||
scale = bounds.height / height;
|
scale = bounds.height / height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scale != priv->scale) {
|
if (scale != renderer->priv->scale) {
|
||||||
priv->scale = scale;
|
renderer->priv->scale = scale;
|
||||||
invalidate (renderer);
|
invalidate (renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,18 +936,15 @@ eek_renderer_get_size (EekRenderer *renderer,
|
|||||||
gdouble *width,
|
gdouble *width,
|
||||||
gdouble *height)
|
gdouble *height)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
eek_element_get_bounds (EEK_ELEMENT(renderer->priv->keyboard), &bounds);
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
|
|
||||||
if (width)
|
if (width)
|
||||||
*width = bounds.width * priv->scale;
|
*width = bounds.width * renderer->priv->scale;
|
||||||
if (height)
|
if (height)
|
||||||
*height = bounds.height * priv->scale;
|
*height = bounds.height * renderer->priv->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -960,7 +953,6 @@ eek_renderer_get_key_bounds (EekRenderer *renderer,
|
|||||||
EekBounds *bounds,
|
EekBounds *bounds,
|
||||||
gboolean rotate)
|
gboolean rotate)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekElement *section;
|
EekElement *section;
|
||||||
EekBounds section_bounds, keyboard_bounds;
|
EekBounds section_bounds, keyboard_bounds;
|
||||||
gint angle = 0;
|
gint angle = 0;
|
||||||
@ -971,21 +963,20 @@ eek_renderer_get_key_bounds (EekRenderer *renderer,
|
|||||||
g_return_if_fail (EEK_IS_KEY(key));
|
g_return_if_fail (EEK_IS_KEY(key));
|
||||||
g_return_if_fail (bounds != NULL);
|
g_return_if_fail (bounds != NULL);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
|
||||||
|
|
||||||
section = eek_element_get_parent (EEK_ELEMENT(key));
|
section = eek_element_get_parent (EEK_ELEMENT(key));
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(key), bounds);
|
eek_element_get_bounds (EEK_ELEMENT(key), bounds);
|
||||||
eek_element_get_bounds (section, §ion_bounds);
|
eek_element_get_bounds (section, §ion_bounds);
|
||||||
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &keyboard_bounds);
|
eek_element_get_bounds (EEK_ELEMENT(renderer->priv->keyboard),
|
||||||
|
&keyboard_bounds);
|
||||||
|
|
||||||
if (!rotate) {
|
if (!rotate) {
|
||||||
bounds->x += keyboard_bounds.x + section_bounds.x;
|
bounds->x += keyboard_bounds.x + section_bounds.x;
|
||||||
bounds->y += keyboard_bounds.y + section_bounds.y;
|
bounds->y += keyboard_bounds.y + section_bounds.y;
|
||||||
bounds->x *= priv->scale;
|
bounds->x *= renderer->priv->scale;
|
||||||
bounds->y *= priv->scale;
|
bounds->y *= renderer->priv->scale;
|
||||||
bounds->width *= priv->scale;
|
bounds->width *= renderer->priv->scale;
|
||||||
bounds->height *= priv->scale;
|
bounds->height *= renderer->priv->scale;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
points[0].x = bounds->x;
|
points[0].x = bounds->x;
|
||||||
@ -1017,34 +1008,24 @@ eek_renderer_get_key_bounds (EekRenderer *renderer,
|
|||||||
bounds->y = keyboard_bounds.y + section_bounds.y + min.y;
|
bounds->y = keyboard_bounds.y + section_bounds.y + min.y;
|
||||||
bounds->width = (max.x - min.x);
|
bounds->width = (max.x - min.x);
|
||||||
bounds->height = (max.y - min.y);
|
bounds->height = (max.y - min.y);
|
||||||
bounds->x *= priv->scale;
|
bounds->x *= renderer->priv->scale;
|
||||||
bounds->y *= priv->scale;
|
bounds->y *= renderer->priv->scale;
|
||||||
bounds->width *= priv->scale;
|
bounds->width *= renderer->priv->scale;
|
||||||
bounds->height *= priv->scale;
|
bounds->height *= renderer->priv->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdouble
|
gdouble
|
||||||
eek_renderer_get_scale (EekRenderer *renderer)
|
eek_renderer_get_scale (EekRenderer *renderer)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
g_return_val_if_fail (EEK_IS_RENDERER(renderer), 0);
|
||||||
|
return renderer->priv->scale;
|
||||||
g_assert (EEK_IS_RENDERER(renderer));
|
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
|
||||||
|
|
||||||
return priv->scale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PangoLayout *
|
PangoLayout *
|
||||||
eek_renderer_create_pango_layout (EekRenderer *renderer)
|
eek_renderer_create_pango_layout (EekRenderer *renderer)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
g_return_val_if_fail (EEK_IS_RENDERER(renderer), NULL);
|
||||||
|
return pango_layout_new (renderer->priv->pcontext);
|
||||||
g_assert (EEK_IS_RENDERER(renderer));
|
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
|
||||||
|
|
||||||
return pango_layout_new (priv->pcontext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1119,26 +1100,20 @@ void
|
|||||||
eek_renderer_set_default_foreground_color (EekRenderer *renderer,
|
eek_renderer_set_default_foreground_color (EekRenderer *renderer,
|
||||||
const EekColor *color)
|
const EekColor *color)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (color);
|
g_return_if_fail (color);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
memcpy (&renderer->priv->default_foreground_color, color, sizeof(EekColor));
|
||||||
priv->default_foreground_color = *color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eek_renderer_set_default_background_color (EekRenderer *renderer,
|
eek_renderer_set_default_background_color (EekRenderer *renderer,
|
||||||
const EekColor *color)
|
const EekColor *color)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (color);
|
g_return_if_fail (color);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
memcpy (&renderer->priv->default_background_color, color, sizeof(EekColor));
|
||||||
priv->default_background_color = *color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1146,19 +1121,17 @@ eek_renderer_get_foreground_color (EekRenderer *renderer,
|
|||||||
EekElement *element,
|
EekElement *element,
|
||||||
EekColor *color)
|
EekColor *color)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekThemeNode *theme_node;
|
EekThemeNode *theme_node;
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (color);
|
g_return_if_fail (color);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
|
||||||
|
|
||||||
theme_node = g_object_get_data (G_OBJECT(element), "theme-node");
|
theme_node = g_object_get_data (G_OBJECT(element), "theme-node");
|
||||||
if (theme_node)
|
if (theme_node)
|
||||||
eek_theme_node_get_foreground_color (theme_node, color);
|
eek_theme_node_get_foreground_color (theme_node, color);
|
||||||
else
|
else
|
||||||
*color = priv->default_foreground_color;
|
memcpy (color, &renderer->priv->default_foreground_color,
|
||||||
|
sizeof(EekColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1166,19 +1139,17 @@ eek_renderer_get_background_color (EekRenderer *renderer,
|
|||||||
EekElement *element,
|
EekElement *element,
|
||||||
EekColor *color)
|
EekColor *color)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekThemeNode *theme_node;
|
EekThemeNode *theme_node;
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_return_if_fail (color);
|
g_return_if_fail (color);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
|
||||||
|
|
||||||
theme_node = g_object_get_data (G_OBJECT(element), "theme-node");
|
theme_node = g_object_get_data (G_OBJECT(element), "theme-node");
|
||||||
if (theme_node)
|
if (theme_node)
|
||||||
eek_theme_node_get_background_color (theme_node, color);
|
eek_theme_node_get_background_color (theme_node, color);
|
||||||
else
|
else
|
||||||
*color = priv->default_background_color;
|
memcpy (color, &renderer->priv->default_background_color,
|
||||||
|
sizeof(EekColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1225,13 +1196,10 @@ find_key_by_position_key_callback (EekElement *element,
|
|||||||
{
|
{
|
||||||
FindKeyByPositionCallbackData *data = user_data;
|
FindKeyByPositionCallbackData *data = user_data;
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekPoint points[4];
|
EekPoint points[4];
|
||||||
gint i;
|
gint i;
|
||||||
gboolean b1, b2, b3;
|
gboolean b1, b2, b3;
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(data->renderer);
|
|
||||||
|
|
||||||
eek_element_get_bounds (element, &bounds);
|
eek_element_get_bounds (element, &bounds);
|
||||||
|
|
||||||
points[0].x = bounds.x;
|
points[0].x = bounds.x;
|
||||||
@ -1247,8 +1215,8 @@ find_key_by_position_key_callback (EekElement *element,
|
|||||||
eek_point_rotate (&points[i], data->angle);
|
eek_point_rotate (&points[i], data->angle);
|
||||||
points[i].x += data->origin.x;
|
points[i].x += data->origin.x;
|
||||||
points[i].y += data->origin.y;
|
points[i].y += data->origin.y;
|
||||||
points[i].x *= priv->scale;
|
points[i].x *= data->renderer->priv->scale;
|
||||||
points[i].y *= priv->scale;
|
points[i].y *= data->renderer->priv->scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
b1 = sign (&data->point, &points[0], &points[1]) < 0.0;
|
b1 = sign (&data->point, &points[0], &points[1]) < 0.0;
|
||||||
@ -1298,19 +1266,17 @@ eek_renderer_find_key_by_position (EekRenderer *renderer,
|
|||||||
gdouble x,
|
gdouble x,
|
||||||
gdouble y)
|
gdouble y)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
FindKeyByPositionCallbackData data;
|
FindKeyByPositionCallbackData data;
|
||||||
|
|
||||||
g_assert (EEK_IS_RENDERER(renderer));
|
g_return_val_if_fail (EEK_IS_RENDERER(renderer), NULL);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
eek_element_get_bounds (EEK_ELEMENT(renderer->priv->keyboard), &bounds);
|
||||||
eek_element_get_bounds (EEK_ELEMENT(priv->keyboard), &bounds);
|
|
||||||
|
|
||||||
if (x < bounds.x * priv->scale ||
|
if (x < bounds.x * renderer->priv->scale ||
|
||||||
y < bounds.y * priv->scale ||
|
y < bounds.y * renderer->priv->scale ||
|
||||||
x > bounds.width * priv->scale ||
|
x > bounds.width * renderer->priv->scale ||
|
||||||
y > bounds.height * priv->scale)
|
y > bounds.height * renderer->priv->scale)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
data.point.x = x;
|
data.point.x = x;
|
||||||
@ -1320,7 +1286,7 @@ eek_renderer_find_key_by_position (EekRenderer *renderer,
|
|||||||
data.key = NULL;
|
data.key = NULL;
|
||||||
data.renderer = renderer;
|
data.renderer = renderer;
|
||||||
|
|
||||||
eek_container_find (EEK_CONTAINER(priv->keyboard),
|
eek_container_find (EEK_CONTAINER(renderer->priv->keyboard),
|
||||||
find_key_by_position_section_callback,
|
find_key_by_position_section_callback,
|
||||||
&data);
|
&data);
|
||||||
return data.key;
|
return data.key;
|
||||||
@ -1338,14 +1304,11 @@ create_theme_node_key_callback (EekElement *element,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CreateThemeNodeData *data = user_data;
|
CreateThemeNodeData *data = user_data;
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekThemeNode *theme_node;
|
EekThemeNode *theme_node;
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(data->renderer);
|
|
||||||
|
|
||||||
theme_node = eek_theme_node_new (data->context,
|
theme_node = eek_theme_node_new (data->context,
|
||||||
data->parent,
|
data->parent,
|
||||||
priv->theme,
|
data->renderer->priv->theme,
|
||||||
EEK_TYPE_KEY,
|
EEK_TYPE_KEY,
|
||||||
eek_element_get_name (element),
|
eek_element_get_name (element),
|
||||||
"key",
|
"key",
|
||||||
@ -1358,7 +1321,7 @@ create_theme_node_key_callback (EekElement *element,
|
|||||||
|
|
||||||
theme_node = eek_theme_node_new (data->context,
|
theme_node = eek_theme_node_new (data->context,
|
||||||
data->parent,
|
data->parent,
|
||||||
priv->theme,
|
data->renderer->priv->theme,
|
||||||
EEK_TYPE_KEY,
|
EEK_TYPE_KEY,
|
||||||
eek_element_get_name (element),
|
eek_element_get_name (element),
|
||||||
"key",
|
"key",
|
||||||
@ -1375,14 +1338,11 @@ create_theme_node_section_callback (EekElement *element,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
CreateThemeNodeData *data = user_data;
|
CreateThemeNodeData *data = user_data;
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekThemeNode *theme_node, *parent;
|
EekThemeNode *theme_node, *parent;
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(data->renderer);
|
|
||||||
|
|
||||||
theme_node = eek_theme_node_new (data->context,
|
theme_node = eek_theme_node_new (data->context,
|
||||||
data->parent,
|
data->parent,
|
||||||
priv->theme,
|
data->renderer->priv->theme,
|
||||||
EEK_TYPE_SECTION,
|
EEK_TYPE_SECTION,
|
||||||
eek_element_get_name (element),
|
eek_element_get_name (element),
|
||||||
"section",
|
"section",
|
||||||
@ -1405,31 +1365,28 @@ void
|
|||||||
eek_renderer_set_theme (EekRenderer *renderer,
|
eek_renderer_set_theme (EekRenderer *renderer,
|
||||||
EekTheme *theme)
|
EekTheme *theme)
|
||||||
{
|
{
|
||||||
EekRendererPrivate *priv;
|
|
||||||
EekThemeContext *theme_context;
|
EekThemeContext *theme_context;
|
||||||
EekThemeNode *theme_node;
|
EekThemeNode *theme_node;
|
||||||
CreateThemeNodeData data;
|
CreateThemeNodeData data;
|
||||||
|
|
||||||
g_assert (EEK_IS_RENDERER(renderer));
|
g_return_if_fail (EEK_IS_RENDERER(renderer));
|
||||||
g_assert (EEK_IS_THEME(theme));
|
g_return_if_fail (EEK_IS_THEME(theme));
|
||||||
|
g_return_if_fail (renderer->priv->keyboard);
|
||||||
|
|
||||||
priv = EEK_RENDERER_GET_PRIVATE(renderer);
|
if (renderer->priv->theme)
|
||||||
g_assert (priv->keyboard);
|
g_object_unref (renderer->priv->theme);
|
||||||
|
renderer->priv->theme = g_object_ref (theme);
|
||||||
if (priv->theme)
|
|
||||||
g_object_unref (priv->theme);
|
|
||||||
priv->theme = g_object_ref (theme);
|
|
||||||
|
|
||||||
theme_context = eek_theme_context_new ();
|
theme_context = eek_theme_context_new ();
|
||||||
theme_node = eek_theme_node_new (theme_context,
|
theme_node = eek_theme_node_new (theme_context,
|
||||||
NULL,
|
NULL,
|
||||||
priv->theme,
|
renderer->priv->theme,
|
||||||
EEK_TYPE_KEYBOARD,
|
EEK_TYPE_KEYBOARD,
|
||||||
"keyboard",
|
"keyboard",
|
||||||
"keyboard",
|
"keyboard",
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
g_object_set_data_full (G_OBJECT(priv->keyboard),
|
g_object_set_data_full (G_OBJECT(renderer->priv->keyboard),
|
||||||
"theme-node",
|
"theme-node",
|
||||||
theme_node,
|
theme_node,
|
||||||
(GDestroyNotify)g_object_unref);
|
(GDestroyNotify)g_object_unref);
|
||||||
@ -1437,7 +1394,7 @@ eek_renderer_set_theme (EekRenderer *renderer,
|
|||||||
data.context = theme_context;
|
data.context = theme_context;
|
||||||
data.parent = theme_node;
|
data.parent = theme_node;
|
||||||
data.renderer = renderer;
|
data.renderer = renderer;
|
||||||
eek_container_foreach_child (EEK_CONTAINER(priv->keyboard),
|
eek_container_foreach_child (EEK_CONTAINER(renderer->priv->keyboard),
|
||||||
create_theme_node_section_callback,
|
create_theme_node_section_callback,
|
||||||
&data);
|
&data);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,35 +118,35 @@ static void
|
|||||||
on_pressed (EekKey *key,
|
on_pressed (EekKey *key,
|
||||||
EekSection *section)
|
EekSection *section)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (section, "key-pressed", key);
|
g_signal_emit (section, signals[KEY_PRESSED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_released (EekKey *key,
|
on_released (EekKey *key,
|
||||||
EekSection *section)
|
EekSection *section)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (section, "key-released", key);
|
g_signal_emit (section, signals[KEY_RELEASED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_locked (EekKey *key,
|
on_locked (EekKey *key,
|
||||||
EekSection *section)
|
EekSection *section)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (section, "key-locked", key);
|
g_signal_emit (section, signals[KEY_LOCKED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_unlocked (EekKey *key,
|
on_unlocked (EekKey *key,
|
||||||
EekSection *section)
|
EekSection *section)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (section, "key-unlocked", key);
|
g_signal_emit (section, signals[KEY_UNLOCKED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_cancelled (EekKey *key,
|
on_cancelled (EekKey *key,
|
||||||
EekSection *section)
|
EekSection *section)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (section, "key-cancelled", key);
|
g_signal_emit (section, signals[KEY_CANCELLED], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static EekKey *
|
static EekKey *
|
||||||
@ -488,7 +488,7 @@ eek_section_set_angle (EekSection *section,
|
|||||||
g_return_if_fail (EEK_IS_SECTION(section));
|
g_return_if_fail (EEK_IS_SECTION(section));
|
||||||
if (section->priv->angle != angle) {
|
if (section->priv->angle != angle) {
|
||||||
section->priv->angle = angle;
|
section->priv->angle = angle;
|
||||||
g_object_notify (section, "angle");
|
g_object_notify (G_OBJECT(section), "angle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -103,20 +103,16 @@ eek_xkl_layout_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_MODEL:
|
case PROP_MODEL:
|
||||||
eek_xkl_layout_set_model (EEK_XKL_LAYOUT(object),
|
eek_xkl_layout_set_model (layout, g_value_get_string (value));
|
||||||
g_value_get_string (value));
|
|
||||||
break;
|
break;
|
||||||
case PROP_LAYOUTS:
|
case PROP_LAYOUTS:
|
||||||
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(object),
|
eek_xkl_layout_set_layouts (layout, g_value_get_boxed (value));
|
||||||
g_value_get_boxed (value));
|
|
||||||
break;
|
break;
|
||||||
case PROP_VARIANTS:
|
case PROP_VARIANTS:
|
||||||
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(object),
|
eek_xkl_layout_set_variants (layout, g_value_get_boxed (value));
|
||||||
g_value_get_boxed (value));
|
|
||||||
break;
|
break;
|
||||||
case PROP_OPTIONS:
|
case PROP_OPTIONS:
|
||||||
eek_xkl_layout_set_options (EEK_XKL_LAYOUT(object),
|
eek_xkl_layout_set_options (layout, g_value_get_boxed (value));
|
||||||
g_value_get_boxed (value));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -135,19 +131,19 @@ eek_xkl_layout_get_property (GObject *object,
|
|||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_MODEL:
|
case PROP_MODEL:
|
||||||
g_value_set_string (value,
|
g_value_set_string (value,
|
||||||
eek_xkl_layout_get_model (EEK_XKL_LAYOUT(object)));
|
eek_xkl_layout_get_model (layout));
|
||||||
break;
|
break;
|
||||||
case PROP_LAYOUTS:
|
case PROP_LAYOUTS:
|
||||||
g_value_set_boxed (value,
|
g_value_set_boxed (value,
|
||||||
eek_xkl_layout_get_layouts (EEK_XKL_LAYOUT(object)));
|
eek_xkl_layout_get_layouts (layout));
|
||||||
break;
|
break;
|
||||||
case PROP_VARIANTS:
|
case PROP_VARIANTS:
|
||||||
g_value_set_boxed (value,
|
g_value_set_boxed (value,
|
||||||
eek_xkl_layout_get_variants (EEK_XKL_LAYOUT(object)));
|
eek_xkl_layout_get_variants (layout));
|
||||||
break;
|
break;
|
||||||
case PROP_OPTIONS:
|
case PROP_OPTIONS:
|
||||||
g_value_set_boxed (value,
|
g_value_set_boxed (value,
|
||||||
eek_xkl_layout_get_options (EEK_XKL_LAYOUT(object)));
|
eek_xkl_layout_get_options (layout));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
|||||||
@ -115,10 +115,8 @@ eekboard_client_class_init (EekboardClientClass *klass)
|
|||||||
static void
|
static void
|
||||||
eekboard_client_init (EekboardClient *self)
|
eekboard_client_init (EekboardClient *self)
|
||||||
{
|
{
|
||||||
EekboardClientPrivate *priv;
|
self->priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
||||||
|
self->priv->context_hash =
|
||||||
priv = self->priv = EEKBOARD_CLIENT_GET_PRIVATE(self);
|
|
||||||
priv->context_hash =
|
|
||||||
g_hash_table_new_full (g_str_hash,
|
g_hash_table_new_full (g_str_hash,
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
(GDestroyNotify)g_free,
|
(GDestroyNotify)g_free,
|
||||||
@ -191,9 +189,7 @@ on_context_destroyed (EekboardContext *context,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardClient *client = user_data;
|
EekboardClient *client = user_data;
|
||||||
EekboardClientPrivate *priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
g_hash_table_remove (client->priv->context_hash,
|
||||||
|
|
||||||
g_hash_table_remove (priv->context_hash,
|
|
||||||
g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)));
|
g_dbus_proxy_get_object_path (G_DBUS_PROXY(context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +211,6 @@ eekboard_client_create_context (EekboardClient *client,
|
|||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
const gchar *object_path;
|
const gchar *object_path;
|
||||||
EekboardContext *context;
|
EekboardContext *context;
|
||||||
EekboardClientPrivate *priv;
|
|
||||||
GError *error;
|
GError *error;
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
|
|
||||||
@ -244,8 +239,7 @@ eekboard_client_create_context (EekboardClient *client,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
g_hash_table_insert (client->priv->context_hash,
|
||||||
g_hash_table_insert (priv->context_hash,
|
|
||||||
g_strdup (object_path),
|
g_strdup (object_path),
|
||||||
g_object_ref (context));
|
g_object_ref (context));
|
||||||
g_signal_connect (context, "destroyed",
|
g_signal_connect (context, "destroyed",
|
||||||
@ -285,7 +279,6 @@ eekboard_client_push_context (EekboardClient *client,
|
|||||||
EekboardContext *context,
|
EekboardContext *context,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardClientPrivate *priv;
|
|
||||||
const gchar *object_path;
|
const gchar *object_path;
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||||
@ -293,8 +286,8 @@ eekboard_client_push_context (EekboardClient *client,
|
|||||||
|
|
||||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
context = g_hash_table_lookup (client->priv->context_hash,
|
||||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
object_path);
|
||||||
if (!context)
|
if (!context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -364,15 +357,13 @@ eekboard_client_destroy_context (EekboardClient *client,
|
|||||||
EekboardContext *context,
|
EekboardContext *context,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardClientPrivate *priv;
|
|
||||||
const gchar *object_path;
|
const gchar *object_path;
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
|
|
||||||
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
|
||||||
g_hash_table_remove (priv->context_hash, object_path);
|
g_hash_table_remove (client->priv->context_hash, object_path);
|
||||||
|
|
||||||
send_destroy_context (client, context, cancellable);
|
send_destroy_context (client, context, cancellable);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,7 @@ eekboard_context_service_real_create_keyboard (EekboardContextService *self,
|
|||||||
error = NULL;
|
error = NULL;
|
||||||
layout = eek_xml_layout_new (keyboard_type, &error);
|
layout = eek_xml_layout_new (keyboard_type, &error);
|
||||||
if (layout == NULL) {
|
if (layout == NULL) {
|
||||||
g_warning ("can't create keyboard: %s",
|
g_warning ("can't create keyboard %s: %s",
|
||||||
keyboard_type, error->message);
|
keyboard_type, error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -206,41 +206,40 @@ eekboard_context_service_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
gboolean was_visible;
|
gboolean was_visible;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_OBJECT_PATH:
|
case PROP_OBJECT_PATH:
|
||||||
if (priv->object_path)
|
if (context->priv->object_path)
|
||||||
g_free (priv->object_path);
|
g_free (context->priv->object_path);
|
||||||
priv->object_path = g_strdup (g_value_get_string (value));
|
context->priv->object_path = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_CONNECTION:
|
case PROP_CONNECTION:
|
||||||
connection = g_value_get_object (value);
|
connection = g_value_get_object (value);
|
||||||
if (priv->connection)
|
if (context->priv->connection)
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (context->priv->connection);
|
||||||
priv->connection = g_object_ref (connection);
|
context->priv->connection = g_object_ref (connection);
|
||||||
break;
|
break;
|
||||||
case PROP_CLIENT_NAME:
|
case PROP_CLIENT_NAME:
|
||||||
if (priv->client_name)
|
if (context->priv->client_name)
|
||||||
g_free (priv->client_name);
|
g_free (context->priv->client_name);
|
||||||
priv->client_name = g_strdup (g_value_get_string (value));
|
context->priv->client_name = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_KEYBOARD:
|
case PROP_KEYBOARD:
|
||||||
if (priv->keyboard)
|
if (context->priv->keyboard)
|
||||||
g_object_unref (priv->keyboard);
|
g_object_unref (context->priv->keyboard);
|
||||||
priv->keyboard = g_value_get_object (value);
|
context->priv->keyboard = g_value_get_object (value);
|
||||||
break;
|
break;
|
||||||
case PROP_VISIBLE:
|
case PROP_VISIBLE:
|
||||||
was_visible = priv->visible;
|
was_visible = context->priv->visible;
|
||||||
priv->visible = g_value_get_boolean (value);
|
context->priv->visible = g_value_get_boolean (value);
|
||||||
if (was_visible != priv->visible)
|
if (was_visible != context->priv->visible)
|
||||||
emit_visibility_changed_signal (EEKBOARD_CONTEXT_SERVICE(object),
|
emit_visibility_changed_signal (context,
|
||||||
priv->visible);
|
context->priv->visible);
|
||||||
break;
|
break;
|
||||||
case PROP_FULLSCREEN:
|
case PROP_FULLSCREEN:
|
||||||
priv->fullscreen = g_value_get_boolean (value);
|
context->priv->fullscreen = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -255,26 +254,25 @@ eekboard_context_service_get_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_OBJECT_PATH:
|
case PROP_OBJECT_PATH:
|
||||||
g_value_set_string (value, priv->object_path);
|
g_value_set_string (value, context->priv->object_path);
|
||||||
break;
|
break;
|
||||||
case PROP_CONNECTION:
|
case PROP_CONNECTION:
|
||||||
g_value_set_object (value, priv->connection);
|
g_value_set_object (value, context->priv->connection);
|
||||||
break;
|
break;
|
||||||
case PROP_CLIENT_NAME:
|
case PROP_CLIENT_NAME:
|
||||||
g_value_set_string (value, priv->client_name);
|
g_value_set_string (value, context->priv->client_name);
|
||||||
break;
|
break;
|
||||||
case PROP_KEYBOARD:
|
case PROP_KEYBOARD:
|
||||||
g_value_set_object (value, priv->keyboard);
|
g_value_set_object (value, context->priv->keyboard);
|
||||||
break;
|
break;
|
||||||
case PROP_VISIBLE:
|
case PROP_VISIBLE:
|
||||||
g_value_set_boolean (value, priv->visible);
|
g_value_set_boolean (value, context->priv->visible);
|
||||||
break;
|
break;
|
||||||
case PROP_FULLSCREEN:
|
case PROP_FULLSCREEN:
|
||||||
g_value_set_boolean (value, priv->fullscreen);
|
g_value_set_boolean (value, context->priv->fullscreen);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -286,63 +284,61 @@ static void
|
|||||||
eekboard_context_service_dispose (GObject *object)
|
eekboard_context_service_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
|
|
||||||
if (priv->keyboard_hash) {
|
if (context->priv->keyboard_hash) {
|
||||||
g_hash_table_destroy (priv->keyboard_hash);
|
g_hash_table_destroy (context->priv->keyboard_hash);
|
||||||
priv->keyboard_hash = NULL;
|
context->priv->keyboard_hash = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->connection) {
|
if (context->priv->connection) {
|
||||||
if (priv->registration_id > 0) {
|
if (context->priv->registration_id > 0) {
|
||||||
g_dbus_connection_unregister_object (priv->connection,
|
g_dbus_connection_unregister_object (context->priv->connection,
|
||||||
priv->registration_id);
|
context->priv->registration_id);
|
||||||
priv->registration_id = 0;
|
context->priv->registration_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (context->priv->connection);
|
||||||
priv->connection = NULL;
|
context->priv->connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->introspection_data) {
|
if (context->priv->introspection_data) {
|
||||||
g_dbus_node_info_unref (priv->introspection_data);
|
g_dbus_node_info_unref (context->priv->introspection_data);
|
||||||
priv->introspection_data = NULL;
|
context->priv->introspection_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->dispose (object);
|
G_OBJECT_CLASS (eekboard_context_service_parent_class)->
|
||||||
|
dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_service_finalize (GObject *object)
|
eekboard_context_service_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
|
|
||||||
g_free (priv->object_path);
|
g_free (context->priv->object_path);
|
||||||
g_free (priv->client_name);
|
g_free (context->priv->client_name);
|
||||||
|
|
||||||
G_OBJECT_CLASS (eekboard_context_service_parent_class)->finalize (object);
|
G_OBJECT_CLASS (eekboard_context_service_parent_class)->
|
||||||
|
finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_service_constructed (GObject *object)
|
eekboard_context_service_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
|
EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE (object);
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
|
|
||||||
if (priv->connection && priv->object_path) {
|
if (context->priv->connection && context->priv->object_path) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
context->priv->registration_id = g_dbus_connection_register_object
|
||||||
priv->registration_id = g_dbus_connection_register_object
|
(context->priv->connection,
|
||||||
(priv->connection,
|
context->priv->object_path,
|
||||||
priv->object_path,
|
context->priv->introspection_data->interfaces[0],
|
||||||
priv->introspection_data->interfaces[0],
|
|
||||||
&interface_vtable,
|
&interface_vtable,
|
||||||
context,
|
context,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
if (priv->registration_id == 0) {
|
if (context->priv->registration_id == 0) {
|
||||||
g_warning ("failed to register context object: %s",
|
g_warning ("failed to register context object: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
@ -489,57 +485,53 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_service_init (EekboardContextService *context)
|
eekboard_context_service_init (EekboardContextService *self)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
|
self->priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(self);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
priv->introspection_data =
|
self->priv->introspection_data =
|
||||||
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
||||||
if (priv->introspection_data == NULL) {
|
if (self->priv->introspection_data == NULL) {
|
||||||
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->keyboard_hash =
|
self->priv->keyboard_hash =
|
||||||
g_hash_table_new_full (g_direct_hash,
|
g_hash_table_new_full (g_direct_hash,
|
||||||
g_direct_equal,
|
g_direct_equal,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify)g_object_unref);
|
(GDestroyNotify)g_object_unref);
|
||||||
|
|
||||||
priv->settings = g_settings_new ("org.fedorahosted.eekboard");
|
self->priv->settings = g_settings_new ("org.fedorahosted.eekboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disconnect_keyboard_signals (EekboardContextService *context)
|
disconnect_keyboard_signals (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
if (g_signal_handler_is_connected (context->priv->keyboard,
|
||||||
|
context->priv->key_pressed_handler))
|
||||||
if (g_signal_handler_is_connected (priv->keyboard,
|
g_signal_handler_disconnect (context->priv->keyboard,
|
||||||
priv->key_pressed_handler))
|
context->priv->key_pressed_handler);
|
||||||
g_signal_handler_disconnect (priv->keyboard,
|
if (g_signal_handler_is_connected (context->priv->keyboard,
|
||||||
priv->key_pressed_handler);
|
context->priv->key_released_handler))
|
||||||
if (g_signal_handler_is_connected (priv->keyboard,
|
g_signal_handler_disconnect (context->priv->keyboard,
|
||||||
priv->key_released_handler))
|
context->priv->key_released_handler);
|
||||||
g_signal_handler_disconnect (priv->keyboard,
|
|
||||||
priv->key_released_handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
emit_visibility_changed_signal (EekboardContextService *context,
|
emit_visibility_changed_signal (EekboardContextService *context,
|
||||||
gboolean visible)
|
gboolean visible)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
if (context->priv->connection && context->priv->enabled) {
|
||||||
|
|
||||||
if (priv->connection && priv->enabled) {
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
priv->object_path,
|
context->priv->object_path,
|
||||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||||
"VisibilityChanged",
|
"VisibilityChanged",
|
||||||
g_variant_new ("(b)", visible),
|
g_variant_new ("(b)", visible),
|
||||||
@ -557,15 +549,13 @@ static void
|
|||||||
emit_group_changed_signal (EekboardContextService *context,
|
emit_group_changed_signal (EekboardContextService *context,
|
||||||
gint group)
|
gint group)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
if (context->priv->connection && context->priv->enabled) {
|
||||||
|
|
||||||
if (priv->connection && priv->enabled) {
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
priv->object_path,
|
context->priv->object_path,
|
||||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||||
"GroupChanged",
|
"GroupChanged",
|
||||||
g_variant_new ("(i)", group),
|
g_variant_new ("(i)", group),
|
||||||
@ -583,12 +573,10 @@ static void
|
|||||||
emit_key_activated_dbus_signal (EekboardContextService *context,
|
emit_key_activated_dbus_signal (EekboardContextService *context,
|
||||||
EekKey *key)
|
EekKey *key)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
if (context->priv->connection && context->priv->enabled) {
|
||||||
|
|
||||||
if (priv->connection && priv->enabled) {
|
|
||||||
const gchar *keyname = eek_element_get_name (EEK_ELEMENT(key));
|
const gchar *keyname = eek_element_get_name (EEK_ELEMENT(key));
|
||||||
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
|
EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
|
||||||
guint modifiers = eek_keyboard_get_modifiers (priv->keyboard);
|
guint modifiers = eek_keyboard_get_modifiers (context->priv->keyboard);
|
||||||
GVariant *variant;
|
GVariant *variant;
|
||||||
GError *error;
|
GError *error;
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
@ -596,9 +584,9 @@ emit_key_activated_dbus_signal (EekboardContextService *context,
|
|||||||
variant = eek_serializable_serialize (EEK_SERIALIZABLE(symbol));
|
variant = eek_serializable_serialize (EEK_SERIALIZABLE(symbol));
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
priv->object_path,
|
context->priv->object_path,
|
||||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||||
"KeyActivated",
|
"KeyActivated",
|
||||||
g_variant_new ("(svu)",
|
g_variant_new ("(svu)",
|
||||||
@ -606,7 +594,6 @@ emit_key_activated_dbus_signal (EekboardContextService *context,
|
|||||||
variant,
|
variant,
|
||||||
modifiers),
|
modifiers),
|
||||||
&error);
|
&error);
|
||||||
g_variant_unref (variant);
|
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
g_warning ("failed to emit KeyActivated signal: %s",
|
g_warning ("failed to emit KeyActivated signal: %s",
|
||||||
error->message);
|
error->message);
|
||||||
@ -621,14 +608,13 @@ static gboolean on_repeat_timeout (EekboardContextService *context);
|
|||||||
static gboolean
|
static gboolean
|
||||||
on_repeat_timeout (EekboardContextService *context)
|
on_repeat_timeout (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
guint delay;
|
guint delay;
|
||||||
|
|
||||||
g_settings_get (priv->settings, "repeat-interval", "u", &delay);
|
g_settings_get (context->priv->settings, "repeat-interval", "u", &delay);
|
||||||
|
|
||||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
emit_key_activated_dbus_signal (context, context->priv->repeat_key);
|
||||||
|
|
||||||
priv->repeat_timeout_id =
|
context->priv->repeat_timeout_id =
|
||||||
g_timeout_add (delay,
|
g_timeout_add (delay,
|
||||||
(GSourceFunc)on_repeat_timeout,
|
(GSourceFunc)on_repeat_timeout,
|
||||||
context);
|
context);
|
||||||
@ -639,25 +625,23 @@ on_repeat_timeout (EekboardContextService *context)
|
|||||||
static gboolean
|
static gboolean
|
||||||
on_repeat_timeout_init (EekboardContextService *context)
|
on_repeat_timeout_init (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
emit_key_activated_dbus_signal (context, context->priv->repeat_key);
|
||||||
|
|
||||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
|
||||||
|
|
||||||
/* FIXME: clear modifiers for further key repeat; better not
|
/* FIXME: clear modifiers for further key repeat; better not
|
||||||
depend on modifier behavior is LATCH */
|
depend on modifier behavior is LATCH */
|
||||||
eek_keyboard_set_modifiers (priv->keyboard, 0);
|
eek_keyboard_set_modifiers (context->priv->keyboard, 0);
|
||||||
|
|
||||||
/* reschedule repeat timeout only when "repeat" option is set */
|
/* reschedule repeat timeout only when "repeat" option is set */
|
||||||
if (g_settings_get_boolean (priv->settings, "repeat")) {
|
if (g_settings_get_boolean (context->priv->settings, "repeat")) {
|
||||||
guint delay;
|
guint delay;
|
||||||
|
|
||||||
g_settings_get (priv->settings, "repeat-interval", "u", &delay);
|
g_settings_get (context->priv->settings, "repeat-interval", "u", &delay);
|
||||||
priv->repeat_timeout_id =
|
context->priv->repeat_timeout_id =
|
||||||
g_timeout_add (delay,
|
g_timeout_add (delay,
|
||||||
(GSourceFunc)on_repeat_timeout,
|
(GSourceFunc)on_repeat_timeout,
|
||||||
context);
|
context);
|
||||||
} else
|
} else
|
||||||
priv->repeat_timeout_id = 0;
|
context->priv->repeat_timeout_id = 0;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -668,18 +652,17 @@ on_key_pressed (EekKeyboard *keyboard,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = user_data;
|
EekboardContextService *context = user_data;
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
guint delay;
|
guint delay;
|
||||||
|
|
||||||
g_settings_get (priv->settings, "repeat-delay", "u", &delay);
|
g_settings_get (context->priv->settings, "repeat-delay", "u", &delay);
|
||||||
|
|
||||||
if (priv->repeat_timeout_id) {
|
if (context->priv->repeat_timeout_id) {
|
||||||
g_source_remove (priv->repeat_timeout_id);
|
g_source_remove (context->priv->repeat_timeout_id);
|
||||||
priv->repeat_timeout_id = 0;
|
context->priv->repeat_timeout_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->repeat_key = key;
|
context->priv->repeat_key = key;
|
||||||
priv->repeat_timeout_id =
|
context->priv->repeat_timeout_id =
|
||||||
g_timeout_add (delay,
|
g_timeout_add (delay,
|
||||||
(GSourceFunc)on_repeat_timeout_init,
|
(GSourceFunc)on_repeat_timeout_init,
|
||||||
context);
|
context);
|
||||||
@ -691,28 +674,26 @@ on_key_released (EekKeyboard *keyboard,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = user_data;
|
EekboardContextService *context = user_data;
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
|
|
||||||
if (priv->repeat_timeout_id > 0) {
|
if (context->priv->repeat_timeout_id > 0) {
|
||||||
g_source_remove (priv->repeat_timeout_id);
|
g_source_remove (context->priv->repeat_timeout_id);
|
||||||
priv->repeat_timeout_id = 0;
|
context->priv->repeat_timeout_id = 0;
|
||||||
|
|
||||||
/* KeyActivated signal has not been emitted in repeat handler */
|
/* KeyActivated signal has not been emitted in repeat handler */
|
||||||
emit_key_activated_dbus_signal (context, priv->repeat_key);
|
emit_key_activated_dbus_signal (context,
|
||||||
|
context->priv->repeat_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
connect_keyboard_signals (EekboardContextService *context)
|
connect_keyboard_signals (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
context->priv->key_pressed_handler =
|
||||||
|
g_signal_connect (context->priv->keyboard, "key-pressed",
|
||||||
priv->key_pressed_handler =
|
|
||||||
g_signal_connect (priv->keyboard, "key-pressed",
|
|
||||||
G_CALLBACK(on_key_pressed),
|
G_CALLBACK(on_key_pressed),
|
||||||
context);
|
context);
|
||||||
priv->key_released_handler =
|
context->priv->key_released_handler =
|
||||||
g_signal_connect (priv->keyboard, "key-released",
|
g_signal_connect (context->priv->keyboard, "key-released",
|
||||||
G_CALLBACK(on_key_released),
|
G_CALLBACK(on_key_released),
|
||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
@ -728,7 +709,6 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardContextService *context = user_data;
|
EekboardContextService *context = user_data;
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
|
EekboardContextServiceClass *klass = EEKBOARD_CONTEXT_SERVICE_GET_CLASS(context);
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "AddKeyboard") == 0) {
|
if (g_strcmp0 (method_name, "AddKeyboard") == 0) {
|
||||||
@ -751,7 +731,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||||
|
|
||||||
keyboard_id++;
|
keyboard_id++;
|
||||||
g_hash_table_insert (priv->keyboard_hash,
|
g_hash_table_insert (context->priv->keyboard_hash,
|
||||||
GUINT_TO_POINTER(keyboard_id),
|
GUINT_TO_POINTER(keyboard_id),
|
||||||
keyboard);
|
keyboard);
|
||||||
g_object_set_data (G_OBJECT(keyboard),
|
g_object_set_data (G_OBJECT(keyboard),
|
||||||
@ -769,15 +749,15 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
g_variant_get (parameters, "(u)", &keyboard_id);
|
g_variant_get (parameters, "(u)", &keyboard_id);
|
||||||
|
|
||||||
current_keyboard_id =
|
current_keyboard_id =
|
||||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(priv->keyboard),
|
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(context->priv->keyboard),
|
||||||
"keyboard-id"));
|
"keyboard-id"));
|
||||||
if (keyboard_id == current_keyboard_id) {
|
if (keyboard_id == current_keyboard_id) {
|
||||||
disconnect_keyboard_signals (context);
|
disconnect_keyboard_signals (context);
|
||||||
priv->keyboard = NULL;
|
context->priv->keyboard = NULL;
|
||||||
g_object_notify (G_OBJECT(context), "keyboard");
|
g_object_notify (G_OBJECT(context), "keyboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_remove (priv->keyboard_hash,
|
g_hash_table_remove (context->priv->keyboard_hash,
|
||||||
GUINT_TO_POINTER(keyboard_id));
|
GUINT_TO_POINTER(keyboard_id));
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
return;
|
return;
|
||||||
@ -790,7 +770,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
|
|
||||||
g_variant_get (parameters, "(u)", &keyboard_id);
|
g_variant_get (parameters, "(u)", &keyboard_id);
|
||||||
|
|
||||||
keyboard = g_hash_table_lookup (priv->keyboard_hash,
|
keyboard = g_hash_table_lookup (context->priv->keyboard_hash,
|
||||||
GUINT_TO_POINTER(keyboard_id));
|
GUINT_TO_POINTER(keyboard_id));
|
||||||
if (!keyboard) {
|
if (!keyboard) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
@ -800,20 +780,20 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyboard == priv->keyboard) {
|
if (keyboard == context->priv->keyboard) {
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->keyboard)
|
if (context->priv->keyboard)
|
||||||
disconnect_keyboard_signals (context);
|
disconnect_keyboard_signals (context);
|
||||||
|
|
||||||
priv->keyboard = keyboard;
|
context->priv->keyboard = keyboard;
|
||||||
connect_keyboard_signals (context);
|
connect_keyboard_signals (context);
|
||||||
|
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
|
|
||||||
group = eek_element_get_group (EEK_ELEMENT(priv->keyboard));
|
group = eek_element_get_group (EEK_ELEMENT(context->priv->keyboard));
|
||||||
emit_group_changed_signal (context, group);
|
emit_group_changed_signal (context, group);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT(context), "keyboard");
|
g_object_notify (G_OBJECT(context), "keyboard");
|
||||||
@ -825,11 +805,11 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
|
|
||||||
g_variant_get (parameters, "(b)", &fullscreen);
|
g_variant_get (parameters, "(b)", &fullscreen);
|
||||||
|
|
||||||
if (priv->fullscreen == fullscreen) {
|
if (context->priv->fullscreen == fullscreen) {
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
priv->fullscreen = fullscreen;
|
context->priv->fullscreen = fullscreen;
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT(context), "fullscreen");
|
g_object_notify (G_OBJECT(context), "fullscreen");
|
||||||
@ -839,7 +819,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
if (g_strcmp0 (method_name, "SetGroup") == 0) {
|
if (g_strcmp0 (method_name, "SetGroup") == 0) {
|
||||||
gint group;
|
gint group;
|
||||||
|
|
||||||
if (!priv->keyboard) {
|
if (!context->priv->keyboard) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED_HANDLED,
|
G_IO_ERROR_FAILED_HANDLED,
|
||||||
@ -848,14 +828,14 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_variant_get (parameters, "(i)", &group);
|
g_variant_get (parameters, "(i)", &group);
|
||||||
eek_element_set_group (EEK_ELEMENT(priv->keyboard), group);
|
eek_element_set_group (EEK_ELEMENT(context->priv->keyboard), group);
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
emit_group_changed_signal (context, group);
|
emit_group_changed_signal (context, group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "ShowKeyboard") == 0) {
|
if (g_strcmp0 (method_name, "ShowKeyboard") == 0) {
|
||||||
if (!priv->keyboard) {
|
if (!context->priv->keyboard) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED_HANDLED,
|
G_IO_ERROR_FAILED_HANDLED,
|
||||||
@ -881,7 +861,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
EekKey *key;
|
EekKey *key;
|
||||||
guint keycode;
|
guint keycode;
|
||||||
|
|
||||||
if (!priv->keyboard) {
|
if (!context->priv->keyboard) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED_HANDLED,
|
G_IO_ERROR_FAILED_HANDLED,
|
||||||
@ -890,7 +870,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_variant_get (parameters, "(u)", &keycode);
|
g_variant_get (parameters, "(u)", &keycode);
|
||||||
key = eek_keyboard_find_key_by_keycode (priv->keyboard, keycode);
|
key = eek_keyboard_find_key_by_keycode (context->priv->keyboard, keycode);
|
||||||
|
|
||||||
if (!key) {
|
if (!key) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
@ -902,17 +882,17 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "PressKeycode") == 0) {
|
if (g_strcmp0 (method_name, "PressKeycode") == 0) {
|
||||||
g_signal_handler_block (priv->keyboard,
|
g_signal_handler_block (context->priv->keyboard,
|
||||||
priv->key_pressed_handler);
|
context->priv->key_pressed_handler);
|
||||||
g_signal_emit_by_name (key, "pressed");
|
g_signal_emit_by_name (key, "pressed");
|
||||||
g_signal_handler_unblock (priv->keyboard,
|
g_signal_handler_unblock (context->priv->keyboard,
|
||||||
priv->key_pressed_handler);
|
context->priv->key_pressed_handler);
|
||||||
} else {
|
} else {
|
||||||
g_signal_handler_block (priv->keyboard,
|
g_signal_handler_block (context->priv->keyboard,
|
||||||
priv->key_released_handler);
|
context->priv->key_released_handler);
|
||||||
g_signal_emit_by_name (key, "released");
|
g_signal_emit_by_name (key, "released");
|
||||||
g_signal_handler_unblock (priv->keyboard,
|
g_signal_handler_unblock (context->priv->keyboard,
|
||||||
priv->key_released_handler);
|
context->priv->key_released_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
@ -932,21 +912,20 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
void
|
void
|
||||||
eekboard_context_service_enable (EekboardContextService *context)
|
eekboard_context_service_enable (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||||
g_return_if_fail (priv->connection);
|
g_return_if_fail (context->priv->connection);
|
||||||
|
|
||||||
if (!priv->enabled) {
|
if (!context->priv->enabled) {
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
priv->enabled = TRUE;
|
context->priv->enabled = TRUE;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
priv->object_path,
|
context->priv->object_path,
|
||||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||||
"Enabled",
|
"Enabled",
|
||||||
NULL,
|
NULL,
|
||||||
@ -957,7 +936,7 @@ eekboard_context_service_enable (EekboardContextService *context)
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
g_signal_emit_by_name (context, "enabled", NULL);
|
g_signal_emit (context, signals[ENABLED], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,21 +950,20 @@ eekboard_context_service_enable (EekboardContextService *context)
|
|||||||
void
|
void
|
||||||
eekboard_context_service_disable (EekboardContextService *context)
|
eekboard_context_service_disable (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT_SERVICE(context));
|
||||||
g_return_if_fail (priv->connection);
|
g_return_if_fail (context->priv->connection);
|
||||||
|
|
||||||
if (priv->enabled) {
|
if (context->priv->enabled) {
|
||||||
gboolean retval;
|
gboolean retval;
|
||||||
|
|
||||||
priv->enabled = FALSE;
|
context->priv->enabled = FALSE;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
retval = g_dbus_connection_emit_signal (priv->connection,
|
retval = g_dbus_connection_emit_signal (context->priv->connection,
|
||||||
NULL,
|
NULL,
|
||||||
priv->object_path,
|
context->priv->object_path,
|
||||||
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
EEKBOARD_CONTEXT_SERVICE_INTERFACE,
|
||||||
"Disabled",
|
"Disabled",
|
||||||
NULL,
|
NULL,
|
||||||
@ -996,7 +974,7 @@ eekboard_context_service_disable (EekboardContextService *context)
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
g_signal_emit_by_name (context, "disabled", NULL);
|
g_signal_emit (context, signals[DISABLED], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1010,8 +988,7 @@ eekboard_context_service_disable (EekboardContextService *context)
|
|||||||
EekKeyboard *
|
EekKeyboard *
|
||||||
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
eekboard_context_service_get_keyboard (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
return context->priv->keyboard;
|
||||||
return priv->keyboard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1024,8 +1001,7 @@ eekboard_context_service_get_keyboard (EekboardContextService *context)
|
|||||||
gboolean
|
gboolean
|
||||||
eekboard_context_service_get_fullscreen (EekboardContextService *context)
|
eekboard_context_service_get_fullscreen (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
return context->priv->fullscreen;
|
||||||
return priv->fullscreen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1038,6 +1014,5 @@ eekboard_context_service_get_fullscreen (EekboardContextService *context)
|
|||||||
const gchar *
|
const gchar *
|
||||||
eekboard_context_service_get_client_name (EekboardContextService *context)
|
eekboard_context_service_get_client_name (EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardContextServicePrivate *priv = EEKBOARD_CONTEXT_SERVICE_GET_PRIVATE(context);
|
return context->priv->client_name;
|
||||||
return priv->client_name;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,15 +69,14 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
GVariant *parameters)
|
GVariant *parameters)
|
||||||
{
|
{
|
||||||
EekboardContext *context = EEKBOARD_CONTEXT (self);
|
EekboardContext *context = EEKBOARD_CONTEXT (self);
|
||||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
|
|
||||||
if (g_strcmp0 (signal_name, "Enabled") == 0) {
|
if (g_strcmp0 (signal_name, "Enabled") == 0) {
|
||||||
g_signal_emit_by_name (context, "enabled");
|
g_signal_emit (context, signals[ENABLED], 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (signal_name, "Disabled") == 0) {
|
if (g_strcmp0 (signal_name, "Disabled") == 0) {
|
||||||
g_signal_emit_by_name (context, "disabled");
|
g_signal_emit (context, signals[DISABLED], 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +86,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
guint modifiers = 0;
|
guint modifiers = 0;
|
||||||
EekSerializable *serializable;
|
EekSerializable *serializable;
|
||||||
|
|
||||||
g_variant_get (parameters, "(&svu)", &keyname, &variant, &modifiers);
|
g_variant_get (parameters, "(&svu)",
|
||||||
|
&keyname, &variant, &modifiers);
|
||||||
g_return_if_fail (variant != NULL);
|
g_return_if_fail (variant != NULL);
|
||||||
|
|
||||||
serializable = eek_serializable_deserialize (variant);
|
serializable = eek_serializable_deserialize (variant);
|
||||||
@ -95,8 +95,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
|
|
||||||
g_return_if_fail (EEK_IS_SYMBOL(serializable));
|
g_return_if_fail (EEK_IS_SYMBOL(serializable));
|
||||||
|
|
||||||
g_signal_emit_by_name (context, "key-pressed",
|
g_signal_emit (context, signals[KEY_PRESSED], 0,
|
||||||
keyname, EEK_SYMBOL(serializable), modifiers);
|
keyname, EEK_SYMBOL(serializable), modifiers);
|
||||||
g_object_unref (serializable);
|
g_object_unref (serializable);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -106,8 +106,8 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
gboolean visible = FALSE;
|
gboolean visible = FALSE;
|
||||||
|
|
||||||
g_variant_get (parameters, "(b)", &visible);
|
g_variant_get (parameters, "(b)", &visible);
|
||||||
if (visible != priv->visible) {
|
if (visible != context->priv->visible) {
|
||||||
priv->visible = visible;
|
context->priv->visible = visible;
|
||||||
g_object_notify (G_OBJECT(context), "visible");
|
g_object_notify (G_OBJECT(context), "visible");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -117,9 +117,9 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
gint group = 0;
|
gint group = 0;
|
||||||
|
|
||||||
g_variant_get (parameters, "(i)", &group);
|
g_variant_get (parameters, "(i)", &group);
|
||||||
if (group != priv->group) {
|
if (group != context->priv->group) {
|
||||||
priv->group = group;
|
context->priv->group = group;
|
||||||
//g_object_notify (G_OBJECT(context), "group");
|
/* g_object_notify (G_OBJECT(context), "group"); */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -130,15 +130,13 @@ eekboard_context_real_g_signal (GDBusProxy *self,
|
|||||||
static void
|
static void
|
||||||
eekboard_context_real_enabled (EekboardContext *self)
|
eekboard_context_real_enabled (EekboardContext *self)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
|
self->priv->enabled = TRUE;
|
||||||
priv->enabled = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_context_real_disabled (EekboardContext *self)
|
eekboard_context_real_disabled (EekboardContext *self)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
|
self->priv->enabled = FALSE;
|
||||||
priv->enabled = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -160,15 +158,13 @@ eekboard_context_get_property (GObject *object,
|
|||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(object);
|
EekboardContext *context = EEKBOARD_CONTEXT(object);
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_VISIBLE:
|
case PROP_VISIBLE:
|
||||||
g_value_set_boolean (value, priv->visible);
|
g_value_set_boolean (value, context->priv->visible);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_object_get_property (object,
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
g_param_spec_get_name (pspec),
|
|
||||||
value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,7 +291,7 @@ context_name_vanished_callback (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardContext *context = user_data;
|
EekboardContext *context = user_data;
|
||||||
g_signal_emit_by_name (context, "destroyed", NULL);
|
g_signal_emit (context, signals[DESTROYED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -316,8 +312,8 @@ eekboard_context_new (GDBusConnection *connection,
|
|||||||
GInitable *initable;
|
GInitable *initable;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
g_assert (object_path != NULL);
|
g_return_val_if_fail (object_path != NULL, NULL);
|
||||||
g_assert (G_IS_DBUS_CONNECTION(connection));
|
g_return_val_if_fail (G_IS_DBUS_CONNECTION(connection), NULL);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
initable =
|
initable =
|
||||||
@ -481,13 +477,9 @@ eekboard_context_set_group (EekboardContext *context,
|
|||||||
gint group,
|
gint group,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
if (context->priv->group != group) {
|
||||||
|
|
||||||
if (priv->group != group) {
|
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
"SetGroup",
|
"SetGroup",
|
||||||
g_variant_new ("(i)", group),
|
g_variant_new ("(i)", group),
|
||||||
@ -510,12 +502,8 @@ gint
|
|||||||
eekboard_context_get_group (EekboardContext *context,
|
eekboard_context_get_group (EekboardContext *context,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
|
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
|
||||||
|
return context->priv->group;
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
return priv->group;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -530,22 +518,18 @@ void
|
|||||||
eekboard_context_show_keyboard (EekboardContext *context,
|
eekboard_context_show_keyboard (EekboardContext *context,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
if (context->priv->enabled) {
|
||||||
if (!priv->enabled)
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
return;
|
"ShowKeyboard",
|
||||||
|
NULL,
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
"ShowKeyboard",
|
-1,
|
||||||
NULL,
|
cancellable,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
context_async_ready_callback,
|
||||||
-1,
|
NULL);
|
||||||
cancellable,
|
}
|
||||||
context_async_ready_callback,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -559,22 +543,18 @@ void
|
|||||||
eekboard_context_hide_keyboard (EekboardContext *context,
|
eekboard_context_hide_keyboard (EekboardContext *context,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
if (context->priv->enabled) {
|
||||||
if (!priv->enabled)
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
return;
|
"HideKeyboard",
|
||||||
|
NULL,
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
"HideKeyboard",
|
-1,
|
||||||
NULL,
|
cancellable,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
context_async_ready_callback,
|
||||||
-1,
|
NULL);
|
||||||
cancellable,
|
}
|
||||||
context_async_ready_callback,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -590,22 +570,18 @@ eekboard_context_press_keycode (EekboardContext *context,
|
|||||||
guint keycode,
|
guint keycode,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
if (context->priv->enabled) {
|
||||||
if (!priv->enabled)
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
return;
|
"PressKeycode",
|
||||||
|
g_variant_new ("(u)", keycode),
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
"PressKeycode",
|
-1,
|
||||||
g_variant_new ("(u)", keycode),
|
cancellable,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
context_async_ready_callback,
|
||||||
-1,
|
NULL);
|
||||||
cancellable,
|
}
|
||||||
context_async_ready_callback,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -621,22 +597,18 @@ eekboard_context_release_keycode (EekboardContext *context,
|
|||||||
guint keycode,
|
guint keycode,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
if (context->priv->enabled) {
|
||||||
if (!priv->enabled)
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
return;
|
"ReleaseKeycode",
|
||||||
|
g_variant_new ("(u)", keycode),
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
"ReleaseKeycode",
|
-1,
|
||||||
g_variant_new ("(u)", keycode),
|
cancellable,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
context_async_ready_callback,
|
||||||
-1,
|
NULL);
|
||||||
cancellable,
|
}
|
||||||
context_async_ready_callback,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -648,12 +620,8 @@ eekboard_context_release_keycode (EekboardContext *context,
|
|||||||
gboolean
|
gboolean
|
||||||
eekboard_context_is_visible (EekboardContext *context)
|
eekboard_context_is_visible (EekboardContext *context)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||||
|
return context->priv->enabled && context->priv->visible;
|
||||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
return priv->enabled && priv->visible;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -669,12 +637,8 @@ void
|
|||||||
eekboard_context_set_enabled (EekboardContext *context,
|
eekboard_context_set_enabled (EekboardContext *context,
|
||||||
gboolean enabled)
|
gboolean enabled)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
context->priv->enabled = enabled;
|
||||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
priv->enabled = enabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -686,12 +650,8 @@ eekboard_context_set_enabled (EekboardContext *context,
|
|||||||
gboolean
|
gboolean
|
||||||
eekboard_context_is_enabled (EekboardContext *context)
|
eekboard_context_is_enabled (EekboardContext *context)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), FALSE);
|
||||||
|
return context->priv->enabled;
|
||||||
g_assert (EEKBOARD_IS_CONTEXT(context));
|
|
||||||
|
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
return priv->enabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -707,12 +667,8 @@ eekboard_context_set_fullscreen (EekboardContext *context,
|
|||||||
gboolean fullscreen,
|
gboolean fullscreen,
|
||||||
GCancellable *cancellable)
|
GCancellable *cancellable)
|
||||||
{
|
{
|
||||||
EekboardContextPrivate *priv;
|
|
||||||
|
|
||||||
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
|
||||||
|
if (context->priv->fullscreen != fullscreen) {
|
||||||
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
|
|
||||||
if (priv->fullscreen != fullscreen) {
|
|
||||||
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
g_dbus_proxy_call (G_DBUS_PROXY(context),
|
||||||
"SetFullscreen",
|
"SetFullscreen",
|
||||||
g_variant_new ("(b)", fullscreen),
|
g_variant_new ("(b)", fullscreen),
|
||||||
|
|||||||
@ -101,20 +101,19 @@ eekboard_service_set_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
GDBusConnection *connection;
|
GDBusConnection *connection;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_OBJECT_PATH:
|
case PROP_OBJECT_PATH:
|
||||||
if (priv->object_path)
|
if (service->priv->object_path)
|
||||||
g_free (priv->object_path);
|
g_free (service->priv->object_path);
|
||||||
priv->object_path = g_strdup (g_value_get_string (value));
|
service->priv->object_path = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_CONNECTION:
|
case PROP_CONNECTION:
|
||||||
connection = g_value_get_object (value);
|
connection = g_value_get_object (value);
|
||||||
if (priv->connection)
|
if (service->priv->connection)
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (service->priv->connection);
|
||||||
priv->connection = g_object_ref (connection);
|
service->priv->connection = g_object_ref (connection);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -129,14 +128,13 @@ eekboard_service_get_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_OBJECT_PATH:
|
case PROP_OBJECT_PATH:
|
||||||
g_value_set_string (value, priv->object_path);
|
g_value_set_string (value, service->priv->object_path);
|
||||||
break;
|
break;
|
||||||
case PROP_CONNECTION:
|
case PROP_CONNECTION:
|
||||||
g_value_set_object (value, priv->connection);
|
g_value_set_object (value, service->priv->connection);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -148,34 +146,33 @@ static void
|
|||||||
eekboard_service_dispose (GObject *object)
|
eekboard_service_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardService *service = EEKBOARD_SERVICE(object);
|
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
GSList *head;
|
GSList *head;
|
||||||
|
|
||||||
if (priv->context_hash) {
|
if (service->priv->context_hash) {
|
||||||
g_hash_table_destroy (priv->context_hash);
|
g_hash_table_destroy (service->priv->context_hash);
|
||||||
priv->context_hash = NULL;
|
service->priv->context_hash = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (head = priv->context_stack; head; head = priv->context_stack) {
|
for (head = service->priv->context_stack; head; head = service->priv->context_stack) {
|
||||||
g_object_unref (head->data);
|
g_object_unref (head->data);
|
||||||
priv->context_stack = g_slist_next (head);
|
service->priv->context_stack = g_slist_next (head);
|
||||||
g_slist_free1 (head);
|
g_slist_free1 (head);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->connection) {
|
if (service->priv->connection) {
|
||||||
if (priv->registration_id > 0) {
|
if (service->priv->registration_id > 0) {
|
||||||
g_dbus_connection_unregister_object (priv->connection,
|
g_dbus_connection_unregister_object (service->priv->connection,
|
||||||
priv->registration_id);
|
service->priv->registration_id);
|
||||||
priv->registration_id = 0;
|
service->priv->registration_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (service->priv->connection);
|
||||||
priv->connection = NULL;
|
service->priv->connection = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->introspection_data) {
|
if (service->priv->introspection_data) {
|
||||||
g_dbus_node_info_unref (priv->introspection_data);
|
g_dbus_node_info_unref (service->priv->introspection_data);
|
||||||
priv->introspection_data = NULL;
|
service->priv->introspection_data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (eekboard_service_parent_class)->dispose (object);
|
G_OBJECT_CLASS (eekboard_service_parent_class)->dispose (object);
|
||||||
@ -184,9 +181,9 @@ eekboard_service_dispose (GObject *object)
|
|||||||
static void
|
static void
|
||||||
eekboard_service_finalize (GObject *object)
|
eekboard_service_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(object);
|
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||||
|
|
||||||
g_free (priv->object_path);
|
g_free (service->priv->object_path);
|
||||||
|
|
||||||
G_OBJECT_CLASS (eekboard_service_parent_class)->finalize (object);
|
G_OBJECT_CLASS (eekboard_service_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -194,20 +191,20 @@ eekboard_service_finalize (GObject *object)
|
|||||||
static void
|
static void
|
||||||
eekboard_service_constructed (GObject *object)
|
eekboard_service_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(object);
|
EekboardService *service = EEKBOARD_SERVICE(object);
|
||||||
if (priv->connection && priv->object_path) {
|
if (service->priv->connection && service->priv->object_path) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
priv->registration_id = g_dbus_connection_register_object
|
service->priv->registration_id = g_dbus_connection_register_object
|
||||||
(priv->connection,
|
(service->priv->connection,
|
||||||
priv->object_path,
|
service->priv->object_path,
|
||||||
priv->introspection_data->interfaces[0],
|
service->priv->introspection_data->interfaces[0],
|
||||||
&interface_vtable,
|
&interface_vtable,
|
||||||
object,
|
object,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
if (priv->registration_id == 0) {
|
if (service->priv->registration_id == 0) {
|
||||||
g_warning ("failed to register context object: %s",
|
g_warning ("failed to register context object: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
@ -279,23 +276,22 @@ eekboard_service_class_init (EekboardServiceClass *klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_service_init (EekboardService *service)
|
eekboard_service_init (EekboardService *self)
|
||||||
{
|
{
|
||||||
EekboardServicePrivate *priv;
|
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
priv = service->priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
self->priv = EEKBOARD_SERVICE_GET_PRIVATE(self);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
priv->introspection_data =
|
self->priv->introspection_data =
|
||||||
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
g_dbus_node_info_new_for_xml (introspection_xml, &error);
|
||||||
if (priv->introspection_data == NULL) {
|
if (self->priv->introspection_data == NULL) {
|
||||||
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
g_warning ("failed to parse D-Bus XML: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->context_hash =
|
self->priv->context_hash =
|
||||||
g_hash_table_new_full (g_str_hash,
|
g_hash_table_new_full (g_str_hash,
|
||||||
g_str_equal,
|
g_str_equal,
|
||||||
(GDestroyNotify)g_free,
|
(GDestroyNotify)g_free,
|
||||||
@ -306,17 +302,16 @@ static void
|
|||||||
remove_context_from_stack (EekboardService *service,
|
remove_context_from_stack (EekboardService *service,
|
||||||
EekboardContextService *context)
|
EekboardContextService *context)
|
||||||
{
|
{
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
GSList *head;
|
GSList *head;
|
||||||
|
|
||||||
head = g_slist_find (priv->context_stack, context);
|
head = g_slist_find (service->priv->context_stack, context);
|
||||||
if (head) {
|
if (head) {
|
||||||
priv->context_stack = g_slist_remove_link (priv->context_stack, head);
|
service->priv->context_stack = g_slist_remove_link (service->priv->context_stack, head);
|
||||||
g_object_unref (head->data);
|
g_object_unref (head->data);
|
||||||
g_slist_free1 (head);
|
g_slist_free1 (head);
|
||||||
}
|
}
|
||||||
if (priv->context_stack)
|
if (service->priv->context_stack)
|
||||||
eekboard_context_service_enable (priv->context_stack->data);
|
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -325,25 +320,24 @@ service_name_vanished_callback (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardService *service = user_data;
|
EekboardService *service = user_data;
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
GSList *head;
|
GSList *head;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer k, v;
|
gpointer k, v;
|
||||||
|
|
||||||
g_hash_table_iter_init (&iter, priv->context_hash);
|
g_hash_table_iter_init (&iter, service->priv->context_hash);
|
||||||
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
while (g_hash_table_iter_next (&iter, &k, &v)) {
|
||||||
const gchar *owner = g_object_get_data (G_OBJECT(v), "owner");
|
const gchar *owner = g_object_get_data (G_OBJECT(v), "owner");
|
||||||
if (g_strcmp0 (owner, name) == 0)
|
if (g_strcmp0 (owner, name) == 0)
|
||||||
g_hash_table_iter_remove (&iter);
|
g_hash_table_iter_remove (&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (head = priv->context_stack; head; ) {
|
for (head = service->priv->context_stack; head; ) {
|
||||||
const gchar *owner = g_object_get_data (G_OBJECT(head->data), "owner");
|
const gchar *owner = g_object_get_data (G_OBJECT(head->data), "owner");
|
||||||
GSList *next = g_slist_next (head);
|
GSList *next = g_slist_next (head);
|
||||||
|
|
||||||
if (g_strcmp0 (owner, name) == 0) {
|
if (g_strcmp0 (owner, name) == 0) {
|
||||||
priv->context_stack =
|
service->priv->context_stack =
|
||||||
g_slist_remove_link (priv->context_stack, head);
|
g_slist_remove_link (service->priv->context_stack, head);
|
||||||
g_object_unref (head->data);
|
g_object_unref (head->data);
|
||||||
g_slist_free1 (head);
|
g_slist_free1 (head);
|
||||||
}
|
}
|
||||||
@ -351,8 +345,8 @@ service_name_vanished_callback (GDBusConnection *connection,
|
|||||||
head = next;
|
head = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->context_stack)
|
if (service->priv->context_stack)
|
||||||
eekboard_context_service_enable (priv->context_stack->data);
|
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -366,7 +360,6 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardService *service = user_data;
|
EekboardService *service = user_data;
|
||||||
EekboardServicePrivate *priv = EEKBOARD_SERVICE_GET_PRIVATE(service);
|
|
||||||
EekboardServiceClass *klass = EEKBOARD_SERVICE_GET_CLASS(service);
|
EekboardServiceClass *klass = EEKBOARD_SERVICE_GET_CLASS(service);
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "CreateContext") == 0) {
|
if (g_strcmp0 (method_name, "CreateContext") == 0) {
|
||||||
@ -382,12 +375,12 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
g_object_set_data_full (G_OBJECT(context),
|
g_object_set_data_full (G_OBJECT(context),
|
||||||
"owner", g_strdup (sender),
|
"owner", g_strdup (sender),
|
||||||
(GDestroyNotify)g_free);
|
(GDestroyNotify)g_free);
|
||||||
g_hash_table_insert (priv->context_hash,
|
g_hash_table_insert (service->priv->context_hash,
|
||||||
object_path,
|
object_path,
|
||||||
context);
|
context);
|
||||||
|
|
||||||
/* the vanished callback is called when clients are disconnected */
|
/* the vanished callback is called when clients are disconnected */
|
||||||
g_bus_watch_name_on_connection (priv->connection,
|
g_bus_watch_name_on_connection (service->priv->connection,
|
||||||
sender,
|
sender,
|
||||||
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
G_BUS_NAME_WATCHER_FLAGS_NONE,
|
||||||
NULL,
|
NULL,
|
||||||
@ -405,7 +398,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
EekboardContextService *context;
|
EekboardContextService *context;
|
||||||
|
|
||||||
g_variant_get (parameters, "(&s)", &object_path);
|
g_variant_get (parameters, "(&s)", &object_path);
|
||||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
context = g_hash_table_lookup (service->priv->context_hash, object_path);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
@ -413,9 +406,9 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
"context not found");
|
"context not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (priv->context_stack)
|
if (service->priv->context_stack)
|
||||||
eekboard_context_service_disable (priv->context_stack->data);
|
eekboard_context_service_disable (service->priv->context_stack->data);
|
||||||
priv->context_stack = g_slist_prepend (priv->context_stack,
|
service->priv->context_stack = g_slist_prepend (service->priv->context_stack,
|
||||||
g_object_ref (context));
|
g_object_ref (context));
|
||||||
eekboard_context_service_enable (context);
|
eekboard_context_service_enable (context);
|
||||||
|
|
||||||
@ -424,8 +417,8 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "PopContext") == 0) {
|
if (g_strcmp0 (method_name, "PopContext") == 0) {
|
||||||
if (priv->context_stack) {
|
if (service->priv->context_stack) {
|
||||||
EekboardContextService *context = priv->context_stack->data;
|
EekboardContextService *context = service->priv->context_stack->data;
|
||||||
gchar *object_path;
|
gchar *object_path;
|
||||||
const gchar *owner;
|
const gchar *owner;
|
||||||
|
|
||||||
@ -443,9 +436,9 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
g_free (object_path);
|
g_free (object_path);
|
||||||
|
|
||||||
eekboard_context_service_disable (context);
|
eekboard_context_service_disable (context);
|
||||||
priv->context_stack = g_slist_next (priv->context_stack);
|
service->priv->context_stack = g_slist_next (service->priv->context_stack);
|
||||||
if (priv->context_stack)
|
if (service->priv->context_stack)
|
||||||
eekboard_context_service_enable (priv->context_stack->data);
|
eekboard_context_service_enable (service->priv->context_stack->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
@ -458,7 +451,7 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
const gchar *owner;
|
const gchar *owner;
|
||||||
|
|
||||||
g_variant_get (parameters, "(&s)", &object_path);
|
g_variant_get (parameters, "(&s)", &object_path);
|
||||||
context = g_hash_table_lookup (priv->context_hash, object_path);
|
context = g_hash_table_lookup (service->priv->context_hash, object_path);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
g_dbus_method_invocation_return_error (invocation,
|
g_dbus_method_invocation_return_error (invocation,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
@ -479,13 +472,13 @@ handle_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove_context_from_stack (service, context);
|
remove_context_from_stack (service, context);
|
||||||
g_hash_table_remove (priv->context_hash, object_path);
|
g_hash_table_remove (service->priv->context_hash, object_path);
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0 (method_name, "Destroy") == 0) {
|
if (g_strcmp0 (method_name, "Destroy") == 0) {
|
||||||
g_signal_emit_by_name (service, "destroyed", NULL);
|
g_signal_emit (service, signals[DESTROYED], 0);
|
||||||
g_dbus_method_invocation_return_value (invocation, NULL);
|
g_dbus_method_invocation_return_value (invocation, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -442,8 +442,8 @@ client_enable_atspi_keystroke (Client *client)
|
|||||||
|
|
||||||
client->keystroke_listener =
|
client->keystroke_listener =
|
||||||
atspi_device_listener_new ((AtspiDeviceListenerCB)keystroke_listener_cb,
|
atspi_device_listener_new ((AtspiDeviceListenerCB)keystroke_listener_cb,
|
||||||
NULL,
|
client,
|
||||||
client);
|
NULL);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!atspi_register_keystroke_listener
|
if (!atspi_register_keystroke_listener
|
||||||
@ -521,7 +521,7 @@ focus_listener_cb (const AtspiEvent *event,
|
|||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
role = atspi_accessible_get_role (accessible, &error);
|
role = atspi_accessible_get_role (accessible, &error);
|
||||||
if (role == NULL) {
|
if (role == ATSPI_ROLE_INVALID) {
|
||||||
g_warning ("can't get accessible role: %s",
|
g_warning ("can't get accessible role: %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
|||||||
@ -108,7 +108,7 @@ preferences_dialog_new (void)
|
|||||||
ui_path = g_strdup_printf ("%s/%s", PKGDATADIR, "preferences-dialog.ui");
|
ui_path = g_strdup_printf ("%s/%s", PKGDATADIR, "preferences-dialog.ui");
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (gtk_builder_add_from_file (builder, ui_path, &error) == 0) {
|
if (gtk_builder_add_from_file (builder, ui_path, &error) == 0) {
|
||||||
g_warning ("can't load %s: %s", error->message);
|
g_warning ("can't load %s: %s", ui_path, error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
g_free (ui_path);
|
g_free (ui_path);
|
||||||
|
|||||||
@ -26,43 +26,21 @@
|
|||||||
#endif /* HAVE_CONFIG_H */
|
#endif /* HAVE_CONFIG_H */
|
||||||
|
|
||||||
#include "eek/eek.h"
|
#include "eek/eek.h"
|
||||||
#include "eek/eek-xkl.h"
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_output_parse (void)
|
test_output_parse (void)
|
||||||
{
|
{
|
||||||
GString *output;
|
|
||||||
GInputStream *input;
|
|
||||||
EekLayout *layout;
|
EekLayout *layout;
|
||||||
EekKeyboard *keyboard;
|
EekKeyboard *keyboard;
|
||||||
Display *display;
|
GError *error;
|
||||||
|
|
||||||
output = g_string_sized_new (8192);
|
error = NULL;
|
||||||
|
layout = eek_xml_layout_new ("us", &error);
|
||||||
display = XOpenDisplay (NULL);
|
g_assert_no_error (error);
|
||||||
layout = eek_xkl_layout_new (display, NULL);
|
|
||||||
|
|
||||||
keyboard = eek_keyboard_new (layout, 640, 480);
|
|
||||||
g_object_unref (layout);
|
|
||||||
|
|
||||||
eek_keyboard_output (keyboard, output, 0);
|
|
||||||
g_object_unref (keyboard);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
fwrite (output->str, sizeof(gchar), output->len, stdout);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
input = g_memory_input_stream_new_from_data (output->str,
|
|
||||||
output->len,
|
|
||||||
NULL);
|
|
||||||
layout = eek_xml_layout_new (input);
|
|
||||||
g_object_unref (input);
|
|
||||||
|
|
||||||
keyboard = eek_keyboard_new (layout, 640, 480);
|
keyboard = eek_keyboard_new (layout, 640, 480);
|
||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
g_object_unref (keyboard);
|
g_object_unref (keyboard);
|
||||||
|
|
||||||
g_string_free (output, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
Reference in New Issue
Block a user