Enlightenment CVS committal Author : devilhorns Project : e_modules Module : mem
Dir : e_modules/mem Modified Files: e_mod_config.c e_mod_main.c machdep_freebsd.c machdep_linux.c Log Message: Indent =================================================================== RCS file: /cvs/e/e_modules/mem/e_mod_config.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- e_mod_config.c 17 Jul 2006 23:21:51 -0000 1.10 +++ e_mod_config.c 18 Jul 2006 00:00:05 -0000 1.11 @@ -3,125 +3,137 @@ struct _E_Config_Dialog_Data { - double poll_time; - int always_text; - int show_percent; + double poll_time; + int always_text; + int show_percent; #ifdef __linux__ - int real_ignore_buffers; - int real_ignore_cached; + int real_ignore_buffers; + int real_ignore_cached; #endif }; /* Protos */ -static void *_create_data(E_Config_Dialog *cfd); -static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); -static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); -static void _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata); +static void *_create_data (E_Config_Dialog * cfd); +static void _free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata); +static Evas_Object *_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas, + E_Config_Dialog_Data * cfdata); +static int _basic_apply_data (E_Config_Dialog * cfd, + E_Config_Dialog_Data * cfdata); +static void _fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata); /* Config Calls */ void -_config_mem_module(Config_Item *ci) +_config_mem_module (Config_Item * ci) { - E_Config_Dialog *cfd; - E_Config_Dialog_View *v; - E_Container *con; - char buf[4096]; - - v = E_NEW(E_Config_Dialog_View, 1); - - v->create_cfdata = _create_data; - v->free_cfdata = _free_data; - v->basic.apply_cfdata = _basic_apply_data; - v->basic.create_widgets = _basic_create_widgets; - - snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mem_config->module)); - con = e_container_current_get(e_manager_current_get()); - cfd = e_config_dialog_new(con, D_("Mem Configuration"), buf, 0, v, ci); - mem_config->config_dialog = cfd; + E_Config_Dialog *cfd; + E_Config_Dialog_View *v; + E_Container *con; + char buf[4096]; + + v = E_NEW (E_Config_Dialog_View, 1); + + v->create_cfdata = _create_data; + v->free_cfdata = _free_data; + v->basic.apply_cfdata = _basic_apply_data; + v->basic.create_widgets = _basic_create_widgets; + + snprintf (buf, sizeof (buf), "%s/module.eap", + e_module_dir_get (mem_config->module)); + con = e_container_current_get (e_manager_current_get ()); + cfd = e_config_dialog_new (con, D_ ("Mem Configuration"), buf, 0, v, ci); + mem_config->config_dialog = cfd; } static void -_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata) +_fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata) { - cfdata->poll_time = ci->poll_time; + cfdata->poll_time = ci->poll_time; #ifdef __linux__ - cfdata->real_ignore_buffers = ci->real_ignore_buffers; - cfdata->real_ignore_cached = ci->real_ignore_cached; + cfdata->real_ignore_buffers = ci->real_ignore_buffers; + cfdata->real_ignore_cached = ci->real_ignore_cached; #endif // cfdata->show_text = c->conf->show_text; - cfdata->always_text = ci->always_text; - cfdata->show_percent = ci->show_percent; + cfdata->always_text = ci->always_text; + cfdata->show_percent = ci->show_percent; } static void * -_create_data(E_Config_Dialog *cfd) +_create_data (E_Config_Dialog * cfd) { - E_Config_Dialog_Data *cfdata; - Config_Item *ci; + E_Config_Dialog_Data *cfdata; + Config_Item *ci; - ci = cfd->data; - cfdata = E_NEW(E_Config_Dialog_Data, 1); + ci = cfd->data; + cfdata = E_NEW (E_Config_Dialog_Data, 1); - _fill_data(ci, cfdata); - return cfdata; + _fill_data (ci, cfdata); + return cfdata; } static void -_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +_free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata) { - if (!mem_config) - return; - mem_config->config_dialog = NULL; - free(cfdata); - cfdata = NULL; + if (!mem_config) + return; + mem_config->config_dialog = NULL; + free (cfdata); + cfdata = NULL; } static Evas_Object * -_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata) +_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas, + E_Config_Dialog_Data * cfdata) { - Evas_Object *o, *of, *ob; - E_Radio_Group *rg; - - o = e_widget_list_add(evas, 0, 0); - of = e_widget_framelist_add(evas, D_("General Settings"), 0); - rg = e_widget_radio_group_new(&(cfdata->always_text)); - ob = e_widget_radio_add(evas, D_("Always Show Text"), 1, rg); - e_widget_framelist_object_append(of, ob); - ob = e_widget_radio_add(evas, D_("Show Text On Mouse Over"), 0, rg); - e_widget_framelist_object_append(of, ob); - ob = e_widget_check_add(evas, D_("Show Text As Percent"), &(cfdata->show_percent)); - e_widget_framelist_object_append(of, ob); + Evas_Object *o, *of, *ob; + E_Radio_Group *rg; + + o = e_widget_list_add (evas, 0, 0); + of = e_widget_framelist_add (evas, D_ ("General Settings"), 0); + rg = e_widget_radio_group_new (&(cfdata->always_text)); + ob = e_widget_radio_add (evas, D_ ("Always Show Text"), 1, rg); + e_widget_framelist_object_append (of, ob); + ob = e_widget_radio_add (evas, D_ ("Show Text On Mouse Over"), 0, rg); + e_widget_framelist_object_append (of, ob); + ob = + e_widget_check_add (evas, D_ ("Show Text As Percent"), + &(cfdata->show_percent)); + e_widget_framelist_object_append (of, ob); #ifdef __linux__ - ob = e_widget_check_add(evas, D_("Ignore Buffers"), &(cfdata->real_ignore_buffers)); - e_widget_framelist_object_append(of, ob); - ob = e_widget_check_add(evas, D_("Ignore Cached"), &(cfdata->real_ignore_cached)); - e_widget_framelist_object_append(of, ob); + ob = + e_widget_check_add (evas, D_ ("Ignore Buffers"), + &(cfdata->real_ignore_buffers)); + e_widget_framelist_object_append (of, ob); + ob = + e_widget_check_add (evas, D_ ("Ignore Cached"), + &(cfdata->real_ignore_cached)); + e_widget_framelist_object_append (of, ob); #endif - ob = e_widget_label_add(evas, D_("Check Interval:")); - e_widget_framelist_object_append(of, ob); - ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1.0, 60.0, 1.0, 0, &(cfdata->poll_time), NULL, 150); - e_widget_framelist_object_append(of, ob); - e_widget_list_object_append(o, of, 1, 1, 0.5); + ob = e_widget_label_add (evas, D_ ("Check Interval:")); + e_widget_framelist_object_append (of, ob); + ob = + e_widget_slider_add (evas, 1, 0, _("%1.0f seconds"), 1.0, 60.0, 1.0, 0, + &(cfdata->poll_time), NULL, 150); + e_widget_framelist_object_append (of, ob); + e_widget_list_object_append (o, of, 1, 1, 0.5); - return o; + return o; } static int -_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) +_basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata) { - Config_Item *ci; - - ci = cfd->data; - ci->poll_time = cfdata->poll_time; + Config_Item *ci; + + ci = cfd->data; + ci->poll_time = cfdata->poll_time; #ifdef __linux__ - ci->real_ignore_buffers = cfdata->real_ignore_buffers; - ci->real_ignore_cached = cfdata->real_ignore_cached; + ci->real_ignore_buffers = cfdata->real_ignore_buffers; + ci->real_ignore_cached = cfdata->real_ignore_cached; #endif - ci->always_text = cfdata->always_text; - ci->show_percent = cfdata->show_percent; - e_config_save_queue(); - _mem_config_updated(ci->id); - - return 1; + ci->always_text = cfdata->always_text; + ci->show_percent = cfdata->show_percent; + e_config_save_queue (); + _mem_config_updated (ci->id); + + return 1; } =================================================================== RCS file: /cvs/e/e_modules/mem/e_mod_main.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -3 -r1.36 -r1.37 --- e_mod_main.c 17 Jul 2006 23:21:51 -0000 1.36 +++ e_mod_main.c 18 Jul 2006 00:00:05 -0000 1.37 @@ -4,432 +4,457 @@ typedef struct _Instance Instance; typedef struct _Mem Mem; -struct _Instance +struct _Instance { - E_Gadcon_Client *gcc; - Evas_Object *mem_obj; - Mem *mem; - Ecore_Timer *check_timer; + E_Gadcon_Client *gcc; + Evas_Object *mem_obj; + Mem *mem; + Ecore_Timer *check_timer; }; -struct _Mem +struct _Mem { - Instance *inst; - Evas_Object *mem_obj; + Instance *inst; + Evas_Object *mem_obj; }; /* Func Protos for Gadcon */ -static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); -static void _gc_shutdown(E_Gadcon_Client *gcc); -static void _gc_orient(E_Gadcon_Client *gcc); -static char *_gc_label(void); -static Evas_Object *_gc_icon(Evas *evas); +static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name, + const char *id, const char *style); +static void _gc_shutdown (E_Gadcon_Client * gcc); +static void _gc_orient (E_Gadcon_Client * gcc); +static char *_gc_label (void); +static Evas_Object *_gc_icon (Evas * evas); /* Func Protos for Module */ -static void _mem_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _mem_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _mem_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _mem_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi); -static void _mem_menu_cb_post(void *data, E_Menu *m); -static Config_Item *_mem_config_item_get(const char *id); -static Mem *_mem_new(Evas *evas); -static void _mem_free(Mem *mem); -static int _mem_cb_check(void *data); +static void _mem_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, + void *event_info); +static void _mem_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, + void *event_info); +static void _mem_cb_mouse_out (void *data, Evas * e, Evas_Object * obj, + void *event_info); +static void _mem_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi); +static void _mem_menu_cb_post (void *data, E_Menu * m); +static Config_Item *_mem_config_item_get (const char *id); +static Mem *_mem_new (Evas * evas); +static void _mem_free (Mem * mem); +static int _mem_cb_check (void *data); static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_item_edd = NULL; Config *mem_config = NULL; -static const E_Gadcon_Client_Class _gc_class = -{ - GADCON_CLIENT_CLASS_VERSION, - "mem", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon} +static const E_Gadcon_Client_Class _gc_class = { + GADCON_CLIENT_CLASS_VERSION, + "mem", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon} }; static E_Gadcon_Client * -_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) +_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style) { - E_Gadcon_Client *gcc; - Evas_Object *o; - Instance *inst; - Config_Item *ci; - Mem *mem; - - inst = E_NEW(Instance, 1); - - ci = _mem_config_item_get(id); - if (!ci->id) ci->id = evas_stringshare_add(id); - - mem = _mem_new(gc->evas); - mem->inst = inst; - inst->mem = mem; - - o = mem->mem_obj; - gcc = e_gadcon_client_new(gc, name, id, style, o); - gcc->data = inst; - inst->gcc = gcc; - inst->mem_obj = o; - - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mem_cb_mouse_down, inst); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mem_cb_mouse_in, inst); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mem_cb_mouse_out, inst); - - if (ci->always_text) - edje_object_signal_emit(inst->mem_obj, "label_active", ""); - - _mem_cb_check(inst); - - inst->check_timer = ecore_timer_add(ci->poll_time, _mem_cb_check, inst); - mem_config->instances = evas_list_append(mem_config->instances, inst); - return gcc; + E_Gadcon_Client *gcc; + Evas_Object *o; + Instance *inst; + Config_Item *ci; + Mem *mem; + + inst = E_NEW (Instance, 1); + + ci = _mem_config_item_get (id); + if (!ci->id) + ci->id = evas_stringshare_add (id); + + mem = _mem_new (gc->evas); + mem->inst = inst; + inst->mem = mem; + + o = mem->mem_obj; + gcc = e_gadcon_client_new (gc, name, id, style, o); + gcc->data = inst; + inst->gcc = gcc; + inst->mem_obj = o; + + evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN, + _mem_cb_mouse_down, inst); + evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_IN, _mem_cb_mouse_in, + inst); + evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_OUT, + _mem_cb_mouse_out, inst); + + if (ci->always_text) + edje_object_signal_emit (inst->mem_obj, "label_active", ""); + + _mem_cb_check (inst); + + inst->check_timer = ecore_timer_add (ci->poll_time, _mem_cb_check, inst); + mem_config->instances = evas_list_append (mem_config->instances, inst); + return gcc; } static void -_gc_orient(E_Gadcon_Client *gcc) +_gc_orient (E_Gadcon_Client * gcc) { - e_gadcon_client_aspect_set(gcc, 16, 16); - e_gadcon_client_min_size_set(gcc, 16, 16); + e_gadcon_client_aspect_set (gcc, 16, 16); + e_gadcon_client_min_size_set (gcc, 16, 16); } static char * -_gc_label(void) +_gc_label (void) { - return D_("Mem"); + return D_ ("Mem"); } static Evas_Object * -_gc_icon(Evas *evas) +_gc_icon (Evas * evas) { - Evas_Object *o; - char buf[4096]; - - o = edje_object_add(evas); - snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(mem_config->module)); - edje_object_file_set(o, buf, "icon"); - return o; + Evas_Object *o; + char buf[4096]; + + o = edje_object_add (evas); + snprintf (buf, sizeof (buf), "%s/module.eap", + e_module_dir_get (mem_config->module)); + edje_object_file_set (o, buf, "icon"); + return o; } static void -_gc_shutdown(E_Gadcon_Client *gcc) +_gc_shutdown (E_Gadcon_Client * gcc) { - Instance *inst; - - inst = gcc->data; - if (inst->check_timer) ecore_timer_del(inst->check_timer); - mem_config->instances = evas_list_remove(mem_config->instances, inst); - _mem_free(inst->mem); - free(inst); - inst = NULL; + Instance *inst; + + inst = gcc->data; + if (inst->check_timer) + ecore_timer_del (inst->check_timer); + mem_config->instances = evas_list_remove (mem_config->instances, inst); + _mem_free (inst->mem); + free (inst); + inst = NULL; } static void -_mem_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +_mem_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, void *event_info) { - Instance *inst; - Evas_Event_Mouse_Down *ev; + Instance *inst; + Evas_Event_Mouse_Down *ev; - inst = data; - ev = event_info; - if ((ev->button == 3) && (!mem_config->menu)) - { - E_Menu *mn; - E_Menu_Item *mi; - int x, y, w, h; - - mn = e_menu_new(); - e_menu_post_deactivate_callback_set(mn, _mem_menu_cb_post, inst); - mem_config->menu = mn; - - mi = e_menu_item_new(mn); - e_menu_item_label_set(mi, D_("Configuration")); - e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration"); - e_menu_item_callback_set(mi, _mem_menu_cb_configure, inst); - - mi = e_menu_item_new(mn); - e_menu_item_separator_set(mi, 1); - - e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0); - e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, &w, &h); - e_menu_activate_mouse(mn, - e_util_zone_current_get(e_manager_current_get()), - x + ev->output.x, y + ev->output.y, 1, 1, E_MENU_POP_DIRECTION_DOWN, ev->timestamp); - evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, EVAS_BUTTON_NONE, ev->timestamp, NULL); - } + inst = data; + ev = event_info; + if ((ev->button == 3) && (!mem_config->menu)) + { + E_Menu *mn; + E_Menu_Item *mi; + int x, y, w, h; + + mn = e_menu_new (); + e_menu_post_deactivate_callback_set (mn, _mem_menu_cb_post, inst); + mem_config->menu = mn; + + mi = e_menu_item_new (mn); + e_menu_item_label_set (mi, D_ ("Configuration")); + e_util_menu_item_edje_icon_set (mi, "enlightenment/configuration"); + e_menu_item_callback_set (mi, _mem_menu_cb_configure, inst); + + mi = e_menu_item_new (mn); + e_menu_item_separator_set (mi, 1); + + e_gadcon_client_util_menu_items_append (inst->gcc, mn, 0); + e_gadcon_canvas_zone_geometry_get (inst->gcc->gadcon, &x, &y, &w, &h); + e_menu_activate_mouse (mn, + e_util_zone_current_get (e_manager_current_get + ()), x + ev->output.x, + y + ev->output.y, 1, 1, + E_MENU_POP_DIRECTION_DOWN, ev->timestamp); + evas_event_feed_mouse_up (inst->gcc->gadcon->evas, ev->button, + EVAS_BUTTON_NONE, ev->timestamp, NULL); + } } static void -_mem_menu_cb_post(void *data, E_Menu *m) +_mem_menu_cb_post (void *data, E_Menu * m) { - if (!mem_config->menu) return; - e_object_del(E_OBJECT(mem_config->menu)); - mem_config->menu = NULL; + if (!mem_config->menu) + return; + e_object_del (E_OBJECT (mem_config->menu)); + mem_config->menu = NULL; } static void -_mem_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi) +_mem_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi) { - Instance *inst; - Config_Item *ci; - - inst = data; - ci = _mem_config_item_get(inst->gcc->id); - _config_mem_module(ci); + Instance *inst; + Config_Item *ci; + + inst = data; + ci = _mem_config_item_get (inst->gcc->id); + _config_mem_module (ci); } void -_mem_config_updated(const char *id) +_mem_config_updated (const char *id) { - Evas_List *l; - Config_Item *ci; + Evas_List *l; + Config_Item *ci; - if (!mem_config) return; - ci = _mem_config_item_get(id); - for (l = mem_config->instances; l; l = l->next) - { - Instance *inst; - - inst = l->data; - if (!inst->gcc->id) continue; - - if (!strcmp(inst->gcc->id, ci->id)) - { - if (inst->check_timer) ecore_timer_del(inst->check_timer); - inst->check_timer = ecore_timer_add((double)ci->poll_time, _mem_cb_check, inst); - if (ci->always_text) - edje_object_signal_emit(inst->mem_obj, "label_active", ""); - else - edje_object_signal_emit(inst->mem_obj, "label_passive", ""); - - break; - } - } + if (!mem_config) + return; + ci = _mem_config_item_get (id); + for (l = mem_config->instances; l; l = l->next) + { + Instance *inst; + + inst = l->data; + if (!inst->gcc->id) + continue; + + if (!strcmp (inst->gcc->id, ci->id)) + { + if (inst->check_timer) + ecore_timer_del (inst->check_timer); + inst->check_timer = + ecore_timer_add ((double) ci->poll_time, _mem_cb_check, inst); + if (ci->always_text) + edje_object_signal_emit (inst->mem_obj, "label_active", ""); + else + edje_object_signal_emit (inst->mem_obj, "label_passive", ""); + + break; + } + } } static Config_Item * -_mem_config_item_get(const char *id) +_mem_config_item_get (const char *id) { - Evas_List *l; - Config_Item *ci; + Evas_List *l; + Config_Item *ci; - for (l = mem_config->items; l; l = l->next) - { - ci = l->data; - if (!ci->id) continue; - if (!strcmp(ci->id, id)) return ci; - } - ci = E_NEW(Config_Item, 1); - ci->id = evas_stringshare_add(id); - ci->poll_time = 1.0; - ci->always_text = 0; - ci->show_percent = 1; + for (l = mem_config->items; l; l = l->next) + { + ci = l->data; + if (!ci->id) + continue; + if (!strcmp (ci->id, id)) + return ci; + } + ci = E_NEW (Config_Item, 1); + ci->id = evas_stringshare_add (id); + ci->poll_time = 1.0; + ci->always_text = 0; + ci->show_percent = 1; #ifdef __linux__ - ci->real_ignore_buffers = 0; - ci->real_ignore_cached = 0; + ci->real_ignore_buffers = 0; + ci->real_ignore_cached = 0; #endif - mem_config->items = evas_list_append(mem_config->items, ci); - return ci; + mem_config->items = evas_list_append (mem_config->items, ci); + return ci; } -EAPI E_Module_Api e_modapi = -{ - E_MODULE_API_VERSION, - "Mem" +EAPI E_Module_Api e_modapi = { + E_MODULE_API_VERSION, + "Mem" }; EAPI void * -e_modapi_init(E_Module *m) +e_modapi_init (E_Module * m) { - bindtextdomain(PACKAGE, LOCALEDIR); - bind_textdomain_codeset(PACKAGE, "UTF-8"); + bindtextdomain (PACKAGE, LOCALEDIR); + bind_textdomain_codeset (PACKAGE, "UTF-8"); - conf_item_edd = E_CONFIG_DD_NEW("Mem_Config_Item", Config_Item); + conf_item_edd = E_CONFIG_DD_NEW ("Mem_Config_Item", Config_Item); #undef T #undef D #define T Config_Item #define D conf_item_edd - E_CONFIG_VAL(D, T, id, STR); - E_CONFIG_VAL(D, T, poll_time, DOUBLE); - E_CONFIG_VAL(D, T, always_text, INT); - E_CONFIG_VAL(D, T, show_percent, INT); + E_CONFIG_VAL (D, T, id, STR); + E_CONFIG_VAL (D, T, poll_time, DOUBLE); + E_CONFIG_VAL (D, T, always_text, INT); + E_CONFIG_VAL (D, T, show_percent, INT); #ifdef __linux__ - E_CONFIG_VAL(D, T, real_ignore_buffers, INT); - E_CONFIG_VAL(D, T, real_ignore_cached, INT); + E_CONFIG_VAL (D, T, real_ignore_buffers, INT); + E_CONFIG_VAL (D, T, real_ignore_cached, INT); #endif - conf_edd = E_CONFIG_DD_NEW("Mem_Config", Config); + conf_edd = E_CONFIG_DD_NEW ("Mem_Config", Config); #undef T #undef D #define T Config #define D conf_edd - E_CONFIG_LIST(D, T, items, conf_item_edd); + E_CONFIG_LIST (D, T, items, conf_item_edd); - mem_config = e_config_domain_load("module.mem", conf_edd); - if (!mem_config) - { - Config_Item *ci; - - mem_config = E_NEW(Config, 1); - - ci = E_NEW(Config_Item, 1); - ci->id = evas_stringshare_add("0"); - ci->poll_time = 1.0; - ci->always_text = 0; - ci->show_percent = 1; + mem_config = e_config_domain_load ("module.mem", conf_edd); + if (!mem_config) + { + Config_Item *ci; + + mem_config = E_NEW (Config, 1); + + ci = E_NEW (Config_Item, 1); + ci->id = evas_stringshare_add ("0"); + ci->poll_time = 1.0; + ci->always_text = 0; + ci->show_percent = 1; #ifdef __linux__ - ci->real_ignore_buffers = 0; - ci->real_ignore_cached = 0; + ci->real_ignore_buffers = 0; + ci->real_ignore_cached = 0; #endif - mem_config->items = evas_list_append(mem_config->items, ci); - } - mem_config->module = m; - e_gadcon_provider_register(&_gc_class); - return m; + mem_config->items = evas_list_append (mem_config->items, ci); + } + mem_config->module = m; + e_gadcon_provider_register (&_gc_class); + return m; } EAPI int -e_modapi_shutdown(E_Module *m) +e_modapi_shutdown (E_Module * m) { - mem_config->module = NULL; - e_gadcon_provider_unregister(&_gc_class); + mem_config->module = NULL; + e_gadcon_provider_unregister (&_gc_class); - if (mem_config->config_dialog) - e_object_del(E_OBJECT(mem_config->config_dialog)); - if (mem_config->menu) - { - e_menu_post_deactivate_callback_set(mem_config->menu, NULL, NULL); - e_object_del(E_OBJECT(mem_config->menu)); - mem_config->menu = NULL; - } - while (mem_config->items) - { - Config_Item *ci; - - ci = mem_config->items->data; - mem_config->items = evas_list_remove_list(mem_config->items, mem_config->items); - if (ci->id) evas_stringshare_del(ci->id); - free(ci); - ci = NULL; - } - free(mem_config); - mem_config = NULL; - E_CONFIG_DD_FREE(conf_item_edd); - E_CONFIG_DD_FREE(conf_edd); - return 1; + if (mem_config->config_dialog) + e_object_del (E_OBJECT (mem_config->config_dialog)); + if (mem_config->menu) + { + e_menu_post_deactivate_callback_set (mem_config->menu, NULL, NULL); + e_object_del (E_OBJECT (mem_config->menu)); + mem_config->menu = NULL; + } + while (mem_config->items) + { + Config_Item *ci; + + ci = mem_config->items->data; + mem_config->items = + evas_list_remove_list (mem_config->items, mem_config->items); + if (ci->id) + evas_stringshare_del (ci->id); + free (ci); + ci = NULL; + } + free (mem_config); + mem_config = NULL; + E_CONFIG_DD_FREE (conf_item_edd); + E_CONFIG_DD_FREE (conf_edd); + return 1; } EAPI int -e_modapi_save(E_Module *m) +e_modapi_save (E_Module * m) { - Evas_List *l; + Evas_List *l; - for (l = mem_config->instances; l; l = l->next) - { - Instance *inst; - Config_Item *ci; - - inst = l->data; - ci = _mem_config_item_get(inst->gcc->id); - if (ci->id) evas_stringshare_del(ci->id); - ci->id = evas_stringshare_add(inst->gcc->id); - } - e_config_domain_save("module.mem", conf_edd, mem_config); - return 1; + for (l = mem_config->instances; l; l = l->next) + { + Instance *inst; + Config_Item *ci; + + inst = l->data; + ci = _mem_config_item_get (inst->gcc->id); + if (ci->id) + evas_stringshare_del (ci->id); + ci->id = evas_stringshare_add (inst->gcc->id); + } + e_config_domain_save ("module.mem", conf_edd, mem_config); + return 1; } EAPI int -e_modapi_about(E_Module *m) +e_modapi_about (E_Module * m) { - e_module_dialog_show(m, D_("Enlightenment Mem Monitor Module"), - D_("This module is used to monitor memory.")); - return 1; + e_module_dialog_show (m, D_ ("Enlightenment Mem Monitor Module"), + D_ ("This module is used to monitor memory.")); + return 1; } static Mem * -_mem_new(Evas *evas) +_mem_new (Evas * evas) { - Mem *mem; - char buf[4096]; + Mem *mem; + char buf[4096]; - mem = E_NEW(Mem, 1); + mem = E_NEW (Mem, 1); - mem->mem_obj = edje_object_add(evas); - snprintf(buf, sizeof(buf), "%s/mem.edj", e_module_dir_get(mem_config->module)); - if (!e_theme_edje_object_set(mem->mem_obj, "base/theme/modules/mem", "modules/mem/main")) - edje_object_file_set(mem->mem_obj, buf, "modules/mem/main"); - evas_object_show(mem->mem_obj); + mem->mem_obj = edje_object_add (evas); + snprintf (buf, sizeof (buf), "%s/mem.edj", + e_module_dir_get (mem_config->module)); + if (!e_theme_edje_object_set + (mem->mem_obj, "base/theme/modules/mem", "modules/mem/main")) + edje_object_file_set (mem->mem_obj, buf, "modules/mem/main"); + evas_object_show (mem->mem_obj); - return mem; + return mem; } static void -_mem_free(Mem *m) +_mem_free (Mem * m) { - evas_object_del(m->mem_obj); - free(m); - m = NULL; + evas_object_del (m->mem_obj); + free (m); + m = NULL; } static void -_mem_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info) +_mem_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info) { - Instance *inst; + Instance *inst; - inst = data; - edje_object_signal_emit(inst->mem_obj, "label_active", ""); + inst = data; + edje_object_signal_emit (inst->mem_obj, "label_active", ""); } static void -_mem_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info) +_mem_cb_mouse_out (void *data, Evas * e, Evas_Object * obj, void *event_info) { - Instance *inst; - Config_Item *ci; + Instance *inst; + Config_Item *ci; - inst = data; - ci = _mem_config_item_get(inst->gcc->id); - if (!ci->always_text) - edje_object_signal_emit(inst->mem_obj, "label_passive", ""); + inst = data; + ci = _mem_config_item_get (inst->gcc->id); + if (!ci->always_text) + edje_object_signal_emit (inst->mem_obj, "label_passive", ""); } static int -_mem_cb_check(void *data) +_mem_cb_check (void *data) { - Instance *inst; - Config_Item *ci; - Edje_Message_Float msg; - int real, swap, total_real, total_swap; - char real_str[100]; - char swap_str[100]; - - inst = data; - ci = _mem_config_item_get(inst->gcc->id); - _mem_get_values(ci, &real, &swap, &total_real, &total_swap); - - if (!ci->show_percent) - { - snprintf(real_str, sizeof(real_str), "Real: %d/%d MB", (real / 1024), (total_real / 1024)); - snprintf(swap_str, sizeof(swap_str), "Swap: %d/%d MB", (swap / 1024), (total_swap / 1024)); - } - else - { - double tr; - - tr = (((double)real / (double)total_real) * 100); - snprintf(real_str, sizeof(real_str), "Real: %1.2f%%", tr); - tr = (((double)swap / (double)total_swap) * 100); - snprintf(swap_str, sizeof(swap_str), "Swap: %1.2f%%", tr); - } - edje_object_part_text_set(inst->mem_obj, "real_label", real_str); - edje_object_part_text_set(inst->mem_obj, "swap_label", swap_str); - - double tr = ((double)real / (double)total_real); - msg.val = tr; - edje_object_message_send(inst->mem_obj, EDJE_MESSAGE_FLOAT, 1, &msg); - - double ts = ((double)swap / (double)total_swap); - msg.val = ts; - edje_object_message_send(inst->mem_obj, EDJE_MESSAGE_FLOAT, 2, &msg); + Instance *inst; + Config_Item *ci; + Edje_Message_Float msg; + int real, swap, total_real, total_swap; + char real_str[100]; + char swap_str[100]; + + inst = data; + ci = _mem_config_item_get (inst->gcc->id); + _mem_get_values (ci, &real, &swap, &total_real, &total_swap); + + if (!ci->show_percent) + { + snprintf (real_str, sizeof (real_str), "Real: %d/%d MB", (real / 1024), + (total_real / 1024)); + snprintf (swap_str, sizeof (swap_str), "Swap: %d/%d MB", (swap / 1024), + (total_swap / 1024)); + } + else + { + double tr; + + tr = (((double) real / (double) total_real) * 100); + snprintf (real_str, sizeof (real_str), "Real: %1.2f%%", tr); + tr = (((double) swap / (double) total_swap) * 100); + snprintf (swap_str, sizeof (swap_str), "Swap: %1.2f%%", tr); + } + edje_object_part_text_set (inst->mem_obj, "real_label", real_str); + edje_object_part_text_set (inst->mem_obj, "swap_label", swap_str); + + double tr = ((double) real / (double) total_real); + msg.val = tr; + edje_object_message_send (inst->mem_obj, EDJE_MESSAGE_FLOAT, 1, &msg); + + double ts = ((double) swap / (double) total_swap); + msg.val = ts; + edje_object_message_send (inst->mem_obj, EDJE_MESSAGE_FLOAT, 2, &msg); - return 1; + return 1; } =================================================================== RCS file: /cvs/e/e_modules/mem/machdep_freebsd.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- machdep_freebsd.c 14 Jun 2006 14:15:39 -0000 1.1 +++ machdep_freebsd.c 18 Jul 2006 00:00:05 -0000 1.2 @@ -12,91 +12,102 @@ #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof (var)) -static int getsysctl(char *name, void *ptr, size_t len) +static int +getsysctl (char *name, void *ptr, size_t len) { - size_t nlen = len; - if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) { - return (1); - } - - if (nlen != len) { - return (1); - } + size_t nlen = len; + if (sysctlbyname (name, ptr, &nlen, NULL, 0) == -1) + { + return (1); + } + + if (nlen != len) + { + return (1); + } - return (0); + return (0); } -static int swapinfo(int *total, int *used) +static int +swapinfo (int *total, int *used) { - int pagesize = getpagesize(); - size_t mibsize, size; - struct xswdev xsw; - int mib[16], n; - int tmp_total, tmp_used; - - *total = 0; - *used = 0; - - mibsize = sizeof mib / sizeof mib[0]; - if (sysctlnametomib("vm.swap_info", mib, &mibsize) == -1) { - warn("sysctlnametomib()"); - return 1; - } + int pagesize = getpagesize (); + size_t mibsize, size; + struct xswdev xsw; + int mib[16], n; + int tmp_total, tmp_used; + + *total = 0; + *used = 0; + + mibsize = sizeof mib / sizeof mib[0]; + if (sysctlnametomib ("vm.swap_info", mib, &mibsize) == -1) + { + warn ("sysctlnametomib()"); + return 1; + } + + for (n = 0;; n++) + { + mib[mibsize] = n; + size = sizeof xsw; + if (sysctl (mib, mibsize + 1, &xsw, &size, NULL, 0) == -1) + break; + + if (xsw.xsw_version != XSWDEV_VERSION) + { + warnx ("xswdev version mismatch"); + return 1; + } + + tmp_total = (long long) xsw.xsw_nblks * pagesize; + tmp_used = (long long) xsw.xsw_used * pagesize; + *total += tmp_total; + *used += tmp_used; + } + if (errno != ENOENT) + warn ("sysctl()"); - for (n = 0; ; n++) { - mib[mibsize] = n; - size = sizeof xsw; - if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1) - break; - - if (xsw.xsw_version != XSWDEV_VERSION) { - warnx("xswdev version mismatch"); - return 1; - } - - tmp_total = (long long)xsw.xsw_nblks * pagesize; - tmp_used = (long long)xsw.xsw_used * pagesize; - *total += tmp_total; - *used += tmp_used; - } - if (errno != ENOENT) - warn("sysctl()"); - - return 0; + return 0; } void -_mem_get_values(ci, phys_used, sw_used, phys_total, sw_total) - Config_Item *ci; - int *phys_used; - int *sw_used; - int *phys_total; - int *sw_total; +_mem_get_values (ci, phys_used, sw_used, phys_total, sw_total) + Config_Item *ci; + int *phys_used; + int *sw_used; + int *phys_total; + int *sw_total; { - int total_pages, inactive_pages, free_pages; - - int pagesize = getpagesize(); + int total_pages, inactive_pages, free_pages; - if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) { - warnx("can't read sysctl \"vm.stats.vm.v_page_count\""); - return; - } - - if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) { - warnx("can't read sysctl \"vm.stats.vm.v_free_count\""); - return; - } + int pagesize = getpagesize (); - if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) { - warnx("can't read sysctl \"vm.stats.vm.v_inactive_count\""); - return; - } - - *phys_total = (total_pages * pagesize) >> 10; - *phys_used = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10; - - if ((swapinfo(sw_total, sw_used)) != 0) { - *sw_total = 0; - *sw_used = 0; - } + if (GETSYSCTL ("vm.stats.vm.v_page_count", total_pages)) + { + warnx ("can't read sysctl \"vm.stats.vm.v_page_count\""); + return; + } + + if (GETSYSCTL ("vm.stats.vm.v_free_count", free_pages)) + { + warnx ("can't read sysctl \"vm.stats.vm.v_free_count\""); + return; + } + + if (GETSYSCTL ("vm.stats.vm.v_inactive_count", inactive_pages)) + { + warnx ("can't read sysctl \"vm.stats.vm.v_inactive_count\""); + return; + } + + *phys_total = (total_pages * pagesize) >> 10; + *phys_used = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10; + + if ((swapinfo (sw_total, sw_used)) != 0) + { + *sw_total = 0; + *sw_used = 0; + } } =================================================================== RCS file: /cvs/e/e_modules/mem/machdep_linux.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- machdep_linux.c 14 Jun 2006 14:15:39 -0000 1.1 +++ machdep_linux.c 18 Jul 2006 00:00:05 -0000 1.2 @@ -2,62 +2,68 @@ #include "e_mod_main.h" void -_mem_get_values(Config_Item *ci, int *real, int *swap, int *total_real, int *total_swap) +_mem_get_values (Config_Item * ci, int *real, int *swap, int *total_real, + int *total_swap) { - FILE *pmeminfo = NULL; - int cursor = 0; - char *line, *field; - unsigned char c; - long int value = 0, mtotal = 0, stotal = 0, mfree = 0, sfree = 0; - ldiv_t ldresult; - long int liresult; - - if (!(pmeminfo = fopen("/proc/meminfo", "r"))) - { - fprintf(stderr, "can't open /proc/meminfo"); - return; - } - - line = (char *)calloc(64, sizeof(char)); - while (fscanf(pmeminfo, "%c", &c) != EOF) - { - if (c != '\n') line[cursor++] = c; - else - { - field = (char *)malloc(strlen(line) * sizeof(char)); - sscanf(line, "%s %ld kB", field, &value); - if (!strcmp(field, "MemTotal:")) mtotal = value; - else if (!strcmp(field, "MemFree:")) mfree = value; - else if (ci->real_ignore_buffers && (!strcmp(field, "Buffers:"))) - mfree += value; - else if (ci->real_ignore_cached && (!strcmp(field, "Cached:"))) - mfree += value; - else if (ci->real_ignore_cached && (!strcmp(field, "SwapCached:"))) - sfree += value; - else if (!strcmp(field, "SwapTotal:")) stotal = value; - else if (!strcmp(field, "SwapFree:")) sfree = value; - - free(line); - free(field); - cursor = 0; - line = (char *)calloc(64, sizeof(char)); - } - } - fclose(pmeminfo); - - if (stotal >= 1) - { - ldresult = ldiv(stotal, 100); - liresult = ldresult.quot; - ldresult = ldiv((stotal - sfree), liresult); - } - - ldresult = ldiv(mtotal, 100); - liresult = ldresult.quot; - ldresult = ldiv((mtotal - mfree), liresult); - - *real = (mtotal - mfree); - *swap = (stotal - sfree); - *total_real = mtotal; - *total_swap = stotal; + FILE *pmeminfo = NULL; + int cursor = 0; + char *line, *field; + unsigned char c; + long int value = 0, mtotal = 0, stotal = 0, mfree = 0, sfree = 0; + ldiv_t ldresult; + long int liresult; + + if (!(pmeminfo = fopen ("/proc/meminfo", "r"))) + { + fprintf (stderr, "can't open /proc/meminfo"); + return; + } + + line = (char *) calloc (64, sizeof (char)); + while (fscanf (pmeminfo, "%c", &c) != EOF) + { + if (c != '\n') + line[cursor++] = c; + else + { + field = (char *) malloc (strlen (line) * sizeof (char)); + sscanf (line, "%s %ld kB", field, &value); + if (!strcmp (field, "MemTotal:")) + mtotal = value; + else if (!strcmp (field, "MemFree:")) + mfree = value; + else if (ci->real_ignore_buffers && (!strcmp (field, "Buffers:"))) + mfree += value; + else if (ci->real_ignore_cached && (!strcmp (field, "Cached:"))) + mfree += value; + else if (ci->real_ignore_cached && (!strcmp (field, "SwapCached:"))) + sfree += value; + else if (!strcmp (field, "SwapTotal:")) + stotal = value; + else if (!strcmp (field, "SwapFree:")) + sfree = value; + + free (line); + free (field); + cursor = 0; + line = (char *) calloc (64, sizeof (char)); + } + } + fclose (pmeminfo); + + if (stotal >= 1) + { + ldresult = ldiv (stotal, 100); + liresult = ldresult.quot; + ldresult = ldiv ((stotal - sfree), liresult); + } + + ldresult = ldiv (mtotal, 100); + liresult = ldresult.quot; + ldresult = ldiv ((mtotal - mfree), liresult); + + *real = (mtotal - mfree); + *swap = (stotal - sfree); + *total_real = mtotal; + *total_swap = stotal; } ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs