Here's a patch for the cpu-module to make it play with the shelf.
I've changed the theme to look like the net and mem modules, the pngs
showing the meters can be downloaded here:
http://347.shit.la/pics.tar.gz
(renamed images from from net-module).
/Regards
Tobias Glenstrup
--- Makefile.am.orig 2006-06-29 06:59:33.000000000 +0200
+++ Makefile.am 2006-06-29 06:59:39.000000000 +0200
@@ -33,7 +33,7 @@
e_mod_config.c \
e_mod_config.h
-module_la_LIBADD = @e_libs@ -lm
+module_la_LIBADD = @e_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
--- cpu.edc.orig 2006-06-28 01:25:46.000000000 +0200
+++ cpu.edc 2006-06-30 00:45:34.000000000 +0200
@@ -1,6 +1,28 @@
images
{
image: "cpu.png" COMP;
+ image: "cpu_hi_00.png" COMP;
+ image: "cpu_hi_01.png" COMP;
+ image: "cpu_hi_02.png" COMP;
+ image: "cpu_hi_03.png" COMP;
+ image: "cpu_hi_04.png" COMP;
+ image: "cpu_hi_05.png" COMP;
+ image: "cpu_hi_06.png" COMP;
+ image: "cpu_hi_07.png" COMP;
+ image: "cpu_hi_08.png" COMP;
+ image: "cpu_hi_09.png" COMP;
+ image: "cpu_hi_10.png" COMP;
+ image: "cpu_lo_00.png" COMP;
+ image: "cpu_lo_01.png" COMP;
+ image: "cpu_lo_02.png" COMP;
+ image: "cpu_lo_03.png" COMP;
+ image: "cpu_lo_04.png" COMP;
+ image: "cpu_lo_05.png" COMP;
+ image: "cpu_lo_06.png" COMP;
+ image: "cpu_lo_07.png" COMP;
+ image: "cpu_lo_08.png" COMP;
+ image: "cpu_lo_09.png" COMP;
+ image: "cpu_lo_10.png" COMP;
}
fonts
@@ -13,125 +35,379 @@
group
{
name: "modules/cpu/main";
+ min: 4 4;
+ max: 128 128;
+ script
+ {
+ public message(Msg_Type:type, id, ...)
+ {
+ if ((type == MSG_INT_SET) && (id == 1))
+ {
+ new f = getarg(2);
+ new Float:value;
+
+ value = f;
+ value = (value / 50);
+ if (value >= 1.0)
+ {
+ set_state(PART:"cpu_lo_meter", "default", 1.0);
+ set_state(PART:"cpu_hi_meter", "default", value - 1.0);
+ }
+ else
+ {
+ set_state(PART:"cpu_hi_meter", "default", 0.0);
+ set_state(PART:"cpu_lo_meter", "default", value);
+ }
+
+ }
+ }
+ }
+
parts
{
part
{
- name: "fade_clip";
- type: RECT;
- mouse_events: 0;
+ name: "fade_clip";
+ type: RECT;
description
{
state: "default" 0.0;
color: 255 255 255 255;
+ rel1
+ {
+ relative: 0.0 0.0;
+ offset: 0 0;
+ }
+ rel2
+ {
+ relative: 1.0 1.0;
+ offset: -1 -1;
+ }
}
}
part
{
name: "cpu";
+ type: IMAGE;
clip_to: "fade_clip";
description
{
state: "default" 0.0;
aspect: 1.0 1.0;
- align: 0.5 0.5;
rel1
{
relative: 0.0 0.0;
+ offset: 0 0;
}
rel2
{
relative: 1.0 1.0;
+ offset: -1 -1;
}
image
{
normal: "cpu.png";
}
+ color: 255 255 255 192;
}
}
-
- part
+ part
{
- name, "lines";
- mouse_events, 0;
- type, SWALLOW;
- clip_to: "fade_clip";
- description
+ name: "cpu_label";
+ type: TEXT;
+ clip_to: "fade_clip";
+ effect: SOFT_SHADOW;
+ description
{
- state, "default" 0.0;
- rel1
+ state: "default" 0.0;
+ color: 255 255 255 0;
+ color3: 0 0 0 0;
+ visible: 0;
+ rel1
{
relative: 0.0 0.0;
+ offset: 0 0;
+ to: "cpu";
}
- rel2
+ rel2
{
relative: 1.0 1.0;
+ offset: 1 -1;
+ to: "cpu";
+ }
+ text
+ {
+ text: "XX%";
+ font: "VeraMono";
+ size: 9;
+ min: 1 1;
+ align: 0.5 0.5;
+ text_class: "module_normal";
}
- color, 0 0 0 0;
+ }
+ description
+ {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ color: 0 0 0 255;
+ color3: 255 255 255 42;
}
}
- }
- }
- //close group net
-
- group
- {
- name: "modules/cpu/text";
- parts
- {
part
{
- name: "text_clip";
- type: RECT;
- mouse_events: 0;
+ name: "cpu_hi_meter";
+ type: IMAGE;
+ clip_to: "fade_clip";
+
description
{
state: "default" 0.0;
- color: 255 255 255 255;
- rel1
+ rel1
{
relative: 0.0 0.0;
offset: 0 0;
}
- rel2
+ rel2
{
- relative: 1.0 1.0;
- offset: -1 -1;
+ relative: 1.0 0.25;
+ offset: -1 -1;
+ }
+ image
+ {
+ normal: "cpu_hi_00.png";
}
+ color: 255 255 255 192;
}
- }
+ description
+ {
+ state: "default" 0.1;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_01.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.2;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_02.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.3;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_03.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.4;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_04.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.5;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_05.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.6;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_06.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.7;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_07.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.8;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_08.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.9;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_09.png";
+ }
+ }
+ description
+ {
+ state: "default" 1.0;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_hi_10.png";
+ }
+ }
+ }
part
{
- name: "in-text";
- type: TEXT;
- effect: SOFT_SHADOW;
- mouse_events: 0;
- clip_to: "text_clip";
+ name: "cpu_lo_meter";
+ type: IMAGE;
+ clip_to: "fade_clip";
+
description
{
state: "default" 0.0;
- align: 0.5 0.5;
rel1
{
- relative: 0.5 0.5;
+ relative: 0.0 0.75;
+ offset: 0 0;
}
rel2
{
- relative: 0.5 0.5;
+ relative: 1.0 1.0;
+ offset: -1 -1;
}
- color: 0 0 0 255;
- color3: 255 255 255 100;
- text
+ image
{
- text: "";
- font: "VeraMono";
- size: 10;
- min: 1 1;
- align: 0.5 0.5;
+ normal: "cpu_lo_00.png";
+ }
+ color: 255 255 255 192;
+ }
+ description
+ {
+ state: "default" 0.1;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_01.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.2;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_02.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.3;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_03.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.4;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_04.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.5;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_05.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.6;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_06.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.7;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_07.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.8;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_08.png";
+ }
+ }
+ description
+ {
+ state: "default" 0.9;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_09.png";
+ }
+ }
+ description
+ {
+ state: "default" 1.0;
+ inherit: "default" 0.0;
+ image
+ {
+ normal: "cpu_lo_10.png";
}
}
}
+
+ }
+ programs
+ {
+ program
+ {
+ name: "go_active";
+ signal: "label_active";
+ source: "";
+ action: STATE_SET "visible" 0.0;
+ transition: SINUSOIDAL 0.5;
+ target: "cpu_label";
+ }
+ program
+ {
+ name: "go_passive";
+ signal: "label_passive";
+ source: "";
+ action: STATE_SET "default" 0.0;
+ transition: SINUSOIDAL 1.0;
+ target: "cpu_label";
+ }
}
}
}
-
--- e_mod_config.c.orig 2006-06-26 07:30:39.000000000 +0200
+++ e_mod_config.c 2006-06-29 06:49:00.000000000 +0200
@@ -1,28 +1,29 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
#include <e.h>
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
struct _E_Config_Dialog_Data
{
- int check_interval;
- int show_text;
- int show_graph;
+ int check_interval;
+ int always_text;
};
/* 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(Cpu *c, 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
-_configure_cpu_module(E_Container *con, Cpu *c)
+_config_cpu_module(Config_Item * ci)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
+ E_Container *con;
v = E_NEW(E_Config_Dialog_View, 1);
@@ -31,54 +32,53 @@
v->basic.apply_cfdata = _basic_apply_data;
v->basic.create_widgets = _basic_create_widgets;
- cfd = e_config_dialog_new(con, D_("Cpu Configuration"), NULL, 0, v, c);
- c->cfd = cfd;
+ con = e_container_current_get(e_manager_current_get());
+ cfd = e_config_dialog_new(con, D_("Cpu Configuration"), NULL, 0, v, ci);
+ cpu_config->config_dialog = cfd;
}
static void
-_fill_data(Cpu *c, E_Config_Dialog_Data *cfdata)
+_fill_data(Config_Item * ci, E_Config_Dialog_Data * cfdata)
{
- cfdata->check_interval = c->conf->check_interval;
- cfdata->show_text = c->conf->show_text;
- cfdata->show_graph = c->conf->show_graph;
+ cfdata->check_interval = ci->poll_time;
+ cfdata->always_text = ci->always_text;
}
static void *
-_create_data(E_Config_Dialog *cfd)
+_create_data(E_Config_Dialog * cfd)
{
E_Config_Dialog_Data *cfdata;
- Cpu *c;
+ Config_Item *ci;
- c = cfd->data;
+ ci = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
- _fill_data(c, 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)
{
- Cpu *c;
-
- c = cfd->data;
- c->cfd = NULL;
+ if (!cpu_config)
+ return;
+ cpu_config->config_dialog = NULL;
free(cfdata);
}
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;
- Cpu *c;
-
- c = cfd->data;
+ E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0);
- of = e_widget_framelist_add(evas, D_("Cpu Settings"), 0);
- ob = e_widget_check_add(evas, D_("Show Text"), (&(cfdata->show_text)));
+
+ 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_check_add(evas, D_("Show Graph"), (&(cfdata->show_graph)));
+ ob = e_widget_radio_add(evas, D_("Show Text On Mouse Over"), 0, rg);
e_widget_framelist_object_append(of, ob);
ob = e_widget_label_add(evas, D_("Check Interval:"));
@@ -91,18 +91,15 @@
}
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)
{
- char *tmp;
- Cpu *c;
+ Config_Item *ci;
- c = cfd->data;
- c->conf->check_interval = cfdata->check_interval;
- c->conf->show_text = cfdata->show_text;
- c->conf->show_graph = cfdata->show_graph;
+ ci = cfd->data;
+ ci->always_text = cfdata->always_text;
+ ci->poll_time = cfdata->check_interval;
e_config_save_queue();
- if (c->face->monitor)
- ecore_timer_interval_set(c->face->monitor, (double)cfdata->check_interval);
+ _cpu_config_updated(ci->id);
return 1;
}
--- e_mod_config.h.orig 2006-06-26 07:30:47.000000000 +0200
+++ e_mod_config.h 2006-06-28 01:10:05.000000000 +0200
@@ -5,7 +5,7 @@
#include "e_mod_main.h"
-void _configure_cpu_module(E_Container *con, Cpu *c);
+void _configure_cpu_module(E_Container * con, Cpu * c);
#endif
#endif
--- e_mod_main.c.orig 2006-06-26 07:30:17.000000000 +0200
+++ e_mod_main.c 2006-06-29 06:53:08.000000000 +0200
@@ -1,463 +1,396 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
#include <e.h>
#include "e_mod_main.h"
-#include "e_mod_config.h"
-#include "config.h"
+typedef struct _Instance Instance;
+typedef struct _Cpu Cpu;
-static Cpu *_cpu_init(E_Module *m);
-static void _cpu_shutdown(Cpu *n);
-static void _cpu_config_menu_new(Cpu *n);
-static int _cpu_face_init(Cpu_Face *cf);
-static void _cpu_face_menu_new(Cpu_Face *cf);
-static void _cpu_face_enable(Cpu_Face *cf);
-static void _cpu_face_disable(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_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_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
-static int _cpu_face_update_values(void *data);
-static int _cpu_face_get_cpu_count(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_clear(Cpu_Face *cf);
+struct _Instance
+{
+ E_Gadcon_Client *gcc;
+ Evas_Object *o_text;
+ Cpu *cpu;
+ Ecore_Timer *check_timer;
+ unsigned long old_u[4];
+ unsigned long old_n[4];
+ unsigned long old_s[4];
+ unsigned long old_i[4];
+ unsigned long old_wa[4];
+ unsigned long old_hi[4];
+ unsigned long old_si[4];
+};
+
+struct _Cpu
+{
+ Instance *inst;
+ Evas_Object *cpu_obj;
+};
+static void _cpu_update(void *data, int value);
+
+/* gadcon requirements */
+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);
+
+/* protos for module */
+static void _cpu_cb_mouse_down(void *data, Evas * evas, Evas_Object * obj, void *event_info);
+static void _cpu_cb_mouse_in(void *data, Evas * evas, Evas_Object * obj, void *event_info);
+static void _cpu_cb_mouse_out(void *data, Evas * evas, Evas_Object * obj, void *event_info);
+static void _cpu_menu_cb_post(void *data, E_Menu * m);
+static void _cpu_menu_cb_configure(void *data, E_Menu * mn, E_Menu_Item * mi);
+static void _cpu_get_load(Instance * inst);
+static int _cpu_update_values(void *data);
+static int _cpu_get_cpu_count(void);
+
+static Config_Item *_cpu_config_item_get(const char *id);
+static Cpu *_cpu_new(Evas * evas);
+static void _cpu_free(Cpu * cpu);
+
+static E_Config_DD *conf_edd = NULL;
+static E_Config_DD *conf_item_edd = NULL;
+
+Config *cpu_config = NULL;
static int cpu_count;
static int cpu_stats[4];
-EAPI E_Module_Api e_modapi = {
- E_MODULE_API_VERSION,
- "Cpu"
+static const E_Gadcon_Client_Class _gc_class = {
+ GADCON_CLIENT_CLASS_VERSION,
+ "cpu", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon}
};
-EAPI void *
-e_modapi_init(E_Module *m)
+static E_Gadcon_Client *
+_gc_init(E_Gadcon * gc, const char *name, const char *id, const char *style)
{
- Cpu *c;
+ E_Gadcon_Client *gcc;
+ Evas_Object *o;
+ Instance *inst;
+ Config_Item *ci;
+ Cpu *cpu;
- /* Set up module's message catalogue */
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, "UTF-8");
+ inst = E_NEW(Instance, 1);
- c = _cpu_init(m);
- if (!c)
- return NULL;
+ ci = _cpu_config_item_get(id);
+ if (!ci->id)
+ ci->id = evas_stringshare_add(id);
- return c;
-}
+ cpu = _cpu_new(gc->evas);
+ cpu->inst = inst;
+ inst->cpu = cpu;
-EAPI int
-e_modapi_shutdown(E_Module *m)
-{
- Cpu *c;
+ o = cpu->cpu_obj;
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+ inst->gcc = gcc;
+ inst->cpu->cpu_obj = o;
- c = m->data;
- if (!c)
- return 0;
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _cpu_cb_mouse_down, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _cpu_cb_mouse_in, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _cpu_cb_mouse_in, inst);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _cpu_cb_mouse_out, inst);
- if (c->cfd)
- {
- e_object_del(E_OBJECT(c->cfd));
- c->cfd = NULL;
- }
- _cpu_shutdown(c);
- return 1;
-}
+ if (ci->always_text)
+ edje_object_signal_emit(cpu->cpu_obj, "label_active", "");
+ else
+ edje_object_signal_emit(cpu->cpu_obj, "label_passive", "");
-EAPI int
-e_modapi_save(E_Module *m)
-{
- Cpu *c;
+ _cpu_update_values(inst);
- c = m->data;
- if (!c)
- return 0;
- e_config_domain_save("module.cpu", c->conf_edd, c->conf);
- return 1;
+ inst->check_timer = ecore_timer_add(ci->poll_time, _cpu_update_values, inst);
+ cpu_config->instances = evas_list_append(cpu_config->instances, inst);
+
+ return gcc;
}
-EAPI int
-e_modapi_about(E_Module *m)
+static void
+_gc_orient(E_Gadcon_Client * gcc)
{
- e_module_dialog_show(D_("Enlightenment Cpu Monitor Module"), D_("This module is used to monitor a cpu."));
- return 1;
+ e_gadcon_client_aspect_set(gcc, 16, 16);
+ e_gadcon_client_min_size_set(gcc, 16, 16);
}
-EAPI int
-e_modapi_config(E_Module *m)
+static char *
+_gc_label(void)
{
- Cpu *c;
- E_Container *con;
-
- c = m->data;
- if (!c)
- return 0;
- if (!c->face)
- return 0;
-
- con = e_container_current_get(e_manager_current_get());
- if (c->face->con == con)
- _configure_cpu_module(con, c);
-
- return 1;
+ return D_("Cpu");
}
-static Cpu *
-_cpu_init(E_Module *m)
+static Evas_Object *
+_gc_icon(Evas * evas)
{
- Cpu *c;
- E_Menu_Item *mi;
- Evas_List *mans, *l, *l2;
-
- c = E_NEW(Cpu, 1);
+ Evas_Object *o;
+ char buf[4096];
- if (!c)
- return NULL;
+ o = edje_object_add(evas);
+ snprintf(buf, sizeof(buf), "%s/module.eap", e_module_dir_get(cpu_config->module));
+ edje_object_file_set(o, buf, "icon");
+ return o;
+}
- c->conf_edd = E_CONFIG_DD_NEW("Cpu_Config", Config);
-#undef T
-#undef D
-#define T Config
-#define D c->conf_edd
- E_CONFIG_VAL(D, T, check_interval, INT);
- E_CONFIG_VAL(D, T, show_text, INT);
- E_CONFIG_VAL(D, T, show_graph, INT);
+static void
+_gc_shutdown(E_Gadcon_Client * gcc)
+{
+ Instance *inst;
- c->conf = e_config_domain_load("module.cpu", c->conf_edd);
- if (!c->conf)
- {
- c->conf = E_NEW(Config, 1);
+ inst = gcc->data;
- c->conf->check_interval = 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->show_text, 0, 1);
- E_CONFIG_LIMIT(c->conf->show_graph, 0, 1);
+ if (inst->check_timer)
+ ecore_timer_del(inst->check_timer);
+ cpu_config->instances = evas_list_remove(cpu_config->instances, inst);
- _cpu_config_menu_new(c);
+ evas_object_event_callback_del(inst->cpu->cpu_obj, EVAS_CALLBACK_MOUSE_DOWN, _cpu_cb_mouse_down);
+ evas_object_event_callback_del(inst->cpu->cpu_obj, EVAS_CALLBACK_MOUSE_IN, _cpu_cb_mouse_in);
+ evas_object_event_callback_del(inst->cpu->cpu_obj, EVAS_CALLBACK_MOUSE_MOVE, _cpu_cb_mouse_in);
+ evas_object_event_callback_del(inst->cpu->cpu_obj, EVAS_CALLBACK_MOUSE_OUT, _cpu_cb_mouse_out);
- mans = e_manager_list();
- for (l = mans; l; l = l->next)
- {
- E_Manager *man;
+ _cpu_free(inst->cpu);
+ free(inst);
+}
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
- {
- E_Container *con;
- Cpu_Face *cf;
+EAPI E_Module_Api e_modapi = {
+ E_MODULE_API_VERSION,
+ "Cpu"
+};
- con = l2->data;
- cf = E_NEW(Cpu_Face, 1);
+EAPI void *
+e_modapi_init(E_Module * m)
+{
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
- if (cf)
- {
- cf->conf_face_edd = E_CONFIG_DD_NEW("Cpu_Face_Config", Config_Face);
+ conf_item_edd = E_CONFIG_DD_NEW("Cpu_Config_Item", Config_Item);
#undef T
#undef D
-#define T Config_Face
-#define D cf->conf_face_edd
- E_CONFIG_VAL(D, T, enabled, UCHAR);
-
- c->face = cf;
- cf->cpu = c;
- cf->con = con;
- cf->evas = con->bg_evas;
-
- cf->conf = E_NEW(Config_Face, 1);
-
- cf->conf->enabled = 1;
+#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);
- if (!_cpu_face_init(cf))
- return NULL;
+ conf_edd = E_CONFIG_DD_NEW("Cpu_Config", Config);
- _cpu_face_menu_new(cf);
+#undef T
+#undef D
+#define T Config
+#define D conf_edd
+ E_CONFIG_LIST(D, T, items, conf_item_edd);
- mi = e_menu_item_new(c->config_menu);
- e_menu_item_label_set(mi, _("Configuration"));
- e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
+ cpu_config = e_config_domain_load("module.cpu", conf_edd);
+ if (!cpu_config)
+ {
+ Config_Item *ci;
- mi = e_menu_item_new(c->config_menu);
- e_menu_item_label_set(mi, con->name);
- e_menu_item_submenu_set(mi, cf->menu);
+ cpu_config = E_NEW(Config, 1);
+ ci = E_NEW(Config_Item, 1);
- if (!cf->conf->enabled)
- _cpu_face_disable(cf);
- else
- _cpu_face_enable(cf);
- }
- }
+ ci->id = evas_stringshare_add("0");
+ ci->poll_time = 1.0;
+ ci->always_text = 0;
+ cpu_config->items = evas_list_append(cpu_config->items, ci);
}
- return c;
+ cpu_config->module = m;
+ e_gadcon_provider_register(&_gc_class);
+ return 1;
}
-static void
-_cpu_shutdown(Cpu *c)
+EAPI int
+e_modapi_shutdown(E_Module * m)
{
- _cpu_face_free(c->face);
-
- E_FREE(c->conf);
- E_CONFIG_DD_FREE(c->conf_edd);
- E_FREE(c);
-}
+ cpu_config->module = NULL;
+ e_gadcon_provider_unregister(&_gc_class);
-static void
-_cpu_config_menu_new(Cpu *c)
-{
- E_Menu *mn;
+ if (cpu_config->config_dialog)
+ e_object_del(E_OBJECT(cpu_config->config_dialog));
+ if (cpu_config->menu)
+ {
+ e_menu_post_deactivate_callback_set(cpu_config->menu, NULL, NULL);
+ e_object_del(E_OBJECT(cpu_config->menu));
+ cpu_config->menu = NULL;
+ }
+ while (cpu_config->items)
+ {
+ Config_Item *ci;
- mn = e_menu_new();
- c->config_menu = mn;
+ ci = cpu_config->items->data;
+ cpu_config->items = evas_list_remove_list(cpu_config->items, cpu_config->items);
+ if (ci->id)
+ evas_stringshare_del(ci->id);
+ free(ci);
+ }
+ free(cpu_config);
+ cpu_config = NULL;
+ E_CONFIG_DD_FREE(conf_item_edd);
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-static int
-_cpu_face_init(Cpu_Face *cf)
+EAPI int
+e_modapi_save(E_Module * m)
{
- Evas_Object *o;
- char buf[4096];
-
- evas_event_freeze(cf->evas);
+ Evas_List *l;
- o = edje_object_add(cf->evas);
- cf->cpu_obj = o;
- if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/main"))
+ for (l = cpu_config->instances; l; l = l->next)
{
- snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/cpu.edj");
- edje_object_file_set(o, buf, "modules/cpu/main");
- }
- evas_object_pass_events_set(o, 1);
- evas_object_show(o);
-
- o = edje_object_add(cf->evas);
- cf->chart_obj = o;
- evas_object_layer_set(o, 1);
- evas_object_repeat_events_set(o, 0);
- evas_object_pass_events_set(o, 1);
- evas_object_color_set(o, 255, 255, 255, 255);
- evas_object_show(o);
+ Instance *inst;
+ Config_Item *ci;
- o = edje_object_add(cf->evas);
- cf->txt_obj = o;
- if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", "modules/cpu/text"))
- {
- snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR "/cpu.edj");
- edje_object_file_set(o, buf, "modules/cpu/text");
+ inst = l->data;
+ ci = _cpu_config_item_get(inst->gcc->id);
+ if (ci->id)
+ evas_stringshare_del(ci->id);
+ ci->id = evas_stringshare_add(inst->gcc->id);
}
- evas_object_layer_set(o, 2);
- evas_object_repeat_events_set(o, 0);
- evas_object_pass_events_set(o, 1);
- evas_object_color_set(o, 255, 255, 255, 255);
- evas_object_show(o);
-
- o = evas_object_rectangle_add(cf->evas);
- cf->event_obj = o;
- evas_object_layer_set(o, 3);
- evas_object_repeat_events_set(o, 1);
- 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_show(o);
-
- cf->gmc = e_gadman_client_new(cf->con->gadman);
- e_gadman_client_domain_set(cf->gmc, "module.cpu", cpu_count++);
- e_gadman_client_policy_set(cf->gmc,
- E_GADMAN_POLICY_ANYWHERE |
- E_GADMAN_POLICY_HMOVE | 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_align_set(cf->gmc, 1.0, 1.0);
- 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_load(cf->gmc);
-
- evas_event_thaw(cf->evas);
-
- cf->monitor = ecore_timer_add((double)cf->cpu->conf->check_interval, _cpu_face_update_values, cf);
+ e_config_domain_save("module.cpu", conf_edd, cpu_config);
return 1;
}
-static void
-_cpu_face_menu_new(Cpu_Face *cf)
+EAPI int
+e_modapi_about(E_Module * m)
{
- E_Menu *mn;
- E_Menu_Item *mi;
-
- mn = e_menu_new();
- cf->menu = mn;
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
- e_menu_item_callback_set(mi, _cpu_face_cb_menu_configure, cf);
-
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Edit Mode"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _cpu_face_cb_menu_edit, cf);
+ e_module_dialog_show(D_("Enlightenment Cpu Monitor Module"), D_("This module is used to monitor a cpu."));
+ return 1;
}
-static void
-_cpu_face_enable(Cpu_Face *cf)
+static Cpu *
+_cpu_new(Evas * evas)
{
- cf->conf->enabled = 1;
- e_config_save_queue();
- evas_object_show(cf->cpu_obj);
- evas_object_show(cf->event_obj);
- if (cf->cpu->conf->show_graph)
- evas_object_show(cf->chart_obj);
- if (cf->cpu->conf->show_text)
- evas_object_show(cf->txt_obj);
+ Cpu *cpu;
+ char buf[4096];
+
+ cpu = E_NEW(Cpu, 1);
+ cpu->cpu_obj = edje_object_add(evas);
+ snprintf(buf, sizeof(buf), "%s/cpu.edj", e_module_dir_get(cpu_config->module));
+ if (!e_theme_edje_object_set(cpu->cpu_obj, "base/theme/modules/cpu", "modules/cpu/main"))
+ edje_object_file_set(cpu->cpu_obj, buf, "modules/cpu/main");
+ evas_object_show(cpu->cpu_obj);
+ return cpu;
}
static void
-_cpu_face_disable(Cpu_Face *cf)
+_cpu_free(Cpu * cpu)
{
- cf->conf->enabled = 0;
- e_config_save_queue();
- evas_object_hide(cf->event_obj);
- evas_object_hide(cf->chart_obj);
- evas_object_hide(cf->cpu_obj);
- evas_object_hide(cf->txt_obj);
+ evas_object_del(cpu->cpu_obj);
+ free(cpu);
}
-
static void
-_cpu_face_free(Cpu_Face *cf)
+_cpu_cb_mouse_down(void *data, Evas * evas, Evas_Object * obj, void *event_info)
{
- if (cf->monitor)
- ecore_timer_del(cf->monitor);
- if (cf->menu)
- e_object_del(E_OBJECT(cf->menu));
- if (cf->event_obj)
- evas_object_del(cf->event_obj);
- if (cf->cpu_obj)
- evas_object_del(cf->cpu_obj);
- if (cf->old_values)
- _cpu_face_graph_clear(cf);
- if (cf->chart_obj)
- evas_object_del(cf->chart_obj);
- if (cf->txt_obj)
- evas_object_del(cf->txt_obj);
+ Evas_Event_Mouse_Down *ev;
+ Instance *inst;
- if (cf->gmc)
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!cpu_config->menu))
{
- e_gadman_client_save(cf->gmc);
- e_object_del(E_OBJECT(cf->gmc));
- }
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int x, y, w, h;
- E_FREE(cf->conf);
- E_FREE(cf);
- cpu_count--;
-}
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _cpu_menu_cb_post, inst);
+ cpu_config->menu = mn;
-static void
-_cpu_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
-{
- Cpu_Face *cf;
- Evas_Coord x, y, w, h;
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _cpu_menu_cb_configure, inst);
- 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;
+ 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
-_cpu_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+_cpu_cb_mouse_in(void *data, Evas * evas, Evas_Object * obj, void *event_info)
{
- Cpu_Face *cf;
- Evas_Event_Mouse_Down *ev;
+ Instance *inst;
- 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);
- }
+ inst = data;
+ edje_object_signal_emit(inst->cpu->cpu_obj, "label_active", "");
}
-
static void
-_cpu_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi)
+_cpu_cb_mouse_out(void *data, Evas * evas, Evas_Object * obj, void *event_info)
{
- Cpu_Face *cf;
+ Instance *inst;
+ Config_Item *ci;
- cf = data;
- e_gadman_mode_set(cf->gmc->gadman, E_GADMAN_MODE_EDIT);
+ inst = data;
+ ci = _cpu_config_item_get(inst->gcc->id);
+ if (!ci->always_text)
+ edje_object_signal_emit(inst->cpu->cpu_obj, "label_passive", "");
+}
+static void
+_cpu_menu_cb_post(void *data, E_Menu * m)
+{
+ if (!cpu_config->menu)
+ return;
+ e_object_del(E_OBJECT(cpu_config->menu));
+ cpu_config->menu = NULL;
}
static void
-_cpu_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
+_cpu_menu_cb_configure(void *data, E_Menu * mn, E_Menu_Item * mi)
{
- Cpu_Face *cf;
+ Instance *inst;
+ Config_Item *ci;
- cf = data;
- _configure_cpu_module(cf->con, cf->cpu);
+ inst = data;
+
+ if (!inst)
+ return;
+
+ ci = _cpu_config_item_get(inst->gcc->id);
+ _config_cpu_module(ci);
}
static int
-_cpu_face_update_values(void *data)
+_cpu_update_values(void *data)
{
- Cpu_Face *cf;
+ Instance *inst;
char str[100];
- int i = 0;
+ int i = 0;
char str_tmp[100];
- cf = data;
- _cpu_face_get_load(cf);
+ inst = data;
- if (cpu_stats[0] == -1)
- return 1;
+ _cpu_get_load(inst);
- if (cf->cpu->conf->show_text)
+ if (cpu_stats[0] == -1)
{
- snprintf(str, sizeof(str), "%d%%", cpu_stats[0]);
- i = 1;
- while (i < cpu_count)
- {
- snprintf(str_tmp, sizeof(str_tmp), " / %d%%", cpu_stats[i]);
- strncat(str, str_tmp, sizeof(str));
- i++;
- }
- edje_object_part_text_set(cf->txt_obj, "in-text", str);
+ return 1;
}
- else
- edje_object_part_text_set(cf->txt_obj, "in-text", "");
- if ((cf->cpu->conf->show_graph) && (edje_object_part_exists(cf->cpu_obj, "lines")))
- _cpu_face_graph_values(cf);
- else
- _cpu_face_graph_clear(cf);
+ snprintf(str, sizeof(str), "%d%%", cpu_stats[0]);
+ i = 1;
+ while (i < cpu_count + 1)
+ {
+ snprintf(str_tmp, sizeof(str_tmp), " / %d%%", cpu_stats[i]);
+ strncat(str, str_tmp, sizeof(str));
+ i++;
+ }
+ edje_object_part_text_set(inst->cpu->cpu_obj, "cpu_label", str);
+ _cpu_update(inst, cpu_stats[0]);
return 1;
}
static int
-_cpu_face_get_cpu_count(Cpu_Face *cf)
+_cpu_get_cpu_count(void)
{
char tmp[4];
FILE *f;
- int cpu = -1;
+ int cpu = -1;
if (!(f = fopen("/proc/stat", "r")))
return -1;
@@ -470,174 +403,136 @@
}
static void
-_cpu_face_get_load(Cpu_Face *cf)
+_cpu_get_load(Instance * inst)
{
- static unsigned long old_u[4], old_n[4], old_s[4], old_i[4], old_wa[4], old_hi[4], old_si[4];
+ Config_Item *ci;
unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 0, ticks_past;
- int tmp_u, tmp_n, tmp_s, tmp_i;
+ int tmp_u, tmp_n, tmp_s, tmp_i;
char dummy[16];
FILE *stat;
- int cpu_count;
- Edje_Message_Float msg;
+ int cpu_count;
+ int i = 0;
- cpu_count = _cpu_face_get_cpu_count(cf);
+ cpu_count = _cpu_get_cpu_count();
if (cpu_count == -1)
return;
if (!(stat = fopen("/proc/stat", "r")))
return;
- int i = 0;
+ ci = _cpu_config_item_get(inst->gcc->id);
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) -
- (old_u[i] + old_n[i] + old_s[i] + old_i[i] + old_wa[i] + old_hi[i] + old_si[i]));
+ 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;
+ }
- if (ticks_past)
- {
- 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;
- }
+ ticks_past =
+ ((new_u + new_n + new_s + new_i + new_wa + new_hi + new_si) -
+ (inst->old_u[i] + inst->old_n[i] + inst->old_s[i] + inst->old_i[i] + inst->old_wa[i] + inst->old_hi[i] + inst->old_si[i]));
- /* Update the values */
- cpu_stats[i] = (tmp_u + tmp_n + tmp_s) / cpu_count;
+ if (ticks_past)
+ {
+ tmp_u = ((new_u - inst->old_u[i]));
+ tmp_n = ((new_n - inst->old_n[i]));
+ tmp_s = ((new_s - inst->old_s[i]));
+ tmp_i = ((new_i - inst->old_i[i]));
+ }
+ else
+ {
+ tmp_u = 0;
+ tmp_n = 0;
+ tmp_s = 0;
+ tmp_i = 0;
+ }
- old_u[i] = new_u;
- old_n[i] = new_n;
- old_s[i] = new_s;
- old_i[i] = new_i;
- old_wa[i] = new_wa;
- old_hi[i] = new_hi;
- old_si[i] = new_si;
+ /* Update the values */
+ cpu_stats[i] = ((tmp_u + tmp_n + tmp_s) / cpu_count) / ci->poll_time;
- if (cpu_stats[i] >= 100)
- cpu_stats[i] = 100;
+ inst->old_u[i] = new_u;
+ inst->old_n[i] = new_n;
+ inst->old_s[i] = new_s;
+ inst->old_i[i] = new_i;
+ inst->old_wa[i] = new_wa;
+ inst->old_hi[i] = new_hi;
+ inst->old_si[i] = new_si;
- msg.val = cpu_stats[i];
- edje_object_message_send(cf->cpu_obj, EDJE_MESSAGE_FLOAT, i, &msg);
+ if (cpu_stats[i] >= 100)
+ cpu_stats[i] = 100;
- i++;
+ i++;
}
fclose(stat);
}
-static void
-_cpu_face_graph_values(Cpu_Face *cf)
+void
+_cpu_config_updated(const char *id)
{
- int x, y, w, h;
- Evas_Object *o;
- Evas_Object *last = NULL;
Evas_List *l;
- int i, j = 0;
- int v;
- int a = 255;
- int b = 0;
- int c = 100;
- int d = 0;
-
- evas_event_freeze(cf->evas);
-
- evas_object_geometry_get(cf->chart_obj, &x, &y, &w, &h);
+ Config_Item *ci;
- while (d < cpu_count)
+ if (!cpu_config)
+ return;
+ ci = _cpu_config_item_get(id);
+ for (l = cpu_config->instances; l; l = l->next)
{
- v = (int)((double)cpu_stats[d] * ((double)h / (double)100));
- o = evas_object_line_add(cf->evas);
- edje_object_part_swallow(cf->chart_obj, "lines", o);
- evas_object_layer_set(o, 1);
- if (cpu_stats[d] == 0)
- evas_object_hide(o);
- else
- {
- evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) - v));
- switch (d)
- {
- case 0:
- evas_object_color_set(o, a, b, b, c);
- break;
- case 1:
- evas_object_color_set(o, b, a, b, c);
- break;
- case 2:
- evas_object_color_set(o, b, b, a, c);
- break;
- case 3:
- evas_object_color_set(o, a, a, b, c);
- break;
- default:
- break;
- }
- evas_object_pass_events_set(o, 1);
- evas_object_show(o);
- }
-
- cf->old_values[d] = evas_list_prepend(cf->old_values[d], o);
- l = cf->old_values[d];
- for (i = (x + w); l && (j - 2) < w; l = l->next, j++)
- {
- Evas_Coord oy;
- Evas_Object *lo;
+ Instance *inst;
- lo = (Evas_Object *)evas_list_data(l);
- evas_object_geometry_get(lo, NULL, &oy, NULL, NULL);
- evas_object_move(lo, i--, oy);
- last = lo;
- }
+ inst = l->data;
+ if (!inst->gcc->id)
+ continue;
- if ((j - 2) >= w)
- {
- cf->old_values[d] = evas_list_remove(cf->old_values[d], last);
- edje_object_part_unswallow(cf->chart_obj, last);
- evas_object_del(last);
- }
- d++;
+ 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, _cpu_update_values, inst);
+ if (ci->always_text)
+ edje_object_signal_emit(inst->cpu->cpu_obj, "label_active", "");
+ else
+ edje_object_signal_emit(inst->cpu->cpu_obj, "label_passive", "");
+ break;
+ }
}
-
- evas_event_thaw(cf->evas);
}
-static void
-_cpu_face_graph_clear(Cpu_Face *cf)
+static Config_Item *
+_cpu_config_item_get(const char *id)
{
- int i = 0;
Evas_List *l;
+ Config_Item *ci;
- evas_event_freeze(cf->evas);
-
- while (i < cpu_count)
+ for (l = cpu_config->items; l; l = l->next)
{
- for (l = cf->old_values[i]; l; l = l->next)
- {
- Evas_Object *o;
-
- o = evas_list_data(l);
- edje_object_part_unswallow(cf->chart_obj, o);
- evas_object_del(o);
- }
- evas_list_free(cf->old_values[i]);
- cf->old_values[i] = NULL;
- i++;
+ ci = l->data;
+ if (!ci->id)
+ continue;
+ if (!strcmp(ci->id, id))
+ return ci;
}
- if (!cf->cpu->conf->show_graph)
- evas_object_hide(cf->chart_obj);
+ ci = E_NEW(Config_Item, 1);
+ ci->id = evas_stringshare_add(id);
+ ci->poll_time = 1.0;
+ ci->always_text = 0;
+ cpu_config->items = evas_list_append(cpu_config->items, ci);
+ return ci;
+}
- evas_event_thaw(cf->evas);
+static void
+_cpu_update(void *data, int value)
+{
+ Edje_Message_Int_Set val;
+ Instance *inst;
+
+ inst = data;
+ val.count = 1;
+ val.val[0] = value;
+ edje_object_message_send(inst->cpu->cpu_obj, EDJE_MESSAGE_INT_SET, 1, &val);
}
--- e_mod_main.h.orig 2006-06-26 07:30:13.000000000 +0200
+++ e_mod_main.h 2006-06-28 01:10:08.000000000 +0200
@@ -4,59 +4,33 @@
#define E_MOD_MAIN_H
typedef struct _Config Config;
-typedef struct _Config_Face Config_Face;
-typedef struct _Cpu Cpu;
-typedef struct _Cpu_Face Cpu_Face;
+typedef struct _Config_Item Config_Item;
struct _Config
{
- int check_interval;
- int show_text;
- int show_graph;
-};
-
-struct _Config_Face
-{
- unsigned char enabled;
-};
-
-struct _Cpu
-{
- E_Menu *config_menu;
- Cpu_Face *face;
- Config *conf;
-
- E_Config_DD *conf_edd;
- E_Config_Dialog *cfd;
+ E_Module *module;
+ E_Config_Dialog *config_dialog;
+ E_Menu *menu;
+ Evas_List *instances;
+ Evas_List *items;
};
-struct _Cpu_Face
+struct _Config_Item
{
- Evas *evas;
- E_Container *con;
- E_Menu *menu;
- Cpu *cpu;
- Evas_List *old_values[4];
-
- Config_Face *conf;
- E_Config_DD *conf_face_edd;
-
- Evas_Object *cpu_obj;
- Evas_Object *event_obj;
- Evas_Object *chart_obj;
- Evas_Object *txt_obj;
-
- Ecore_Timer *monitor;
-
- E_Gadman_Client *gmc;
+ const char *id;
+ double poll_time;
+ int always_text;
};
EAPI extern E_Module_Api e_modapi;
-EAPI void *e_modapi_init(E_Module *m);
-EAPI int e_modapi_shutdown(E_Module *m);
-EAPI int e_modapi_save(E_Module *m);
-EAPI int e_modapi_about(E_Module *m);
-EAPI int e_modapi_config(E_Module *m);
+EAPI void *e_modapi_init(E_Module * m);
+EAPI int e_modapi_shutdown(E_Module * m);
+EAPI int e_modapi_save(E_Module * m);
+EAPI int e_modapi_about(E_Module * m);
+
+void _cpu_config_updated(const char *id);
+void _config_cpu_module(Config_Item * ci);
+extern Config *cpu_config;
#endif
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel