projects
/
ruby-evas.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated for new smart object API.
[ruby-evas.git]
/
src
/
rb_smart.c
diff --git
a/src/rb_smart.c
b/src/rb_smart.c
index ba7bd30ba6984b79c8c85e1b0a31e79cb281121c..b6ea30416db1153d5fad3fd53617f0d6d9bbde84 100644
(file)
--- a/
src/rb_smart.c
+++ b/
src/rb_smart.c
@@
-1,6
+1,4
@@
/*
/*
- * $Id: rb_smart.c 374 2006-02-21 21:20:35Z tilman $
- *
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
* This library is free software; you can redistribute it and/or
* Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de)
*
* This library is free software; you can redistribute it and/or
@@
-31,54
+29,50
@@
static ID id; \
\
if (!id) \
static ID id; \
\
if (!id) \
- id = rb_intern ("
on
_"#name); \
+ id = rb_intern ("
smart
_"#name); \
\
if (!rb_respond_to (self, id)) \
return;
#define SMART_CB(name) \
\
if (!rb_respond_to (self, id)) \
return;
#define SMART_CB(name) \
- static void
on
_##name (Evas_Object *o) \
+ static void
smart
_##name (Evas_Object *o) \
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 0); \
}
#define SMART_CB_OBJ(name) \
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 0); \
}
#define SMART_CB_OBJ(name) \
- static void
on
_##name (Evas_Object *o, Evas_Object *other) \
+ static void
smart
_##name (Evas_Object *o, Evas_Object *other) \
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 1, TO_EVAS_OBJECT (other)); \
}
#define SMART_CB_COORD(name) \
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 1, TO_EVAS_OBJECT (other)); \
}
#define SMART_CB_COORD(name) \
- static void
on
_##name (Evas_Object *o, Evas_Coord a, Evas_Coord b) \
+ static void
smart
_##name (Evas_Object *o, Evas_Coord a, Evas_Coord b) \
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 2, INT2FIX ((int) a), INT2FIX ((int) b)); \
}
{ \
SMART_CB_BODY (name); \
rb_funcall (self, id, 2, INT2FIX ((int) a), INT2FIX ((int) b)); \
}
-static ID id_smart_object;
+typedef struct {
+ Evas_Smart_Class smart_class;
+ Evas_Smart *smart;
+
+ VALUE name;
+} SmartData;
+
+static ID id_smart_data;
SMART_CB (delete);
SMART_CB (delete);
-SMART_CB (raise);
-SMART_CB (lower);
SMART_CB (show);
SMART_CB (hide);
SMART_CB (clip_unset);
SMART_CB (show);
SMART_CB (hide);
SMART_CB (clip_unset);
-SMART_CB_OBJ (stack_above);
-SMART_CB_OBJ (stack_below);
SMART_CB_OBJ (clip_set);
SMART_CB_COORD (move);
SMART_CB_COORD (resize);
SMART_CB_OBJ (clip_set);
SMART_CB_COORD (move);
SMART_CB_COORD (resize);
-static void on_layer_set (Evas_Object *o, int layer)
-{
- SMART_CB_BODY (layer_set);
-
- rb_funcall (self, id, 1, FIX2INT (layer));
-}
-
-static void on_color_set (Evas_Object *o, int r, int g, int b, int a)
+static void smart_color_set (Evas_Object *o, int r, int g, int b, int a)
{
SMART_CB_BODY (color_set);
{
SMART_CB_BODY (color_set);
@@
-88,15
+82,21
@@
static void on_color_set (Evas_Object *o, int r, int g, int b, int a)
static VALUE c_inherited (VALUE klass, VALUE child)
{
static VALUE c_inherited (VALUE klass, VALUE child)
{
- rb_const_set (child, id_smart_
object
, Qnil);
+ rb_const_set (child, id_smart_
data
, Qnil);
return Qnil;
}
return Qnil;
}
+static void
+c_data_mark (SmartData *sd)
+{
+ rb_gc_mark (sd->name);
+}
+
static VALUE c_init (VALUE self, VALUE evas)
{
static VALUE c_init (VALUE self, VALUE evas)
{
- VALUE klass,
smart, name
;
-
Evas_Smart **s = NULL
;
+ VALUE klass,
data
;
+
SmartData *sd
;
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
CHECK_CLASS (evas, cEvas);
GET_OBJ (evas, RbEvas, e);
@@
-105,38
+105,59
@@
static VALUE c_init (VALUE self, VALUE evas)
klass = rb_obj_class (self);
/* check whether the smart object has been created already */
klass = rb_obj_class (self);
/* check whether the smart object has been created already */
-
smart = rb_const_get (klass, id_smart_object
);
- if (!NIL_P (
smart
))
- Data_Get_Struct (
smart, Evas_Smart *, s
);
+
data = rb_const_get (klass, id_smart_data
);
+ if (!NIL_P (
data
))
+ Data_Get_Struct (
data, SmartData, sd
);
else {
else {
- name = rb_class_path (klass);
+ data = Data_Make_Struct (rb_cObject, SmartData,
+ c_data_mark, NULL, sd);
+
+ sd->name = rb_class_path (klass);
+
+ sd->smart_class.name = StringValuePtr (sd->name);
+ sd->smart_class.version = EVAS_SMART_CLASS_VERSION;
- smart = Data_Make_Struct (rb_cObject, Evas_Smart *, NULL, NULL, s);
+ sd->smart_class.add = NULL;
+ sd->smart_class.del = smart_delete;
+ sd->smart_class.move = smart_move;
+ sd->smart_class.resize = smart_resize;
+ sd->smart_class.show = smart_show;
+ sd->smart_class.hide = smart_hide;
+ sd->smart_class.color_set = smart_color_set;
+ sd->smart_class.clip_set = smart_clip_set;
+ sd->smart_class.clip_unset = smart_clip_unset;
- *s = evas_smart_new (StringValuePtr (name),
- NULL, on_delete, on_layer_set,
- on_raise, on_lower, on_stack_above,
- on_stack_below, on_move, on_resize,
- on_show, on_hide, on_color_set,
- on_clip_set, on_clip_unset, NULL);
+ sd->smart = evas_smart_class_new (&sd->smart_class);
- rb_mod_remove_const
(klass, ID2SYM (id_smart_object
));
- rb_const_set (klass, id_smart_
object, smart
);
+ rb_mod_remove_const
(klass, ID2SYM (id_smart_data
));
+ rb_const_set (klass, id_smart_
data, data
);
}
}
- s2->real = evas_object_smart_add (e->real,
*s
);
+ s2->real = evas_object_smart_add (e->real,
sd->smart
);
rb_call_super (1, &evas);
return self;
}
rb_call_super (1, &evas);
return self;
}
+static VALUE c_add_member (VALUE self, VALUE member)
+{
+ GET_OBJ (self, RbEvasObject, e);
+ GET_OBJ (member, RbEvasObject, e2);
+
+ /* weird order of arguments */
+ evas_object_smart_member_add (e2->real, e->real);
+
+ return Qnil;
+}
+
void Init_Smart (void)
{
VALUE c = rb_define_class_under (mEvas, "Smart", cEvasObject);
rb_define_singleton_method (c, "inherited", c_inherited, 1);
rb_define_method (c, "initialize", c_init, 1);
void Init_Smart (void)
{
VALUE c = rb_define_class_under (mEvas, "Smart", cEvasObject);
rb_define_singleton_method (c, "inherited", c_inherited, 1);
rb_define_method (c, "initialize", c_init, 1);
+ rb_define_method (c, "add_member", c_add_member, 1);
- id_smart_
object = rb_intern ("SMART_OBJECT
");
+ id_smart_
data = rb_intern ("SMART_DATA
");
}
}