From 455555b3ce7258e14cf34699e03ac6b918d1eaea Mon Sep 17 00:00:00 2001 From: rephorm Date: Fri, 11 Jan 2002 23:53:20 +0000 Subject: [PATCH] Epplets! Quite a bit has been implemented. Check the data/epplets dir for examples. Currently the only loading method is a file called .e_epplets.bits.db which contains bits whose names are equal to the epplet name, and whose geometry is the default epplet geometry (unless overridden in the script). The idea being that one could set up an entire desktop epplet layout within one file, making it easily transferable. So, to use epplets make sure you copy the default epplets.bits.db to ~/.e/desktop/default/.e_epplets.bits.db Also, make sure you update ebits SVN revision: 5826 --- src/Makefile.am | 5 + src/config.c | 4 + src/e_ferite.fec | 475 +++++++++++++++++++++++++++++++++++++++++++- src/epplet.c | 502 +++++++++++++++++++++++++++++++++++++++++++++++ src/epplet.h | 81 ++++++++ src/view.c | 2 + src/view.h | 3 + 7 files changed, 1071 insertions(+), 1 deletion(-) create mode 100644 src/epplet.c create mode 100644 src/epplet.h diff --git a/src/Makefile.am b/src/Makefile.am index 44d894caa..18b629d39 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,11 @@ ferite_c = e_ferite_gen_core.c \ e_ferite_gen_header.h \ e_ferite_gen_e.c \ e_ferite_gen_window.c \ + e_ferite_gen_Epplet.c \ + e_ferite_gen_Ebits.c \ + e_ferite_gen_EvasObject.c \ e_ferite.h e_ferite.c + endif enlightenment_SOURCES = \ @@ -36,6 +40,7 @@ enlightenment_SOURCES = \ desktops.h desktops.c \ embed.c embed.h \ entry.h entry.c \ + epplet.h epplet.c \ exec.h exec.c \ focus.h focus.c \ file.h file.c \ diff --git a/src/config.c b/src/config.c index ca07d8872..eb206682c 100644 --- a/src/config.c +++ b/src/config.c @@ -21,6 +21,7 @@ static char cfg_images_dir[PATH_MAX] = ""; static char cfg_cursors_dir[PATH_MAX] = ""; static char cfg_backgrounds_dir[PATH_MAX] = ""; static char cfg_fonts_dir[PATH_MAX] = ""; +static char cfg_epplets_dir[PATH_MAX] = ""; char * e_config_get(char *type) @@ -83,6 +84,9 @@ e_config_get(char *type) PACKAGE_DATA_DIR"/data/backgrounds/"); E_CONF("fonts", cfg_fonts_dir, PACKAGE_DATA_DIR"/data/fonts/"); + E_CONF("epplets", cfg_epplets_dir, + PACKAGE_DATA_DIR"/data/epplets/"); + D_RETURN_(""); } diff --git a/src/e_ferite.fec b/src/e_ferite.fec index 25f8b7559..f299f7593 100644 --- a/src/e_ferite.fec +++ b/src/e_ferite.fec @@ -1,8 +1,17 @@ header %{ #include "Ecore.h" - #include "desktops.h" + #include "Ebits.h" + #include "desktops.h" + #include "border.h" + #include "epplet.h" + #include "debug.h" + #include "globals.h" + + #define BitsObj ((Ebits_Object)self->odata) + #define EppObj ((E_Epplet *)(self->odata)) + #define EvasObj ((Evas_Object_Wrapper *)(self->odata)) %} class window { @@ -39,6 +48,7 @@ class window { } + namespace e { function flip_to_desktop( number desk ) @@ -55,6 +65,7 @@ namespace e { function get_desktop_count() %{ int retval = e_desktops_get_num(); + printf("desktop_count: %i\n", retval); FE_RETURN_LONG( retval ); %} @@ -67,3 +78,465 @@ namespace e { ecore_event_loop_quit(); %} } + +class EvasObject +{ + function EvasObject(object epp) + %{ + EvasObj = NEW(Evas_Object_Wrapper, 1); + ZERO(EvasObj, Evas_Object_Wrapper, 1); + + EvasObj->evas = ((E_Epplet *)(epp->odata))->view->evas; + %} + + function Destructor() + %{ + %} + + function addImage(string path) + %{ + if (EvasObj->evas) + EvasObj->obj = evas_add_image_from_file(EvasObj->evas, path); + ffree(path); + %} + + function addRectangle() + %{ + if (EvasObj->evas) + EvasObj->obj = evas_add_rectangle(EvasObj->evas); + %} + + function addText(string font, number size, string text) + %{ + if (EvasObj->evas) + EvasObj->obj = evas_add_text(EvasObj->evas, font, (long)size, text); + ffree(font); + ffree(text); + %} + + function setImageFile(string path) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_set_image_file(EvasObj->evas, EvasObj->obj, path); + ffree(path); + %} + + function setText(string text) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_set_text(EvasObj->evas, EvasObj->obj, text); + ffree(text); + %} + + function move(number x, number y) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_move(EvasObj->evas, EvasObj->obj, x, y); + %} + + function resize(number w, number h) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_resize(EvasObj->evas, EvasObj->obj, w, h); + %} + + function resizeF(number w, number h) + %{ + if (EvasObj->evas && EvasObj->obj) + { + evas_resize(EvasObj->evas, EvasObj->obj, w, h); + evas_set_image_fill(EvasObj->evas, EvasObj->obj, 0, 0, w, h); + } + %} + + function setLayer(number l) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_set_layer(EvasObj->evas, EvasObj->obj, l); + %} + + function show() + %{ + if (EvasObj->evas && EvasObj->obj) + evas_show(EvasObj->evas, EvasObj->obj); + %} + + function hide() + %{ + if (EvasObj->evas && EvasObj->obj) + evas_hide(EvasObj->evas, EvasObj->obj); + %} + + function setColor(number r, number g, number b, number a) + %{ + D("in setColor\n"); + if (EvasObj->evas && EvasObj->obj) + evas_set_color(EvasObj->evas, EvasObj->obj, (long)r, (long)g, (long)b, (long)a); + D("leaving setColor\n"); + %} + + + function setImageFill(number x, number y, number w, number h) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_set_image_fill(EvasObj->evas, EvasObj->obj, x, y, w, h); + %} + + function setImageBorder(number l, number r, number t, number b) + %{ + if (EvasObj->evas && EvasObj->obj) + evas_set_image_border(EvasObj->evas, EvasObj->obj, l, r, t, b); + %} + + function getX() + %{ + double x; + if (EvasObj->evas && EvasObj->obj) + { + evas_get_geometry(EvasObj->evas, EvasObj->obj, &x, NULL, NULL, NULL); + FE_RETURN_DOUBLE(x); + } + %} + + function getY() + %{ + double y; + if (EvasObj->evas && EvasObj->obj) + { + evas_get_geometry(EvasObj->evas, EvasObj->obj, NULL, &y, NULL, NULL); + FE_RETURN_DOUBLE(y); + } + %} + + function getW() + %{ + double w; + if (EvasObj->evas && EvasObj->obj) + { + evas_get_geometry(EvasObj->evas, EvasObj->obj, NULL, NULL, &w, NULL); + FE_RETURN_DOUBLE(w); + } + %} + + function getH() + %{ + double h; + if (EvasObj->evas && EvasObj->obj) + { + evas_get_geometry(EvasObj->evas, EvasObj->obj, NULL, NULL, NULL, &h); + FE_RETURN_DOUBLE(h); + } + %} + + function setCallback(string type, string func, object data) + %{ + E_Epplet_CB_Info *cb; + + D("create cb\n"); + + cb = e_epplet_cb_new(script, func, data, self); + + D("check for callback type\n"); + if(!strcmp(type, "CALLBACK_MOUSE_DOWN")) + { + D("mouse down cb!\n"); + evas_callback_add(EvasObj->evas, EvasObj->obj, CALLBACK_MOUSE_DOWN, + e_epplet_evas_cb, cb); + } + + else if(!strcmp(type, "CALLBACK_MOUSE_UP")) + { + D("mouse up cb!\n"); + evas_callback_add(EvasObj->evas, EvasObj->obj, CALLBACK_MOUSE_UP, + e_epplet_evas_cb, cb); + } + + else if(!strcmp(type, "CALLBACK_MOUSE_MOVE")) + { + D("mouse move cb!\n"); + evas_callback_add(EvasObj->evas, EvasObj->obj, CALLBACK_MOUSE_MOVE, + e_epplet_evas_cb, cb); + } + +// ffree(func); + ffree(type); + %} + +} + +class Ebits +{ + + function Ebits(string path) + %{ + D("in Ebits constructor\n"); + D("loading bits\n"); + BitsObj = NULL; + BitsObj = ebits_load(path); + if (BitsObj) + printf("bits loaded\n"); + else + printf("ERROR: bits not found\n"); + + ffree(path); + %} + + function Destructor() + %{ + /* FIXME: if i leave this in, the bits get freed and removed before you can + see them. I guess it just needs to be called when the epplet itself is + destroyed */ + /* + ebits_free(BitsObj); + */ + %} + + function show() + %{ + ebits_show(BitsObj); + %} + + function hide() + %{ + ebits_hide(BitsObj); + %} + + function raise() + %{ + ebits_raise(BitsObj); + %} + + function lower() + %{ + ebits_lower(BitsObj); + %} + + function move(number x, number y) + %{ + ebits_move(BitsObj, x, y); + %} + + function resize(number w, number h) + %{ + ebits_resize(BitsObj, w, h); + %} + + function set_layer(number l) + %{ + ebits_set_layer(BitsObj, l); + %} + + function getNamedBitGeometry(string bitName, number x, number y, number w, number h) + %{ + double xx, yy, ww, hh; + ebits_get_named_bit_geometry(BitsObj, bitName, &xx, &yy, &ww, &hh); + + x = xx; + y = yy; + w = ww; + h = hh; + %} + + function getNamedBitGeometryX(string bitName) + %{ + double x; + ebits_get_named_bit_geometry(BitsObj, bitName, &x, NULL, NULL, NULL); + D("%s.x: %i\n", bitName, x); + ffree(bitName); + FE_RETURN_DOUBLE(x); + %} + + function getNamedBitGeometryY(string bitName) + %{ + double y; + ebits_get_named_bit_geometry(BitsObj, bitName, NULL, &y, NULL, NULL); + ffree(bitName); + FE_RETURN_DOUBLE(y); + %} + + function getNamedBitGeometryW(string bitName) + %{ + double w; + ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, &w, NULL); + ffree(bitName); + FE_RETURN_DOUBLE(w); + %} + + function getNamedBitGeometryH(string bitName) + %{ + double h; + ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, NULL, &h); + ffree(bitName); + FE_RETURN_DOUBLE(h); + %} + + function setCallback(string bitClass, string func, object data) + %{ + E_Epplet_CB_Info *cb; + + cb = e_epplet_cb_new(script, func, data, NULL); + + ebits_set_classed_bit_callback(BitsObj, bitClass, CALLBACK_MOUSE_DOWN, e_epplet_bits_cb, cb); + + ffree(bitClass); + ffree(func); + %} +} + +class Epplet +{ + + object bits; + + function Epplet() + %{ + EppObj = malloc(sizeof(E_Epplet)); + memset(EppObj, 0, sizeof(E_Epplet)); + + EppObj->context = e_epplet_get_context_from_script(script); + EppObj->view = EppObj->context->view; + EppObj->name = strdup(EppObj->context->name); + EppObj->current.x = EppObj->context->geom.x; + EppObj->current.y = EppObj->context->geom.y; + EppObj->current.w = EppObj->context->geom.w; + EppObj->current.h = EppObj->context->geom.h; + + if (!EppObj->view) { D("Error: no view found for script\n"); } + else { D("got view: %s\n", EppObj->view->dir); } + %} + + function setBits(object ebits) + %{ + EppObj->bits = ((Ebits_Object)ebits->odata); + EppObj->fbits = ebits; + + if(EppObj->bits && EppObj->view) + { + ebits_add_to_evas(EppObj->bits, EppObj->view->evas); + e_epplet_set_common_callbacks(EppObj); + D("bits added to view\n"); + D("view dir: %s\n", EppObj->view->dir); + } + else + { + D("ERROR: no bits or no view, can't add bits to view evas\n"); + } + + %} + + function move(number x, number y) + %{ + D("in epp.move\n"); + EppObj->current.x = x; + EppObj->current.y = y; + + D("moving epplet: %f, %f\n", x, y); + + if (EppObj->bits) + ebits_move(EppObj->bits, EppObj->current.x, EppObj->current.y); + %} + + function resize(number w, number h) + %{ + EppObj->current.w = w; + EppObj->current.h = h; + if (EppObj->bits) + ebits_resize(EppObj->bits, EppObj->current.w, EppObj->current.h); + %} + + function getX() + %{ + FE_RETURN_DOUBLE(EppObj->current.x); + %} + + function getY() + %{ + FE_RETURN_DOUBLE(EppObj->current.y); + %} + + function getW() + %{ + FE_RETURN_DOUBLE(EppObj->current.w); + %} + + function getH() + %{ + FE_RETURN_DOUBLE(EppObj->current.h); + %} + + function display() + %{ + int mw, mh; + + if(EppObj->view && EppObj->bits) + { + D("adding bits for epplet `%s'\n", EppObj->context->name); + D("x: %f, y: %f, w: %f, h: %f\n", EppObj->context->geom.x, EppObj->context->geom.y, EppObj->context->geom.w, EppObj->context->geom.h); +// ebits_add_to_evas(EppObj->bits, EppObj->view->evas); + ebits_show(EppObj->bits); + + if ((EppObj->context->geom.w) && (EppObj->context->geom.h)) + { + EppObj->current.w = EppObj->context->geom.w; + EppObj->current.h = EppObj->context->geom.h; + + ebits_get_min_size(EppObj->bits, &mw, &mh); + if ( EppObj->current.w < mw ) EppObj->current.w = mw; + if ( EppObj->current.h < mh ) EppObj->current.h = mh; + } + + else + { + ebits_get_min_size(EppObj->bits, &mw, &mh); + if (mw == 0 || mh == 0) + { + mw = mh = 50; + } + EppObj->current.w = mw; + EppObj->current.h = mh; + } + + EppObj->current.x = EppObj->context->geom.x; + EppObj->current.y = EppObj->context->geom.y; + + ebits_get_min_size(EppObj->bits, &mw, &mh); + + if (EppObj->current.x > (EppObj->view->size.w - mw)) + EppObj->current.x = EppObj->view->size.w - mw; + if (EppObj->current.y > (EppObj->view->size.h - mh)) + EppObj->current.y = EppObj->view->size.h - mh; + + ebits_set_layer(EppObj->bits, 12000); + ebits_resize(EppObj->bits, EppObj->current.w, EppObj->current.h); + ebits_move(EppObj->bits, EppObj->current.x, EppObj->current.y); + } + %} + + function getBits() + %{ + FE_RETURN_VAR(EppObj->fbits); + %} + + function getViewW() + %{ + FE_RETURN_LONG(EppObj->view->size.w); + %} + + function getViewH() + %{ + FE_RETURN_LONG(EppObj->view->size.h); + %} + + function getEppletDir() + %{ + char buf[PATH_MAX], *retval; + + printf("getting dir:\n"); + sprintf(buf, "%s%s/", e_config_get("epplets"), EppObj->name); + printf("%s\n", buf); + retval = (char *)buf; + FE_RETURN_STR(retval, 0); + %} + +} + diff --git a/src/epplet.c b/src/epplet.c new file mode 100644 index 000000000..3ba352c72 --- /dev/null +++ b/src/epplet.c @@ -0,0 +1,502 @@ +#include "debug.h" +#include "epplet.h" +#include "globals.h" +#include "file.h" + +#include "e_ferite.h" + +static void e_epplet_mouse_down_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); + +static void e_epplet_mouse_up_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); + +static void e_epplet_mouse_move_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); + + +void +e_epplet_load_from_layout (E_View * v) +{ + char buf[PATH_MAX]; + Evas_List bit_names, l; + + D_ENTER; + + sprintf (buf, "%s/.e_epplets.bits.db", v->dir); + v->epplet_layout = ebits_load (buf); + if (!v->epplet_layout) + D_RETURN; + ebits_add_to_evas (v->epplet_layout, v->evas); + ebits_resize (v->epplet_layout, v->size.w, v->size.h); + ebits_move (v->epplet_layout, 0, 0); + + bit_names = ebits_get_bit_names (v->epplet_layout); + + for (l = bit_names; l; l = l->next) + { + double x, y, w, h; + E_Epplet_Context *context; + + context = NEW (E_Epplet_Context, 1); + ZERO (context, E_Epplet_Context, 1); + + context->name = l->data; + + ebits_get_named_bit_geometry (v->epplet_layout, context->name, &x, &y, + &w, &h); + + context->geom.x = x; + context->geom.y = y; + context->geom.w = w; + context->geom.h = h; + context->view = v; + D ("epplet has following info:\n"); + D ("x: %f, y: %f, w: %f, h: %f\n", x, y, w, h); + + v->epplet_contexts = evas_list_append (v->epplet_contexts, context); + + sprintf (buf, "%s%s/%s.fe", e_config_get ("epplets"), context->name, + context->name); + if (e_file_exists (buf)) + e_epplet_script_load (context, buf); + else + D ("Error: Can't find epplet `%s'\n", buf); + } + + D_RETURN; +} + + + +E_Epplet_Context * +e_epplet_get_context_from_script (FeriteScript * script) +{ + Evas_List l, ll; + + D_ENTER; + + D ("script address: %p\n", script); + + for (l = views; l; l = l->next) + { + E_View *v; + + v = l->data; + D ("searching view: %s\n", v->dir); + + if (v->epplet_contexts == NULL) + D ("no scripts in view\n"); + for (ll = v->epplet_contexts; ll; ll = ll->next) + { + E_Epplet_Context *context = ll->data; + D ("found script: %p\n", context->script); + + if (context->script == script) + D_RETURN_ (context); + } + } + + D_RETURN_ (NULL); +} + + +void +e_epplet_script_load (E_Epplet_Context * context, char *path) +{ + FeriteScript *script = NULL; + + D_ENTER; + + D ("Ferite: Compiling epplet script `%s'\n", path); + script = ferite_script_compile (path); + + if (!script) + { + D ("Error compiling script... aborting\n"); + D_RETURN; + } + context->script = script; + e_ferite_register (script, script->mainns); + script->error_cb = e_ferite_script_error; + script->warning_cb = e_ferite_script_warning; + D ("Ferite: executing epplet.\n"); + + ferite_script_execute (script); + D ("Ferite: epplet executed.\n"); + /*ferite_script_delete(script); */ + + D_RETURN; +} + +void +e_epplet_set_common_callbacks (E_Epplet * epp) +{ + D ("setting callbacks\n"); + + if (!epp->bits) + { + D ("Error: no bits to set callbacks on\n"); + D_RETURN; + } + + + ebits_set_classed_bit_callback (epp->bits, "Title_Bar", + CALLBACK_MOUSE_DOWN, e_epplet_mouse_down_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Title_Bar", CALLBACK_MOUSE_UP, + e_epplet_mouse_up_cb, epp); + ebits_set_classed_bit_callback (epp->bits, "Title_Bar", CALLBACK_MOUSE_MOVE, + e_epplet_mouse_move_cb, epp); + + ebits_set_classed_bit_callback (epp->bits, "Resize", + CALLBACK_MOUSE_DOWN, e_epplet_mouse_down_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Resize", CALLBACK_MOUSE_UP, + e_epplet_mouse_up_cb, epp); + ebits_set_classed_bit_callback (epp->bits, "Resize", CALLBACK_MOUSE_MOVE, + e_epplet_mouse_move_cb, epp); + + ebits_set_classed_bit_callback (epp->bits, "Resize_Vertical", + CALLBACK_MOUSE_DOWN, e_epplet_mouse_down_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Resize_Vertical", + CALLBACK_MOUSE_UP, e_epplet_mouse_up_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Resize_Vertical", + CALLBACK_MOUSE_MOVE, e_epplet_mouse_move_cb, + epp); + + ebits_set_classed_bit_callback (epp->bits, "Resize_Horizontal", + CALLBACK_MOUSE_DOWN, e_epplet_mouse_down_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Resize_Horizontal", + CALLBACK_MOUSE_UP, e_epplet_mouse_up_cb, + epp); + ebits_set_classed_bit_callback (epp->bits, "Resize_Horizontal", + CALLBACK_MOUSE_MOVE, e_epplet_mouse_move_cb, + epp); + + + D ("callbacks set\n"); +} + +static void +e_epplet_mouse_down_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) +{ + E_Epplet *epp; + + D_ENTER; + + epp = _data; + + if (!strcmp (_c, "Title_Bar")) + { + epp->state.moving = 1; + epp->offset.x = _x - epp->current.x; + epp->offset.y = _y - epp->current.y; + } + + if (!strcmp (_c, "Resize")) + { + if (_x < epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.left = 1; + epp->offset.x = epp->current.x - _x; + } + if (_x >= epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.right = 1; + epp->offset.x = epp->current.x + epp->current.w - _x; + } + if (_y < epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.up = 1; + epp->offset.y = epp->current.y - _y; + } + if (_y >= epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.down = 1; + epp->offset.y = epp->current.y + epp->current.h - _y; + } + + } + + if (!strcmp (_c, "Resize_Horizontal")) + { + if (_x < epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.left = 1; + epp->offset.x = epp->current.x - _x; + } + else + { + epp->state.resizing.right = 1; + epp->offset.x = epp->current.x + epp->current.w - _x; + } + } + + if (!strcmp (_c, "Resize_Vertical")) + { + if (_y < epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.up = 1; + epp->offset.y = epp->current.y - _y; + } + else + { + epp->state.resizing.down = 1; + epp->offset.y = epp->current.y + epp->current.h - _y; + } + } + + D_RETURN; +} + + + +static void +e_epplet_mouse_up_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) +{ + E_Epplet *epp; + + D_ENTER; + + epp = _data; + + if (!strcmp (_c, "Title_Bar")) + { + epp->state.moving = 0; + } + + if (!strncmp (_c, "Resize", 6)) + { + epp->state.resizing.up = 0; + epp->state.resizing.down = 0; + epp->state.resizing.left = 0; + epp->state.resizing.right = 0; + } + D_RETURN; +} + +static void +e_epplet_mouse_move_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) +{ + E_Epplet *epp; + double x, y; + + D_ENTER; + + epp = _data; + + if (epp->state.moving) + { + x = _x - epp->offset.x; + y = _y - epp->offset.y; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + if (x > epp->view->size.w - epp->current.w) + x = epp->view->size.w - epp->current.w; + if (y > epp->view->size.h - epp->current.h) + y = epp->view->size.h - epp->current.h; + epp->current.x = x; + epp->current.y = y; + + ebits_move (epp->bits, epp->current.x, epp->current.y); + } + + if (epp->state.resizing.left || epp->state.resizing.right + || epp->state.resizing.up || epp->state.resizing.down) + { + int w, h, x, y; + int mw, mh; + + if (epp->state.resizing.left) + { + w = epp->current.x + epp->current.w - _x - epp->offset.x; + x = _x + epp->offset.x; + } + else if (epp->state.resizing.right) + { + w = _x - epp->current.x + epp->offset.x; + x = epp->current.x; + } + else + { + w = epp->current.w; + x = epp->current.x; + } + + if (epp->state.resizing.up) + { + h = epp->current.h + epp->current.y - _y - epp->offset.y; + y = _y + epp->offset.y; + } + + else if (epp->state.resizing.down) + { + h = _y - epp->current.y + epp->offset.y; + y = epp->current.y; + } + else + { + h = epp->current.h; + y = epp->current.y; + } + + ebits_get_max_size (epp->bits, &mw, &mh); + if (w >= mw) + { + w = mw; + x = epp->current.x; + } + if (h >= mh) + { + h = mh; + y = epp->current.y; + } + + ebits_get_min_size (epp->bits, &mw, &mh); + if (w < mw) + { + w = mw; + x = epp->current.x; + } + if (h < mh) + { + h = mh; + y = epp->current.y; + } + + epp->current.x = x; + epp->current.y = y; + epp->current.w = w; + epp->current.h = h; + + ebits_resize (epp->bits, epp->current.w, epp->current.h); + ebits_move (epp->bits, epp->current.x, epp->current.y); + + } + + D_RETURN; +} + + +E_Epplet_CB_Info * +e_epplet_cb_new( FeriteScript *script, char *func_name, FeriteObject *data, FeriteObject *data2 ) +{ + E_Epplet_CB_Info *cb; + FeriteNamespaceBucket *nsb; + + D_ENTER; + + cb = NEW(E_Epplet_CB_Info, 1); + ZERO(cb, E_Epplet_CB_Info, 1); + + if (data && data2) + { D("d1: %s, d2: %s\n", data->name, data2->name);} + + nsb = __ferite_find_namespace( script, script->mainns, func_name, FENS_FNC); + if (nsb != NULL) + { + D("setting cb info\n"); + cb->func = nsb->data; + if (data) + { + cb->data = data; + data->refcount++; +/* cb->data = fmalloc(sizeof(FeriteObject)); + memset(cb->data, 0, sizeof(FeriteObject)); + + cb->data->name = data->name; + cb->data->oid = data->oid; + cb->data->odata = data->odata; + cb->data->refcount = data->refcount; + cb->data-> = data->; + cb->data-> = data->; + cb->data-> = data->; + cb->data-> = data->; + cb->data-> = data->; + cb->data-> = data->; +*/ + } + if (data2) + { + cb->data2 = data2; + data2->refcount++; + } + cb->script = script; + D("cb info set\n"); + } + + D_RETURN_(cb); +} + +void +e_epplet_bits_cb (void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) +{ + E_Epplet_CB_Info *cb; + FeriteVariable **params; + + D_ENTER; + + cb = _data; + + if (cb->script) { + D("creating params and calling func\n"); + params = __ferite_create_parameter_list_from_data( cb->script, "osnnnnnnn", + cb->data, _c, _b, _x, _y, _ox, _oy, _ow, _oh ); + __ferite_variable_destroy( cb->script, __ferite_call_function( cb->script, cb->func, params)); + __ferite_delete_parameter_list( cb->script, params ); + D("func called, params deleted\n"); + } + else + { + D("ERROR: script does not exist\n"); + } + D_RETURN; +} + +void +e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o, + int _b, int _x, int _y) + +{ + E_Epplet_CB_Info *cb; + FeriteVariable **params; + + D_ENTER; + + cb = _data; + + D("d1: %s, d2: %s\n", cb->data->name, cb->data2->name); + + if (cb->script) { + D("creating params\n"); + params = __ferite_create_parameter_list_from_data( cb->script, "oonnn", + cb->data, cb->data2, (double)_b, (double)_x, (double)_y ); + D("calling func\n"); + __ferite_variable_destroy( cb->script, __ferite_call_function( cb->script, cb->func, params)); + __ferite_delete_parameter_list( cb->script, params ); + D("func called, params deleted\n"); + } + else + { + D("ERROR: script does not exist\n"); + } + D_RETURN; +} + diff --git a/src/epplet.h b/src/epplet.h new file mode 100644 index 000000000..08a86a5a7 --- /dev/null +++ b/src/epplet.h @@ -0,0 +1,81 @@ +#ifndef E_EPPLET_H +#define E_EPPLET_H + +#include "e.h" +#include "view.h" +#include "e_ferite.h" + +typedef struct _E_Epplet E_Epplet; +typedef struct _E_Epplet_Context E_Epplet_Context; +typedef struct _E_Epplet_CB_Info E_Epplet_CB_Info; +typedef struct _Evas_Object_Wrapper Evas_Object_Wrapper; + + +struct _E_Epplet_CB_Info +{ + FeriteScript *script; + FeriteFunction *func; + FeriteObject *data; + FeriteObject *data2; +}; + + +struct _E_Epplet_Context +{ + char *name; + E_View *view; + FeriteScript *script; + + struct { + double x, y; + double w, h; + } geom; +}; + + +struct _E_Epplet +{ + E_Object o; + + E_Epplet_Context *context; + + char *name; + E_View *view; + Ebits_Object bits; + + FeriteVariable *fbits; + + struct { + double x, y; + double w, h; + } current, requested, offset; + + struct { + int changed; + int moving; + struct { + int up, down, left, right; + }resizing; + } state; + + void *data; + +}; + +struct _Evas_Object_Wrapper +{ + Evas evas; + Evas_Object obj; +}; + +void e_epplet_load_from_layout(E_View *v); +E_Epplet_Context *e_epplet_get_context_from_script(FeriteScript *script); +void e_epplet_script_load(E_Epplet_Context *v, char *script_path); +void e_epplet_set_common_callbacks(E_Epplet *epp); +E_Epplet_CB_Info *e_epplet_cb_new( FeriteScript *script, char *func_name, FeriteObject *data, FeriteObject *data2 ); +void e_epplet_bits_cb (void *_data, Ebits_Object _o, char *_c, + int _b, int _x, int _y, int _ox, int _oy, int _ow, int _oh); +void e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); + + +#endif diff --git a/src/view.c b/src/view.c index 4f5348547..c6393be38 100644 --- a/src/view.c +++ b/src/view.c @@ -12,6 +12,7 @@ #include "util.h" #include "globals.h" #include "icons.h" +#include "epplet.h" static Ecore_Event *current_ev = NULL; @@ -2009,6 +2010,7 @@ e_view_realize(E_View *v) e_iconbar_set_view_window_spacing(v->iconbar); } + e_epplet_load_from_layout(v); v->changed = 1; D_RETURN; diff --git a/src/view.h b/src/view.h index 161564f62..73ffb3b00 100644 --- a/src/view.h +++ b/src/view.h @@ -165,6 +165,9 @@ struct _E_View int changed; E_Iconbar *iconbar; + + Evas_List epplet_contexts; + Ebits_Object epplet_layout; };