summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen 'Okra' Houston <smhouston88@gmail.com>2017-01-26 14:06:56 -0600
committerStephen 'Okra' Houston <smhouston88@gmail.com>2017-01-26 14:06:56 -0600
commitc06e36fa2a7261e96977ae4ff826b0d39f7233eb (patch)
treefd2205e5e965852949cc918fbc0b0bb95607d933
parentf1b0cfcdea44530db581463b941518cd4bfdd792 (diff)
Enlightenment: Sysinfo Gadget - Show real time data in popups and fix sizing of memusage and cpumonitor.
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor.c70
-rw-r--r--src/modules/sysinfo/memusage/memusage.c62
-rw-r--r--src/modules/sysinfo/netstatus/netstatus.c8
-rw-r--r--src/modules/sysinfo/sysinfo.h3
4 files changed, 54 insertions, 89 deletions
diff --git a/src/modules/sysinfo/cpumonitor/cpumonitor.c b/src/modules/sysinfo/cpumonitor/cpumonitor.c
index 187dbb448..4fb54320d 100644
--- a/src/modules/sysinfo/cpumonitor/cpumonitor.c
+++ b/src/modules/sysinfo/cpumonitor/cpumonitor.c
@@ -26,6 +26,12 @@ _cpumonitor_face_update(Instance *inst)
26 usage_msg); 26 usage_msg);
27 free(usage_msg); 27 free(usage_msg);
28 } 28 }
29 if (inst->cfg->cpumonitor.popup)
30 {
31 char text[4096];
32 snprintf(text, sizeof(text), "%s: %d%%", _("Total CPU Usage"), inst->cfg->cpumonitor.percent);
33 elm_object_text_set(inst->cfg->cpumonitor.popup_label, text);
34 }
29} 35}
30 36
31static Evas_Object * 37static Evas_Object *
@@ -81,7 +87,8 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
81 elm_object_text_set(label, text); 87 elm_object_text_set(label, text);
82 elm_object_content_set(popup, label); 88 elm_object_content_set(popup, label);
83 evas_object_show(label); 89 evas_object_show(label);
84 90 inst->cfg->cpumonitor.popup_label = label;
91
85 e_comp_object_util_autoclose(popup, NULL, NULL, NULL); 92 e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
86 evas_object_show(popup); 93 evas_object_show(popup);
87 e_gadget_util_ctxpopup_place(inst->o_main, popup, inst->cfg->cpumonitor.o_gadget); 94 e_gadget_util_ctxpopup_place(inst->o_main, popup, inst->cfg->cpumonitor.o_gadget);
@@ -104,6 +111,16 @@ _cpumonitor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
104} 111}
105 112
106static void 113static void
114_cpumonitor_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
115{
116 Evas_Coord w, h;
117 Instance *inst = data;
118
119 evas_object_geometry_get(inst->cfg->cpumonitor.o_gadget, 0, 0, &w, &h);
120 evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
121}
122
123static void
107_cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th) 124_cpumonitor_cb_usage_check_main(void *data, Ecore_Thread *th)
108{ 125{
109 Thread_Config *thc = data; 126 Thread_Config *thc = data;
@@ -244,52 +261,6 @@ sysinfo_cpumonitor_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
244} 261}
245 262
246static void 263static void
247_cpumonitor_eval_instance_aspect(Instance *inst)
248{
249 Evas_Coord w, h;
250 Evas_Coord sw = 1, sh = 1;
251 Evas_Object *owner, *ed;
252 CPU_Core *first_core;
253 int num_cores = eina_list_count(inst->cfg->cpumonitor.cores);
254
255 if (num_cores < 1)
256 return;
257
258 if (!inst->o_main)
259 return;
260
261 owner = e_gadget_site_get(inst->o_main);
262 if (!owner)
263 return;
264
265 switch (e_gadget_site_orient_get(owner))
266 {
267 case E_GADGET_SITE_ORIENT_HORIZONTAL:
268 case E_GADGET_SITE_ORIENT_NONE:
269 evas_object_geometry_get(owner, NULL, NULL, NULL, &sh);
270 break;
271
272 case E_GADGET_SITE_ORIENT_VERTICAL:
273 evas_object_geometry_get(owner, NULL, NULL, &sw, NULL);
274 break;
275
276 default:
277 sw = sh = 48;
278 break;
279 }
280
281 first_core = eina_list_nth(inst->cfg->cpumonitor.cores, 0);
282 evas_object_resize(first_core->layout, sw, sh);
283 ed = elm_layout_edje_get(first_core->layout);
284 edje_object_parts_extends_calc(ed, NULL, NULL, &w, &h);
285 if (e_gadget_site_orient_get(owner) == E_GADGET_SITE_ORIENT_VERTICAL)
286 h *= num_cores;
287 else
288 w *= num_cores;
289 evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
290}
291
292static void
293_cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) 264_cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
294{ 265{
295 Instance *inst = data; 266 Instance *inst = data;
@@ -299,6 +270,7 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
299 270
300 inst->cfg->cpumonitor.o_gadget = elm_box_add(inst->o_main); 271 inst->cfg->cpumonitor.o_gadget = elm_box_add(inst->o_main);
301 elm_box_padding_set(inst->cfg->cpumonitor.o_gadget, 0, 0); 272 elm_box_padding_set(inst->cfg->cpumonitor.o_gadget, 0, 0);
273 elm_box_homogeneous_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
302 if (orient == E_GADGET_SITE_ORIENT_VERTICAL) 274 if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
303 elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_FALSE); 275 elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_FALSE);
304 else 276 else
@@ -307,10 +279,10 @@ _cpumonitor_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSE
307 E_FILL(inst->cfg->cpumonitor.o_gadget); 279 E_FILL(inst->cfg->cpumonitor.o_gadget);
308 elm_box_pack_end(inst->o_main, inst->cfg->cpumonitor.o_gadget); 280 elm_box_pack_end(inst->o_main, inst->cfg->cpumonitor.o_gadget);
309 evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst); 281 evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst);
282 evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_RESIZE, _cpumonitor_resize_cb, inst);
310 evas_object_show(inst->cfg->cpumonitor.o_gadget); 283 evas_object_show(inst->cfg->cpumonitor.o_gadget);
311 evas_object_smart_callback_del_full(obj, "gadget_created", _cpumonitor_created_cb, data); 284 evas_object_smart_callback_del_full(obj, "gadget_created", _cpumonitor_created_cb, data);
312 _cpumonitor_config_updated(inst); 285 _cpumonitor_config_updated(inst);
313 _cpumonitor_eval_instance_aspect(inst);
314} 286}
315 287
316Evas_Object * 288Evas_Object *
@@ -318,12 +290,12 @@ sysinfo_cpumonitor_create(Evas_Object *parent, Instance *inst)
318{ 290{
319 inst->cfg->cpumonitor.o_gadget = elm_box_add(parent); 291 inst->cfg->cpumonitor.o_gadget = elm_box_add(parent);
320 elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE); 292 elm_box_horizontal_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
293 elm_box_homogeneous_set(inst->cfg->cpumonitor.o_gadget, EINA_TRUE);
321 E_EXPAND(inst->cfg->cpumonitor.o_gadget); 294 E_EXPAND(inst->cfg->cpumonitor.o_gadget);
322 E_FILL(inst->cfg->cpumonitor.o_gadget); 295 E_FILL(inst->cfg->cpumonitor.o_gadget);
323 evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst); 296 evas_object_event_callback_add(inst->cfg->cpumonitor.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _cpumonitor_mouse_down_cb, inst);
324 evas_object_show(inst->cfg->cpumonitor.o_gadget); 297 evas_object_show(inst->cfg->cpumonitor.o_gadget);
325 _cpumonitor_config_updated(inst); 298 _cpumonitor_config_updated(inst);
326 _cpumonitor_eval_instance_aspect(inst);
327 299
328 return inst->cfg->cpumonitor.o_gadget; 300 return inst->cfg->cpumonitor.o_gadget;
329} 301}
diff --git a/src/modules/sysinfo/memusage/memusage.c b/src/modules/sysinfo/memusage/memusage.c
index c8b1008db..895cfbbcd 100644
--- a/src/modules/sysinfo/memusage/memusage.c
+++ b/src/modules/sysinfo/memusage/memusage.c
@@ -23,6 +23,14 @@ _memusage_face_update(Instance *inst, int mem, int swap)
23 edje_object_message_send(elm_layout_edje_get(inst->cfg->memusage.o_gadget), 23 edje_object_message_send(elm_layout_edje_get(inst->cfg->memusage.o_gadget),
24 EDJE_MESSAGE_INT_SET, 1, msg); 24 EDJE_MESSAGE_INT_SET, 1, msg);
25 free(msg); 25 free(msg);
26
27 if (inst->cfg->memusage.popup)
28 {
29 char text[4096];
30 snprintf(text, sizeof(text), "%s: %d%%<br>%s: %d%%", _("Total Memory Usage"),
31 inst->cfg->memusage.real, _("Total Swap Usage"), inst->cfg->memusage.swap);
32 elm_object_text_set(inst->cfg->memusage.popup_label, text);
33 }
26} 34}
27 35
28static Evas_Object * 36static Evas_Object *
@@ -79,6 +87,7 @@ _memusage_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
79 elm_object_text_set(label, text); 87 elm_object_text_set(label, text);
80 elm_object_content_set(popup, label); 88 elm_object_content_set(popup, label);
81 evas_object_show(label); 89 evas_object_show(label);
90 inst->cfg->memusage.popup_label = label;
82 91
83 e_comp_object_util_autoclose(popup, NULL, NULL, NULL); 92 e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
84 evas_object_show(popup); 93 evas_object_show(popup);
@@ -102,6 +111,17 @@ _memusage_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
102} 111}
103 112
104static void 113static void
114_memusage_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
115{
116 Evas_Coord w, h;
117 Instance *inst = data;
118
119 evas_object_geometry_get(inst->cfg->memusage.o_gadget, 0, 0, &w, &h);
120 if (inst->cfg->esm == E_SYSINFO_MODULE_MEMUSAGE)
121 evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
122}
123
124static void
105_memusage_cb_usage_check_main(void *data, Ecore_Thread *th) 125_memusage_cb_usage_check_main(void *data, Ecore_Thread *th)
106{ 126{
107 Thread_Config *thc = data; 127 Thread_Config *thc = data;
@@ -197,44 +217,6 @@ sysinfo_memusage_remove(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
197} 217}
198 218
199static void 219static void
200_memusage_eval_instance_aspect(Instance *inst)
201{
202 Evas_Coord w, h;
203 Evas_Coord sw = 0, sh = 0;
204 Evas_Object *owner, *ed;
205
206 if (!inst->o_main)
207 return;
208
209 owner = e_gadget_site_get(inst->o_main);
210 if (!owner)
211 return;
212
213 switch (e_gadget_site_orient_get(owner))
214 {
215 case E_GADGET_SITE_ORIENT_HORIZONTAL:
216 case E_GADGET_SITE_ORIENT_NONE:
217 evas_object_geometry_get(owner, NULL, NULL, NULL, &sh);
218 sw = sh;
219 break;
220
221 case E_GADGET_SITE_ORIENT_VERTICAL:
222 evas_object_geometry_get(owner, NULL, NULL, &sw, NULL);
223 sh = sw;
224 break;
225
226 default:
227 sw = sh = 48;
228 break;
229 }
230
231 evas_object_resize(inst->cfg->memusage.o_gadget, sw, sh);
232 ed = elm_layout_edje_get(inst->cfg->memusage.o_gadget);
233 edje_object_parts_extends_calc(ed, NULL, NULL, &w, &h);
234 evas_object_size_hint_aspect_set(inst->o_main, EVAS_ASPECT_CONTROL_BOTH, w, h);
235}
236
237static void
238_memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED) 220_memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
239{ 221{
240 Instance *inst = data; 222 Instance *inst = data;
@@ -256,9 +238,9 @@ _memusage_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED)
256 E_FILL(inst->cfg->memusage.o_gadget); 238 E_FILL(inst->cfg->memusage.o_gadget);
257 elm_box_pack_end(inst->o_main, inst->cfg->memusage.o_gadget); 239 elm_box_pack_end(inst->o_main, inst->cfg->memusage.o_gadget);
258 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst); 240 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst);
241 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_RESIZE, _memusage_resize_cb, inst);
259 evas_object_show(inst->cfg->memusage.o_gadget); 242 evas_object_show(inst->cfg->memusage.o_gadget);
260 evas_object_smart_callback_del_full(obj, "gadget_created", _memusage_created_cb, data); 243 evas_object_smart_callback_del_full(obj, "gadget_created", _memusage_created_cb, data);
261 _memusage_eval_instance_aspect(inst);
262 _memusage_config_updated(inst); 244 _memusage_config_updated(inst);
263} 245}
264 246
@@ -271,8 +253,8 @@ sysinfo_memusage_create(Evas_Object *parent, Instance *inst)
271 E_EXPAND(inst->cfg->memusage.o_gadget); 253 E_EXPAND(inst->cfg->memusage.o_gadget);
272 E_FILL(inst->cfg->memusage.o_gadget); 254 E_FILL(inst->cfg->memusage.o_gadget);
273 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst); 255 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_MOUSE_DOWN, _memusage_mouse_down_cb, inst);
256 evas_object_event_callback_add(inst->cfg->memusage.o_gadget, EVAS_CALLBACK_RESIZE, _memusage_resize_cb, inst);
274 evas_object_show(inst->cfg->memusage.o_gadget); 257 evas_object_show(inst->cfg->memusage.o_gadget);
275 _memusage_eval_instance_aspect(inst);
276 _memusage_config_updated(inst); 258 _memusage_config_updated(inst);
277 259
278 return inst->cfg->memusage.o_gadget; 260 return inst->cfg->memusage.o_gadget;
diff --git a/src/modules/sysinfo/netstatus/netstatus.c b/src/modules/sysinfo/netstatus/netstatus.c
index 93f4a62fb..3b0f7fbc4 100644
--- a/src/modules/sysinfo/netstatus/netstatus.c
+++ b/src/modules/sysinfo/netstatus/netstatus.c
@@ -27,6 +27,13 @@ _netstatus_face_update(Instance *inst)
27 edje_object_message_send(elm_layout_edje_get(inst->cfg->netstatus.o_gadget), 27 edje_object_message_send(elm_layout_edje_get(inst->cfg->netstatus.o_gadget),
28 EDJE_MESSAGE_INT_SET, 1, msg); 28 EDJE_MESSAGE_INT_SET, 1, msg);
29 free(msg); 29 free(msg);
30
31 if (inst->cfg->netstatus.popup)
32 {
33 char text[4096];
34 snprintf(text, sizeof(text), "%s<br>%s", inst->cfg->netstatus.instring, inst->cfg->netstatus.outstring);
35 elm_object_text_set(inst->cfg->netstatus.popup_label, text);
36 }
30} 37}
31 38
32static Evas_Object * 39static Evas_Object *
@@ -82,6 +89,7 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
82 elm_object_text_set(label, text); 89 elm_object_text_set(label, text);
83 elm_object_content_set(popup, label); 90 elm_object_content_set(popup, label);
84 evas_object_show(label); 91 evas_object_show(label);
92 inst->cfg->netstatus.popup_label = label;
85 93
86 e_comp_object_util_autoclose(popup, NULL, NULL, NULL); 94 e_comp_object_util_autoclose(popup, NULL, NULL, NULL);
87 evas_object_show(popup); 95 evas_object_show(popup);
diff --git a/src/modules/sysinfo/sysinfo.h b/src/modules/sysinfo/sysinfo.h
index b3dcb02b3..65fced322 100644
--- a/src/modules/sysinfo/sysinfo.h
+++ b/src/modules/sysinfo/sysinfo.h
@@ -189,6 +189,7 @@ struct _Config_Item
189 { 189 {
190 Evas_Object *o_gadget; 190 Evas_Object *o_gadget;
191 Evas_Object *popup; 191 Evas_Object *popup;
192 Evas_Object *popup_label;
192 Evas_Object *configure; 193 Evas_Object *configure;
193 int poll_interval; 194 int poll_interval;
194 int percent; 195 int percent;
@@ -202,6 +203,7 @@ struct _Config_Item
202 { 203 {
203 Evas_Object *o_gadget; 204 Evas_Object *o_gadget;
204 Evas_Object *popup; 205 Evas_Object *popup;
206 Evas_Object *popup_label;
205 Evas_Object *configure; 207 Evas_Object *configure;
206 int poll_interval; 208 int poll_interval;
207 int real; 209 int real;
@@ -212,6 +214,7 @@ struct _Config_Item
212 { 214 {
213 Evas_Object *o_gadget; 215 Evas_Object *o_gadget;
214 Evas_Object *popup; 216 Evas_Object *popup;
217 Evas_Object *popup_label;
215 Evas_Object *configure; 218 Evas_Object *configure;
216 Eina_Bool automax; 219 Eina_Bool automax;
217 Netstatus_Unit receive_units; 220 Netstatus_Unit receive_units;