libeek: share a single drawing context among each clutter elements

A new class EekClutterDrawingContext maintains the context used to draw actors. Single EekClutterDrawingContext instance is shared by EekClutterKeyboard, EekClutterSection, EekClutterKey, and EekClutterKeyActor.
This commit is contained in:
Daiki Ueno
2010-06-16 10:32:34 +09:00
parent 63b9fea27b
commit 473a9a9b2a
15 changed files with 349 additions and 145 deletions

View File

@ -56,6 +56,8 @@ libeek_clutter_la_SOURCES = \
eek-clutter-key.h \
eek-clutter-key-actor.c \
eek-clutter-key-actor.h \
eek-clutter-drawing-context.c \
eek-clutter-drawing-context.h \
eek-drawing.h \
eek-drawing.c \
eek-clutter.h

View File

@ -0,0 +1,137 @@
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "eek-clutter-drawing-context.h"
G_DEFINE_TYPE (EekClutterDrawingContext, eek_clutter_drawing_context,
G_TYPE_INITIALLY_UNOWNED);
#define EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextPrivate))
struct _EekClutterDrawingContextPrivate
{
/* outline pointer -> ClutterTexture */
GHashTable *outline_textures;
/* keysym category -> PangoFontDescription * */
PangoFontDescription *category_fonts[EEK_KEYSYM_CATEGORY_LAST];
};
static void
eek_clutter_drawing_context_dispose (GObject *object)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(object);
if (priv->outline_textures) {
g_hash_table_unref (priv->outline_textures);
priv->outline_textures = NULL;
}
}
static void
eek_clutter_drawing_context_finalize (GObject *object)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(object);
gint i;
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++)
pango_font_description_free (priv->category_fonts[i]);
}
static void
eek_clutter_drawing_context_class_init (EekClutterDrawingContextClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (gobject_class,
sizeof (EekClutterDrawingContextPrivate));
gobject_class->finalize = eek_clutter_drawing_context_finalize;
}
static void
eek_clutter_drawing_context_init (EekClutterDrawingContext *self)
{
EekClutterDrawingContextPrivate *priv;
priv = self->priv = EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(self);
priv->outline_textures = g_hash_table_new (g_direct_hash, g_direct_equal);
memset (priv->category_fonts, 0, sizeof *priv->category_fonts);
}
void
eek_clutter_drawing_context_set_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline,
ClutterActor *texture)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_if_fail (priv);
g_hash_table_insert (context->priv->outline_textures, outline, texture);
}
ClutterActor *
eek_clutter_drawing_context_get_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_val_if_fail (priv, NULL);
return g_hash_table_lookup (context->priv->outline_textures, outline);
}
void
eek_clutter_drawing_context_set_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category,
PangoFontDescription *font)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_if_fail (priv);
priv->category_fonts[category] = pango_font_description_copy (font);
}
PangoFontDescription *
eek_clutter_drawing_context_get_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category)
{
EekClutterDrawingContextPrivate *priv =
EEK_CLUTTER_DRAWING_CONTEXT_GET_PRIVATE(context);
g_return_val_if_fail (priv, NULL);
return priv->category_fonts[category];
}
EekClutterDrawingContext *
eek_clutter_drawing_context_new (void)
{
return g_object_new (EEK_TYPE_CLUTTER_DRAWING_CONTEXT, NULL);
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2010 Daiki Ueno <ueno@unixuser.org>
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef EEK_CLUTTER_DRAWING_CONTEXT_H
#define EEK_CLUTTER_DRAWING_CONTEXT_H 1
#include <clutter/clutter.h>
#include <pango/pango.h>
#include "eek-keysym.h"
#include "eek-types.h"
G_BEGIN_DECLS
#define EEK_TYPE_CLUTTER_DRAWING_CONTEXT (eek_clutter_drawing_context_get_type())
#define EEK_CLUTTER_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContext))
#define EEK_CLUTTER_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextClass))
#define EEK_IS_CLUTTER_DRAWING_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT))
#define EEK_IS_CLUTTER_DRAWING_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EEK_TYPE_CLUTTER_DRAWING_CONTEXT))
#define EEK_CLUTTER_DRAWING_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EEK_TYPE_CLUTTER_DRAWING_CONTEXT, EekClutterDrawingContextClass))
typedef struct _EekClutterDrawingContext EekClutterDrawingContext;
typedef struct _EekClutterDrawingContextClass EekClutterDrawingContextClass;
typedef struct _EekClutterDrawingContextPrivate EekClutterDrawingContextPrivate;
struct _EekClutterDrawingContext
{
/*< private >*/
GInitiallyUnowned parent;
/*< private >*/
EekClutterDrawingContextPrivate *priv;
};
struct _EekClutterDrawingContextClass
{
/*< private >*/
GInitiallyUnownedClass parent_class;
};
GType eek_clutter_drawing_context_get_type
(void) G_GNUC_CONST;
EekClutterDrawingContext *eek_clutter_drawing_context_new
(void);
void eek_clutter_drawing_context_set_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline,
ClutterActor *texture);
ClutterActor *eek_clutter_drawing_context_get_outline_texture
(EekClutterDrawingContext *context,
EekOutline *outline);
void eek_clutter_drawing_context_set_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category,
PangoFontDescription *fonts);
PangoFontDescription *eek_clutter_drawing_context_get_category_font
(EekClutterDrawingContext *context,
EekKeysymCategory category);
G_END_DECLS
#endif /* EEK_CLUTTER_DRAWING_CONTEXT_H */

