section: Removed multiple rows in section, row/column in key
This commit is contained in:
@ -50,7 +50,7 @@ static void
|
|||||||
eek_container_real_add_child (EekContainer *self,
|
eek_container_real_add_child (EekContainer *self,
|
||||||
EekElement *child)
|
EekElement *child)
|
||||||
{
|
{
|
||||||
EekContainerPrivate *priv = eek_container_get_instance_private (self);
|
EekContainerPrivate *priv = (EekContainerPrivate*)eek_container_get_instance_private (self);
|
||||||
|
|
||||||
g_return_if_fail (EEK_IS_ELEMENT(child));
|
g_return_if_fail (EEK_IS_ELEMENT(child));
|
||||||
g_object_ref (child);
|
g_object_ref (child);
|
||||||
|
|||||||
@ -54,8 +54,6 @@ typedef struct _EekKeyPrivate
|
|||||||
{
|
{
|
||||||
guint keycode;
|
guint keycode;
|
||||||
EekSymbolMatrix *symbol_matrix;
|
EekSymbolMatrix *symbol_matrix;
|
||||||
gint column;
|
|
||||||
gint row;
|
|
||||||
gulong oref; // UI outline reference
|
gulong oref; // UI outline reference
|
||||||
gboolean is_pressed;
|
gboolean is_pressed;
|
||||||
gboolean is_locked;
|
gboolean is_locked;
|
||||||
@ -432,59 +430,6 @@ eek_key_get_symbol_at_index (EekKey *key,
|
|||||||
level];
|
level];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_key_set_index:
|
|
||||||
* @key: an #EekKey
|
|
||||||
* @column: column index of @key in #EekSection
|
|
||||||
* @row: row index of @key in #EekSection
|
|
||||||
*
|
|
||||||
* Set the location of @key in #EekSection with @column and @row.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_key_set_index (EekKey *key,
|
|
||||||
gint column,
|
|
||||||
gint row)
|
|
||||||
{
|
|
||||||
g_return_if_fail (EEK_IS_KEY(key));
|
|
||||||
g_return_if_fail (0 <= column);
|
|
||||||
g_return_if_fail (0 <= row);
|
|
||||||
|
|
||||||
EekKeyPrivate *priv = eek_key_get_instance_private (key);
|
|
||||||
|
|
||||||
if (priv->column != column) {
|
|
||||||
priv->column = column;
|
|
||||||
g_object_notify (G_OBJECT(key), "column");
|
|
||||||
}
|
|
||||||
if (priv->row != row) {
|
|
||||||
priv->row = row;
|
|
||||||
g_object_notify (G_OBJECT(key), "row");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* eek_key_get_index:
|
|
||||||
* @key: an #EekKey
|
|
||||||
* @column: (allow-none): pointer where the column index of @key in #EekSection will be stored
|
|
||||||
* @row: (allow-none): pointer where the row index of @key in #EekSection will be stored
|
|
||||||
*
|
|
||||||
* Get the location of @key in #EekSection.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
eek_key_get_index (EekKey *key,
|
|
||||||
gint *column,
|
|
||||||
gint *row)
|
|
||||||
{
|
|
||||||
g_return_if_fail (EEK_IS_KEY(key));
|
|
||||||
g_return_if_fail (column != NULL || row != NULL);
|
|
||||||
|
|
||||||
EekKeyPrivate *priv = eek_key_get_instance_private (key);
|
|
||||||
|
|
||||||
if (column != NULL)
|
|
||||||
*column = priv->column;
|
|
||||||
if (row != NULL)
|
|
||||||
*row = priv->row;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eek_key_set_oref:
|
* eek_key_set_oref:
|
||||||
* @key: an #EekKey
|
* @key: an #EekKey
|
||||||
|
|||||||
@ -61,7 +61,7 @@ typedef struct _EekRow EekRow;
|
|||||||
typedef struct _EekSectionPrivate
|
typedef struct _EekSectionPrivate
|
||||||
{
|
{
|
||||||
gint angle;
|
gint angle;
|
||||||
GSList *rows;
|
EekRow row;
|
||||||
EekModifierType modifiers;
|
EekModifierType modifiers;
|
||||||
} EekSectionPrivate;
|
} EekSectionPrivate;
|
||||||
|
|
||||||
@ -70,9 +70,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (EekSection, eek_section, EEK_TYPE_CONTAINER)
|
|||||||
static gint
|
static gint
|
||||||
eek_section_real_get_n_rows (EekSection *self)
|
eek_section_real_get_n_rows (EekSection *self)
|
||||||
{
|
{
|
||||||
EekSectionPrivate *priv = eek_section_get_instance_private (self);
|
return 1;
|
||||||
|
|
||||||
return g_slist_length (priv->rows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -80,13 +78,14 @@ eek_section_real_add_row (EekSection *self,
|
|||||||
gint num_columns,
|
gint num_columns,
|
||||||
EekOrientation orientation)
|
EekOrientation orientation)
|
||||||
{
|
{
|
||||||
EekSectionPrivate *priv = eek_section_get_instance_private (self);
|
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
|
||||||
EekRow *row;
|
priv->row.num_columns = num_columns;
|
||||||
|
priv->row.orientation = orientation;
|
||||||
|
/*
|
||||||
row = g_slice_new (EekRow);
|
row = g_slice_new (EekRow);
|
||||||
row->num_columns = num_columns;
|
row->num_columns = num_columns;
|
||||||
row->orientation = orientation;
|
row->orientation = orientation;
|
||||||
priv->rows = g_slist_append (priv->rows, row);
|
priv->rows = g_slist_append (priv->rows, row);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -95,15 +94,14 @@ eek_section_real_get_row (EekSection *self,
|
|||||||
gint *num_columns,
|
gint *num_columns,
|
||||||
EekOrientation *orientation)
|
EekOrientation *orientation)
|
||||||
{
|
{
|
||||||
EekSectionPrivate *priv = eek_section_get_instance_private (self);
|
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
|
||||||
EekRow *row;
|
EekRow *row = &priv->row;
|
||||||
|
if (num_columns) {
|
||||||
row = g_slist_nth_data (priv->rows, index);
|
|
||||||
g_return_if_fail (row);
|
|
||||||
if (num_columns)
|
|
||||||
*num_columns = row->num_columns;
|
*num_columns = row->num_columns;
|
||||||
if (orientation)
|
}
|
||||||
|
if (orientation) {
|
||||||
*orientation = row->orientation;
|
*orientation = row->orientation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -123,27 +121,17 @@ on_unlocked (EekKey *key,
|
|||||||
static EekKey *
|
static EekKey *
|
||||||
eek_section_real_create_key (EekSection *self,
|
eek_section_real_create_key (EekSection *self,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gint keycode,
|
gint keycode)
|
||||||
gint column_index,
|
|
||||||
gint row_index)
|
|
||||||
{
|
{
|
||||||
EekKey *key;
|
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
|
||||||
gint num_rows;
|
|
||||||
EekRow *row;
|
|
||||||
|
|
||||||
num_rows = eek_section_get_n_rows (self);
|
EekRow *row = &priv->row;
|
||||||
g_return_val_if_fail (0 <= row_index && row_index < num_rows, NULL);
|
row->num_columns++;
|
||||||
|
|
||||||
EekSectionPrivate *priv = eek_section_get_instance_private (self);
|
EekKey *key = (EekKey*)g_object_new (EEK_TYPE_KEY,
|
||||||
|
"name", name,
|
||||||
row = g_slist_nth_data (priv->rows, row_index);
|
"keycode", keycode,
|
||||||
if (row->num_columns < column_index + 1)
|
NULL);
|
||||||
row->num_columns = column_index + 1;
|
|
||||||
|
|
||||||
key = g_object_new (EEK_TYPE_KEY,
|
|
||||||
"name", name,
|
|
||||||
"keycode", keycode,
|
|
||||||
NULL);
|
|
||||||
g_return_val_if_fail (key, NULL);
|
g_return_val_if_fail (key, NULL);
|
||||||
|
|
||||||
EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
|
EEK_CONTAINER_GET_CLASS(self)->add_child (EEK_CONTAINER(self),
|
||||||
@ -223,12 +211,7 @@ static void
|
|||||||
eek_section_finalize (GObject *object)
|
eek_section_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
EekSection *self = EEK_SECTION (object);
|
EekSection *self = EEK_SECTION (object);
|
||||||
EekSectionPrivate *priv = eek_section_get_instance_private (self);
|
EekSectionPrivate *priv = (EekSectionPrivate*)eek_section_get_instance_private (self);
|
||||||
GSList *head;
|
|
||||||
|
|
||||||
for (head = priv->rows; head; head = g_slist_next (head))
|
|
||||||
g_slice_free (EekRow, head->data);
|
|
||||||
g_slist_free (priv->rows);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (eek_section_parent_class)->finalize (object);
|
G_OBJECT_CLASS (eek_section_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -473,16 +456,12 @@ eek_section_get_row (EekSection *section,
|
|||||||
EekKey *
|
EekKey *
|
||||||
eek_section_create_key (EekSection *section,
|
eek_section_create_key (EekSection *section,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gint keycode,
|
gint keycode)
|
||||||
gint column,
|
|
||||||
gint row)
|
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (EEK_IS_SECTION(section), NULL);
|
g_return_val_if_fail (EEK_IS_SECTION(section), NULL);
|
||||||
return EEK_SECTION_GET_CLASS(section)->create_key (section,
|
return EEK_SECTION_GET_CLASS(section)->create_key (section,
|
||||||
name,
|
name,
|
||||||
keycode,
|
keycode);
|
||||||
column,
|
|
||||||
row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const double keyspacing = 4.0;
|
const double keyspacing = 4.0;
|
||||||
|
|||||||
@ -63,9 +63,7 @@ struct _EekSectionClass
|
|||||||
|
|
||||||
EekKey *(* create_key) (EekSection *self,
|
EekKey *(* create_key) (EekSection *self,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gint keycode,
|
gint keycode);
|
||||||
gint row,
|
|
||||||
gint column);
|
|
||||||
|
|
||||||
/* signals */
|
/* signals */
|
||||||
void (* key_pressed) (EekSection *self,
|
void (* key_pressed) (EekSection *self,
|
||||||
@ -101,9 +99,7 @@ void eek_section_get_row (EekSection *section,
|
|||||||
|
|
||||||
EekKey *eek_section_create_key (EekSection *section,
|
EekKey *eek_section_create_key (EekSection *section,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
gint keycode,
|
gint keycode);
|
||||||
gint column,
|
|
||||||
gint row);
|
|
||||||
|
|
||||||
EekKey *eek_section_find_key_by_keycode (EekSection *section,
|
EekKey *eek_section_find_key_by_keycode (EekSection *section,
|
||||||
guint keycode);
|
guint keycode);
|
||||||
|
|||||||
@ -414,9 +414,7 @@ geometry_start_element_callback (GMarkupParseContext *pcontext,
|
|||||||
|
|
||||||
data->key = eek_section_create_key (data->section,
|
data->key = eek_section_create_key (data->section,
|
||||||
name,
|
name,
|
||||||
keycode,
|
keycode);
|
||||||
data->num_columns,
|
|
||||||
data->num_rows - 1);
|
|
||||||
|
|
||||||
attribute = get_attribute (attribute_names, attribute_values,
|
attribute = get_attribute (attribute_names, attribute_values,
|
||||||
"oref");
|
"oref");
|
||||||
|
|||||||
@ -32,9 +32,9 @@ test_create (void)
|
|||||||
section = eek_keyboard_create_section (keyboard);
|
section = eek_keyboard_create_section (keyboard);
|
||||||
g_assert (EEK_IS_SECTION(section));
|
g_assert (EEK_IS_SECTION(section));
|
||||||
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
|
eek_section_add_row (section, 2, EEK_ORIENTATION_HORIZONTAL);
|
||||||
key0 = eek_section_create_key (section, "key0", 1, 0, 0);
|
key0 = eek_section_create_key (section, "key0", 1);
|
||||||
g_assert (EEK_IS_KEY(key0));
|
g_assert (EEK_IS_KEY(key0));
|
||||||
key1 = eek_section_create_key (section, "key1", 2, 1, 0);
|
key1 = eek_section_create_key (section, "key1", 2);
|
||||||
g_assert (EEK_IS_KEY(key1));
|
g_assert (EEK_IS_KEY(key1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user