Wed Apr 5 13:48:36 2006 Michael Jennings (mej)
Indent! ---------------------------------------------------------------------- SVN revision: 21859
This commit is contained in:
parent
9d018cd674
commit
52783331a4
|
@ -11,11 +11,11 @@ struct _E_Config_Dialog_Data
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Protos */
|
/* Protos */
|
||||||
static void *_create_data (E_Config_Dialog *cfd);
|
static void *_create_data(E_Config_Dialog *cfd);
|
||||||
static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
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 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 int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||||
static void _fill_data (Cpu *c, E_Config_Dialog_Data *cfdata);
|
static void _fill_data(Cpu *c, E_Config_Dialog_Data *cfdata);
|
||||||
|
|
||||||
/* Config Calls */
|
/* Config Calls */
|
||||||
void
|
void
|
||||||
|
@ -30,7 +30,7 @@ _configure_cpu_module(E_Container *con, Cpu *c)
|
||||||
v->free_cfdata = _free_data;
|
v->free_cfdata = _free_data;
|
||||||
v->basic.apply_cfdata = _basic_apply_data;
|
v->basic.apply_cfdata = _basic_apply_data;
|
||||||
v->basic.create_widgets = _basic_create_widgets;
|
v->basic.create_widgets = _basic_create_widgets;
|
||||||
|
|
||||||
cfd = e_config_dialog_new(con, D_("Cpu Configuration"), NULL, 0, v, c);
|
cfd = e_config_dialog_new(con, D_("Cpu Configuration"), NULL, 0, v, c);
|
||||||
c->cfd = cfd;
|
c->cfd = cfd;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ _configure_cpu_module(E_Container *con, Cpu *c)
|
||||||
static void
|
static void
|
||||||
_fill_data(Cpu *c, E_Config_Dialog_Data *cfdata)
|
_fill_data(Cpu *c, E_Config_Dialog_Data *cfdata)
|
||||||
{
|
{
|
||||||
cfdata->check_interval = c->conf->check_interval;
|
cfdata->check_interval = c->conf->check_interval;
|
||||||
cfdata->show_text = c->conf->show_text;
|
cfdata->show_text = c->conf->show_text;
|
||||||
cfdata->show_graph = c->conf->show_graph;
|
cfdata->show_graph = c->conf->show_graph;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ _create_data(E_Config_Dialog *cfd)
|
||||||
|
|
||||||
c = cfd->data;
|
c = cfd->data;
|
||||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
|
||||||
_fill_data(c, cfdata);
|
_fill_data(c, cfdata);
|
||||||
return cfdata;
|
return cfdata;
|
||||||
}
|
}
|
||||||
|
@ -70,14 +71,14 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
||||||
{
|
{
|
||||||
Evas_Object *o, *of, *ob;
|
Evas_Object *o, *of, *ob;
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
|
|
||||||
c = cfd->data;
|
c = cfd->data;
|
||||||
|
|
||||||
o = e_widget_list_add(evas, 0, 0);
|
o = e_widget_list_add(evas, 0, 0);
|
||||||
of = e_widget_framelist_add(evas, D_("Cpu Settings"), 0);
|
of = e_widget_framelist_add(evas, D_("Cpu Settings"), 0);
|
||||||
ob = e_widget_check_add(evas, D_("Show Text"), (&(cfdata->show_text)));
|
ob = e_widget_check_add(evas, D_("Show Text"), (&(cfdata->show_text)));
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
ob = e_widget_check_add(evas, D_("Show Graph"), (&(cfdata->show_graph)));
|
ob = e_widget_check_add(evas, D_("Show Graph"), (&(cfdata->show_graph)));
|
||||||
e_widget_framelist_object_append(of, ob);
|
e_widget_framelist_object_append(of, ob);
|
||||||
|
|
||||||
ob = e_widget_label_add(evas, D_("Check Interval:"));
|
ob = e_widget_label_add(evas, D_("Check Interval:"));
|
||||||
|
@ -96,12 +97,12 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
|
|
||||||
c = cfd->data;
|
c = cfd->data;
|
||||||
c->conf->check_interval = cfdata->check_interval;
|
c->conf->check_interval = cfdata->check_interval;
|
||||||
c->conf->show_text = cfdata->show_text;
|
c->conf->show_text = cfdata->show_text;
|
||||||
c->conf->show_graph = cfdata->show_graph;
|
c->conf->show_graph = cfdata->show_graph;
|
||||||
e_config_save_queue ();
|
e_config_save_queue();
|
||||||
if (c->face->monitor)
|
if (c->face->monitor)
|
||||||
ecore_timer_interval_set(c->face->monitor, (double)cfdata->check_interval);
|
ecore_timer_interval_set(c->face->monitor, (double)cfdata->check_interval);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
684
e_mod_main.c
684
e_mod_main.c
|
@ -3,35 +3,34 @@
|
||||||
#include "e_mod_config.h"
|
#include "e_mod_config.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
static Cpu *_cpu_init (E_Module *m);
|
static Cpu *_cpu_init(E_Module *m);
|
||||||
static void _cpu_shutdown (Cpu *n);
|
static void _cpu_shutdown(Cpu *n);
|
||||||
static void _cpu_config_menu_new (Cpu *n);
|
static void _cpu_config_menu_new(Cpu *n);
|
||||||
static int _cpu_face_init (Cpu_Face *cf);
|
static int _cpu_face_init(Cpu_Face *cf);
|
||||||
static void _cpu_face_menu_new (Cpu_Face *cf);
|
static void _cpu_face_menu_new(Cpu_Face *cf);
|
||||||
static void _cpu_face_enable (Cpu_Face *cf);
|
static void _cpu_face_enable(Cpu_Face *cf);
|
||||||
static void _cpu_face_disable (Cpu_Face *cf);
|
static void _cpu_face_disable(Cpu_Face *cf);
|
||||||
static void _cpu_face_free (Cpu_Face *cf);
|
static void _cpu_face_free(Cpu_Face *cf);
|
||||||
static void _cpu_face_cb_gmc_change (void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
|
static void _cpu_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
|
||||||
static void _cpu_face_cb_mouse_down (void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
static void _cpu_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||||
static void _cpu_face_cb_menu_edit (void *data, E_Menu *mn, E_Menu_Item *mi);
|
static void _cpu_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||||
static void _cpu_face_cb_menu_configure (void *data, E_Menu *mn, E_Menu_Item *mi);
|
static void _cpu_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||||
static int _cpu_face_update_values (void *data);
|
static int _cpu_face_update_values(void *data);
|
||||||
static int _cpu_face_get_cpu_count (Cpu_Face *cf);
|
static int _cpu_face_get_cpu_count(Cpu_Face *cf);
|
||||||
static void _cpu_face_get_load (Cpu_Face *cf);
|
static void _cpu_face_get_load(Cpu_Face *cf);
|
||||||
static void _cpu_face_graph_values (Cpu_Face *cf);
|
static void _cpu_face_graph_values(Cpu_Face *cf);
|
||||||
static void _cpu_face_graph_clear (Cpu_Face *cf);
|
static void _cpu_face_graph_clear(Cpu_Face *cf);
|
||||||
|
|
||||||
static int cpu_count;
|
static int cpu_count;
|
||||||
static int cpu_stats[4];
|
static int cpu_stats[4];
|
||||||
|
|
||||||
EAPI E_Module_Api e_modapi =
|
EAPI E_Module_Api e_modapi = {
|
||||||
{
|
|
||||||
E_MODULE_API_VERSION,
|
E_MODULE_API_VERSION,
|
||||||
"Cpu"
|
"Cpu"
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI void *
|
EAPI void *
|
||||||
e_modapi_init(E_Module *m)
|
e_modapi_init(E_Module *m)
|
||||||
{
|
{
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
|
|
||||||
|
@ -41,203 +40,207 @@ e_modapi_init(E_Module *m)
|
||||||
|
|
||||||
c = _cpu_init(m);
|
c = _cpu_init(m);
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
m->config_menu = c->config_menu;
|
m->config_menu = c->config_menu;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_shutdown(E_Module *m)
|
e_modapi_shutdown(E_Module *m)
|
||||||
{
|
{
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
|
|
||||||
c = m->data;
|
c = m->data;
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (m->config_menu)
|
if (m->config_menu)
|
||||||
{
|
{
|
||||||
e_menu_deactivate(m->config_menu);
|
e_menu_deactivate(m->config_menu);
|
||||||
e_object_del(E_OBJECT(m->config_menu));
|
e_object_del(E_OBJECT(m->config_menu));
|
||||||
m->config_menu = NULL;
|
m->config_menu = NULL;
|
||||||
}
|
}
|
||||||
if (c->cfd)
|
if (c->cfd)
|
||||||
{
|
{
|
||||||
e_object_del(E_OBJECT(c->cfd));
|
e_object_del(E_OBJECT(c->cfd));
|
||||||
c->cfd = NULL;
|
c->cfd = NULL;
|
||||||
}
|
}
|
||||||
_cpu_shutdown(c);
|
_cpu_shutdown(c);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_save(E_Module *m)
|
e_modapi_save(E_Module *m)
|
||||||
{
|
{
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
|
|
||||||
c = m->data;
|
c = m->data;
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
e_config_domain_save("module.cpu", c->conf_edd, c->conf);
|
e_config_domain_save("module.cpu", c->conf_edd, c->conf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_info(E_Module *m)
|
e_modapi_info(E_Module *m)
|
||||||
{
|
{
|
||||||
m->icon_file = strdup(PACKAGE_DATA_DIR"/module_icon.png");
|
m->icon_file = strdup(PACKAGE_DATA_DIR "/module_icon.png");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_about(E_Module *m)
|
e_modapi_about(E_Module *m)
|
||||||
{
|
{
|
||||||
e_module_dialog_show(D_("Enlightenment Cpu Monitor Module"),
|
e_module_dialog_show(D_("Enlightenment Cpu Monitor Module"), D_("This module is used to monitor a cpu."));
|
||||||
D_("This module is used to monitor a cpu."));
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_config(E_Module *m)
|
e_modapi_config(E_Module *m)
|
||||||
{
|
{
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
E_Container *con;
|
E_Container *con;
|
||||||
|
|
||||||
c = m->data;
|
c = m->data;
|
||||||
if (!c)
|
if (!c)
|
||||||
return 0;
|
return 0;
|
||||||
if (!c->face)
|
if (!c->face)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
con = e_container_current_get(e_manager_current_get());
|
con = e_container_current_get(e_manager_current_get());
|
||||||
if (c->face->con == con)
|
if (c->face->con == con)
|
||||||
_configure_cpu_module(con, c);
|
_configure_cpu_module(con, c);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Cpu *
|
static Cpu *
|
||||||
_cpu_init(E_Module *m)
|
_cpu_init(E_Module *m)
|
||||||
{
|
{
|
||||||
Cpu *c;
|
Cpu *c;
|
||||||
E_Menu_Item *mi;
|
E_Menu_Item *mi;
|
||||||
Evas_List *mans, *l, *l2;
|
Evas_List *mans, *l, *l2;
|
||||||
|
|
||||||
c = E_NEW(Cpu, 1);
|
c = E_NEW(Cpu, 1);
|
||||||
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
c->conf_edd = E_CONFIG_DD_NEW("Cpu_Config", Config);
|
c->conf_edd = E_CONFIG_DD_NEW("Cpu_Config", Config);
|
||||||
#undef T
|
#undef T
|
||||||
#undef D
|
#undef D
|
||||||
#define T Config
|
#define T Config
|
||||||
#define D c->conf_edd
|
#define D c->conf_edd
|
||||||
E_CONFIG_VAL(D, T, check_interval, INT);
|
E_CONFIG_VAL(D, T, check_interval, INT);
|
||||||
E_CONFIG_VAL(D, T, show_text, INT);
|
E_CONFIG_VAL(D, T, show_text, INT);
|
||||||
E_CONFIG_VAL(D, T, show_graph, INT);
|
E_CONFIG_VAL(D, T, show_graph, INT);
|
||||||
|
|
||||||
c->conf = e_config_domain_load("module.cpu", c->conf_edd);
|
c->conf = e_config_domain_load("module.cpu", c->conf_edd);
|
||||||
if (!c->conf)
|
if (!c->conf)
|
||||||
{
|
{
|
||||||
c->conf = E_NEW(Config, 1);
|
c->conf = E_NEW(Config, 1);
|
||||||
c->conf->check_interval = 1;
|
|
||||||
c->conf->show_text = 1;
|
c->conf->check_interval = 1;
|
||||||
c->conf->show_graph = 1;
|
c->conf->show_text = 1;
|
||||||
|
c->conf->show_graph = 1;
|
||||||
}
|
}
|
||||||
E_CONFIG_LIMIT(c->conf->check_interval, 0, 60);
|
E_CONFIG_LIMIT(c->conf->check_interval, 0, 60);
|
||||||
E_CONFIG_LIMIT(c->conf->show_text, 0, 1);
|
E_CONFIG_LIMIT(c->conf->show_text, 0, 1);
|
||||||
E_CONFIG_LIMIT(c->conf->show_graph, 0, 1);
|
E_CONFIG_LIMIT(c->conf->show_graph, 0, 1);
|
||||||
|
|
||||||
_cpu_config_menu_new(c);
|
_cpu_config_menu_new(c);
|
||||||
|
|
||||||
mans = e_manager_list();
|
mans = e_manager_list();
|
||||||
for (l = mans; l; l = l->next)
|
for (l = mans; l; l = l->next)
|
||||||
{
|
{
|
||||||
E_Manager *man;
|
E_Manager *man;
|
||||||
|
|
||||||
man = l->data;
|
man = l->data;
|
||||||
for (l2 = man->containers; l2; l2 = l2->next)
|
for (l2 = man->containers; l2; l2 = l2->next)
|
||||||
{
|
{
|
||||||
E_Container *con;
|
E_Container *con;
|
||||||
Cpu_Face *cf;
|
Cpu_Face *cf;
|
||||||
|
|
||||||
con = l2->data;
|
con = l2->data;
|
||||||
cf = E_NEW(Cpu_Face, 1);
|
cf = E_NEW(Cpu_Face, 1);
|
||||||
if (cf)
|
|
||||||
{
|
if (cf)
|
||||||
cf->conf_face_edd = E_CONFIG_DD_NEW("Cpu_Face_Config", Config_Face);
|
{
|
||||||
#undef T
|
cf->conf_face_edd = E_CONFIG_DD_NEW("Cpu_Face_Config", Config_Face);
|
||||||
#undef D
|
|
||||||
#define T Config_Face
|
#undef T
|
||||||
#define D cf->conf_face_edd
|
#undef D
|
||||||
E_CONFIG_VAL(D, T, enabled, UCHAR);
|
#define T Config_Face
|
||||||
|
#define D cf->conf_face_edd
|
||||||
c->face = cf;
|
E_CONFIG_VAL(D, T, enabled, UCHAR);
|
||||||
cf->cpu = c;
|
|
||||||
cf->con = con;
|
c->face = cf;
|
||||||
cf->evas = con->bg_evas;
|
cf->cpu = c;
|
||||||
|
cf->con = con;
|
||||||
cf->conf = E_NEW(Config_Face, 1);
|
cf->evas = con->bg_evas;
|
||||||
cf->conf->enabled = 1;
|
|
||||||
|
cf->conf = E_NEW(Config_Face, 1);
|
||||||
if (!_cpu_face_init(cf))
|
|
||||||
return NULL;
|
cf->conf->enabled = 1;
|
||||||
|
|
||||||
_cpu_face_menu_new(cf);
|
if (!_cpu_face_init(cf))
|
||||||
|
return NULL;
|
||||||
mi = e_menu_item_new(c->config_menu);
|
|
||||||
e_menu_item_label_set(mi, _("Configuration"));
|
_cpu_face_menu_new(cf);
|
||||||
e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
|
|
||||||
|
mi = e_menu_item_new(c->config_menu);
|
||||||
mi = e_menu_item_new(c->config_menu);
|
e_menu_item_label_set(mi, _("Configuration"));
|
||||||
e_menu_item_label_set(mi, con->name);
|
e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
|
||||||
e_menu_item_submenu_set(mi, cf->menu);
|
|
||||||
|
mi = e_menu_item_new(c->config_menu);
|
||||||
if (!cf->conf->enabled)
|
e_menu_item_label_set(mi, con->name);
|
||||||
_cpu_face_disable(cf);
|
e_menu_item_submenu_set(mi, cf->menu);
|
||||||
else
|
|
||||||
_cpu_face_enable(cf);
|
if (!cf->conf->enabled)
|
||||||
}
|
_cpu_face_disable(cf);
|
||||||
}
|
else
|
||||||
|
_cpu_face_enable(cf);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_shutdown(Cpu *c)
|
_cpu_shutdown(Cpu *c)
|
||||||
{
|
{
|
||||||
_cpu_face_free(c->face);
|
_cpu_face_free(c->face);
|
||||||
|
|
||||||
E_FREE(c->conf);
|
E_FREE(c->conf);
|
||||||
E_CONFIG_DD_FREE(c->conf_edd);
|
E_CONFIG_DD_FREE(c->conf_edd);
|
||||||
E_FREE(c);
|
E_FREE(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_config_menu_new(Cpu *c)
|
_cpu_config_menu_new(Cpu *c)
|
||||||
{
|
{
|
||||||
E_Menu *mn;
|
E_Menu *mn;
|
||||||
|
|
||||||
mn = e_menu_new();
|
mn = e_menu_new();
|
||||||
c->config_menu = mn;
|
c->config_menu = mn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cpu_face_init(Cpu_Face *cf)
|
_cpu_face_init(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
evas_event_freeze(cf->evas);
|
evas_event_freeze(cf->evas);
|
||||||
|
|
||||||
o = edje_object_add(cf->evas);
|
o = edje_object_add(cf->evas);
|
||||||
cf->cpu_obj = o;
|
cf->cpu_obj = o;
|
||||||
if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/main"))
|
if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/main"))
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/cpu.edj");
|
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/cpu.edj");
|
||||||
edje_object_file_set(o, buf, "modules/cpu/main");
|
edje_object_file_set(o, buf, "modules/cpu/main");
|
||||||
}
|
}
|
||||||
evas_object_pass_events_set(o, 1);
|
evas_object_pass_events_set(o, 1);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
|
@ -251,17 +254,17 @@ _cpu_face_init(Cpu_Face *cf)
|
||||||
|
|
||||||
o = edje_object_add(cf->evas);
|
o = edje_object_add(cf->evas);
|
||||||
cf->txt_obj = o;
|
cf->txt_obj = o;
|
||||||
if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/text"))
|
if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/text"))
|
||||||
{
|
{
|
||||||
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/cpu.edj");
|
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/cpu.edj");
|
||||||
edje_object_file_set(o, buf, "modules/cpu/text");
|
edje_object_file_set(o, buf, "modules/cpu/text");
|
||||||
}
|
}
|
||||||
evas_object_layer_set(o, 2);
|
evas_object_layer_set(o, 2);
|
||||||
evas_object_repeat_events_set(o, 0);
|
evas_object_repeat_events_set(o, 0);
|
||||||
evas_object_pass_events_set(o, 1);
|
evas_object_pass_events_set(o, 1);
|
||||||
evas_object_color_set(o, 255, 255, 255, 255);
|
evas_object_color_set(o, 255, 255, 255, 255);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
o = evas_object_rectangle_add(cf->evas);
|
o = evas_object_rectangle_add(cf->evas);
|
||||||
cf->event_obj = o;
|
cf->event_obj = o;
|
||||||
evas_object_layer_set(o, 3);
|
evas_object_layer_set(o, 3);
|
||||||
|
@ -269,21 +272,18 @@ _cpu_face_init(Cpu_Face *cf)
|
||||||
evas_object_color_set(o, 0, 0, 0, 0);
|
evas_object_color_set(o, 0, 0, 0, 0);
|
||||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _cpu_face_cb_mouse_down, cf);
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _cpu_face_cb_mouse_down, cf);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
|
|
||||||
cf->gmc = e_gadman_client_new(cf->con->gadman);
|
cf->gmc = e_gadman_client_new(cf->con->gadman);
|
||||||
e_gadman_client_domain_set(cf->gmc, "module.cpu", cpu_count++);
|
e_gadman_client_domain_set(cf->gmc, "module.cpu", cpu_count++);
|
||||||
e_gadman_client_policy_set(cf->gmc,
|
e_gadman_client_policy_set(cf->gmc,
|
||||||
E_GADMAN_POLICY_ANYWHERE |
|
E_GADMAN_POLICY_ANYWHERE |
|
||||||
E_GADMAN_POLICY_HMOVE |
|
E_GADMAN_POLICY_HMOVE | E_GADMAN_POLICY_HSIZE | E_GADMAN_POLICY_VMOVE | E_GADMAN_POLICY_VSIZE);
|
||||||
E_GADMAN_POLICY_HSIZE |
|
|
||||||
E_GADMAN_POLICY_VMOVE |
|
|
||||||
E_GADMAN_POLICY_VSIZE);
|
|
||||||
e_gadman_client_auto_size_set(cf->gmc, 45, 50);
|
e_gadman_client_auto_size_set(cf->gmc, 45, 50);
|
||||||
e_gadman_client_align_set(cf->gmc, 1.0, 1.0);
|
e_gadman_client_align_set(cf->gmc, 1.0, 1.0);
|
||||||
e_gadman_client_resize(cf->gmc, 45, 50);
|
e_gadman_client_resize(cf->gmc, 45, 50);
|
||||||
e_gadman_client_change_func_set(cf->gmc, _cpu_face_cb_gmc_change, cf);
|
e_gadman_client_change_func_set(cf->gmc, _cpu_face_cb_gmc_change, cf);
|
||||||
e_gadman_client_load(cf->gmc);
|
e_gadman_client_load(cf->gmc);
|
||||||
|
|
||||||
evas_event_thaw(cf->evas);
|
evas_event_thaw(cf->evas);
|
||||||
|
|
||||||
cf->monitor = ecore_timer_add((double)cf->cpu->conf->check_interval, _cpu_face_update_values, cf);
|
cf->monitor = ecore_timer_add((double)cf->cpu->conf->check_interval, _cpu_face_update_values, cf);
|
||||||
|
@ -291,138 +291,137 @@ _cpu_face_init(Cpu_Face *cf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_menu_new(Cpu_Face *cf)
|
_cpu_face_menu_new(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
E_Menu *mn;
|
E_Menu *mn;
|
||||||
E_Menu_Item *mi;
|
E_Menu_Item *mi;
|
||||||
|
|
||||||
mn = e_menu_new();
|
mn = e_menu_new();
|
||||||
cf->menu = mn;
|
cf->menu = mn;
|
||||||
|
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, _("Configuration"));
|
e_menu_item_label_set(mi, _("Configuration"));
|
||||||
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
|
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
|
||||||
e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
|
e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
|
||||||
|
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, _("Edit Mode"));
|
e_menu_item_label_set(mi, _("Edit Mode"));
|
||||||
e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
|
e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
|
||||||
e_menu_item_callback_set(mi, _cpu_face_cb_menu_edit, cf);
|
e_menu_item_callback_set(mi, _cpu_face_cb_menu_edit, cf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_enable(Cpu_Face *cf)
|
_cpu_face_enable(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
cf->conf->enabled = 1;
|
cf->conf->enabled = 1;
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
evas_object_show(cf->cpu_obj);
|
evas_object_show(cf->cpu_obj);
|
||||||
evas_object_show(cf->event_obj);
|
evas_object_show(cf->event_obj);
|
||||||
if (cf->cpu->conf->show_graph)
|
if (cf->cpu->conf->show_graph)
|
||||||
evas_object_show(cf->chart_obj);
|
evas_object_show(cf->chart_obj);
|
||||||
if (cf->cpu->conf->show_text)
|
if (cf->cpu->conf->show_text)
|
||||||
evas_object_show(cf->txt_obj);
|
evas_object_show(cf->txt_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_disable(Cpu_Face *cf)
|
_cpu_face_disable(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
cf->conf->enabled = 0;
|
cf->conf->enabled = 0;
|
||||||
e_config_save_queue();
|
e_config_save_queue();
|
||||||
evas_object_hide(cf->event_obj);
|
evas_object_hide(cf->event_obj);
|
||||||
evas_object_hide(cf->chart_obj);
|
evas_object_hide(cf->chart_obj);
|
||||||
evas_object_hide(cf->cpu_obj);
|
evas_object_hide(cf->cpu_obj);
|
||||||
evas_object_hide(cf->txt_obj);
|
evas_object_hide(cf->txt_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_free(Cpu_Face *cf)
|
_cpu_face_free(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
if (cf->monitor)
|
if (cf->monitor)
|
||||||
ecore_timer_del(cf->monitor);
|
ecore_timer_del(cf->monitor);
|
||||||
if (cf->menu)
|
if (cf->menu)
|
||||||
e_object_del(E_OBJECT(cf->menu));
|
e_object_del(E_OBJECT(cf->menu));
|
||||||
if (cf->event_obj)
|
if (cf->event_obj)
|
||||||
evas_object_del(cf->event_obj);
|
evas_object_del(cf->event_obj);
|
||||||
if (cf->cpu_obj)
|
if (cf->cpu_obj)
|
||||||
evas_object_del(cf->cpu_obj);
|
evas_object_del(cf->cpu_obj);
|
||||||
if (cf->old_values)
|
if (cf->old_values)
|
||||||
_cpu_face_graph_clear(cf);
|
_cpu_face_graph_clear(cf);
|
||||||
if (cf->chart_obj)
|
if (cf->chart_obj)
|
||||||
evas_object_del(cf->chart_obj);
|
evas_object_del(cf->chart_obj);
|
||||||
if (cf->txt_obj)
|
if (cf->txt_obj)
|
||||||
evas_object_del(cf->txt_obj);
|
evas_object_del(cf->txt_obj);
|
||||||
|
|
||||||
if (cf->gmc)
|
if (cf->gmc)
|
||||||
{
|
{
|
||||||
e_gadman_client_save(cf->gmc);
|
e_gadman_client_save(cf->gmc);
|
||||||
e_object_del(E_OBJECT(cf->gmc));
|
e_object_del(E_OBJECT(cf->gmc));
|
||||||
}
|
}
|
||||||
|
|
||||||
E_FREE(cf->conf);
|
E_FREE(cf->conf);
|
||||||
E_FREE(cf);
|
E_FREE(cf);
|
||||||
cpu_count--;
|
cpu_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
|
_cpu_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
|
||||||
{
|
{
|
||||||
Cpu_Face *cf;
|
Cpu_Face *cf;
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
cf = data;
|
|
||||||
switch (change)
|
|
||||||
{
|
|
||||||
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
|
||||||
e_gadman_client_geometry_get(cf->gmc, &x, &y, &w, &h);
|
|
||||||
evas_object_move(cf->chart_obj, x, y);
|
|
||||||
evas_object_move(cf->event_obj, x, y);
|
|
||||||
evas_object_move(cf->cpu_obj, x, y);
|
|
||||||
evas_object_move(cf->txt_obj, x, y);
|
|
||||||
evas_object_resize(cf->chart_obj, w, h);
|
|
||||||
evas_object_resize(cf->event_obj, w, h);
|
|
||||||
evas_object_resize(cf->cpu_obj, w, h);
|
|
||||||
evas_object_resize(cf->txt_obj, w, h);
|
|
||||||
_cpu_face_graph_clear(cf);
|
|
||||||
break;
|
|
||||||
case E_GADMAN_CHANGE_RAISE:
|
|
||||||
evas_object_raise(cf->cpu_obj);
|
|
||||||
evas_object_raise(cf->chart_obj);
|
|
||||||
evas_object_raise(cf->event_obj);
|
|
||||||
evas_object_raise(cf->txt_obj);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_cpu_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
|
||||||
{
|
|
||||||
Cpu_Face *cf;
|
|
||||||
Evas_Event_Mouse_Down *ev;
|
|
||||||
|
|
||||||
ev = event_info;
|
|
||||||
cf = data;
|
cf = data;
|
||||||
if (ev->button == 3)
|
switch (change)
|
||||||
{
|
{
|
||||||
e_menu_activate_mouse(cf->menu, e_zone_current_get(cf->con),
|
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
||||||
ev->output.x, ev->output.y, 1, 1,
|
e_gadman_client_geometry_get(cf->gmc, &x, &y, &w, &h);
|
||||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
evas_object_move(cf->chart_obj, x, y);
|
||||||
e_util_container_fake_mouse_up_all_later(cf->con);
|
evas_object_move(cf->event_obj, x, y);
|
||||||
|
evas_object_move(cf->cpu_obj, x, y);
|
||||||
|
evas_object_move(cf->txt_obj, x, y);
|
||||||
|
evas_object_resize(cf->chart_obj, w, h);
|
||||||
|
evas_object_resize(cf->event_obj, w, h);
|
||||||
|
evas_object_resize(cf->cpu_obj, w, h);
|
||||||
|
evas_object_resize(cf->txt_obj, w, h);
|
||||||
|
_cpu_face_graph_clear(cf);
|
||||||
|
break;
|
||||||
|
case E_GADMAN_CHANGE_RAISE:
|
||||||
|
evas_object_raise(cf->cpu_obj);
|
||||||
|
evas_object_raise(cf->chart_obj);
|
||||||
|
evas_object_raise(cf->event_obj);
|
||||||
|
evas_object_raise(cf->txt_obj);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi)
|
_cpu_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Cpu_Face *cf;
|
Cpu_Face *cf;
|
||||||
|
Evas_Event_Mouse_Down *ev;
|
||||||
|
|
||||||
|
ev = event_info;
|
||||||
|
cf = data;
|
||||||
|
if (ev->button == 3)
|
||||||
|
{
|
||||||
|
e_menu_activate_mouse(cf->menu, e_zone_current_get(cf->con),
|
||||||
|
ev->output.x, ev->output.y, 1, 1, E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||||
|
e_util_container_fake_mouse_up_all_later(cf->con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_cpu_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||||
|
{
|
||||||
|
Cpu_Face *cf;
|
||||||
|
|
||||||
cf = data;
|
cf = data;
|
||||||
e_gadman_mode_set(cf->gmc->gadman, E_GADMAN_MODE_EDIT);
|
e_gadman_mode_set(cf->gmc->gadman, E_GADMAN_MODE_EDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
_cpu_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||||
{
|
{
|
||||||
Cpu_Face *cf;
|
Cpu_Face *cf;
|
||||||
|
|
||||||
|
@ -430,8 +429,8 @@ _cpu_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||||
_configure_cpu_module(cf->con, cf->cpu);
|
_configure_cpu_module(cf->con, cf->cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cpu_face_update_values(void *data)
|
_cpu_face_update_values(void *data)
|
||||||
{
|
{
|
||||||
Cpu_Face *cf;
|
Cpu_Face *cf;
|
||||||
char str[100];
|
char str[100];
|
||||||
|
@ -440,53 +439,52 @@ _cpu_face_update_values(void *data)
|
||||||
|
|
||||||
cf = data;
|
cf = data;
|
||||||
_cpu_face_get_load(cf);
|
_cpu_face_get_load(cf);
|
||||||
|
|
||||||
if (cpu_stats[0] == -1)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (cf->cpu->conf->show_text)
|
if (cpu_stats[0] == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (cf->cpu->conf->show_text)
|
||||||
{
|
{
|
||||||
snprintf(str, sizeof(str), "%d%%", cpu_stats[0]);
|
snprintf(str, sizeof(str), "%d%%", cpu_stats[0]);
|
||||||
i = 1;
|
i = 1;
|
||||||
while (i < cpu_count)
|
while (i < cpu_count)
|
||||||
{
|
{
|
||||||
snprintf(str_tmp, sizeof(str_tmp), " / %d%%", cpu_stats[i]);
|
snprintf(str_tmp, sizeof(str_tmp), " / %d%%", cpu_stats[i]);
|
||||||
strncat(str, str_tmp, sizeof(str));
|
strncat(str, str_tmp, sizeof(str));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
edje_object_part_text_set(cf->txt_obj, "in-text", str);
|
edje_object_part_text_set(cf->txt_obj, "in-text", str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
edje_object_part_text_set(cf->txt_obj, "in-text", "");
|
edje_object_part_text_set(cf->txt_obj, "in-text", "");
|
||||||
|
|
||||||
if ((cf->cpu->conf->show_graph) &&
|
if ((cf->cpu->conf->show_graph) && (edje_object_part_exists(cf->cpu_obj, "lines")))
|
||||||
(edje_object_part_exists (cf->cpu_obj,"lines")))
|
_cpu_face_graph_values(cf);
|
||||||
_cpu_face_graph_values(cf);
|
else
|
||||||
else
|
_cpu_face_graph_clear(cf);
|
||||||
_cpu_face_graph_clear(cf);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cpu_face_get_cpu_count(Cpu_Face *cf)
|
_cpu_face_get_cpu_count(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
char tmp[4];
|
char tmp[4];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int cpu = -1;
|
int cpu = -1;
|
||||||
|
|
||||||
if (!(f = fopen("/proc/stat", "r")))
|
if (!(f = fopen("/proc/stat", "r")))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (fscanf(f, "cp%s %*u %*u %*u %*u %*u %*u %*u %*u\n", (char *)&tmp) == 1)
|
while (fscanf(f, "cp%s %*u %*u %*u %*u %*u %*u %*u %*u\n", (char *)&tmp) == 1)
|
||||||
cpu++;
|
cpu++;
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return cpu;
|
return cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_get_load(Cpu_Face *cf)
|
_cpu_face_get_load(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
static unsigned long old_u[4], old_n[4], old_s[4], old_i[4], old_wa[4], old_hi[4], old_si[4];
|
static unsigned long old_u[4], old_n[4], old_s[4], old_i[4], old_wa[4], old_hi[4], old_si[4];
|
||||||
unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 0, ticks_past;
|
unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 0, ticks_past;
|
||||||
|
@ -495,68 +493,67 @@ _cpu_face_get_load(Cpu_Face *cf)
|
||||||
FILE *stat;
|
FILE *stat;
|
||||||
int cpu_count;
|
int cpu_count;
|
||||||
Edje_Message_Float msg;
|
Edje_Message_Float msg;
|
||||||
|
|
||||||
cpu_count = _cpu_face_get_cpu_count(cf);
|
cpu_count = _cpu_face_get_cpu_count(cf);
|
||||||
if (cpu_count == -1)
|
if (cpu_count == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(stat = fopen("/proc/stat", "r")))
|
if (!(stat = fopen("/proc/stat", "r")))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (i < cpu_count)
|
while (i < cpu_count)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu", dummy,
|
|
||||||
&new_u, &new_n, &new_s, &new_i, &new_wa, &new_hi, &new_si) < 5)
|
|
||||||
{
|
|
||||||
fclose(stat);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ticks_past = ((new_u + new_n + new_s + new_i + new_wa + new_hi + new_si) -
|
if (fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu", dummy, &new_u, &new_n, &new_s, &new_i, &new_wa, &new_hi, &new_si) < 5)
|
||||||
(old_u[i] + old_n[i] + old_s[i] + old_i[i] + old_wa[i] + old_hi[i] + old_si[i]));
|
{
|
||||||
|
fclose(stat);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ticks_past)
|
ticks_past = ((new_u + new_n + new_s + new_i + new_wa + new_hi + new_si) -
|
||||||
{
|
(old_u[i] + old_n[i] + old_s[i] + old_i[i] + old_wa[i] + old_hi[i] + old_si[i]));
|
||||||
tmp_u = ((new_u - old_u[i]));
|
|
||||||
tmp_n = ((new_n - old_n[i]));
|
|
||||||
tmp_s = ((new_s - old_s[i]));
|
|
||||||
tmp_i = ((new_i - old_i[i]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmp_u = 0;
|
|
||||||
tmp_n = 0;
|
|
||||||
tmp_s = 0;
|
|
||||||
tmp_i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update the values */
|
if (ticks_past)
|
||||||
cpu_stats[i] = (tmp_u + tmp_n + tmp_s) / cpu_count;
|
{
|
||||||
|
tmp_u = ((new_u - old_u[i]));
|
||||||
old_u[i] = new_u;
|
tmp_n = ((new_n - old_n[i]));
|
||||||
old_n[i] = new_n;
|
tmp_s = ((new_s - old_s[i]));
|
||||||
old_s[i] = new_s;
|
tmp_i = ((new_i - old_i[i]));
|
||||||
old_i[i] = new_i;
|
}
|
||||||
old_wa[i] = new_wa;
|
else
|
||||||
old_hi[i] = new_hi;
|
{
|
||||||
old_si[i] = new_si;
|
tmp_u = 0;
|
||||||
|
tmp_n = 0;
|
||||||
|
tmp_s = 0;
|
||||||
|
tmp_i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (cpu_stats[i] >= 100)
|
/* Update the values */
|
||||||
cpu_stats[i] = 100;
|
cpu_stats[i] = (tmp_u + tmp_n + tmp_s) / cpu_count;
|
||||||
|
|
||||||
msg.val = cpu_stats[i];
|
old_u[i] = new_u;
|
||||||
edje_object_message_send(cf->cpu_obj, EDJE_MESSAGE_FLOAT, i, &msg);
|
old_n[i] = new_n;
|
||||||
|
old_s[i] = new_s;
|
||||||
i++;
|
old_i[i] = new_i;
|
||||||
}
|
old_wa[i] = new_wa;
|
||||||
fclose(stat);
|
old_hi[i] = new_hi;
|
||||||
|
old_si[i] = new_si;
|
||||||
|
|
||||||
|
if (cpu_stats[i] >= 100)
|
||||||
|
cpu_stats[i] = 100;
|
||||||
|
|
||||||
|
msg.val = cpu_stats[i];
|
||||||
|
edje_object_message_send(cf->cpu_obj, EDJE_MESSAGE_FLOAT, i, &msg);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
fclose(stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_graph_values(Cpu_Face *cf)
|
_cpu_face_graph_values(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
|
@ -570,90 +567,91 @@ _cpu_face_graph_values(Cpu_Face *cf)
|
||||||
int d = 0;
|
int d = 0;
|
||||||
|
|
||||||
evas_event_freeze(cf->evas);
|
evas_event_freeze(cf->evas);
|
||||||
|
|
||||||
evas_object_geometry_get(cf->chart_obj, &x, &y, &w, &h);
|
evas_object_geometry_get(cf->chart_obj, &x, &y, &w, &h);
|
||||||
|
|
||||||
while (d < cpu_count)
|
while (d < cpu_count)
|
||||||
{
|
{
|
||||||
v = (int)((double)cpu_stats[d] * ((double)h / (double)100));
|
v = (int)((double)cpu_stats[d] * ((double)h / (double)100));
|
||||||
o = evas_object_line_add(cf->evas);
|
o = evas_object_line_add(cf->evas);
|
||||||
edje_object_part_swallow(cf->chart_obj, "lines", o);
|
edje_object_part_swallow(cf->chart_obj, "lines", o);
|
||||||
evas_object_layer_set(o, 1);
|
evas_object_layer_set(o, 1);
|
||||||
if (cpu_stats[d] == 0)
|
if (cpu_stats[d] == 0)
|
||||||
evas_object_hide(o);
|
evas_object_hide(o);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) - v));
|
evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) - v));
|
||||||
switch (d)
|
switch (d)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
evas_object_color_set(o, a, b, b, c);
|
evas_object_color_set(o, a, b, b, c);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
evas_object_color_set(o, b, a, b, c);
|
evas_object_color_set(o, b, a, b, c);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
evas_object_color_set(o, b, b, a, c);
|
evas_object_color_set(o, b, b, a, c);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
evas_object_color_set(o, a, a, b, c);
|
evas_object_color_set(o, a, a, b, c);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
evas_object_pass_events_set(o, 1);
|
evas_object_pass_events_set(o, 1);
|
||||||
evas_object_show(o);
|
evas_object_show(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
cf->old_values[d] = evas_list_prepend(cf->old_values[d], o);
|
cf->old_values[d] = evas_list_prepend(cf->old_values[d], o);
|
||||||
l = cf->old_values[d];
|
l = cf->old_values[d];
|
||||||
for (i = (x + w); l && (j -2) < w; l = l->next, j++)
|
for (i = (x + w); l && (j - 2) < w; l = l->next, j++)
|
||||||
{
|
{
|
||||||
Evas_Coord oy;
|
Evas_Coord oy;
|
||||||
Evas_Object *lo;
|
Evas_Object *lo;
|
||||||
|
|
||||||
lo = (Evas_Object *)evas_list_data(l);
|
lo = (Evas_Object *)evas_list_data(l);
|
||||||
evas_object_geometry_get(lo, NULL, &oy, NULL, NULL);
|
evas_object_geometry_get(lo, NULL, &oy, NULL, NULL);
|
||||||
evas_object_move(lo, i--, oy);
|
evas_object_move(lo, i--, oy);
|
||||||
last = lo;
|
last = lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((j - 2) >= w)
|
if ((j - 2) >= w)
|
||||||
{
|
{
|
||||||
cf->old_values[d] = evas_list_remove(cf->old_values[d], last);
|
cf->old_values[d] = evas_list_remove(cf->old_values[d], last);
|
||||||
edje_object_part_unswallow(cf->chart_obj, last);
|
edje_object_part_unswallow(cf->chart_obj, last);
|
||||||
evas_object_del(last);
|
evas_object_del(last);
|
||||||
}
|
}
|
||||||
d++;
|
d++;
|
||||||
}
|
}
|
||||||
|
|
||||||
evas_event_thaw(cf->evas);
|
evas_event_thaw(cf->evas);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cpu_face_graph_clear(Cpu_Face *cf)
|
_cpu_face_graph_clear(Cpu_Face *cf)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
|
|
||||||
evas_event_freeze(cf->evas);
|
evas_event_freeze(cf->evas);
|
||||||
|
|
||||||
while (i < cpu_count)
|
while (i < cpu_count)
|
||||||
{
|
{
|
||||||
for (l = cf->old_values[i]; l; l = l->next)
|
for (l = cf->old_values[i]; l; l = l->next)
|
||||||
{
|
{
|
||||||
Evas_Object *o;
|
Evas_Object *o;
|
||||||
o = evas_list_data(l);
|
|
||||||
edje_object_part_unswallow(cf->chart_obj, o);
|
o = evas_list_data(l);
|
||||||
evas_object_del(o);
|
edje_object_part_unswallow(cf->chart_obj, o);
|
||||||
}
|
evas_object_del(o);
|
||||||
evas_list_free(cf->old_values[i]);
|
}
|
||||||
cf->old_values[i] = NULL;
|
evas_list_free(cf->old_values[i]);
|
||||||
i++;
|
cf->old_values[i] = NULL;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cf->cpu->conf->show_graph)
|
if (!cf->cpu->conf->show_graph)
|
||||||
evas_object_hide(cf->chart_obj);
|
evas_object_hide(cf->chart_obj);
|
||||||
|
|
||||||
evas_event_thaw(cf->evas);
|
evas_event_thaw(cf->evas);
|
||||||
}
|
}
|
||||||
|
|
30
e_mod_main.h
30
e_mod_main.h
|
@ -8,56 +8,56 @@ typedef struct _Config_Face Config_Face;
|
||||||
typedef struct _Cpu Cpu;
|
typedef struct _Cpu Cpu;
|
||||||
typedef struct _Cpu_Face Cpu_Face;
|
typedef struct _Cpu_Face Cpu_Face;
|
||||||
|
|
||||||
struct _Config
|
struct _Config
|
||||||
{
|
{
|
||||||
int check_interval;
|
int check_interval;
|
||||||
int show_text;
|
int show_text;
|
||||||
int show_graph;
|
int show_graph;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Config_Face
|
struct _Config_Face
|
||||||
{
|
{
|
||||||
unsigned char enabled;
|
unsigned char enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Cpu
|
struct _Cpu
|
||||||
{
|
{
|
||||||
E_Menu *config_menu;
|
E_Menu *config_menu;
|
||||||
Cpu_Face *face;
|
Cpu_Face *face;
|
||||||
Config *conf;
|
Config *conf;
|
||||||
|
|
||||||
E_Config_DD *conf_edd;
|
E_Config_DD *conf_edd;
|
||||||
E_Config_Dialog *cfd;
|
E_Config_Dialog *cfd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Cpu_Face
|
struct _Cpu_Face
|
||||||
{
|
{
|
||||||
Evas *evas;
|
Evas *evas;
|
||||||
E_Container *con;
|
E_Container *con;
|
||||||
E_Menu *menu;
|
E_Menu *menu;
|
||||||
Cpu *cpu;
|
Cpu *cpu;
|
||||||
Evas_List *old_values[4];
|
Evas_List *old_values[4];
|
||||||
|
|
||||||
Config_Face *conf;
|
Config_Face *conf;
|
||||||
E_Config_DD *conf_face_edd;
|
E_Config_DD *conf_face_edd;
|
||||||
|
|
||||||
Evas_Object *cpu_obj;
|
Evas_Object *cpu_obj;
|
||||||
Evas_Object *event_obj;
|
Evas_Object *event_obj;
|
||||||
Evas_Object *chart_obj;
|
Evas_Object *chart_obj;
|
||||||
Evas_Object *txt_obj;
|
Evas_Object *txt_obj;
|
||||||
|
|
||||||
Ecore_Timer *monitor;
|
Ecore_Timer *monitor;
|
||||||
|
|
||||||
E_Gadman_Client *gmc;
|
E_Gadman_Client *gmc;
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI extern E_Module_Api e_modapi;
|
EAPI extern E_Module_Api e_modapi;
|
||||||
|
|
||||||
EAPI void *e_modapi_init (E_Module *m);
|
EAPI void *e_modapi_init(E_Module *m);
|
||||||
EAPI int e_modapi_shutdown (E_Module *m);
|
EAPI int e_modapi_shutdown(E_Module *m);
|
||||||
EAPI int e_modapi_save (E_Module *m);
|
EAPI int e_modapi_save(E_Module *m);
|
||||||
EAPI int e_modapi_info (E_Module *m);
|
EAPI int e_modapi_info(E_Module *m);
|
||||||
EAPI int e_modapi_about (E_Module *m);
|
EAPI int e_modapi_about(E_Module *m);
|
||||||
EAPI int e_modapi_config (E_Module *m);
|
EAPI int e_modapi_config(E_Module *m);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue