summaryrefslogtreecommitdiff
path: root/src/modules/sysinfo/netstatus/netstatus.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/sysinfo/netstatus/netstatus.c')
-rw-r--r--src/modules/sysinfo/netstatus/netstatus.c101
1 files changed, 83 insertions, 18 deletions
diff --git a/src/modules/sysinfo/netstatus/netstatus.c b/src/modules/sysinfo/netstatus/netstatus.c
index 87ea74c..5d29f94 100644
--- a/src/modules/sysinfo/netstatus/netstatus.c
+++ b/src/modules/sysinfo/netstatus/netstatus.c
@@ -41,9 +41,20 @@ _netstatus_face_update(Thread_Config *thc)
41 41
42 if (thc->inst->cfg->netstatus.popup) 42 if (thc->inst->cfg->netstatus.popup)
43 { 43 {
44 char text[4096]; 44 char buf[4096];
45 snprintf(text, sizeof(text), "%s<ps/>%s", thc->instring, thc->outstring); 45 snprintf(buf, sizeof(buf), "%s (%d %%)",
46 elm_object_text_set(thc->inst->cfg->netstatus.popup_label, text); 46 thc->inst->cfg->netstatus.instring,
47 thc->inst->cfg->netstatus.inpercent);
48 elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_inpbar,
49 (float)thc->inst->cfg->netstatus.inpercent / 100);
50 elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_inpbar, buf);
51 memset(buf, 0x00, sizeof(buf));
52 snprintf(buf, sizeof(buf), "%s (%d %%)",
53 thc->inst->cfg->netstatus.outstring,
54 thc->inst->cfg->netstatus.outpercent);
55 elm_progressbar_value_set(thc->inst->cfg->netstatus.popup_outpbar,
56 (float)thc->inst->cfg->netstatus.outpercent / 100);
57 elm_progressbar_unit_format_set(thc->inst->cfg->netstatus.popup_outpbar, buf);
47 } 58 }
48} 59}
49 60
@@ -75,10 +86,10 @@ _netstatus_popup_deleted(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
75static void 86static void
76_netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data) 87_netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data)
77{ 88{
78 Evas_Object *label, *popup; 89 Evas_Object *label, *popup, *table, *pbar;
79 Evas_Event_Mouse_Down *ev = event_data; 90 Evas_Event_Mouse_Down *ev = event_data;
80 Instance *inst = data; 91 Instance *inst = data;
81 char text[4096]; 92 char text[4096], buf[4096];
82 93
83 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; 94 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
84 if (ev->button != 3) 95 if (ev->button != 3)
@@ -93,13 +104,59 @@ _netstatus_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
93 evas_object_smart_callback_add(popup, "dismissed", _netstatus_popup_dismissed, inst); 104 evas_object_smart_callback_add(popup, "dismissed", _netstatus_popup_dismissed, inst);
94 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _netstatus_popup_deleted, inst); 105 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _netstatus_popup_deleted, inst);
95 106
96 snprintf(text, sizeof(text), "%s<ps/>%s", inst->cfg->netstatus.instring, inst->cfg->netstatus.outstring); 107 table = elm_table_add(popup);
97 label = elm_label_add(popup); 108 E_EXPAND(table);
98 elm_object_style_set(label, "marker"); 109 E_FILL(table);
110 elm_object_content_set(popup, table);
111 evas_object_show(table);
112
113 snprintf(text, sizeof(text), "<big><b>%s</b></big>", _("Network Throughput"));
114
115 label = elm_label_add(table);
116 E_EXPAND(label); E_ALIGN(label, 0.5, 0.5);
99 elm_object_text_set(label, text); 117 elm_object_text_set(label, text);
100 elm_object_content_set(popup, label); 118 elm_table_pack(table, label, 0, 0, 2, 1);
101 evas_object_show(label); 119 evas_object_show(label);
102 inst->cfg->netstatus.popup_label = label; 120
121 label = elm_label_add(table);
122 E_ALIGN(label, 0.0, 0.5);
123 elm_object_text_set(label, _("Receiving"));
124 elm_table_pack(table, label, 0, 1, 1, 1);
125 evas_object_show(label);
126
127 snprintf(buf, sizeof(buf), "%s (%d %%)",
128 inst->cfg->netstatus.instring,
129 inst->cfg->netstatus.inpercent);
130
131 pbar = elm_progressbar_add(table);
132 E_EXPAND(pbar);
133 E_FILL(pbar);
134 elm_progressbar_span_size_set(pbar, 200 * e_scale);
135 elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.inpercent / 100);
136 elm_table_pack(table, pbar, 1, 1, 1, 1);
137 evas_object_show(pbar);
138 inst->cfg->netstatus.popup_inpbar = pbar;
139
140 label = elm_label_add(table);
141 E_ALIGN(label, 0.0, 0.5);
142 elm_object_text_set(label, _("Sending"));
143 elm_table_pack(table, label, 0, 2, 1, 1);
144 evas_object_show(label);
145
146 memset(buf, 0x00, sizeof(buf));
147 snprintf(buf, sizeof(buf), "%s (%d %%)",
148 inst->cfg->netstatus.outstring,
149 inst->cfg->netstatus.outpercent);
150
151 pbar = elm_progressbar_add(table);
152 E_EXPAND(pbar);
153 E_FILL(pbar);
154 elm_progressbar_span_size_set(pbar, 200 * e_scale);
155 elm_progressbar_value_set(pbar, (float)inst->cfg->netstatus.outpercent / 100);
156 elm_progressbar_unit_format_set(pbar, buf);
157 elm_table_pack(table, pbar, 1, 2, 1, 1);
158 evas_object_show(pbar);
159 inst->cfg->netstatus.popup_outpbar = pbar;
103 160
104 e_gadget_util_ctxpopup_place(inst->o_main, popup, 161 e_gadget_util_ctxpopup_place(inst->o_main, popup,
105 inst->cfg->netstatus.o_gadget); 162 inst->cfg->netstatus.o_gadget);
@@ -154,30 +211,30 @@ _netstatus_cb_usage_check_main(void *data, Ecore_Thread *th)
154#endif 211#endif
155 if (!thc->incurrent) 212 if (!thc->incurrent)
156 { 213 {
157 snprintf(rin, sizeof(rin), "%s: 0 B/s", _("Receiving")); 214 snprintf(rin, sizeof(rin), "0 B/s");
158 } 215 }
159 else 216 else
160 { 217 {
161 if (thc->incurrent > 1048576) 218 if (thc->incurrent > 1048576)
162 snprintf(rin, sizeof(rin), "%s: %.2f MB/s", _("Receiving"), ((float)thc->incurrent / 1048576)); 219 snprintf(rin, sizeof(rin), "%.2f MB/s", ((float)thc->incurrent / 1048576));
163 else if ((thc->incurrent > 1024) && (thc->incurrent < 1048576)) 220 else if ((thc->incurrent > 1024) && (thc->incurrent < 1048576))
164 snprintf(rin, sizeof(rin), "%s: %lu KB/s", _("Receiving"), (thc->incurrent / 1024)); 221 snprintf(rin, sizeof(rin), "%lu KB/s", (thc->incurrent / 1024));
165 else 222 else
166 snprintf(rin, sizeof(rin), "%s: %lu B/s", _("Receiving"), thc->incurrent); 223 snprintf(rin, sizeof(rin), "%lu B/s", thc->incurrent);
167 } 224 }
168 eina_stringshare_replace(&thc->instring, rin); 225 eina_stringshare_replace(&thc->instring, rin);
169 if (!thc->outcurrent) 226 if (!thc->outcurrent)
170 { 227 {
171 snprintf(rout, sizeof(rout), "%s: 0 B/s", _("Sending")); 228 snprintf(rout, sizeof(rout), "0 B/s");
172 } 229 }
173 else 230 else
174 { 231 {
175 if (thc->outcurrent > 1048576) 232 if (thc->outcurrent > 1048576)
176 snprintf(rout, sizeof(rout), "%s: %.2f MB/s", _("Sending"), ((float)thc->outcurrent / 1048576)); 233 snprintf(rout, sizeof(rout), "%.2f MB/s", ((float)thc->outcurrent / 1048576));
177 else if ((thc->outcurrent > 1024) && (thc->outcurrent < 1048576)) 234 else if ((thc->outcurrent > 1024) && (thc->outcurrent < 1048576))
178 snprintf(rout, sizeof(rout), "%s: %lu KB/s", _("Sending"), (thc->outcurrent / 1024)); 235 snprintf(rout, sizeof(rout), "%lu KB/s", (thc->outcurrent / 1024));
179 else 236 else
180 snprintf(rout, sizeof(rout), "%s: %lu B/s", _("Sending"), thc->outcurrent); 237 snprintf(rout, sizeof(rout), "%lu B/s", thc->outcurrent);
181 } 238 }
182 eina_stringshare_replace(&thc->outstring, rout); 239 eina_stringshare_replace(&thc->outstring, rout);
183 ecore_thread_feedback(th, NULL); 240 ecore_thread_feedback(th, NULL);
@@ -199,6 +256,8 @@ _netstatus_cb_usage_check_notify(void *data,
199 256
200 eina_stringshare_replace(&thc->inst->cfg->netstatus.instring, thc->instring); 257 eina_stringshare_replace(&thc->inst->cfg->netstatus.instring, thc->instring);
201 eina_stringshare_replace(&thc->inst->cfg->netstatus.outstring, thc->outstring); 258 eina_stringshare_replace(&thc->inst->cfg->netstatus.outstring, thc->outstring);
259 thc->inst->cfg->netstatus.inpercent = thc->inpercent;
260 thc->inst->cfg->netstatus.outpercent = thc->outpercent;
202 _netstatus_face_update(thc); 261 _netstatus_face_update(thc);
203} 262}
204 263
@@ -346,8 +405,11 @@ _netstatus_created_cb(void *data, Evas_Object *obj, void *event_data EINA_UNUSED
346 405
347 e_gadget_configure_cb_set(inst->o_main, _netstatus_configure_cb); 406 e_gadget_configure_cb_set(inst->o_main, _netstatus_configure_cb);
348 407
408 inst->cfg->netstatus.popup = NULL;
349 inst->cfg->netstatus.instring = NULL; 409 inst->cfg->netstatus.instring = NULL;
350 inst->cfg->netstatus.outstring = NULL; 410 inst->cfg->netstatus.outstring = NULL;
411 inst->cfg->netstatus.inpercent = 0;
412 inst->cfg->netstatus.outpercent = 0;
351 413
352 inst->cfg->netstatus.o_gadget = elm_layout_add(inst->o_main); 414 inst->cfg->netstatus.o_gadget = elm_layout_add(inst->o_main);
353 if (orient == E_GADGET_SITE_ORIENT_VERTICAL) 415 if (orient == E_GADGET_SITE_ORIENT_VERTICAL)
@@ -377,6 +439,9 @@ sysinfo_netstatus_create(Evas_Object *parent, Instance *inst)
377 inst->cfg->netstatus.popup = NULL; 439 inst->cfg->netstatus.popup = NULL;
378 inst->cfg->netstatus.instring = NULL; 440 inst->cfg->netstatus.instring = NULL;
379 inst->cfg->netstatus.outstring = NULL; 441 inst->cfg->netstatus.outstring = NULL;
442 inst->cfg->netstatus.inpercent = 0;
443 inst->cfg->netstatus.outpercent = 0;
444
380 inst->cfg->netstatus.o_gadget = elm_layout_add(parent); 445 inst->cfg->netstatus.o_gadget = elm_layout_add(parent);
381 e_theme_edje_object_set(inst->cfg->netstatus.o_gadget, "base/theme/gadget/netstatus", 446 e_theme_edje_object_set(inst->cfg->netstatus.o_gadget, "base/theme/gadget/netstatus",
382 "e/gadget/netstatus/main"); 447 "e/gadget/netstatus/main");