From 66f6fae181677daeb229a739e6898c36980c53ce Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 4 Jun 2010 14:23:23 +0900 Subject: [PATCH] Minor arrangement for gtk-doc. --- docs/reference/eek/eek-docs.sgml | 1 + eek/eek-clutter-key.c | 37 +++++++++++--------------------- eek/eek-clutter-keyboard.c | 6 +++--- eek/eek-clutter-section.c | 2 +- eek/eek-key.c | 13 ++++++----- eek/eek-key.h | 9 ++++---- eek/eek-keyboard.c | 6 ++---- eek/eek-keysym.c | 6 ++++++ eek/eek-section.c | 18 ++++++++-------- eek/eek-section.h | 3 ++- eek/eek-types.h | 11 ++++------ eek/eek-xkb-layout.c | 14 ++++++------ 12 files changed, 58 insertions(+), 68 deletions(-) diff --git a/docs/reference/eek/eek-docs.sgml b/docs/reference/eek/eek-docs.sgml index 7c75aa0f..9f0e943a 100644 --- a/docs/reference/eek/eek-docs.sgml +++ b/docs/reference/eek/eek-docs.sgml @@ -18,6 +18,7 @@ + Clutter keyboard elements diff --git a/eek/eek-clutter-key.c b/eek/eek-clutter-key.c index ac82736a..30c5adf9 100644 --- a/eek/eek-clutter-key.c +++ b/eek/eek-clutter-key.c @@ -140,8 +140,8 @@ eek_clutter_key_real_set_bounds (EekKey *self, EekBounds *bounds) clutter_actor_set_anchor_point_from_gravity (CLUTTER_ACTOR(self), CLUTTER_GRAVITY_CENTER); clutter_actor_set_position (CLUTTER_ACTOR(self), - bounds->x + bounds->w / 2, - bounds->y + bounds->h / 2); + bounds->x + bounds->width / 2, + bounds->y + bounds->height / 2); } static void @@ -231,7 +231,7 @@ draw_key_on_layout (EekKey *key, PangoRectangle logical_rect = { 0, }; EekBounds bounds; guint keysym; - const gchar *label; + const gchar *label, *empty_label = ""; gdouble scale_x, scale_y; eek_key_get_bounds (key, &bounds); @@ -240,21 +240,23 @@ draw_key_on_layout (EekKey *key, return; label = eek_keysym_to_string (keysym); if (!label) - label = ""; + label = empty_label; /* Compute the layout extents. */ buffer = pango_layout_copy (layout); draw_text_on_layout (buffer, label, 1.0); pango_layout_get_extents (buffer, NULL, &logical_rect); scale_x = scale_y = 1.0; - if (PANGO_PIXELS(logical_rect.width) > bounds.w) - scale_x = bounds.w / PANGO_PIXELS(logical_rect.width); - if (PANGO_PIXELS(logical_rect.height) > bounds.h) - scale_y = bounds.h / PANGO_PIXELS(logical_rect.height); + if (PANGO_PIXELS(logical_rect.width) > bounds.width) + scale_x = bounds.width / PANGO_PIXELS(logical_rect.width); + if (PANGO_PIXELS(logical_rect.height) > bounds.height) + scale_y = bounds.height / PANGO_PIXELS(logical_rect.height); g_object_unref (buffer); /* Actually draw on the layout */ draw_text_on_layout (layout, label, scale_x < scale_y ? scale_x : scale_y); + if (label != empty_label) + g_free ((gpointer)label); } static void @@ -301,25 +303,10 @@ eek_clutter_key_get_preferred_width (ClutterActor *self, gfloat *natural_width_p) { PangoLayout *layout; - PangoFontDescription *font_desc; - PangoRectangle logical_rect = { 0, }; - EekBounds bounds; - guint keysym; - const gchar *label; - gdouble scale = 1.0; - eek_key_get_bounds (EEK_KEY(self), &bounds); - keysym = eek_key_get_keysym (EEK_KEY(self)); - g_return_if_fail (keysym != EEK_INVALID_KEYSYM); - label = eek_keysym_to_string (keysym); - if (!label) - label = ""; - - /* Draw the label on the key. */ + /* Draw the label on the key - just to validate the glyph cache. */ layout = clutter_actor_create_pango_layout (self, NULL); draw_key_on_layout (EEK_KEY(self), layout); - pango_layout_get_extents (layout, NULL, &logical_rect); - cogl_pango_ensure_glyph_cache_for_layout (layout); g_object_unref (layout); @@ -520,7 +507,7 @@ eek_clutter_key_create_texture (EekClutterKey *key) outline = eek_key_get_outline (EEK_KEY(key)); eek_key_get_bounds (EEK_KEY(key), &bounds); - texture = clutter_cairo_texture_new (bounds.w, bounds.h); + texture = clutter_cairo_texture_new (bounds.width, bounds.height); cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE(texture)); cairo_set_line_width (cr, 1); cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); diff --git a/eek/eek-clutter-keyboard.c b/eek/eek-clutter-keyboard.c index 72d10df7..0cdba99a 100644 --- a/eek/eek-clutter-keyboard.c +++ b/eek/eek-clutter-keyboard.c @@ -65,7 +65,7 @@ eek_clutter_keyboard_real_set_bounds (EekKeyboard *self, g_return_if_fail (priv); eek_keyboard_set_bounds (EEK_KEYBOARD(priv->simple), bounds); clutter_actor_set_position (CLUTTER_ACTOR(self), bounds->x, bounds->y); - clutter_actor_set_size (CLUTTER_ACTOR(self), bounds->w, bounds->h); + clutter_actor_set_size (CLUTTER_ACTOR(self), bounds->width, bounds->height); } static void @@ -250,7 +250,7 @@ eek_clutter_keyboard_new (gfloat width, EekBounds bounds; bounds.x = bounds.y = 0; - bounds.w = width; - bounds.h = height; + bounds.width = width; + bounds.height = height; return g_object_new (EEK_TYPE_CLUTTER_KEYBOARD, "bounds", &bounds, NULL); } diff --git a/eek/eek-clutter-section.c b/eek/eek-clutter-section.c index b0fe670d..5bfaf964 100644 --- a/eek/eek-clutter-section.c +++ b/eek/eek-clutter-section.c @@ -114,7 +114,7 @@ eek_clutter_section_real_set_bounds (EekSection *self, g_return_if_fail (priv); eek_section_set_bounds (EEK_SECTION(priv->simple), bounds); clutter_actor_set_position (CLUTTER_ACTOR(self), bounds->x, bounds->y); - clutter_actor_set_size (CLUTTER_ACTOR(self), bounds->w, bounds->h); + clutter_actor_set_size (CLUTTER_ACTOR(self), bounds->width, bounds->height); } static void diff --git a/eek/eek-key.c b/eek/eek-key.c index e1d5d9fd..7c073d4f 100644 --- a/eek/eek-key.c +++ b/eek/eek-key.c @@ -97,7 +97,7 @@ eek_key_base_init (gpointer g_iface) */ /* Use pointer instead of boxed to avoid copy, since we can assume that only a few outline shapes are used in a whole - keyboard (unlike labels and bounds). */ + keyboard (unlike keysyms and bounds). */ pspec = g_param_spec_pointer ("outline", "Outline", "Pointer to outline shape of the key", @@ -119,7 +119,7 @@ eek_key_base_init (gpointer g_iface) /** * EekKey:group: * - * The column index of #EekKey in the label matrix #EekKey:labels. + * The column index of #EekKey in the symbol matrix #EekKey:keysyms. */ pspec = g_param_spec_int ("group", "Group", @@ -131,7 +131,7 @@ eek_key_base_init (gpointer g_iface) /** * EekKey:level: * - * The row index of #EekKey in the label matrix #EekKey:labels. + * The row index of #EekKey in the symbol matrix #EekKey:keysyms. */ pspec = g_param_spec_int ("level", "Level", @@ -208,10 +208,9 @@ eek_key_get_groups (EekKey *key) * eek_key_get_keysym: * @key: an #EekKey * - * Get the current symbol of @key. It is depend on the current group, - * level, and the symbol matrix of @key. They are set with - * eek_key_set_group(), eek_key_set_level(), and eek_key_set_labels(), - * respectively. + * Get the current symbol of @key. It is depend on the current group + * and level, and the symbol matrix of @key. They are set through + * eek_key_set_keysym_index() and eek_key_set_keysyms(), respectively. */ guint eek_key_get_keysym (EekKey *key) diff --git a/eek/eek-key.h b/eek/eek-key.h index 29c83d2a..2377f203 100644 --- a/eek/eek-key.h +++ b/eek/eek-key.h @@ -31,6 +31,7 @@ G_BEGIN_DECLS #define EEK_KEY_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EEK_TYPE_KEY, EekKeyIface)) typedef struct _EekKeyIface EekKeyIface; +typedef struct _EekKey EekKey; struct _EekKeyIface { @@ -40,8 +41,8 @@ struct _EekKeyIface /*< public >*/ void (* set_keysyms) (EekKey *self, guint *keysyms, - gint groups, - gint levels); + gint num_groups, + gint num_levels); gint (* get_groups) (EekKey *self); guint (* get_keysym) (EekKey *self); @@ -72,8 +73,8 @@ GType eek_key_get_type (void) G_GNUC_CONST; void eek_key_set_keysyms (EekKey *key, guint *keysyms, - gint groups, - gint levels); + gint num_groups, + gint num_levels); gint eek_key_get_groups (EekKey *key); guint eek_key_get_keysym (EekKey *key); diff --git a/eek/eek-keyboard.c b/eek/eek-keyboard.c index 26140fc6..281ad874 100644 --- a/eek/eek-keyboard.c +++ b/eek/eek-keyboard.c @@ -163,10 +163,8 @@ eek_keyboard_foreach_section (EekKeyboard *keyboard, * @keyboard: a #EekKeyboard * @layout: a #EekLayout * - * Set the layout of @keyboard to @layout. For the user of EEK, it is - * preferable to call this function rather than - * eek_layout_apply_to_keyboard(), while the implementation calls it - * internally. + * Set the layout of @keyboard to @layout. This actually turns + * @keyboard to be ready to be drawn on the screen. */ void eek_keyboard_set_layout (EekKeyboard *keyboard, diff --git a/eek/eek-keysym.c b/eek/eek-keysym.c index e4bcdfa0..4e428737 100644 --- a/eek/eek-keysym.c +++ b/eek/eek-keysym.c @@ -53,6 +53,12 @@ keysym_label_compare (const void *key0, const void *key1) return (gint)entry0->keysym - (gint)entry1->keysym; } +/** + * eek_keysym_to_string: + * @keysym: keysym ID + * + * Return a string representation of @keysym. + */ G_CONST_RETURN gchar * eek_keysym_to_string (guint keysym) { diff --git a/eek/eek-section.c b/eek/eek-section.c index 628540f2..2203de49 100644 --- a/eek/eek-section.c +++ b/eek/eek-section.c @@ -248,15 +248,15 @@ eek_section_get_bounds (EekSection *section, * Create an #EekKey instance and attach it to @section. */ EekKey * -eek_section_create_key (EekSection *section, - const gchar *name, - guint *keysyms, - gint num_groups, - gint num_levels, - gint column, - gint row, - EekOutline *outline, - EekBounds *bounds) +eek_section_create_key (EekSection *section, + const gchar *name, + guint *keysyms, + gint num_groups, + gint num_levels, + gint column, + gint row, + EekOutline *outline, + EekBounds *bounds) { EekSectionIface *iface; diff --git a/eek/eek-section.h b/eek/eek-section.h index 85d46956..c8f17b47 100644 --- a/eek/eek-section.h +++ b/eek/eek-section.h @@ -30,6 +30,7 @@ G_BEGIN_DECLS #define EEK_SECTION_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EEK_TYPE_SECTION, EekSectionIface)) typedef struct _EekSectionIface EekSectionIface; +typedef struct _EekSection EekSection; struct _EekSectionIface { @@ -86,7 +87,7 @@ void eek_section_get_bounds (EekSection *section, EekKey *eek_section_create_key (EekSection *section, const gchar *name, - guint *labels, + guint *keysyms, gint num_groups, gint num_levels, gint column, diff --git a/eek/eek-types.h b/eek/eek-types.h index 2205184a..90ae1e61 100644 --- a/eek/eek-types.h +++ b/eek/eek-types.h @@ -24,6 +24,8 @@ G_BEGIN_DECLS +typedef struct _EekKeyboard EekKeyboard; + /** * EekKeysymMatrix: * @data: array of keysyms @@ -73,8 +75,8 @@ struct _EekBounds { gdouble x; gdouble y; - gdouble w; - gdouble h; + gdouble width; + gdouble height; }; typedef struct _EekBounds EekBounds; @@ -100,10 +102,5 @@ typedef struct _EekOutline EekOutline; #define EEK_TYPE_OUTLINE (eek_outline_get_type ()) GType eek_outline_get_type (void) G_GNUC_CONST; -/* dummy */ -typedef struct _EekKeyboard EekKeyboard; -typedef struct _EekSection EekSection; -typedef struct _EekKey EekKey; - G_END_DECLS #endif /* EEK_TYPES_H */ diff --git a/eek/eek-xkb-layout.c b/eek/eek-xkb-layout.c index 147c02a2..3fe6725e 100644 --- a/eek/eek-xkb-layout.c +++ b/eek/eek-xkb-layout.c @@ -175,8 +175,8 @@ create_key (EekXkbLayout *layout, xkbbounds = &xkbgeometry->shapes[xkbkey->shape_ndx].bounds; bounds.x = xkb_to_pixmap_coord(layout, xkbbounds->x1 + x); bounds.y = xkb_to_pixmap_coord(layout, xkbbounds->y1 + y); - bounds.w = xkb_to_pixmap_coord(layout, xkbbounds->x2 - xkbbounds->x1); - bounds.h = xkb_to_pixmap_coord(layout, xkbbounds->y2 - xkbbounds->y1); + bounds.width = xkb_to_pixmap_coord(layout, xkbbounds->x2 - xkbbounds->x1); + bounds.height = xkb_to_pixmap_coord(layout, xkbbounds->y2 - xkbbounds->y1); keycode = find_keycode (layout, name); if (keycode == INVALID_KEYCODE) @@ -222,8 +222,8 @@ create_section (EekXkbLayout *layout, bounds.x = xkb_to_pixmap_coord(layout, xkbsection->left); bounds.y = xkb_to_pixmap_coord(layout, xkbsection->top); - bounds.w = xkb_to_pixmap_coord(layout, xkbsection->width); - bounds.h = xkb_to_pixmap_coord(layout, xkbsection->height); + bounds.width = xkb_to_pixmap_coord(layout, xkbsection->width); + bounds.height = xkb_to_pixmap_coord(layout, xkbsection->height); priv = layout->priv; xkbgeometry = priv->xkb->geom; @@ -282,11 +282,11 @@ create_keyboard (EekXkbLayout *layout, EekKeyboard *keyboard) xkbgeometry = priv->xkb->geom; eek_keyboard_get_bounds (keyboard, &bounds); - setup_scaling (EEK_XKB_LAYOUT(layout), bounds.w, bounds.h); + setup_scaling (EEK_XKB_LAYOUT(layout), bounds.width, bounds.height); bounds.x = bounds.y = 0; - bounds.w = xkb_to_pixmap_coord(layout, xkbgeometry->width_mm); - bounds.h = xkb_to_pixmap_coord(layout, xkbgeometry->height_mm); + bounds.width = xkb_to_pixmap_coord(layout, xkbgeometry->width_mm); + bounds.height = xkb_to_pixmap_coord(layout, xkbgeometry->height_mm); eek_keyboard_set_bounds (keyboard, &bounds); for (i = 0; i < xkbgeometry->num_sections; i++) {