View File

@ -54,29 +54,11 @@ G_DEFINE_TYPE (EekClutterKeyActor, eek_clutter_key_actor,
struct _EekClutterKeyActorPrivate
{
EekClutterDrawingContext *context;
EekKey *key;
ClutterActor *texture;
PangoFontDescription *font;
};
static struct {
/* outline pointer -> ClutterTexture */
GHashTable *outline_textures;
/* manually maintain the ref-count of outline_textures to set it
to NULL when all the EekClutterKeyActor are destroyed */
gint outline_textures_ref_count;
} texture_cache;
static struct {
/* keysym category -> PangoFontDescription * */
PangoFontDescription *category_fonts[EEK_KEYSYM_CATEGORY_LAST];
/* manually maintain the ref-count of category_fonts to set it to
NULL when all the EekClutterKeyActor are destroyed */
gint category_fonts_ref_count;
} font_cache;
static ClutterActor *get_texture (EekClutterKeyActor *actor);
static void draw_key_on_layout (EekClutterKeyActor *actor,
PangoLayout *layout);
@ -183,30 +165,14 @@ eek_clutter_key_actor_dispose (GObject *object)
{
EekClutterKeyActorPrivate *priv = EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(object);
if (priv->context) {
g_object_unref (priv->context);
priv->context = NULL;
}
if (priv->key) {
g_object_unref (priv->key);
priv->key = NULL;
}
if (priv->texture) {
/* no need to g_object_unref (priv->texture) */
priv->texture = NULL;
if (--texture_cache.outline_textures_ref_count == 0) {
g_hash_table_unref (texture_cache.outline_textures);
texture_cache.outline_textures = NULL;
}
}
if (priv->font) {
/* no need to pango_font_description_free (priv->font) */
priv->font = NULL;
if (--font_cache.category_fonts_ref_count == 0) {
gint i;
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++) {
pango_font_description_free (font_cache.category_fonts[i]);
font_cache.category_fonts[i] = NULL;
}
}
}
G_OBJECT_CLASS (eek_clutter_key_actor_parent_class)->dispose (object);
}
@ -286,7 +252,6 @@ eek_clutter_key_actor_init (EekClutterKeyActor *self)
priv = self->priv = EEK_CLUTTER_KEY_ACTOR_GET_PRIVATE(self);
priv->key = NULL;
priv->texture = NULL;
priv->font = NULL;
clutter_actor_set_reactive (CLUTTER_ACTOR(self), TRUE);
g_signal_connect (self, "button-press-event",
@ -296,11 +261,13 @@ eek_clutter_key_actor_init (EekClutterKeyActor *self)
}
ClutterActor *
eek_clutter_key_actor_new (EekKey *key)
eek_clutter_key_actor_new (EekClutterDrawingContext *context, EekKey *key)
{
EekClutterKeyActor *actor;
actor = g_object_new (EEK_TYPE_CLUTTER_KEY_ACTOR, NULL);
actor->priv->context = context;
g_object_ref_sink (actor->priv->context);
actor->priv->key = key;
g_object_ref_sink (actor->priv->key);
return CLUTTER_ACTOR(actor);
@ -387,17 +354,17 @@ get_texture (EekClutterKeyActor *actor)
ClutterActor *texture;
EekOutline *outline;
if (!texture_cache.outline_textures)
texture_cache.outline_textures = g_hash_table_new (g_direct_hash,
g_direct_equal);
outline = eek_key_get_outline (actor->priv->key);
texture = g_hash_table_lookup (texture_cache.outline_textures, outline);
texture =
eek_clutter_drawing_context_get_outline_texture (actor->priv->context,
outline);
if (texture == NULL) {
texture = create_texture_for_key (actor->priv->key);
g_hash_table_insert (texture_cache.outline_textures, outline, texture);
eek_clutter_drawing_context_set_outline_texture (actor->priv->context,
outline,
texture);
} else
texture = clutter_clone_new (texture);
texture_cache.outline_textures_ref_count++;
return texture;
}
@ -410,28 +377,7 @@ draw_key_on_layout (EekClutterKeyActor *self,
const gchar *label, *empty_label = "";
EekKeysymCategory category;
EekBounds bounds;
if (font_cache.category_fonts_ref_count == 0) {
EekContainer *keyboard, *section;
PangoFontDescription *font;
PangoLayout *copy;
section = EEK_ELEMENT_GET_CLASS(priv->key)->
get_parent (EEK_ELEMENT(priv->key));
g_return_if_fail (EEK_IS_SECTION(section));
keyboard = EEK_ELEMENT_GET_CLASS(section)->
get_parent (EEK_ELEMENT(section));
g_return_if_fail (EEK_IS_KEYBOARD(keyboard));
copy = pango_layout_copy (layout);
font = pango_font_description_from_string ("Sans");
pango_layout_set_font_description (copy, font);
eek_get_fonts (EEK_KEYBOARD(keyboard), copy,
font_cache.category_fonts);
g_object_unref (G_OBJECT(copy));
}
keysym = eek_key_get_keysym (priv->key);
if (keysym == EEK_INVALID_KEYSYM)
@ -439,11 +385,10 @@ draw_key_on_layout (EekClutterKeyActor *self,
category = eek_keysym_get_category (keysym);
if (category == EEK_KEYSYM_CATEGORY_UNKNOWN)
return;
if (!priv->font) {
priv->font = font_cache.category_fonts[category];
font_cache.category_fonts_ref_count++;
}
pango_layout_set_font_description (layout, priv->font);
font = eek_clutter_drawing_context_get_category_font (priv->context,
category);
pango_layout_set_font_description (layout, font);
eek_element_get_bounds (EEK_ELEMENT(priv->key), &bounds);
pango_layout_set_width (layout, PANGO_SCALE * bounds.width);

View File

@ -21,6 +21,7 @@
#define EEK_CLUTTER_KEY_ACTOR_H 1
#include <clutter/clutter.h>
#include "eek-clutter-drawing-context.h"
#include "eek-key.h"
G_BEGIN_DECLS
@ -54,8 +55,10 @@ struct _EekClutterKeyActorClass
void (* released) (EekClutterKeyActor *self);
};
GType eek_clutter_key_actor_get_type (void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_actor_new (EekKey *key);
GType eek_clutter_key_actor_get_type
(void) G_GNUC_CONST;
ClutterActor *eek_clutter_key_actor_new (EekClutterDrawingContext *context,
EekKey *key);
G_END_DECLS
#endif /* EEK_CLUTTER_KEY_ACTOR_H */

View File

@ -36,6 +36,7 @@ G_DEFINE_TYPE (EekClutterKey, eek_clutter_key, EEK_TYPE_KEY);
struct _EekClutterKeyPrivate
{
EekClutterDrawingContext *context;
ClutterActor *actor;
};
@ -91,6 +92,10 @@ eek_clutter_key_dispose (GObject *object)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(object);
if (priv->context) {
g_object_unref (priv->context);
priv->context = NULL;
}
if (priv->actor) {
g_object_unref (priv->actor);
priv->actor = NULL;
@ -129,9 +134,26 @@ ClutterActor *
eek_clutter_key_get_actor (EekClutterKey *key)
{
EekClutterKeyPrivate *priv = EEK_CLUTTER_KEY_GET_PRIVATE(key);
if (!priv->actor) {
priv->actor = eek_clutter_key_actor_new (EEK_KEY(key));
g_return_val_if_fail (priv->context, NULL);
priv->actor = eek_clutter_key_actor_new (priv->context, EEK_KEY(key));
g_object_ref_sink (priv->actor);
}
return priv->actor;
}
EekKey *
eek_clutter_key_new (EekClutterDrawingContext *context, gint column, gint row)
{
EekClutterKey *key;
g_return_val_if_fail (context, NULL);
key = g_object_new (EEK_TYPE_CLUTTER_KEY,
"column", column,
"row", row,
NULL);
key->priv->context = context;
g_object_ref_sink (key->priv->context);
return EEK_KEY(key);
}

View File

@ -21,6 +21,7 @@
#define EEK_CLUTTER_KEY_H 1
#include <clutter/clutter.h>
#include "eek-clutter-drawing-context.h"
#include "eek-key.h"
G_BEGIN_DECLS
@ -51,6 +52,9 @@ struct _EekClutterKeyClass
};
GType eek_clutter_key_get_type (void) G_GNUC_CONST;
EekKey * eek_clutter_key_new (EekClutterDrawingContext *context,
gint column,
gint row);
ClutterActor *eek_clutter_key_get_actor (EekClutterKey *key);
G_END_DECLS

View File

@ -29,6 +29,7 @@
#endif /* HAVE_CONFIG_H */
#include "eek-clutter-keyboard.h"
#include "eek-clutter-drawing-context.h"
#include "eek-keyboard.h"
G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, EEK_TYPE_KEYBOARD);
@ -39,7 +40,9 @@ G_DEFINE_TYPE (EekClutterKeyboard, eek_clutter_keyboard, EEK_TYPE_KEYBOARD);
struct _EekClutterKeyboardPrivate
{
EekClutterDrawingContext *context;
ClutterActor *actor;
guint key_press_event_handler;
guint key_release_event_handler;
};
@ -92,10 +95,16 @@ key_released_event (EekSection *section,
static EekSection *
eek_clutter_keyboard_real_create_section (EekKeyboard *self)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(self);
EekSection *section;
ClutterActor *actor;
section = g_object_new (EEK_TYPE_CLUTTER_SECTION, NULL);
if (!priv->context) {
priv->context = eek_clutter_drawing_context_new ();
g_object_ref_sink (G_OBJECT(priv->context));
}
section = eek_clutter_section_new (priv->context);
g_return_val_if_fail (section, NULL);
g_signal_connect (section, "key-pressed",
@ -119,6 +128,10 @@ eek_clutter_keyboard_dispose (GObject *object)
{
EekClutterKeyboardPrivate *priv = EEK_CLUTTER_KEYBOARD_GET_PRIVATE(object);
if (priv->context) {
g_object_unref (G_OBJECT(priv->context));
priv->context = NULL;
}
if (priv->actor) {
ClutterActor *stage;
@ -238,6 +251,31 @@ on_clutter_realize (ClutterActor *actor, gpointer user_data)
G_CALLBACK (on_clutter_key_release_event), keyboard);
}
static void
update_category_fonts (EekClutterKeyboard *keyboard)
{
EekClutterKeyboardPrivate *priv =
EEK_CLUTTER_KEYBOARD_GET_PRIVATE(keyboard);
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *fonts[EEK_KEYSYM_CATEGORY_LAST], *base_font;
gint i;
context = clutter_actor_get_pango_context (priv->actor);
layout = pango_layout_new (context);
base_font = pango_font_description_from_string ("Sans");
pango_layout_set_font_description (layout, base_font);
pango_font_description_free (base_font);
eek_get_fonts (EEK_KEYBOARD(keyboard), layout, &fonts);
for (i = 0; i < EEK_KEYSYM_CATEGORY_LAST; i++) {
eek_clutter_drawing_context_set_category_font (priv->context,
i,
fonts[i]);
pango_font_description_free (fonts[i]);
}
g_object_unref (G_OBJECT(layout));
}
ClutterActor *
eek_clutter_keyboard_get_actor (EekClutterKeyboard *keyboard)
{
@ -249,7 +287,9 @@ eek_clutter_keyboard_get_actor (EekClutterKeyboard *keyboard)
g_signal_connect (priv->actor, "realize",
G_CALLBACK (on_clutter_realize), keyboard);
g_return_val_if_fail (priv->actor, NULL);
eek_keyboard_realize (EEK_KEYBOARD(keyboard));
update_category_fonts (keyboard);
}
return priv->actor;
}

View File

@ -35,6 +35,7 @@ G_DEFINE_TYPE (EekClutterSection, eek_clutter_section, EEK_TYPE_SECTION);
struct _EekClutterSectionPrivate
{
EekClutterDrawingContext *context;
ClutterActor *actor;
};
@ -101,6 +102,7 @@ eek_clutter_section_real_create_key (EekSection *self,
gint column,
gint row)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(self);
EekKey *key;
gint num_columns, num_rows;
EekOrientation orientation;
@ -111,10 +113,7 @@ eek_clutter_section_real_create_key (EekSection *self,
eek_section_get_row (self, row, &num_columns, &orientation);
g_return_val_if_fail (column < num_columns, NULL);
key = g_object_new (EEK_TYPE_CLUTTER_KEY,
"column", column,
"row", row,
NULL);
key = eek_clutter_key_new (priv->context, column, row);
g_return_val_if_fail (key, NULL);
g_signal_connect (key, "pressed", G_CALLBACK(pressed_event), self);
@ -136,6 +135,10 @@ eek_clutter_section_dispose (GObject *object)
{
EekClutterSectionPrivate *priv = EEK_CLUTTER_SECTION_GET_PRIVATE(object);
if (priv->context) {
g_object_unref (priv->context);
priv->context = NULL;
}
if (priv->actor) {
g_object_unref (priv->actor);
priv->actor = NULL;
@ -177,3 +180,16 @@ eek_clutter_section_get_actor (EekClutterSection *section)
}
return priv->actor;
}
EekSection *
eek_clutter_section_new (EekClutterDrawingContext *context)
{
EekClutterSection *section;
g_return_val_if_fail (context, NULL);
section = g_object_new (EEK_TYPE_CLUTTER_SECTION, NULL);
section->priv->context = context;
g_object_ref_sink (G_OBJECT(section->priv->context));
return EEK_SECTION(section);
}

View File

@ -20,6 +20,7 @@
#ifndef EEK_CLUTTER_SECTION_H
#define EEK_CLUTTER_SECTION_H 1
#include "eek-clutter-drawing-context.h"
#include "eek-clutter-key.h"
#include "eek-section.h"
@ -50,6 +51,7 @@ struct _EekClutterSectionClass
};
GType eek_clutter_section_get_type (void) G_GNUC_CONST;
EekSection * eek_clutter_section_new (EekClutterDrawingContext *context);
ClutterActor *eek_clutter_section_get_actor (EekClutterSection *section);
G_END_DECLS

View File

@ -61,7 +61,6 @@ eek_container_real_add_child (EekContainer *self,
g_object_ref_sink (child);
priv->children = g_slist_prepend (priv->children, child);
EEK_ELEMENT_GET_CLASS(child)->set_parent (child, self);
}
static void
@ -76,7 +75,6 @@ eek_container_real_remove_child (EekContainer *self,
g_return_if_fail (head);
g_object_unref (child);
priv->children = g_slist_remove_link (priv->children, head);
EEK_ELEMENT_GET_CLASS(child)->set_parent (child, NULL);
}
static void

View File

@ -87,19 +87,15 @@ egf_key_callback (EekElement *element,
{
EekKey *key = EEK_KEY(element);
GetFontSizeCallbackData *data = user_data;
guint *keysyms;
gint num_groups, num_levels, i;
gdouble font_size;
eek_key_get_keysyms (key, &keysyms, &num_groups, &num_levels);
for (i = 0; i < num_groups * num_levels; i++) {
guint keysym = keysyms[i];
guint keysym;
EekBounds bounds;
const gchar *label;
keysym = eek_key_get_keysym (key);
if (keysym == EEK_INVALID_KEYSYM ||
eek_keysym_get_category (keysym) != data->category)
continue;
return;
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
label = eek_keysym_to_string (keysym);
@ -107,7 +103,6 @@ egf_key_callback (EekElement *element,
if (font_size < data->font_size && font_size >= data->minimum_font_size)
data->font_size = font_size;
}
}
static void
egf_section_callback (EekElement *element,

View File

@ -33,7 +33,6 @@
#endif /* HAVE_CONFIG_H */
#include "eek-element.h"
#include "eek-container.h"
enum {
PROP_0,
@ -52,30 +51,8 @@ struct _EekElementPrivate
{
gchar *name;
EekBounds bounds;
EekContainer *parent;
};
static void
eek_element_real_set_parent (EekElement *self,
EekContainer *parent)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
if (parent) {
g_return_if_fail (EEK_IS_CONTAINER(parent));
g_object_ref_sink (G_OBJECT(parent));
} else if (priv->parent)
g_object_unref (G_OBJECT (priv->parent));
priv->parent = parent;
}
static EekContainer *
eek_element_real_get_parent (EekElement *self)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(self);
return priv->parent;
}
static void
eek_element_real_set_name (EekElement *self,
const gchar *name)
@ -117,17 +94,6 @@ eek_element_real_get_bounds (EekElement *self,
g_object_notify (G_OBJECT(self), "bounds");
}
static void
eek_element_dispose (GObject *object)
{
EekElementPrivate *priv = EEK_ELEMENT_GET_PRIVATE(object);
if (priv->parent) {
g_object_unref (G_OBJECT(priv->parent));
priv->parent = NULL;
}
}
static void
eek_element_finalize (GObject *object)
{
@ -190,8 +156,6 @@ eek_element_class_init (EekElementClass *klass)
g_type_class_add_private (gobject_class,
sizeof (EekElementPrivate));
klass->set_parent = eek_element_real_set_parent;
klass->get_parent = eek_element_real_get_parent;
klass->set_name = eek_element_real_set_name;
klass->get_name = eek_element_real_get_name;
klass->set_bounds = eek_element_real_set_bounds;
@ -200,7 +164,6 @@ eek_element_class_init (EekElementClass *klass)
gobject_class->set_property = eek_element_set_property;
gobject_class->get_property = eek_element_get_property;
gobject_class->finalize = eek_element_finalize;
gobject_class->dispose = eek_element_dispose;
/**
* EekElement:name:

View File

@ -47,9 +47,6 @@ struct _EekElementClass
/*< private >*/
GInitiallyUnownedClass parent_class;
void (* set_parent) (EekElement *self,
EekContainer *parent);
EekContainer *(* get_parent) (EekElement *self);
void (* set_name) (EekElement *self,
const gchar *name);

View File

@ -20,6 +20,8 @@
#ifndef EEK_KEYSYM_H
#define EEK_KEYSYM_H 1
#include <glib-object.h>
#define EEK_INVALID_KEYSYM ((guint)(-1))
#define EEK_INVALID_KEYCODE ((guint)(-1))