Split eek_section_{set,get}_dimensions.
This commit is contained in:
@ -59,25 +59,43 @@ struct _EekClutterSectionPrivate
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_clutter_section_real_set_dimensions (EekSection *self,
|
eek_clutter_section_real_set_rows (EekSection *self,
|
||||||
gint columns,
|
gint rows)
|
||||||
gint rows)
|
|
||||||
{
|
{
|
||||||
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
g_return_if_fail (priv);
|
g_return_if_fail (priv);
|
||||||
eek_section_set_dimensions (EEK_SECTION(priv->simple), columns, rows);
|
eek_section_set_rows (EEK_SECTION(priv->simple), rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
eek_clutter_section_real_get_rows (EekSection *self)
|
||||||
|
{
|
||||||
|
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (priv, -1);
|
||||||
|
return eek_section_get_rows (EEK_SECTION(priv->simple));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_clutter_section_real_get_dimensions (EekSection *self,
|
eek_clutter_section_real_set_columns (EekSection *self,
|
||||||
gint *columns,
|
gint row,
|
||||||
gint *rows)
|
gint columns)
|
||||||
{
|
{
|
||||||
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
g_return_if_fail (priv);
|
g_return_if_fail (priv);
|
||||||
eek_section_get_dimensions (EEK_SECTION(priv->simple), columns, rows);
|
eek_section_set_columns (EEK_SECTION(priv->simple), row, columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
eek_clutter_section_real_get_columns (EekSection *self,
|
||||||
|
gint row)
|
||||||
|
{
|
||||||
|
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (priv, -1);
|
||||||
|
return eek_section_get_columns (EEK_SECTION(priv->simple), row);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -146,9 +164,10 @@ eek_clutter_section_real_create_key (EekSection *self,
|
|||||||
|
|
||||||
g_return_val_if_fail (priv, NULL);
|
g_return_val_if_fail (priv, NULL);
|
||||||
|
|
||||||
eek_section_get_dimensions (self, &columns, &rows);
|
rows = eek_section_get_rows (self);
|
||||||
|
g_return_val_if_fail (0 <= row && row < rows, NULL);
|
||||||
|
columns = eek_section_get_columns (self, row);
|
||||||
g_return_val_if_fail (column < columns, NULL);
|
g_return_val_if_fail (column < columns, NULL);
|
||||||
g_return_val_if_fail (row < rows, NULL);
|
|
||||||
|
|
||||||
matrix.data = keysyms;
|
matrix.data = keysyms;
|
||||||
matrix.num_groups = num_groups;
|
matrix.num_groups = num_groups;
|
||||||
@ -196,8 +215,10 @@ eek_clutter_section_real_foreach_key (EekSection *self,
|
|||||||
static void
|
static void
|
||||||
eek_section_iface_init (EekSectionIface *iface)
|
eek_section_iface_init (EekSectionIface *iface)
|
||||||
{
|
{
|
||||||
iface->set_dimensions = eek_clutter_section_real_set_dimensions;
|
iface->set_rows = eek_clutter_section_real_set_rows;
|
||||||
iface->get_dimensions = eek_clutter_section_real_get_dimensions;
|
iface->get_rows = eek_clutter_section_real_get_rows;
|
||||||
|
iface->set_columns = eek_clutter_section_real_set_columns;
|
||||||
|
iface->get_columns = eek_clutter_section_real_get_columns;
|
||||||
iface->set_angle = eek_clutter_section_real_set_angle;
|
iface->set_angle = eek_clutter_section_real_set_angle;
|
||||||
iface->get_angle = eek_clutter_section_real_get_angle;
|
iface->get_angle = eek_clutter_section_real_get_angle;
|
||||||
iface->set_bounds = eek_clutter_section_real_set_bounds;
|
iface->set_bounds = eek_clutter_section_real_set_bounds;
|
||||||
|
|||||||
@ -130,41 +130,71 @@ eek_section_get_type (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eek_section_set_dimensions:
|
* eek_section_set_rows:
|
||||||
* @section: an #EekSection
|
* @section: an #EekSection
|
||||||
* @columns: the number of columns in @section
|
|
||||||
* @rows: the number of rows in @section
|
* @rows: the number of rows in @section
|
||||||
*
|
*
|
||||||
* Set dimensions of @section from @columns and @rows.
|
* Set the number of rows in @section to @rows.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
eek_section_set_dimensions (EekSection *section,
|
eek_section_set_rows (EekSection *section,
|
||||||
gint columns,
|
gint rows)
|
||||||
gint rows)
|
|
||||||
{
|
{
|
||||||
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
||||||
|
|
||||||
g_return_if_fail (iface->set_dimensions);
|
g_return_if_fail (iface->set_rows);
|
||||||
(*iface->set_dimensions) (section, columns, rows);
|
(*iface->set_rows) (section, rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* eek_section_get_dimensions:
|
* eek_section_get_rows:
|
||||||
* @section: an #EekSection
|
* @section: an #EekSection
|
||||||
* @columns: a pointer where the number of columns in @section is stored
|
|
||||||
* @rows: a pointer where the number of rows in @section is stored
|
|
||||||
*
|
*
|
||||||
* Get the rotation angle of @section.
|
* Get the number of rows in @section.
|
||||||
*/
|
*/
|
||||||
void
|
gint
|
||||||
eek_section_get_dimensions (EekSection *section,
|
eek_section_get_rows (EekSection *section)
|
||||||
gint *columns,
|
|
||||||
gint *rows)
|
|
||||||
{
|
{
|
||||||
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
||||||
|
|
||||||
g_return_if_fail (iface->get_dimensions);
|
g_return_if_fail (iface->get_rows);
|
||||||
return (*iface->get_dimensions) (section, columns, rows);
|
return (*iface->get_rows) (section);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eek_section_set_columns:
|
||||||
|
* @section: an #EekSection
|
||||||
|
* @row: the row index in @section
|
||||||
|
* @columns: the number of keys on @row
|
||||||
|
*
|
||||||
|
* Set the number of keys on @row.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
eek_section_set_columns (EekSection *section,
|
||||||
|
gint row,
|
||||||
|
gint columns)
|
||||||
|
{
|
||||||
|
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
||||||
|
|
||||||
|
g_return_if_fail (iface->set_columns);
|
||||||
|
(*iface->set_columns) (section, row, columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eek_section_get_columns:
|
||||||
|
* @section: an #EekSection
|
||||||
|
* @row: the row index in @section
|
||||||
|
*
|
||||||
|
* Get the number of keys on @row.
|
||||||
|
*/
|
||||||
|
gint
|
||||||
|
eek_section_get_columns (EekSection *section,
|
||||||
|
gint row)
|
||||||
|
{
|
||||||
|
EekSectionIface *iface = EEK_SECTION_GET_IFACE(section);
|
||||||
|
|
||||||
|
g_return_if_fail (iface->get_columns);
|
||||||
|
return (*iface->get_columns) (section, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -38,66 +38,72 @@ struct _EekSectionIface
|
|||||||
GTypeInterface g_iface;
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
/*< public >*/
|
/*< public >*/
|
||||||
void (* set_dimensions) (EekSection *self,
|
void (* set_rows) (EekSection *self,
|
||||||
gint columns,
|
gint rows);
|
||||||
gint rows);
|
gint (* get_rows) (EekSection *self);
|
||||||
void (* get_dimensions) (EekSection *self,
|
void (* set_columns) (EekSection *self,
|
||||||
gint *columns,
|
gint row,
|
||||||
gint *rows);
|
gint columns);
|
||||||
void (* set_angle) (EekSection *self,
|
gint (* get_columns) (EekSection *self,
|
||||||
gint angle);
|
gint row);
|
||||||
gint (* get_angle) (EekSection *self);
|
|
||||||
|
|
||||||
void (* set_bounds) (EekSection *self,
|
void (* set_angle) (EekSection *self,
|
||||||
EekBounds *bounds);
|
gint angle);
|
||||||
void (* get_bounds) (EekSection *self,
|
gint (* get_angle) (EekSection *self);
|
||||||
EekBounds *bounds);
|
|
||||||
|
|
||||||
EekKey *(* create_key) (EekSection *self,
|
void (* set_bounds) (EekSection *self,
|
||||||
const gchar *name,
|
EekBounds *bounds);
|
||||||
guint *keysyms,
|
void (* get_bounds) (EekSection *self,
|
||||||
gint num_groups,
|
EekBounds *bounds);
|
||||||
gint num_levels,
|
|
||||||
gint column,
|
|
||||||
gint row,
|
|
||||||
EekOutline *outline,
|
|
||||||
EekBounds *bounds);
|
|
||||||
|
|
||||||
void (* foreach_key) (EekSection *self,
|
EekKey *(* create_key) (EekSection *self,
|
||||||
GFunc func,
|
const gchar *name,
|
||||||
gpointer user_data);
|
guint *keysyms,
|
||||||
|
gint num_groups,
|
||||||
|
gint num_levels,
|
||||||
|
gint column,
|
||||||
|
gint row,
|
||||||
|
EekOutline *outline,
|
||||||
|
EekBounds *bounds);
|
||||||
|
|
||||||
|
void (* foreach_key) (EekSection *self,
|
||||||
|
GFunc func,
|
||||||
|
gpointer user_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType eek_section_get_type (void) G_GNUC_CONST;
|
GType eek_section_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
void eek_section_set_dimensions (EekSection *section,
|
void eek_section_set_rows (EekSection *section,
|
||||||
gint columns,
|
gint rows);
|
||||||
gint rows);
|
gint eek_section_get_rows (EekSection *section);
|
||||||
void eek_section_get_dimensions (EekSection *section,
|
void eek_section_set_columns (EekSection *section,
|
||||||
gint *columns,
|
gint row,
|
||||||
gint *rows);
|
gint columns);
|
||||||
void eek_section_set_angle (EekSection *section,
|
gint eek_section_get_columns (EekSection *section,
|
||||||
gint angle);
|
gint row);
|
||||||
gint eek_section_get_angle (EekSection *section);
|
|
||||||
|
|
||||||
void eek_section_set_bounds (EekSection *section,
|
void eek_section_set_angle (EekSection *section,
|
||||||
EekBounds *bounds);
|
gint angle);
|
||||||
void eek_section_get_bounds (EekSection *section,
|
gint eek_section_get_angle (EekSection *section);
|
||||||
EekBounds *bounds);
|
|
||||||
|
|
||||||
EekKey *eek_section_create_key (EekSection *section,
|
void eek_section_set_bounds (EekSection *section,
|
||||||
const gchar *name,
|
EekBounds *bounds);
|
||||||
guint *keysyms,
|
void eek_section_get_bounds (EekSection *section,
|
||||||
gint num_groups,
|
EekBounds *bounds);
|
||||||
gint num_levels,
|
|
||||||
gint column,
|
|
||||||
gint row,
|
|
||||||
EekOutline *outline,
|
|
||||||
EekBounds *bounds);
|
|
||||||
|
|
||||||
void eek_section_foreach_key (EekSection *section,
|
EekKey *eek_section_create_key (EekSection *section,
|
||||||
GFunc func,
|
const gchar *name,
|
||||||
gpointer user_data);
|
guint *keysyms,
|
||||||
|
gint num_groups,
|
||||||
|
gint num_levels,
|
||||||
|
gint column,
|
||||||
|
gint row,
|
||||||
|
EekOutline *outline,
|
||||||
|
EekBounds *bounds);
|
||||||
|
|
||||||
|
void eek_section_foreach_key (EekSection *section,
|
||||||
|
GFunc func,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEK_SECTION_H */
|
#endif /* EEK_SECTION_H */
|
||||||
|
|||||||
@ -46,35 +46,58 @@ G_DEFINE_TYPE_WITH_CODE (EekSimpleSection, eek_simple_section,
|
|||||||
struct _EekSimpleSectionPrivate
|
struct _EekSimpleSectionPrivate
|
||||||
{
|
{
|
||||||
gchar *name;
|
gchar *name;
|
||||||
gint num_columns;
|
|
||||||
gint num_rows;
|
gint num_rows;
|
||||||
|
gint *num_columns;
|
||||||
gint angle;
|
gint angle;
|
||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
GSList *keys;
|
GSList *keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_simple_section_real_set_dimensions (EekSection *self,
|
eek_simple_section_real_set_rows (EekSection *self,
|
||||||
gint columns,
|
gint rows)
|
||||||
gint rows)
|
|
||||||
{
|
{
|
||||||
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
g_return_if_fail (priv);
|
g_return_if_fail (priv);
|
||||||
priv->num_columns = columns;
|
g_return_if_fail (rows >= 0);
|
||||||
priv->num_rows = rows;
|
priv->num_rows = rows;
|
||||||
|
if (rows > 0) {
|
||||||
|
g_free (priv->num_columns);
|
||||||
|
priv->num_columns = g_slice_alloc (sizeof(gint) * priv->num_rows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
eek_simple_section_real_get_rows (EekSection *self)
|
||||||
|
{
|
||||||
|
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (priv, -1);
|
||||||
|
return priv->num_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eek_simple_section_real_get_dimensions (EekSection *self,
|
eek_simple_section_real_set_columns (EekSection *self,
|
||||||
gint *columns,
|
gint row,
|
||||||
gint *rows)
|
gint columns)
|
||||||
{
|
{
|
||||||
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
g_return_if_fail (priv);
|
g_return_if_fail (priv);
|
||||||
*columns = priv->num_columns;
|
g_return_if_fail (0 <= row && row < priv->num_rows);
|
||||||
*rows = priv->num_rows;
|
priv->num_columns[row] = columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
eek_simple_section_real_get_columns (EekSection *self,
|
||||||
|
gint row)
|
||||||
|
{
|
||||||
|
EekSimpleSectionPrivate *priv = EEK_SIMPLE_SECTION_GET_PRIVATE(self);
|
||||||
|
|
||||||
|
g_return_val_if_fail (priv, -1);
|
||||||
|
g_return_val_if_fail (0 <= row && row < priv->num_rows, -1);
|
||||||
|
return priv->num_columns[row];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -133,8 +156,8 @@ eek_simple_section_real_create_key (EekSection *self,
|
|||||||
EekKeysymMatrix matrix;
|
EekKeysymMatrix matrix;
|
||||||
|
|
||||||
g_return_val_if_fail (priv, NULL);
|
g_return_val_if_fail (priv, NULL);
|
||||||
g_return_val_if_fail (column < priv->num_columns, NULL);
|
g_return_val_if_fail (0 <= row && row < priv->num_rows, NULL);
|
||||||
g_return_val_if_fail (row < priv->num_rows, NULL);
|
g_return_val_if_fail (column < priv->num_columns[row], NULL);
|
||||||
|
|
||||||
matrix.data = keysyms;
|
matrix.data = keysyms;
|
||||||
matrix.num_groups = num_groups;
|
matrix.num_groups = num_groups;
|
||||||
@ -166,8 +189,10 @@ eek_simple_section_real_foreach_key (EekSection *self,
|
|||||||
static void
|
static void
|
||||||
eek_section_iface_init (EekSectionIface *iface)
|
eek_section_iface_init (EekSectionIface *iface)
|
||||||
{
|
{
|
||||||
iface->set_dimensions = eek_simple_section_real_set_dimensions;
|
iface->set_rows = eek_simple_section_real_set_rows;
|
||||||
iface->get_dimensions = eek_simple_section_real_get_dimensions;
|
iface->get_rows = eek_simple_section_real_get_rows;
|
||||||
|
iface->set_columns = eek_simple_section_real_set_columns;
|
||||||
|
iface->get_columns = eek_simple_section_real_get_columns;
|
||||||
iface->set_angle = eek_simple_section_real_set_angle;
|
iface->set_angle = eek_simple_section_real_set_angle;
|
||||||
iface->get_angle = eek_simple_section_real_get_angle;
|
iface->get_angle = eek_simple_section_real_get_angle;
|
||||||
iface->set_bounds = eek_simple_section_real_set_bounds;
|
iface->set_bounds = eek_simple_section_real_set_bounds;
|
||||||
@ -195,6 +220,7 @@ eek_simple_section_finalize (GObject *object)
|
|||||||
|
|
||||||
g_free (priv->name);
|
g_free (priv->name);
|
||||||
g_slist_free (priv->keys);
|
g_slist_free (priv->keys);
|
||||||
|
g_slice_free (gint, priv->num_columns);
|
||||||
G_OBJECT_CLASS (eek_simple_section_parent_class)->finalize (object);
|
G_OBJECT_CLASS (eek_simple_section_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,4 +314,6 @@ eek_simple_section_init (EekSimpleSection *self)
|
|||||||
priv->angle = 0;
|
priv->angle = 0;
|
||||||
memset (&priv->bounds, 0, sizeof priv->bounds);
|
memset (&priv->bounds, 0, sizeof priv->bounds);
|
||||||
priv->keys = NULL;
|
priv->keys = NULL;
|
||||||
|
priv->num_rows = 0;
|
||||||
|
priv->num_columns = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -218,7 +218,7 @@ create_section (EekXkbLayout *layout,
|
|||||||
EekBounds bounds;
|
EekBounds bounds;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
gfloat left, top;
|
gfloat left, top;
|
||||||
gint i, j, columns;
|
gint i, j;
|
||||||
|
|
||||||
bounds.x = xkb_to_pixmap_coord(layout, xkbsection->left);
|
bounds.x = xkb_to_pixmap_coord(layout, xkbsection->left);
|
||||||
bounds.y = xkb_to_pixmap_coord(layout, xkbsection->top);
|
bounds.y = xkb_to_pixmap_coord(layout, xkbsection->top);
|
||||||
@ -234,21 +234,14 @@ create_section (EekXkbLayout *layout,
|
|||||||
xkbsection->angle / 10,
|
xkbsection->angle / 10,
|
||||||
&bounds);
|
&bounds);
|
||||||
|
|
||||||
for (columns = 0, i = 0; i < xkbsection->num_rows; i++) {
|
eek_section_set_rows (section, xkbsection->num_rows);
|
||||||
XkbRowRec *xkbrow;
|
|
||||||
|
|
||||||
xkbrow = &xkbsection->rows[i];
|
|
||||||
if (xkbrow->num_keys > columns)
|
|
||||||
columns = xkbrow->num_keys;
|
|
||||||
}
|
|
||||||
eek_section_set_dimensions (section, columns, xkbsection->num_rows);
|
|
||||||
|
|
||||||
for (i = 0; i < xkbsection->num_rows; i++) {
|
for (i = 0; i < xkbsection->num_rows; i++) {
|
||||||
XkbRowRec *xkbrow;
|
XkbRowRec *xkbrow;
|
||||||
|
|
||||||
xkbrow = &xkbsection->rows[i];
|
xkbrow = &xkbsection->rows[i];
|
||||||
left = xkbrow->left;
|
left = xkbrow->left;
|
||||||
top = xkbrow->top;
|
top = xkbrow->top;
|
||||||
|
eek_section_set_columns (section, i, xkbrow->num_keys);
|
||||||
for (j = 0; j < xkbrow->num_keys; j++) {
|
for (j = 0; j < xkbrow->num_keys; j++) {
|
||||||
XkbKeyRec *xkbkey;
|
XkbKeyRec *xkbkey;
|
||||||
XkbBoundsRec *xkbbounds;
|
XkbBoundsRec *xkbbounds;
|
||||||
|
|||||||
Reference in New Issue
Block a user