diff --git a/src/e.h b/src/e.h index 569d097d0..74bf47251 100644 --- a/src/e.h +++ b/src/e.h @@ -23,6 +23,7 @@ #include #include +/* macros for allowing sections of code to be runtime profiled */ #define E_PROF 1 #ifdef E_PROF extern Evas_List __e_profiles; @@ -79,7 +80,7 @@ printf("%3.3f : %s()\n", __p->total, __p->func); \ #define E_PROF_DUMP #endif - +/* object macros */ #define OBJ_REF(_e_obj) _e_obj->references++ #define OBJ_UNREF(_e_obj) _e_obj->references-- #define OBJ_IF_FREE(_e_obj) if (_e_obj->references == 0) @@ -90,7 +91,6 @@ OBJ_IF_FREE(_e_obj) \ { \ OBJ_FREE(_e_obj); \ } - #define OBJ_PROPERTIES \ int references; \ void (*e_obj_free) (void *e_obj); @@ -99,15 +99,8 @@ void (*e_obj_free) (void *e_obj); _e_obj->references = 1; \ _e_obj->e_obj_free = (void *) _e_obj_free_func; \ } -#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \ -((x < (xx + ww)) && \ -(y < (yy + hh)) && \ -((x + w) > xx) && \ -((y + h) > yy)) -#define SPANS_COMMON(x1, w1, x2, w2) \ -(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) -#define UN(_blah) _blah = 0 +/* action type macros */ #define ACT_MOUSE_IN 0 #define ACT_MOUSE_OUT 1 #define ACT_MOUSE_CLICK 2 @@ -119,6 +112,117 @@ _e_obj->e_obj_free = (void *) _e_obj_free_func; \ #define ACT_KEY_DOWN 8 #define ACT_KEY_UP 9 +/* config macros */ +/* something to check validity of config files where we get data from */ +/* for now its just a 5 second timout so it will only invalidate */ +/* if we havent looked for 5 seconds... BUT later when efsd is more solid */ +/* we should use that to tell us when its invalid */ +#define E_CFG_FILE(_var, _src) \ +static E_Config_File _var = {_src, 0.0} +#define E_CONFIG_CHECK_VALIDITY(_var, _src) \ +{ \ +double __time; \ +__time = e_get_time(); \ +if (_var.last_fetch < (__time - 5.0)) { \ +_var.last_fetch = __time; +#define E_CONFIG_CHECK_VALIDITY_END \ +} \ +} +#define E_CFG_INT_T 123 +#define E_CFG_FLOAT_T 1234 +#define E_CFG_STR_T 12345 +#define E_CFG_DATA_T 123456 +#define E_CFG_INT(_var, _src, _key, _default) \ +static E_Config_Element _var = { _src, _key, 0.0, E_CFG_INT_T, \ +_default, 0.0, NULL, NULL, 0, \ +0, 0.0, NULL, NULL, 0, \ +} +#define E_CFG_FLOAT(_var, _src, _key, _default) \ +static E_Config_Element _var = { _src, _key, 0.0, E_CFG_FLOAT_T, \ +0, _default, NULL, NULL, 0, \ +0, 0.0, NULL, NULL, 0, \ +} +#define E_CFG_STR(_var, _src, _key, _default) \ +static E_Config_Element _var = { _src, _key, 0.0, E_CFG_STR_T, \ +0, 0.0, _default, NULL, 0, \ +0, 0.0, NULL, NULL, 0, \ +} +#define E_CFG_DATA(_var, _src, _key, _default, _default_size) \ +static E_Config_Element _var = { _src, _key, 0.0, E_CFG_DATAT_T, \ +0, 0.0, NULL, _default, _default_size, \ +0, 0.0, NULL, NULL, 0, \ +} +/* yes for now it only fetches them every 5 seconds - in the end i need a */ +/* validity flag for the database file to know if it changed and only then */ +/* get the value again. this is waiting for efsd to become more solid */ +#define E_CFG_VALIDITY_CHECK(_var) \ +{ \ +double __time; \ +__time = e_get_time(); \ +if (_var.last_fetch < (__time - 5.0)) { \ +int __cfg_ok = 0; \ +_var.last_fetch = __time; +#define E_CFG_END_VALIDITY_CHECK \ +} \ +} +#define E_CONFIG_INT_GET(_var, _val) \ +{{ \ +E_CFG_VALIDITY_CHECK(_var) \ +E_DB_INT_GET(e_config_get(_var.src), _var.key, _var.cur_int_val, __cfg_ok); \ +if (!__cfg_ok) _var.cur_int_val = _var.def_int_val; \ +E_CFG_END_VALIDITY_CHECK \ +} \ +_val = _var.cur_int_val;} +#define E_CONFIG_FLOAT_GET(_var, _val) \ +{{ \ +E_CFG_VALIDITY_CHECK(_var) \ +E_DB_FLOAT_GET(e_config_get(_var.src), _var.key, _var.cur_float_val, __cfg_ok); \ +if (!__cfg_ok) _var.cur_float_val = _var.def_float_val; \ +E_CFG_END_VALIDITY_CHECK \ +} \ +_val = _var.cur_float_val;} +#define E_CONFIG_STR_GET(_var, _val) \ +{{ \ +E_CFG_VALIDITY_CHECK(_var) \ +if (_var.cur_str_val) free(_var.cur_str_val); \ +_var.cur_str_val = NULL; \ +E_DB_STR_GET(e_config_get(_var.src), _var.key, _var.cur_str_val, __cfg_ok); \ +if (!__cfg_ok) _var.cur_str_val = _var.def_str_val \ +E_CFG_END_VALIDITY_CHECK \ +} \ +_val = _var.cur_str_val;} +#define E_CONFIG_DATA_GET(_var, _val, _size) \ +{{ \ +E_CFG_VALIDITY_CHECK(_var) \ +if (_var.cur_data_val) free(_var.cur_data_val); \ +_var.cur_data_val = NULL; \ +_var.cur_data_size = 0; \ +{ E_DB_File *__db; \ +__db = e_db_open_read(e_config_get(_var.src)); \ +if (__db) { \ +_var.cur_data_val = e_db_data_get(__db, _var.key, &(_var.cur_data_size)); \ +if (_var.cur_data_val) __cfg_ok = 1; \ +e_db_close(__db); \ +} \ +} \ +if (!__cfg_ok) { \ +_var.cur_data_val = e_memdup(_var.def_data_val, _var.def_data_size); \ +_var.cur_data_size = _var.def_data_size; \ +} \ +E_CFG_END_VALIDITY_CHECK \ +} \ +_val = _var.cur_data_val; \ +_size = _var.cur_data_size;} + +/* misc util macros */ +#define INTERSECTS(x, y, w, h, xx, yy, ww, hh) \ +((x < (xx + ww)) && \ +(y < (yy + hh)) && \ +((x + w) > xx) && \ +((y + h) > yy)) +#define SPANS_COMMON(x1, w1, x2, w2) \ +(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1))))) +#define UN(_blah) _blah = 0 #define SET_BORDER_GRAVITY(_b, _grav) \ e_window_gravity_set(_b->win.container, _grav); \ e_window_gravity_set(_b->win.input, _grav); \ @@ -127,6 +231,7 @@ e_window_gravity_set(_b->win.r, _grav); \ e_window_gravity_set(_b->win.t, _grav); \ e_window_gravity_set(_b->win.b, _grav); +/* data types */ typedef struct _E_Object E_Object; typedef struct _E_Border E_Border; typedef struct _E_Grab E_Grab; @@ -137,17 +242,17 @@ typedef struct _E_Rect E_Rect; typedef struct _E_Active_Action_Timer E_Active_Action_Timer; typedef struct _E_View E_View; typedef struct _E_Icon E_Icon; -typedef struct _E_Shelf E_Shelf; typedef struct _E_Background E_Background; typedef struct _E_Background_Layer E_Background_Layer; typedef struct _E_Menu E_Menu; typedef struct _E_Menu_Item E_Menu_Item; typedef struct _E_Build_Menu E_Build_Menu; typedef struct _E_Entry E_Entry; -typedef struct _E_Pack_Object_Class E_Pack_Object_Class; -typedef struct _E_Pack_Object E_Pack_Object; typedef struct _E_FS_Restarter E_FS_Restarter; +typedef struct _E_Config_File E_Config_File; +typedef struct _E_Config_Element E_Config_Element; +/* actual fdata struct members */ struct _E_Object { OBJ_PROPERTIES; @@ -475,28 +580,6 @@ struct _E_Icon int changed; }; -struct _E_Shelf -{ - OBJ_PROPERTIES; - - char *name; - E_View *view; - - int x, y, w, h; - struct { - Ebits_Object border; - } bit; - struct { - Evas_Object clipper; - } obj; - int visible; - int icon_count; - struct { - int moving; - int resizing; - } state; -}; - struct _E_Background_Layer { int mode; @@ -670,61 +753,35 @@ struct _E_Entry void *data_focus_out; }; -struct _E_Pack_Object_Class -{ - void * (*new) (void); - void (*free) (void *object); - void (*show) (void *object); - void (*hide) (void *object); - void (*raise) (void *object); - void (*lower) (void *object); - void (*layer) (void *object, int l); - void (*evas) (void *object, Evas e); - void (*clip) (void *object, Evas_Object clip); - void (*unclip) (void *object); - void (*move) (void *object, int x, int y); - void (*resize) (void *object, int w, int h); - void (*min) (void *object, int *w, int *h); - void (*max) (void *object, int *w, int *h); - void (*size) (void *object, int x, int y); -}; - -#define PACK_HBOX 0 -#define PACK_VBOX 1 -#define PACK_TABLE 2 -#define PACK_ENTRY 3 -#define PACK_LABEL 4 -#define PACK_BUTTON 5 -#define PACK_RADIO 6 -#define PACK_CHECK 7 - -#define PACK_MAX 8 - -struct _E_Pack_Object -{ - int type; - E_Pack_Object_Class class; - struct { - Evas evas; - Evas_Object clip; - int layer; - int visible; - int x, y, w, h; - void *object; - } data; - int references; - E_Pack_Object *parent; - Evas_List children; -}; - struct _E_FS_Restarter { void (*func) (void *data); void *data; }; -#define DO(_object, _method, _args...) \ -{ if (_object->class._method) _object->class._method(_object->data.object, ## _args); } +struct _E_Config_File +{ + char *src; + double last_fetch; +}; + +struct _E_Config_Element +{ + char *src; + char *key; + double last_fetch; + int type; + int def_int_val; + float def_float_val; + char *def_str_val; + void *def_data_val; + int def_data_val_size; + int cur_int_val; + float cur_float_val; + char *cur_str_val; + void *cur_data_val; + int cur_data_val_size; +}; void e_entry_init(void); void e_entry_free(E_Entry *entry); @@ -862,133 +919,6 @@ pid_t e_exec_run(char *exe); pid_t e_exec_run_in_dir(char *exe, char *dir); pid_t e_run_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, char *launch_path); -/* something to check validity of config files where we get data from */ -/* for now its just a 5 second timout so it will only invalidate */ -/* if we havent looked for 5 seconds... BUT later when efsd is more solid */ -/* we should use that to tell us when its invalid */ -typedef struct _e_config_file E_Config_File; -struct _e_config_file -{ - char *src; - double last_fetch; -}; -#define E_CFG_FILE(_var, _src) \ -static E_Config_File _var = {_src, 0.0} -#define E_CONFIG_CHECK_VALIDITY(_var, _src) \ -{ \ -double __time; \ -__time = e_get_time(); \ -if (_var.last_fetch < (__time - 5.0)) { \ -_var.last_fetch = __time; -#define E_CONFIG_CHECK_VALIDITY_END \ -} \ -} - -typedef struct _e_config_element E_Config_Element; -struct _e_config_element -{ - char *src; - char *key; - double last_fetch; - int type; - int def_int_val; - float def_float_val; - char *def_str_val; - void *def_data_val; - int def_data_val_size; - int cur_int_val; - float cur_float_val; - char *cur_str_val; - void *cur_data_val; - int cur_data_val_size; -}; -#define E_CFG_INT_T 123 -#define E_CFG_FLOAT_T 1234 -#define E_CFG_STR_T 12345 -#define E_CFG_DATA_T 123456 -#define E_CFG_INT(_var, _src, _key, _default) \ -static E_Config_Element _var = { _src, _key, 0.0, E_CFG_INT_T, \ -_default, 0.0, NULL, NULL, 0, \ -0, 0.0, NULL, NULL, 0, \ -} -#define E_CFG_FLOAT(_var, _src, _key, _default) \ -static E_Config_Element _var = { _src, _key, 0.0, E_CFG_FLOAT_T, \ -0, _default, NULL, NULL, 0, \ -0, 0.0, NULL, NULL, 0, \ -} -#define E_CFG_STR(_var, _src, _key, _default) \ -static E_Config_Element _var = { _src, _key, 0.0, E_CFG_STR_T, \ -0, 0.0, _default, NULL, 0, \ -0, 0.0, NULL, NULL, 0, \ -} -#define E_CFG_DATA(_var, _src, _key, _default, _default_size) \ -static E_Config_Element _var = { _src, _key, 0.0, E_CFG_DATAT_T, \ -0, 0.0, NULL, _default, _default_size, \ -0, 0.0, NULL, NULL, 0, \ -} -/* yes for now it only fetches them every 5 seconds - in the end i need a */ -/* validity flag for the database file to know if it changed and only then */ -/* get the value again. this is waiting for efsd to become more solid */ -#define E_CFG_VALIDITY_CHECK(_var) \ -{ \ -double __time; \ -__time = e_get_time(); \ -if (_var.last_fetch < (__time - 5.0)) { \ -int __cfg_ok = 0; \ -_var.last_fetch = __time; -#define E_CFG_END_VALIDITY_CHECK \ -} \ -} - -#define E_CONFIG_INT_GET(_var, _val) \ -{{ \ -E_CFG_VALIDITY_CHECK(_var) \ -E_DB_INT_GET(e_config_get(_var.src), _var.key, _var.cur_int_val, __cfg_ok); \ -if (!__cfg_ok) _var.cur_int_val = _var.def_int_val; \ -E_CFG_END_VALIDITY_CHECK \ -} \ -_val = _var.cur_int_val;} -#define E_CONFIG_FLOAT_GET(_var, _val) \ -{{ \ -E_CFG_VALIDITY_CHECK(_var) \ -E_DB_FLOAT_GET(e_config_get(_var.src), _var.key, _var.cur_float_val, __cfg_ok); \ -if (!__cfg_ok) _var.cur_float_val = _var.def_float_val; \ -E_CFG_END_VALIDITY_CHECK \ -} \ -_val = _var.cur_float_val;} -#define E_CONFIG_STR_GET(_var, _val) \ -{{ \ -E_CFG_VALIDITY_CHECK(_var) \ -if (_var.cur_str_val) free(_var.cur_str_val); \ -_var.cur_str_val = NULL; \ -E_DB_STR_GET(e_config_get(_var.src), _var.key, _var.cur_str_val, __cfg_ok); \ -if (!__cfg_ok) _var.cur_str_val = _var.def_str_val \ -E_CFG_END_VALIDITY_CHECK \ -} \ -_val = _var.cur_str_val;} -#define E_CONFIG_DATA_GET(_var, _val, _size) \ -{{ \ -E_CFG_VALIDITY_CHECK(_var) \ -if (_var.cur_data_val) free(_var.cur_data_val); \ -_var.cur_data_val = NULL; \ -_var.cur_data_size = 0; \ -{ E_DB_File *__db; \ -__db = e_db_open_read(e_config_get(_var.src)); \ -if (__db) { \ -_var.cur_data_val = e_db_data_get(__db, _var.key, &(_var.cur_data_size)); \ -if (_var.cur_data_val) __cfg_ok = 1; \ -e_db_close(__db); \ -} \ -} \ -if (!__cfg_ok) { \ -_var.cur_data_val = e_memdup(_var.def_data_val, _var.def_data_size); \ -_var.cur_data_size = _var.def_data_size; \ -} \ -E_CFG_END_VALIDITY_CHECK \ -} \ -_val = _var.cur_data_val; \ -_size = _var.cur_data_size;} - char *e_config_get(char *type); void e_config_init(void); void e_config_set_user_dir(char *dir); @@ -1069,5 +999,3 @@ E_Icon *e_view_find_icon_by_file(E_View *v, char *file); void e_view_del_icon(E_View *v, E_Icon *icon); void e_ipc_init(void); - -void e_pack_object_init(void); diff --git a/src/fs.c b/src/fs.c index 7ce227aa6..c79fbc7af 100644 --- a/src/fs.c +++ b/src/fs.c @@ -15,13 +15,11 @@ e_fs_child_handle(Eevent *ev) Ev_Child *e; e = ev->event; - printf("child exit code %i pid %i, efsd pid = %i\n", e->exit_code, e->pid, efsd_pid); if (e->pid == efsd_pid) { efsd_close(ec); efsd_pid = 0; ec = NULL; - printf("efsd exited.\n"); _e_fs_restarter(0, NULL); } } @@ -31,7 +29,6 @@ _e_fs_fd_handle(int fd) { double start, current; -/* printf("############## fs event...\n"); */ start = e_get_time(); while ((ec) && efsd_events_pending(ec)) { @@ -57,11 +54,9 @@ _e_fs_fd_handle(int fd) ec = NULL; if (efsd_pid == -2) _e_fs_restarter(0, NULL); -/* efsd_pid = 0;*/ /* FIXME: need to queue a popup dialog here saying */ /* efsd went wonky */ - printf("EEEEEEEEEEK efsd went wonky\n"); -/* _e_fs_restarter(0, NULL);*/ + printf("EEEEEEEEEEK efsd went wonky. Bye bye efsd.\n"); } /* spent more thna 1/20th of a second here.. get out */ @@ -72,26 +67,21 @@ _e_fs_fd_handle(int fd) break; } } -/* printf("############## fs done\n"); */ } static void _e_fs_restarter(int val, void *data) { if (ec) return; - printf("_e_fs_restarter %i\n", efsd_pid); if (val > 0) { - if (efsd_pid <= 0) - efsd_pid = e_exec_run("efsd -f"); - if (efsd_pid > 0) - ec = efsd_open(); + if (efsd_pid <= 0) efsd_pid = e_exec_run("efsd -f"); + if (efsd_pid > 0) ec = efsd_open(); } if (ec) { Evas_List l; - printf("connect!\n"); e_add_event_fd(efsd_get_connection_fd(ec), _e_fs_fd_handle); for (l = fs_restart_handlers; l; l = l->next) { @@ -146,36 +136,7 @@ e_fs_init(void) int i; e_event_filter_handler_add(EV_CHILD, e_fs_child_handle); - /* already have an efsd around? */ - printf("try efsd initial open...\n"); - ec = efsd_open(); - /* no - efsd around */ - if (!ec) - { - /* start efsd */ - printf("start efsd...\n"); - efsd_pid = e_exec_run("efsd -f"); - if (efsd_pid > 0) - { - ec = efsd_open(); - for (i = 0; (!ec) && (i < 15); i++) - { - sleep(1); - printf("try efsd open %i...\n", i, ec); - ec = efsd_open(); - printf("(connection ptr: %p)\n", ec); - } - } - } - else - efsd_pid = -2; - /* after several atempts to talk to efsd - lets give up */ - if (!ec) - { - fprintf(stderr, "efsd is not running !!!\n"); - } - if (ec) - e_add_event_fd(efsd_get_connection_fd(ec), _e_fs_fd_handle); + _e_fs_restarter(0, NULL); } EfsdConnection * diff --git a/src/main.c b/src/main.c index c7088bd5e..36eba1501 100644 --- a/src/main.c +++ b/src/main.c @@ -72,7 +72,6 @@ main(int argc, char **argv) e_reset_error_handler(); e_ungrab(); - e_pack_object_init(); e_fs_init(); e_desktops_init(); e_border_init(); diff --git a/src/pack.c b/src/pack.c index c2364c474..1c816a6a0 100644 --- a/src/pack.c +++ b/src/pack.c @@ -1,141 +1 @@ #include "e.h" - -E_Pack_Object_Class classes[PACK_MAX]; - -void -e_pack_object_init(void) -{ - /* all nulls */ - ZERO(classes, E_Pack_Object_Class, PACK_MAX); - /* set up the entry widget class - we could pack them now */ - classes[PACK_ENTRY] = (E_Pack_Object_Class) - { - e_entry_new, - e_entry_free, - e_entry_show, - e_entry_hide, - e_entry_raise, - e_entry_lower, - e_entry_set_layer, - e_entry_set_evas, - e_entry_set_clip, - e_entry_unset_clip, - e_entry_move, - e_entry_resize, - e_entry_min_size, - e_entry_max_size, - e_entry_set_size - }; -} - -E_Pack_Object * -e_pack_object_new(int type) -{ - E_Pack_Object *po; - - po = NEW(E_Pack_Object, 1); - ZERO(po, E_Pack_Object, 1); - po->type = type; - po->class = classes[type]; - po->references = 0; - if (po->class.new) po->data.object = po->class.new(); - return po; -} - -void -e_pack_object_use(E_Pack_Object *po) -{ - po->references++; -} - -void -e_pack_object_free(E_Pack_Object *po) -{ - Evas_List l; - - po->references--; - if (po->references > 0) return; - if (po->class.free) po->class.free(po->data.object); - if (po->children) - { - for (l = po->children; l; l = l->next) - { - E_Pack_Object *child_po; - - child_po = l->data; - e_pack_object_free(child_po); - } - po->children = evas_list_free(po->children); - } - free(po); -} - -void -e_pack_object_set_evas(E_Pack_Object *po, Evas e) -{ - if (e == po->data.evas) return; - po->data.evas = e; - if (po->class.evas) po->class.evas(po->data.object, e); - if (po->children) - { - Evas_List l; - - for (l = po->children; l; l = l->next) - { - E_Pack_Object *child_po; - - child_po = l->data; - e_pack_object_set_evas(child_po, e); - } - } -} - -void -e_pack_object_show(E_Pack_Object *po) -{ -} - -void -e_pack_object_hide(E_Pack_Object *po) -{ -} - -void -e_pack_object_raise(E_Pack_Object *po) -{ -} - -void -e_pack_object_lower(E_Pack_Object *po) -{ -} - -void -e_pack_object_set_layer(E_Pack_Object *po, int l) -{ -} - -void -e_pack_object_clip(E_Pack_Object *po, Evas_Object clip) -{ -} - -void -e_pack_object_unclip(E_Pack_Object *po) -{ -} - -void -e_pack_object_move(E_Pack_Object *po, int x, int y) -{ -} - -void -e_pack_object_resize(E_Pack_Object *po, int w, int h) -{ -} - -void -e_pack_object_get_size(E_Pack_Object *po, int *w, int *h) -{ -} diff --git a/src/view.c b/src/view.c index 768574f35..37e53a33a 100644 --- a/src/view.c +++ b/src/view.c @@ -1737,6 +1737,7 @@ e_view_free(E_View *v) e_del_event_timer(name); views = evas_list_remove(views, v); + efsd_stop_monitor(e_fs_get_connection(), v->dir, TRUE); if (v->restarter) e_fs_del_restart_handler(v->restarter); v->restarter = NULL; @@ -1806,10 +1807,10 @@ void e_view_set_dir(E_View *v, char *dir) { /* stop monitoring old dir */ + if (v->dir) efsd_stop_monitor(e_fs_get_connection(), v->dir, TRUE); IF_FREE(v->dir); v->dir = e_file_real(dir); /* start monitoring new dir */ - v->restarter = e_fs_add_restart_handler(e_view_handle_fs_restart, v); if (e_fs_get_connection()) {