forked from enlightenment/enlightenment
Epplets run from ~/.e/desktop/default/.e_epplets/eppletName/eppletName.fe
(copy em manually for now) Get epplets to keep track of the ebits / evas objects they create, so they can be cleaned up later. Also, some small epplet API changes. When creating Ebits / EvasObjects, pass a path relative to the .fe file rather than the full path. Usually, you just need a file name, which should be in the same dir as the epplet. if a file named layout.bits.db exists in an epplet's dir, it is used for the default layout (location) of that epplet rather than whatever is in ~/.e/desktop/default/.e_epplets.bits.db. Only use this if a specific size/location of the epplet is necessary. (just create one dummy image in the bits with the name of the epplet, and its location/size relative to the entire view) Note, try to not use this, as user customizability is important... I will eventually make it so that if a ui.bits.db exists, it will automatically be loaded as the main bits file, and set as epplet.bits in the script. (Can't get object creation from within a .fec to work correctly yet...) This would remove the need for the setBits() call. SVN revision: 5881
This commit is contained in:
parent
195f2407e9
commit
38ac2443ca
212
src/e_ferite.fec
212
src/e_ferite.fec
|
@ -2,6 +2,7 @@ header %{
|
||||||
|
|
||||||
#include "Ecore.h"
|
#include "Ecore.h"
|
||||||
#include "Ebits.h"
|
#include "Ebits.h"
|
||||||
|
#include "ferite.h"
|
||||||
|
|
||||||
#include "desktops.h"
|
#include "desktops.h"
|
||||||
#include "border.h"
|
#include "border.h"
|
||||||
|
@ -9,11 +10,13 @@ header %{
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "observer.h"
|
#include "observer.h"
|
||||||
|
#include "file.h"
|
||||||
|
|
||||||
#define BorderObj ((E_Border *)(self->odata))
|
#define BorderObj ((E_Border *)(self->odata))
|
||||||
#define BitsObj ((Ebits_Object)self->odata)
|
#define BitsObj ((Ebits_Object)self->odata)
|
||||||
#define EppObj ((E_Epplet *)(self->odata))
|
#define EppObj ((E_Epplet *)(self->odata))
|
||||||
#define EvasObj ((Evas_Object_Wrapper *)(self->odata))
|
#define EvasObj ((Evas_Object_Wrapper *)(self->odata))
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
class Border {
|
class Border {
|
||||||
|
@ -148,6 +151,11 @@ namespace e {
|
||||||
ecore_event_loop_quit();
|
ecore_event_loop_quit();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
function restart()
|
||||||
|
%{
|
||||||
|
e_exec_restart();
|
||||||
|
%}
|
||||||
|
|
||||||
function dataCopy(object from, object to)
|
function dataCopy(object from, object to)
|
||||||
%{
|
%{
|
||||||
to->odata = from->odata;
|
to->odata = from->odata;
|
||||||
|
@ -172,18 +180,27 @@ class EvasObject
|
||||||
EvasObj = NEW(Evas_Object_Wrapper, 1);
|
EvasObj = NEW(Evas_Object_Wrapper, 1);
|
||||||
ZERO(EvasObj, Evas_Object_Wrapper, 1);
|
ZERO(EvasObj, Evas_Object_Wrapper, 1);
|
||||||
|
|
||||||
EvasObj->evas = ((E_Epplet *)(epp->odata))->view->evas;
|
EvasObj->epp = (E_Epplet *)(epp->odata);
|
||||||
|
EvasObj->evas = EvasObj->epp->view->evas;
|
||||||
|
|
||||||
|
EvasObj->epp->evas_objects = evas_list_append(EvasObj->epp->evas_objects, EvasObj);
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Destructor()
|
function Destructor()
|
||||||
%{
|
%{
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function addImage(string path)
|
function addImage(string file)
|
||||||
%{
|
%{
|
||||||
if (EvasObj->evas)
|
char buf[PATH_MAX];
|
||||||
EvasObj->obj = evas_add_image_from_file(EvasObj->evas, path);
|
|
||||||
ffree(path);
|
if (EvasObj->evas && EvasObj->epp)
|
||||||
|
{
|
||||||
|
snprintf(buf, PATH_MAX, "%s%s", EvasObj->epp->view->dir, file);
|
||||||
|
EvasObj->obj = evas_add_image_from_file(EvasObj->evas, file);
|
||||||
|
}
|
||||||
|
ffree(file);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function addRectangle()
|
function addRectangle()
|
||||||
|
@ -255,10 +272,8 @@ class EvasObject
|
||||||
|
|
||||||
function setColor(number r, number g, number b, number a)
|
function setColor(number r, number g, number b, number a)
|
||||||
%{
|
%{
|
||||||
D("in setColor\n");
|
|
||||||
if (EvasObj->evas && EvasObj->obj)
|
if (EvasObj->evas && EvasObj->obj)
|
||||||
evas_set_color(EvasObj->evas, EvasObj->obj, (long)r, (long)g, (long)b, (long)a);
|
evas_set_color(EvasObj->evas, EvasObj->obj, (long)r, (long)g, (long)b, (long)a);
|
||||||
D("leaving setColor\n");
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
@ -351,18 +366,23 @@ class EvasObject
|
||||||
class Ebits
|
class Ebits
|
||||||
{
|
{
|
||||||
|
|
||||||
function Ebits(string path)
|
function Ebits(string file, object epp)
|
||||||
%{
|
%{
|
||||||
D("in Ebits constructor\n");
|
char buf[PATH_MAX];
|
||||||
D("loading bits\n");
|
|
||||||
|
snprintf(buf, PATH_MAX, "%s/.e_epplets/%s/%s", ((E_Epplet *)(epp->odata))->view->dir, ((E_Epplet *)(epp->odata))->name, file);
|
||||||
|
D("adding ebits: %s\n", buf);
|
||||||
BitsObj = NULL;
|
BitsObj = NULL;
|
||||||
BitsObj = ebits_load(path);
|
BitsObj = ebits_load(buf);
|
||||||
if (BitsObj)
|
|
||||||
printf("bits loaded\n");
|
|
||||||
else
|
|
||||||
printf("ERROR: bits not found\n");
|
|
||||||
|
|
||||||
ffree(path);
|
((E_Epplet *)(epp->odata))->ebits = evas_list_append(((E_Epplet *)(epp->odata))->ebits, BitsObj);
|
||||||
|
/*
|
||||||
|
if (BitsObj)
|
||||||
|
D("bits loaded\n");
|
||||||
|
else
|
||||||
|
D("ERROR: bits not found\n");
|
||||||
|
*/
|
||||||
|
ffree(file);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function Destructor()
|
function Destructor()
|
||||||
|
@ -377,51 +397,60 @@ class Ebits
|
||||||
|
|
||||||
function free()
|
function free()
|
||||||
%{
|
%{
|
||||||
ebits_free(BitsObj);
|
if(BitsObj)
|
||||||
|
ebits_free(BitsObj);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function show()
|
function show()
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_show(BitsObj);
|
ebits_show(BitsObj);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function hide()
|
function hide()
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_hide(BitsObj);
|
ebits_hide(BitsObj);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function raise()
|
function raise()
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_raise(BitsObj);
|
ebits_raise(BitsObj);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function lower()
|
function lower()
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_lower(BitsObj);
|
ebits_lower(BitsObj);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function move(number x, number y)
|
function move(number x, number y)
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_move(BitsObj, x, y);
|
ebits_move(BitsObj, x, y);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function resize(number w, number h)
|
function resize(number w, number h)
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_resize(BitsObj, w, h);
|
ebits_resize(BitsObj, w, h);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function setLayer(number l)
|
function setLayer(number l)
|
||||||
%{
|
%{
|
||||||
|
if(BitsObj)
|
||||||
ebits_set_layer(BitsObj, l);
|
ebits_set_layer(BitsObj, l);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function setState(string bitName, string state)
|
function setState(string bitName, string state)
|
||||||
%{
|
%{
|
||||||
ebits_set_named_bit_state(BitsObj, bitName, state);
|
if(BitsObj)
|
||||||
|
ebits_set_named_bit_state(BitsObj, bitName, state);
|
||||||
ffree(bitName);
|
ffree(bitName);
|
||||||
ffree(state);
|
ffree(state);
|
||||||
%}
|
%}
|
||||||
|
/*
|
||||||
function getNamedBitGeometry(string bitName, number x, number y, number w, number h)
|
function getNamedBitGeometry(string bitName, number x, number y, number w, number h)
|
||||||
%{
|
%{
|
||||||
double xx, yy, ww, hh;
|
double xx, yy, ww, hh;
|
||||||
|
@ -432,12 +461,13 @@ class Ebits
|
||||||
w = ww;
|
w = ww;
|
||||||
h = hh;
|
h = hh;
|
||||||
%}
|
%}
|
||||||
|
*/
|
||||||
|
|
||||||
function getNamedBitGeometryX(string bitName)
|
function getNamedBitGeometryX(string bitName)
|
||||||
%{
|
%{
|
||||||
double x;
|
double x;
|
||||||
ebits_get_named_bit_geometry(BitsObj, bitName, &x, NULL, NULL, NULL);
|
if(BitsObj)
|
||||||
D("%s.x: %i\n", bitName, x);
|
ebits_get_named_bit_geometry(BitsObj, bitName, &x, NULL, NULL, NULL);
|
||||||
ffree(bitName);
|
ffree(bitName);
|
||||||
FE_RETURN_DOUBLE(x);
|
FE_RETURN_DOUBLE(x);
|
||||||
%}
|
%}
|
||||||
|
@ -445,7 +475,8 @@ class Ebits
|
||||||
function getNamedBitGeometryY(string bitName)
|
function getNamedBitGeometryY(string bitName)
|
||||||
%{
|
%{
|
||||||
double y;
|
double y;
|
||||||
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, &y, NULL, NULL);
|
if(BitsObj)
|
||||||
|
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, &y, NULL, NULL);
|
||||||
ffree(bitName);
|
ffree(bitName);
|
||||||
FE_RETURN_DOUBLE(y);
|
FE_RETURN_DOUBLE(y);
|
||||||
%}
|
%}
|
||||||
|
@ -453,7 +484,8 @@ class Ebits
|
||||||
function getNamedBitGeometryW(string bitName)
|
function getNamedBitGeometryW(string bitName)
|
||||||
%{
|
%{
|
||||||
double w;
|
double w;
|
||||||
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, &w, NULL);
|
if(BitsObj)
|
||||||
|
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, &w, NULL);
|
||||||
ffree(bitName);
|
ffree(bitName);
|
||||||
FE_RETURN_DOUBLE(w);
|
FE_RETURN_DOUBLE(w);
|
||||||
%}
|
%}
|
||||||
|
@ -461,7 +493,8 @@ class Ebits
|
||||||
function getNamedBitGeometryH(string bitName)
|
function getNamedBitGeometryH(string bitName)
|
||||||
%{
|
%{
|
||||||
double h;
|
double h;
|
||||||
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, NULL, &h);
|
if(BitsObj)
|
||||||
|
ebits_get_named_bit_geometry(BitsObj, bitName, NULL, NULL, NULL, &h);
|
||||||
ffree(bitName);
|
ffree(bitName);
|
||||||
FE_RETURN_DOUBLE(h);
|
FE_RETURN_DOUBLE(h);
|
||||||
%}
|
%}
|
||||||
|
@ -472,7 +505,9 @@ class Ebits
|
||||||
|
|
||||||
cb = e_epplet_cb_new(script, func, data, NULL);
|
cb = e_epplet_cb_new(script, func, data, NULL);
|
||||||
|
|
||||||
ebits_set_classed_bit_callback(BitsObj, bitClass, CALLBACK_MOUSE_DOWN, e_epplet_bits_cb, cb);
|
if(BitsObj)
|
||||||
|
ebits_set_classed_bit_callback(BitsObj, bitClass, CALLBACK_MOUSE_DOWN,
|
||||||
|
e_epplet_bits_cb, cb);
|
||||||
|
|
||||||
ffree(bitClass);
|
ffree(bitClass);
|
||||||
ffree(func);
|
ffree(func);
|
||||||
|
@ -482,33 +517,62 @@ class Ebits
|
||||||
class Epplet
|
class Epplet
|
||||||
{
|
{
|
||||||
|
|
||||||
object bits;
|
object ui;
|
||||||
|
|
||||||
function Epplet()
|
function Epplet()
|
||||||
%{
|
%{
|
||||||
EppObj = malloc(sizeof(E_Epplet));
|
char buf[PATH_MAX];
|
||||||
memset(EppObj, 0, sizeof(E_Epplet));
|
/* FeriteVariable *ui;
|
||||||
|
FeriteVariable **params;*/
|
||||||
|
|
||||||
EppObj->context = e_epplet_get_context_from_script(script);
|
EppObj = e_epplet_new(script);
|
||||||
EppObj->view = EppObj->context->view;
|
#if 0
|
||||||
EppObj->name = strdup(EppObj->context->name);
|
/* FIXME: this is not complete, object creation doesn't work for some reason??? */
|
||||||
EppObj->current.x = EppObj->context->geom.x;
|
D("epplet created\n");
|
||||||
EppObj->current.y = EppObj->context->geom.y;
|
/* if ui.bits.db exists, make it the ui */
|
||||||
EppObj->current.w = EppObj->context->geom.w;
|
snprintf(buf, PATH_MAX, "%sui.bits.db", EppObj->dir);
|
||||||
EppObj->current.h = EppObj->context->geom.h;
|
if (e_file_exists(buf))
|
||||||
|
{
|
||||||
|
EppObj->ui = ebits_load(buf);
|
||||||
|
ebits_add_to_evas(EppObj->ui, EppObj->view->evas);
|
||||||
|
|
||||||
|
/* ui = __ferite_get_variable_from_hash(script, self->variables, "ui");*/
|
||||||
|
params = __ferite_create_parameter_list_from_data(script, "so", "ui.bits.db", self);
|
||||||
|
ui = __ferite_new_object( script, __ferite_find_class(script, script->mainns, "Ebits"), params );
|
||||||
|
__ferite_delete_parameter_list(script, params);
|
||||||
|
D("object created, name: %s\n", ui->name);
|
||||||
|
|
||||||
if (!EppObj->view) { D("Error: no view found for script\n"); }
|
/*FIXME: how do i set an object's data?*/
|
||||||
else { D("got view: %s\n", EppObj->view->dir); }
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* if layout.bits.db exists, make it the layout */
|
||||||
|
snprintf(buf, PATH_MAX, "%slayout.bits.db", EppObj->dir);
|
||||||
|
if (e_file_exists(buf))
|
||||||
|
{
|
||||||
|
double x, y, w, h;
|
||||||
|
|
||||||
|
EppObj->layout = ebits_load(buf);
|
||||||
|
ebits_add_to_evas(EppObj->layout, EppObj->view->evas);
|
||||||
|
ebits_move(EppObj->layout, 0, 0);
|
||||||
|
ebits_resize(EppObj->layout, EppObj->view->size.w, EppObj->view->size.h);
|
||||||
|
ebits_get_named_bit_geometry(EppObj->layout, EppObj->name,
|
||||||
|
&x, &y, &w, &h);
|
||||||
|
|
||||||
|
EppObj->current.x = x;
|
||||||
|
EppObj->current.y = y;
|
||||||
|
EppObj->current.w = w;
|
||||||
|
EppObj->current.h = h;
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function setBits(object ebits)
|
function setBits(object ebits)
|
||||||
%{
|
%{
|
||||||
EppObj->bits = ((Ebits_Object)ebits->odata);
|
EppObj->ui = ((Ebits_Object)ebits->odata);
|
||||||
EppObj->fbits = ebits;
|
|
||||||
|
|
||||||
if(EppObj->bits && EppObj->view)
|
if(EppObj->ui && EppObj->view)
|
||||||
{
|
{
|
||||||
ebits_add_to_evas(EppObj->bits, EppObj->view->evas);
|
ebits_add_to_evas(EppObj->ui, EppObj->view->evas);
|
||||||
e_epplet_set_common_callbacks(EppObj);
|
e_epplet_set_common_callbacks(EppObj);
|
||||||
D("bits added to view\n");
|
D("bits added to view\n");
|
||||||
D("view dir: %s\n", EppObj->view->dir);
|
D("view dir: %s\n", EppObj->view->dir);
|
||||||
|
@ -528,16 +592,16 @@ class Epplet
|
||||||
|
|
||||||
D("moving epplet: %f, %f\n", x, y);
|
D("moving epplet: %f, %f\n", x, y);
|
||||||
|
|
||||||
if (EppObj->bits)
|
if (EppObj->ui)
|
||||||
ebits_move(EppObj->bits, EppObj->current.x, EppObj->current.y);
|
ebits_move(EppObj->ui, EppObj->current.x, EppObj->current.y);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function resize(number w, number h)
|
function resize(number w, number h)
|
||||||
%{
|
%{
|
||||||
EppObj->current.w = w;
|
EppObj->current.w = w;
|
||||||
EppObj->current.h = h;
|
EppObj->current.h = h;
|
||||||
if (EppObj->bits)
|
if (EppObj->ui)
|
||||||
ebits_resize(EppObj->bits, EppObj->current.w, EppObj->current.h);
|
ebits_resize(EppObj->ui, EppObj->current.w, EppObj->current.h);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
function getX()
|
function getX()
|
||||||
|
@ -563,54 +627,36 @@ class Epplet
|
||||||
function display()
|
function display()
|
||||||
%{
|
%{
|
||||||
int mw, mh;
|
int mw, mh;
|
||||||
|
D("in display()\n");
|
||||||
if(EppObj->view && EppObj->bits)
|
if(EppObj->view && EppObj->ui)
|
||||||
{
|
{
|
||||||
D("adding bits for epplet `%s'\n", EppObj->context->name);
|
ebits_show(EppObj->ui);
|
||||||
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_show(EppObj->bits);
|
|
||||||
|
|
||||||
if ((EppObj->context->geom.w) && (EppObj->context->geom.h))
|
ebits_get_min_size(EppObj->ui, &mw, &mh);
|
||||||
{
|
if ( EppObj->current.w < mw ) EppObj->current.w = mw;
|
||||||
EppObj->current.w = EppObj->context->geom.w;
|
if ( EppObj->current.h < mh ) EppObj->current.h = mh;
|
||||||
EppObj->current.h = EppObj->context->geom.h;
|
|
||||||
|
|
||||||
ebits_get_min_size(EppObj->bits, &mw, &mh);
|
ebits_get_max_size(EppObj->ui, &mw, &mh);
|
||||||
if ( EppObj->current.w < mw ) EppObj->current.w = mw;
|
if ( EppObj->current.w > mw ) EppObj->current.w = mw;
|
||||||
if ( EppObj->current.h < mh ) EppObj->current.h = mh;
|
if ( EppObj->current.h > mh ) EppObj->current.h = mh;
|
||||||
}
|
|
||||||
|
if (EppObj->current.x > (EppObj->view->size.w - EppObj->current.w))
|
||||||
|
EppObj->current.x = EppObj->view->size.w - EppObj->current.w;
|
||||||
|
if (EppObj->current.y > (EppObj->view->size.h - EppObj->current.h))
|
||||||
|
EppObj->current.y = EppObj->view->size.h - EppObj->current.h;
|
||||||
|
|
||||||
else
|
ebits_set_layer(EppObj->ui, 12000);
|
||||||
{
|
ebits_resize(EppObj->ui, EppObj->current.w, EppObj->current.h);
|
||||||
ebits_get_min_size(EppObj->bits, &mw, &mh);
|
ebits_move(EppObj->ui, EppObj->current.x, EppObj->current.y);
|
||||||
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()
|
function getBits()
|
||||||
%{
|
%{
|
||||||
FE_RETURN_VAR(EppObj->fbits);
|
FE_RETURN_VAR(EppObj->fbits);
|
||||||
%}
|
%}
|
||||||
|
*/
|
||||||
|
|
||||||
function getViewW()
|
function getViewW()
|
||||||
%{
|
%{
|
||||||
|
@ -627,7 +673,7 @@ class Epplet
|
||||||
char buf[PATH_MAX], *retval;
|
char buf[PATH_MAX], *retval;
|
||||||
|
|
||||||
printf("getting dir:\n");
|
printf("getting dir:\n");
|
||||||
snprintf(buf, PATH_MAX, "%s%s/", e_config_get("epplets"), EppObj->name);
|
snprintf(buf, PATH_MAX, "%s/.e_epplets/%s/", EppObj->view->dir, EppObj->name);
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
retval = (char *)buf;
|
retval = (char *)buf;
|
||||||
FE_RETURN_STR(retval, 0);
|
FE_RETURN_STR(retval, 0);
|
||||||
|
|
88
src/epplet.c
88
src/epplet.c
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "e_ferite.h"
|
#include "e_ferite.h"
|
||||||
|
|
||||||
|
static void e_epplet_cleanup(E_Epplet *epp);
|
||||||
static void e_epplet_mouse_down_cb (void *_data, Ebits_Object _o,
|
static void e_epplet_mouse_down_cb (void *_data, Ebits_Object _o,
|
||||||
char *_c, int _b, int _x, int _y,
|
char *_c, int _b, int _x, int _y,
|
||||||
int _ox, int _oy, int _ow, int _oh);
|
int _ox, int _oy, int _ow, int _oh);
|
||||||
|
@ -21,6 +22,83 @@ static void e_epplet_mouse_move_cb (void *_data, Ebits_Object _o,
|
||||||
|
|
||||||
static void e_epplet_observer_cleanup(E_Object *o);
|
static void e_epplet_observer_cleanup(E_Object *o);
|
||||||
|
|
||||||
|
E_Epplet *
|
||||||
|
e_epplet_new(void *scr)
|
||||||
|
{
|
||||||
|
#ifdef USE_FERITE
|
||||||
|
E_Epplet *epp;
|
||||||
|
FeriteScript *script;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
D_ENTER;
|
||||||
|
|
||||||
|
script = (FeriteScript *)scr;
|
||||||
|
|
||||||
|
epp = NEW(E_Epplet, 1);
|
||||||
|
ZERO(epp, E_Epplet, 1);
|
||||||
|
|
||||||
|
e_object_init(E_OBJECT(epp), (E_Cleanup_Func) e_epplet_cleanup);
|
||||||
|
|
||||||
|
epp->context = e_epplet_get_context_from_script(script);
|
||||||
|
if (!(epp->context))
|
||||||
|
{
|
||||||
|
D("Error: epplet context not found\n");
|
||||||
|
D_RETURN_(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
epp->view = epp->context->view;
|
||||||
|
epp->name = strdup(epp->context->name);
|
||||||
|
epp->current.x = epp->context->geom.x;
|
||||||
|
epp->current.y = epp->context->geom.y;
|
||||||
|
epp->current.w = epp->context->geom.w;
|
||||||
|
epp->current.h = epp->context->geom.h;
|
||||||
|
epp->context->epp = epp;
|
||||||
|
|
||||||
|
snprintf(buf, PATH_MAX, "%s/.e_epplets/%s/", epp->view->dir, epp->name);
|
||||||
|
epp->dir = strdup(buf);
|
||||||
|
|
||||||
|
if (!(epp->view))
|
||||||
|
{
|
||||||
|
D("Error: no view found for epplet: %s\n", epp->name);
|
||||||
|
e_object_unref(E_OBJECT(epp));
|
||||||
|
D_RETURN_(NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
D_RETURN_(epp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
e_epplet_cleanup(E_Epplet *epp)
|
||||||
|
{
|
||||||
|
Evas_List l;
|
||||||
|
|
||||||
|
D_ENTER;
|
||||||
|
|
||||||
|
#ifdef USE_FERITE
|
||||||
|
for (l = epp->ebits; l; l = l->next)
|
||||||
|
{
|
||||||
|
Ebits_Object o = l->data;
|
||||||
|
ebits_free(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (l = epp->evas_objects; l; l = l->next)
|
||||||
|
{
|
||||||
|
Evas_Object_Wrapper *o = l->data;
|
||||||
|
evas_del_object(o->evas, o->obj);
|
||||||
|
|
||||||
|
free(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (epp->layout) ebits_free(epp->layout);
|
||||||
|
if (epp->ui) ebits_free(epp->ui);
|
||||||
|
#endif
|
||||||
|
D_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
e_epplet_load_from_layout (E_View * v)
|
e_epplet_load_from_layout (E_View * v)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +141,7 @@ e_epplet_load_from_layout (E_View * v)
|
||||||
|
|
||||||
v->epplet_contexts = evas_list_append (v->epplet_contexts, context);
|
v->epplet_contexts = evas_list_append (v->epplet_contexts, context);
|
||||||
|
|
||||||
snprintf (buf, PATH_MAX, "%s%s/%s.fe", e_config_get ("epplets"), context->name,
|
snprintf (buf, PATH_MAX, "%s/.e_epplets/%s/%s.fe", v->dir, context->name,
|
||||||
context->name);
|
context->name);
|
||||||
if (e_file_exists (buf))
|
if (e_file_exists (buf))
|
||||||
e_epplet_script_load (context, buf);
|
e_epplet_script_load (context, buf);
|
||||||
|
@ -141,9 +219,11 @@ e_epplet_script_load (E_Epplet_Context * context, char *path)
|
||||||
D_RETURN;
|
D_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
e_epplet_set_common_callbacks (E_Epplet * epp)
|
e_epplet_set_common_callbacks (E_Epplet * epp)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
D ("setting callbacks\n");
|
D ("setting callbacks\n");
|
||||||
|
|
||||||
#ifdef USE_FERITE
|
#ifdef USE_FERITE
|
||||||
|
@ -193,6 +273,7 @@ e_epplet_set_common_callbacks (E_Epplet * epp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D ("callbacks set\n");
|
D ("callbacks set\n");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -312,7 +393,7 @@ e_epplet_mouse_move_cb (void *_data, Ebits_Object _o,
|
||||||
D_ENTER;
|
D_ENTER;
|
||||||
|
|
||||||
#ifdef USE_FERITE
|
#ifdef USE_FERITE
|
||||||
epp = _data;
|
/* epp = _data;
|
||||||
|
|
||||||
if (epp->state.moving)
|
if (epp->state.moving)
|
||||||
{
|
{
|
||||||
|
@ -329,7 +410,7 @@ e_epplet_mouse_move_cb (void *_data, Ebits_Object _o,
|
||||||
epp->current.x = x;
|
epp->current.x = x;
|
||||||
epp->current.y = y;
|
epp->current.y = y;
|
||||||
|
|
||||||
ebits_move (epp->bits, epp->current.x, epp->current.y);
|
ebits_move (epp->ui, epp->current.x, epp->current.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epp->state.resizing.left || epp->state.resizing.right
|
if (epp->state.resizing.left || epp->state.resizing.right
|
||||||
|
@ -404,6 +485,7 @@ e_epplet_mouse_move_cb (void *_data, Ebits_Object _o,
|
||||||
ebits_move (epp->bits, epp->current.x, epp->current.y);
|
ebits_move (epp->bits, epp->current.x, epp->current.y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
D_RETURN;
|
D_RETURN;
|
||||||
|
|
80
src/epplet.h
80
src/epplet.h
|
@ -35,6 +35,8 @@ struct _E_Epplet_Context
|
||||||
E_View *view;
|
E_View *view;
|
||||||
FeriteScript *script;
|
FeriteScript *script;
|
||||||
|
|
||||||
|
E_Epplet *epp;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
double x, y;
|
double x, y;
|
||||||
double w, h;
|
double w, h;
|
||||||
|
@ -44,55 +46,71 @@ struct _E_Epplet_Context
|
||||||
|
|
||||||
struct _E_Epplet
|
struct _E_Epplet
|
||||||
{
|
{
|
||||||
E_Object o;
|
E_Object o;
|
||||||
|
|
||||||
E_Epplet_Context *context;
|
E_Epplet_Context *context;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
E_View *view;
|
E_View *view;
|
||||||
Ebits_Object bits;
|
char *dir;
|
||||||
|
Ebits_Object layout;
|
||||||
|
Ebits_Object ui;
|
||||||
|
|
||||||
FeriteVariable *fbits;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
double x, y;
|
double x, y;
|
||||||
double w, h;
|
double w, h;
|
||||||
} current, requested, offset;
|
} current, requested, offset;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
int changed;
|
int changed;
|
||||||
int moving;
|
int moving;
|
||||||
struct {
|
struct {
|
||||||
int up, down, left, right;
|
int up, down, left, right;
|
||||||
}resizing;
|
}resizing;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
void *data;
|
|
||||||
|
|
||||||
|
Evas_List evas_objects;
|
||||||
|
Evas_List ebits;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Evas_Object_Wrapper
|
struct _Evas_Object_Wrapper
|
||||||
{
|
{
|
||||||
Evas evas;
|
Evas evas;
|
||||||
Evas_Object obj;
|
Evas_Object obj;
|
||||||
|
E_Epplet *epp;
|
||||||
};
|
};
|
||||||
|
|
||||||
void e_epplet_load_from_layout(E_View *v);
|
/* epplet loading / cleanup */
|
||||||
|
E_Epplet *e_epplet_new();
|
||||||
|
void e_epplet_load_from_layout(E_View *v);
|
||||||
|
void e_epplet_script_load(E_Epplet_Context *v, char *script_path);
|
||||||
E_Epplet_Context *e_epplet_get_context_from_script(FeriteScript *script);
|
E_Epplet_Context *e_epplet_get_context_from_script(FeriteScript *script);
|
||||||
void e_epplet_script_load(E_Epplet_Context *v, char *script_path);
|
|
||||||
|
/* probably won't use this... */
|
||||||
void e_epplet_set_common_callbacks(E_Epplet *epp);
|
void e_epplet_set_common_callbacks(E_Epplet *epp);
|
||||||
|
|
||||||
|
|
||||||
|
/* callbacks */
|
||||||
E_Epplet_CB_Info *e_epplet_cb_new( FeriteScript *script, char *func_name,
|
E_Epplet_CB_Info *e_epplet_cb_new( FeriteScript *script, char *func_name,
|
||||||
FeriteObject *data, FeriteObject *data2 );
|
FeriteObject *data, FeriteObject *data2 );
|
||||||
void e_epplet_cb_cleanup( E_Epplet_CB_Info *cb);
|
void e_epplet_cb_cleanup( E_Epplet_CB_Info *cb);
|
||||||
void e_epplet_bits_cb (void *_data, Ebits_Object _o, char *_c,
|
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);
|
int _b, int _x, int _y, int _ox, int _oy,
|
||||||
void e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o,
|
int _ow, int _oh);
|
||||||
int _b, int _x, int _y);
|
void e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o,
|
||||||
void e_epplet_timer_func(int val, void *data);
|
int _b, int _x, int _y);
|
||||||
|
/* timers */
|
||||||
|
void e_epplet_timer_func(int val, void *data);
|
||||||
|
|
||||||
|
/* Observers */
|
||||||
E_Epplet_Observer *e_epplet_observer_new( FeriteScript *script,
|
E_Epplet_Observer *e_epplet_observer_new( FeriteScript *script,
|
||||||
char *func_name, FeriteObject *data, char *event_type);
|
char *func_name, FeriteObject *data,
|
||||||
void e_epplet_observer_register_desktops(E_Epplet_Observer *obs);
|
char *event_type);
|
||||||
void e_epplet_desktop_observer_func(E_Observer *observer, E_Observee *observee, E_Event_Type event);
|
void e_epplet_observer_register_desktops(E_Epplet_Observer *obs);
|
||||||
|
void e_epplet_desktop_observer_func(E_Observer *observer,
|
||||||
|
E_Observee *observee,
|
||||||
|
E_Event_Type event);
|
||||||
/*void e_epplet_border_observer_func(E_Observer *observer, E_Observee *observee);*/
|
/*void e_epplet_border_observer_func(E_Observer *observer, E_Observee *observee);*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -564,12 +564,9 @@ static void
|
||||||
e_menu_item_unselect (E_Menu_Item *mi)
|
e_menu_item_unselect (E_Menu_Item *mi)
|
||||||
{
|
{
|
||||||
D_ENTER;
|
D_ENTER;
|
||||||
D("mi unselect\n");
|
|
||||||
if ((mi) && (mi->menu->selected == mi))
|
if ((mi) && (mi->menu->selected == mi))
|
||||||
{
|
{
|
||||||
D("mi && mi->menu->selected == mi\n");
|
|
||||||
mi->menu->selected = curr_selected_item = NULL;
|
mi->menu->selected = curr_selected_item = NULL;
|
||||||
D("after setting it NULL\n");
|
|
||||||
|
|
||||||
mi->selected = 0;
|
mi->selected = 0;
|
||||||
mi->menu->redo_sel = 1;
|
mi->menu->redo_sel = 1;
|
||||||
|
|
Loading…
Reference in New Issue