aboutsummaryrefslogtreecommitdiff
path: root/src/statistics
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-12-26 20:04:58 +0000
committerChristian Grothoff <christian@grothoff.org>2011-12-26 20:04:58 +0000
commit10e931a7968629875e2d7521ae9aa60a4e6b0ba3 (patch)
tree3a200305eebde747d4b33264510d85d19589ace4 /src/statistics
parent90513c8a7f4cd29e8db2e51191fff23caf6b6aed (diff)
downloadgnunet-gtk-10e931a7968629875e2d7521ae9aa60a4e6b0ba3.tar.gz
gnunet-gtk-10e931a7968629875e2d7521ae9aa60a4e6b0ba3.zip
-indentation
Diffstat (limited to 'src/statistics')
-rw-r--r--src/statistics/functions.c321
-rw-r--r--src/statistics/functions.h7
-rw-r--r--src/statistics/gnunet-statistics-gtk-about.c2
-rw-r--r--src/statistics/gnunet-statistics-gtk.c112
-rw-r--r--src/statistics/gtk_statistics.c271
-rw-r--r--src/statistics/gtk_statistics.h31
-rw-r--r--src/statistics/gtk_statistics_demo.c70
-rw-r--r--src/statistics/statistics.c325
8 files changed, 546 insertions, 593 deletions
diff --git a/src/statistics/functions.c b/src/statistics/functions.c
index 143860e7..129caada 100644
--- a/src/statistics/functions.c
+++ b/src/statistics/functions.c
@@ -50,8 +50,7 @@ static struct GNUNET_GC_Configuration *cfg;
50static struct GNUNET_CronManager *cron; 50static struct GNUNET_CronManager *cron;
51 51
52static int 52static int
53getStatValue (unsigned long long *value, 53getStatValue (unsigned long long *value, unsigned long long *lvalue,
54 unsigned long long *lvalue,
55 GNUNET_CronTime * dtime, const char *optName, int monotone) 54 GNUNET_CronTime * dtime, const char *optName, int monotone)
56{ 55{
57 unsigned int i; 56 unsigned int i;
@@ -60,25 +59,24 @@ getStatValue (unsigned long long *value,
60 if (lvalue != NULL) 59 if (lvalue != NULL)
61 *lvalue = 0; 60 *lvalue = 0;
62 for (i = 0; i < lsv_size; i++) 61 for (i = 0; i < lsv_size; i++)
62 {
63 if (0 == strcmp (optName, lastStatValues[i].statName))
63 { 64 {
64 if (0 == strcmp (optName, lastStatValues[i].statName)) 65 *value = lastStatValues[i].value;
65 { 66 if (lvalue != NULL)
66 *value = lastStatValues[i].value; 67 *lvalue = lastStatValues[i].lvalue;
67 if (lvalue != NULL) 68 if (dtime != NULL)
68 *lvalue = lastStatValues[i].lvalue; 69 *dtime = lastStatValues[i].delta;
69 if (dtime != NULL) 70 if ((monotone == GNUNET_YES) && (lvalue != NULL) && (*lvalue > *value))
70 *dtime = lastStatValues[i].delta; 71 return GNUNET_SYSERR; /* gnunetd restart? */
71 if ((monotone == GNUNET_YES) && (lvalue != NULL) 72 return GNUNET_OK;
72 && (*lvalue > *value))
73 return GNUNET_SYSERR; /* gnunetd restart? */
74 return GNUNET_OK;
75 }
76 } 73 }
74 }
77#if FUNCTIONS_DEBUG 75#if FUNCTIONS_DEBUG
78 GNUNET_GE_LOG (ectx, 76 GNUNET_GE_LOG (ectx,
79 GNUNET_GE_ERROR | GNUNET_GE_DEVELOPER | GNUNET_GE_ADMIN | 77 GNUNET_GE_ERROR | GNUNET_GE_DEVELOPER | GNUNET_GE_ADMIN |
80 GNUNET_GE_USER | GNUNET_GE_BULK, 78 GNUNET_GE_USER | GNUNET_GE_BULK, "Statistic not found: `%s'\n",
81 "Statistic not found: `%s'\n", optName); 79 optName);
82#endif 80#endif
83 return GNUNET_SYSERR; 81 return GNUNET_SYSERR;
84} 82}
@@ -92,13 +90,13 @@ updateConnectionGoal (void *unused)
92 90
93 GNUNET_mutex_lock (lock); 91 GNUNET_mutex_lock (lock);
94 cmh = 92 cmh =
95 GNUNET_get_daemon_configuration_value (sock, "gnunetd", 93 GNUNET_get_daemon_configuration_value (sock, "gnunetd",
96 "connection-max-hosts"); 94 "connection-max-hosts");
97 availableDown = 95 availableDown =
98 GNUNET_get_daemon_configuration_value (sock, "LOAD", 96 GNUNET_get_daemon_configuration_value (sock, "LOAD",
99 "MAXNETDOWNBPSTOTAL"); 97 "MAXNETDOWNBPSTOTAL");
100 availableUp = 98 availableUp =
101 GNUNET_get_daemon_configuration_value (sock, "LOAD", "MAXNETUPBPSTOTAL"); 99 GNUNET_get_daemon_configuration_value (sock, "LOAD", "MAXNETUPBPSTOTAL");
102 GNUNET_mutex_unlock (lock); 100 GNUNET_mutex_unlock (lock);
103 if (cmh == NULL) 101 if (cmh == NULL)
104 connectionGoal = 0; 102 connectionGoal = 0;
@@ -146,14 +144,13 @@ getLoadStat (const void *closure, gfloat ** data)
146 if (GNUNET_OK != 144 if (GNUNET_OK !=
147 getStatValue (&vali, NULL, NULL, "% of allowed io load", GNUNET_NO)) 145 getStatValue (&vali, NULL, NULL, "% of allowed io load", GNUNET_NO))
148 return GNUNET_SYSERR; 146 return GNUNET_SYSERR;
149 if (GNUNET_OK != getStatValue (&valu, 147 if (GNUNET_OK !=
150 NULL, NULL, "% of allowed network load (up)", 148 getStatValue (&valu, NULL, NULL, "% of allowed network load (up)",
151 GNUNET_NO)) 149 GNUNET_NO))
152 return GNUNET_SYSERR; 150 return GNUNET_SYSERR;
153 if (GNUNET_OK != getStatValue (&vald, 151 if (GNUNET_OK !=
154 NULL, NULL, 152 getStatValue (&vald, NULL, NULL, "% of allowed network load (down)",
155 "% of allowed network load (down)", 153 GNUNET_NO))
156 GNUNET_NO))
157 return GNUNET_SYSERR; 154 return GNUNET_SYSERR;
158 data[0][0] = (gfloat) valc / 100.0; 155 data[0][0] = (gfloat) valc / 100.0;
159 data[0][1] = (gfloat) vali / 100.0; 156 data[0][1] = (gfloat) vali / 100.0;
@@ -170,17 +167,15 @@ getQuotaStat (const void *closure, gfloat ** data)
170 167
171 data[0][0] = 0; 168 data[0][0] = 0;
172 data[0][1] = 0; 169 data[0][1] = 0;
173 if ((GNUNET_OK == getStatValue (&allowed, 170 if ((GNUNET_OK ==
174 NULL, NULL, "# bytes allowed in datastore", 171 getStatValue (&allowed, NULL, NULL, "# bytes allowed in datastore",
175 GNUNET_NO)) && 172 GNUNET_NO)) && (allowed != 0) &&
176 (allowed != 0) &&
177 (GNUNET_OK == 173 (GNUNET_OK ==
178 getStatValue (&have, NULL, NULL, "# bytes in datastore", GNUNET_NO))) 174 getStatValue (&have, NULL, NULL, "# bytes in datastore", GNUNET_NO)))
179 data[0][0] = ((gfloat) have) / allowed; 175 data[0][0] = ((gfloat) have) / allowed;
180 if ((GNUNET_OK == getStatValue (&allowed, 176 if ((GNUNET_OK ==
181 NULL, NULL, "# max bytes allowed in dstore", 177 getStatValue (&allowed, NULL, NULL, "# max bytes allowed in dstore",
182 GNUNET_NO)) && 178 GNUNET_NO)) && (allowed != 0) &&
183 (allowed != 0) &&
184 (GNUNET_OK == 179 (GNUNET_OK ==
185 getStatValue (&have, NULL, NULL, "# bytes in dstore", GNUNET_NO))) 180 getStatValue (&have, NULL, NULL, "# bytes in dstore", GNUNET_NO)))
186 data[0][1] = ((gfloat) have) / allowed; 181 data[0][1] = ((gfloat) have) / allowed;
@@ -208,43 +203,39 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
208 if (GNUNET_OK != 203 if (GNUNET_OK !=
209 getStatValue (&total, &ltotal, &dtime, "# bytes received", GNUNET_YES)) 204 getStatValue (&total, &ltotal, &dtime, "# bytes received", GNUNET_YES))
210 return GNUNET_SYSERR; 205 return GNUNET_SYSERR;
211 if (GNUNET_OK != getStatValue (&noise, 206 if (GNUNET_OK !=
212 &lnoise, NULL, "# bytes of noise received", 207 getStatValue (&noise, &lnoise, NULL, "# bytes of noise received",
213 GNUNET_YES)) 208 GNUNET_YES))
214 return GNUNET_SYSERR; 209 return GNUNET_SYSERR;
215 buffer = GNUNET_malloc (512); 210 buffer = GNUNET_malloc (512);
216 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 211 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
217 GNUNET_P2P_PROTO_GAP_RESULT); 212 GNUNET_P2P_PROTO_GAP_RESULT);
218 if (GNUNET_OK != 213 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
219 getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES)) 214 {
220 { 215 content = 0;
221 content = 0; 216 lcontent = 0;
222 lcontent = 0; 217 }
223 }
224 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 218 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
225 GNUNET_P2P_PROTO_HELLO); 219 GNUNET_P2P_PROTO_HELLO);
226 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES)) 220 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
227 { 221 {
228 hellos = 0; 222 hellos = 0;
229 lhellos = 0; 223 lhellos = 0;
230 } 224 }
231 GNUNET_snprintf (buffer, 512, "# bytes received of type %d", 225 GNUNET_snprintf (buffer, 512, "# bytes received of type %d",
232 GNUNET_P2P_PROTO_GAP_QUERY); 226 GNUNET_P2P_PROTO_GAP_QUERY);
227 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
228 {
229 queries = 0;
230 lqueries = 0;
231 }
233 if (GNUNET_OK != 232 if (GNUNET_OK !=
234 getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES)) 233 getStatValue (&rlimit, &lrlimit, NULL,
235 { 234 "# total bytes per second receive limit", GNUNET_NO))
236 queries = 0; 235 {
237 lqueries = 0; 236 rlimit = 0;
238 } 237 lrlimit = 0;
239 if (GNUNET_OK != getStatValue (&rlimit, 238 }
240 &lrlimit,
241 NULL,
242 "# total bytes per second receive limit",
243 GNUNET_NO))
244 {
245 rlimit = 0;
246 lrlimit = 0;
247 }
248 GNUNET_free (buffer); 239 GNUNET_free (buffer);
249 if (banddown == 0) 240 if (banddown == 0)
250 return GNUNET_SYSERR; 241 return GNUNET_SYSERR;
@@ -255,15 +246,15 @@ getTrafficRecvStats (const void *closure, gfloat ** data)
255 content -= lcontent; 246 content -= lcontent;
256 hellos -= lhellos; 247 hellos -= lhellos;
257 if (banddown <= 0) 248 if (banddown <= 0)
258 { 249 {
259 data[0][0] = 0.0; 250 data[0][0] = 0.0;
260 data[0][1] = 0.0; 251 data[0][1] = 0.0;
261 data[0][2] = 0.0; 252 data[0][2] = 0.0;
262 data[0][3] = 0.0; 253 data[0][3] = 0.0;
263 data[0][4] = 0.0; 254 data[0][4] = 0.0;
264 data[0][5] = 0.0; 255 data[0][5] = 0.0;
265 return GNUNET_OK; 256 return GNUNET_OK;
266 } 257 }
267 data[0][0] = ((gfloat) noise) / (banddown * dtime / GNUNET_CRON_SECONDS); /* red */ 258 data[0][0] = ((gfloat) noise) / (banddown * dtime / GNUNET_CRON_SECONDS); /* red */
268 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* green */ 259 data[0][1] = ((gfloat) (content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* green */
269 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* yellow */ 260 data[0][2] = ((gfloat) (queries + content + noise)) / (banddown * dtime / GNUNET_CRON_SECONDS); /* yellow */
@@ -294,47 +285,41 @@ getTrafficSendStats (const void *closure, gfloat ** data)
294 GNUNET_CronTime dtime; 285 GNUNET_CronTime dtime;
295 char *buffer; 286 char *buffer;
296 287
297 if (GNUNET_OK != getStatValue (&total, 288 if (GNUNET_OK !=
298 &ltotal, &dtime, "# bytes transmitted", 289 getStatValue (&total, &ltotal, &dtime, "# bytes transmitted", GNUNET_YES))
299 GNUNET_YES))
300 return GNUNET_SYSERR; 290 return GNUNET_SYSERR;
301 if (GNUNET_OK != 291 if (GNUNET_OK !=
302 getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", GNUNET_YES)) 292 getStatValue (&noise, &lnoise, NULL, "# bytes noise sent", GNUNET_YES))
303 return GNUNET_SYSERR; 293 return GNUNET_SYSERR;
304 buffer = GNUNET_malloc (512); 294 buffer = GNUNET_malloc (512);
305 GNUNET_snprintf (buffer, 295 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
306 512, "# bytes transmitted of type %d",
307 GNUNET_P2P_PROTO_GAP_RESULT); 296 GNUNET_P2P_PROTO_GAP_RESULT);
308 if (GNUNET_OK != 297 if (GNUNET_OK != getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES))
309 getStatValue (&content, &lcontent, NULL, buffer, GNUNET_YES)) 298 {
310 { 299 content = 0;
311 content = 0; 300 lcontent = 0;
312 lcontent = 0; 301 }
313 } 302 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
314 GNUNET_snprintf (buffer,
315 512, "# bytes transmitted of type %d",
316 GNUNET_P2P_PROTO_GAP_QUERY); 303 GNUNET_P2P_PROTO_GAP_QUERY);
317 if (GNUNET_OK != 304 if (GNUNET_OK != getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES))
318 getStatValue (&queries, &lqueries, NULL, buffer, GNUNET_YES)) 305 {
319 { 306 queries = 0;
320 queries = 0; 307 lqueries = 0;
321 lqueries = 0; 308 }
322 }
323 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d", 309 GNUNET_snprintf (buffer, 512, "# bytes transmitted of type %d",
324 GNUNET_P2P_PROTO_HELLO); 310 GNUNET_P2P_PROTO_HELLO);
325 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES)) 311 if (GNUNET_OK != getStatValue (&hellos, &lhellos, NULL, buffer, GNUNET_YES))
326 { 312 {
327 queries = 0; 313 queries = 0;
328 lqueries = 0; 314 lqueries = 0;
329 } 315 }
330 if (GNUNET_OK != getStatValue (&slimit, 316 if (GNUNET_OK !=
331 &lslimit, 317 getStatValue (&slimit, &lslimit, NULL,
332 NULL, "# total bytes per second send limit", 318 "# total bytes per second send limit", GNUNET_NO))
333 GNUNET_NO)) 319 {
334 { 320 slimit = 0;
335 slimit = 0; 321 lslimit = 0;
336 lslimit = 0; 322 }
337 }
338 GNUNET_free (buffer); 323 GNUNET_free (buffer);
339 if (bandup == 0) 324 if (bandup == 0)
340 return GNUNET_SYSERR; 325 return GNUNET_SYSERR;
@@ -344,15 +329,15 @@ getTrafficSendStats (const void *closure, gfloat ** data)
344 content -= lcontent; 329 content -= lcontent;
345 hellos -= lhellos; 330 hellos -= lhellos;
346 if (bandup <= 0) 331 if (bandup <= 0)
347 { 332 {
348 data[0][0] = 0.0; 333 data[0][0] = 0.0;
349 data[0][1] = 0.0; 334 data[0][1] = 0.0;
350 data[0][2] = 0.0; 335 data[0][2] = 0.0;
351 data[0][3] = 0.0; 336 data[0][3] = 0.0;
352 data[0][4] = 0.0; 337 data[0][4] = 0.0;
353 data[0][5] = 0.0; 338 data[0][5] = 0.0;
354 return GNUNET_OK; 339 return GNUNET_OK;
355 } 340 }
356 data[0][0] = ((gfloat) noise) / (bandup * dtime / GNUNET_CRON_SECONDS); /* red */ 341 data[0][0] = ((gfloat) noise) / (bandup * dtime / GNUNET_CRON_SECONDS); /* red */
357 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* green */ 342 data[0][1] = ((gfloat) (noise + content)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* green */
358 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* yellow */ 343 data[0][2] = ((gfloat) (noise + content + queries)) / (bandup * dtime / GNUNET_CRON_SECONDS); /* yellow */
@@ -376,17 +361,15 @@ getTrustStats (const void *closure, gfloat ** data)
376 unsigned long long lawarded; 361 unsigned long long lawarded;
377 unsigned long long max; 362 unsigned long long max;
378 363
379 if (GNUNET_OK != getStatValue (&spent, 364 if (GNUNET_OK !=
380 &lspent, NULL, "# trust spent", GNUNET_YES)) 365 getStatValue (&spent, &lspent, NULL, "# trust spent", GNUNET_YES))
381 return GNUNET_SYSERR; 366 return GNUNET_SYSERR;
382 if (GNUNET_OK != getStatValue (&earned, 367 if (GNUNET_OK !=
383 &learned, 368 getStatValue (&earned, &learned, NULL, "# trust earned", GNUNET_YES))
384 NULL, "# trust earned", GNUNET_YES))
385 return GNUNET_SYSERR; 369 return GNUNET_SYSERR;
386 if (GNUNET_OK != getStatValue (&awarded, 370 if (GNUNET_OK !=
387 &lawarded, 371 getStatValue (&awarded, &lawarded, NULL, "# gap total trust awarded",
388 NULL, "# gap total trust awarded", 372 GNUNET_YES))
389 GNUNET_YES))
390 return GNUNET_SYSERR; 373 return GNUNET_SYSERR;
391 max = spent; 374 max = spent;
392 if (earned > max) 375 if (earned > max)
@@ -395,17 +378,17 @@ getTrustStats (const void *closure, gfloat ** data)
395 max = awarded; 378 max = awarded;
396 data[0][0] = 0.0; 379 data[0][0] = 0.0;
397 if (max > 0) 380 if (max > 0)
398 { 381 {
399 data[0][0] = (1.0 * spent) / max; 382 data[0][0] = (1.0 * spent) / max;
400 data[0][1] = (1.0 * earned) / max; 383 data[0][1] = (1.0 * earned) / max;
401 data[0][2] = (1.0 * awarded) / max; 384 data[0][2] = (1.0 * awarded) / max;
402 } 385 }
403 else 386 else
404 { 387 {
405 data[0][0] = 0.0; 388 data[0][0] = 0.0;
406 data[0][1] = 0.0; 389 data[0][1] = 0.0;
407 data[0][2] = 0.0; 390 data[0][2] = 0.0;
408 } 391 }
409 return GNUNET_OK; 392 return GNUNET_OK;
410} 393}
411 394
@@ -417,14 +400,13 @@ getEffectivenessStats (const void *closure, gfloat ** data)
417 unsigned long long ltotal; 400 unsigned long long ltotal;
418 unsigned long long lsuccess; 401 unsigned long long lsuccess;
419 402
420 if (GNUNET_OK != getStatValue (&total, 403 if (GNUNET_OK !=
421 &ltotal, 404 getStatValue (&total, &ltotal, NULL, "# gap requests total sent",
422 NULL, 405 GNUNET_YES))
423 "# gap requests total sent", GNUNET_YES))
424 return GNUNET_SYSERR; 406 return GNUNET_SYSERR;
425 if (GNUNET_OK != getStatValue (&success, 407 if (GNUNET_OK !=
426 &lsuccess, 408 getStatValue (&success, &lsuccess, NULL, "# gap routes succeeded",
427 NULL, "# gap routes succeeded", GNUNET_YES)) 409 GNUNET_YES))
428 return GNUNET_SYSERR; 410 return GNUNET_SYSERR;
429 if (total > 0) 411 if (total > 0)
430 data[0][0] = 1.0 * success / total; 412 data[0][0] = 1.0 * success / total;
@@ -455,22 +437,22 @@ statsProcessor (const char *optName, unsigned long long value, void *data)
455 if ((j < lsv_size) && (0 == strcmp (optName, lastStatValues[j].statName))) 437 if ((j < lsv_size) && (0 == strcmp (optName, lastStatValues[j].statName)))
456 found = j; 438 found = j;
457 if (found == (unsigned int) -1) 439 if (found == (unsigned int) -1)
440 {
441 for (j = 0; j < lsv_size; j++)
458 { 442 {
459 for (j = 0; j < lsv_size; j++) 443 if (0 == strcmp (optName, lastStatValues[j].statName))
460 { 444 {
461 if (0 == strcmp (optName, lastStatValues[j].statName)) 445 found = j;
462 { 446 break;
463 found = j; 447 }
464 break;
465 }
466 }
467 } 448 }
449 }
468 if (found == (unsigned int) -1) 450 if (found == (unsigned int) -1)
469 { 451 {
470 found = lsv_size; 452 found = lsv_size;
471 GNUNET_array_grow (lastStatValues, lsv_size, lsv_size + 1); 453 GNUNET_array_grow (lastStatValues, lsv_size, lsv_size + 1);
472 lastStatValues[found].statName = GNUNET_strdup (optName); 454 lastStatValues[found].statName = GNUNET_strdup (optName);
473 } 455 }
474 lastStatValues[found].lvalue = lastStatValues[found].value; 456 lastStatValues[found].lvalue = lastStatValues[found].value;
475 lastStatValues[found].value = value; 457 lastStatValues[found].value = value;
476 lastStatValues[found].delta = *delta; 458 lastStatValues[found].delta = *delta;
@@ -494,17 +476,17 @@ updateDaemonStatus (void *cls)
494 unsigned long long connected_peers; 476 unsigned long long connected_peers;
495 477
496 if (uc->is_running) 478 if (uc->is_running)
497 { 479 {
498 if (GNUNET_OK != 480 if (GNUNET_OK !=
499 getStatValue (&connected_peers, NULL, NULL, 481 getStatValue (&connected_peers, NULL, NULL, "# of connected peers",
500 "# of connected peers", GNUNET_NO)) 482 GNUNET_NO))
501 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_UNKNOWN, 0); 483 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_UNKNOWN, 0);
502 else if (connected_peers > 0) 484 else if (connected_peers > 0)
503 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_CONNECTED, 485 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_CONNECTED,
504 connected_peers); 486 connected_peers);
505 else 487 else
506 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_DISCONNECTED, 0); 488 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_DISCONNECTED, 0);
507 } 489 }
508 else 490 else
509 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_NODAEMON, 0); 491 GNUNET_GTK_display_daemon_status (GNUNET_GTK_STATUS_NODAEMON, 0);
510 return NULL; 492 return NULL;
@@ -613,24 +595,19 @@ StatEntry stats[] = {
613static unsigned long long UPDATE_INTERVAL; 595static unsigned long long UPDATE_INTERVAL;
614 596
615void 597void
616init_functions (struct GNUNET_GE_Context *e, 598init_functions (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c)
617 struct GNUNET_GC_Configuration *c)
618{ 599{
619 ectx = e; 600 ectx = e;
620 cfg = c; 601 cfg = c;
621 GNUNET_GC_get_configuration_value_number (cfg, 602 GNUNET_GC_get_configuration_value_number (cfg, "GNUNET-GTK", "STATS-INTERVAL",
622 "GNUNET-GTK", 603 1, 99 * GNUNET_CRON_YEARS,
623 "STATS-INTERVAL",
624 1,
625 99 * GNUNET_CRON_YEARS,
626 30 * GNUNET_CRON_SECONDS, 604 30 * GNUNET_CRON_SECONDS,
627 &UPDATE_INTERVAL); 605 &UPDATE_INTERVAL);
628 sock = GNUNET_client_connection_create (ectx, cfg); 606 sock = GNUNET_client_connection_create (ectx, cfg);
629 lock = GNUNET_mutex_create (GNUNET_NO); 607 lock = GNUNET_mutex_create (GNUNET_NO);
630 cron = GNUNET_GTK_get_cron_manager (); 608 cron = GNUNET_GTK_get_cron_manager ();
631 GNUNET_cron_add_job (cron, 609 GNUNET_cron_add_job (cron, &updateStatValues, UPDATE_INTERVAL,
632 &updateStatValues, UPDATE_INTERVAL, UPDATE_INTERVAL, 610 UPDATE_INTERVAL, NULL);
633 NULL);
634 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_SECONDS, 611 GNUNET_cron_add_job (cron, &updateConnectionGoal, 5 * GNUNET_CRON_SECONDS,
635 5 * GNUNET_CRON_MINUTES, NULL); 612 5 * GNUNET_CRON_MINUTES, NULL);
636 updateStatValues (NULL); 613 updateStatValues (NULL);
diff --git a/src/statistics/functions.h b/src/statistics/functions.h
index 053531a9..04932862 100644
--- a/src/statistics/functions.h
+++ b/src/statistics/functions.h
@@ -51,9 +51,10 @@ typedef struct SE_
51 51
52extern StatEntry stats[]; 52extern StatEntry stats[];
53 53
54void init_functions (struct GNUNET_GE_Context *e, 54void
55 struct GNUNET_GC_Configuration *c); 55init_functions (struct GNUNET_GE_Context *e, struct GNUNET_GC_Configuration *c);
56 56
57void done_functions (void); 57void
58done_functions (void);
58 59
59#endif 60#endif
diff --git a/src/statistics/gnunet-statistics-gtk-about.c b/src/statistics/gnunet-statistics-gtk-about.c
index ea4591b1..5c50ca66 100644
--- a/src/statistics/gnunet-statistics-gtk-about.c
+++ b/src/statistics/gnunet-statistics-gtk-about.c
@@ -33,7 +33,7 @@
33 */ 33 */
34void 34void
35GNUNET_STATISTICS_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy, 35GNUNET_STATISTICS_GTK_main_menu_help_about_activate_cb (GtkWidget * dummy,
36 gpointer data) 36 gpointer data)
37{ 37{
38 GNUNET_GTK_display_about ("gnunet_statistics_gtk_about_window.glade"); 38 GNUNET_GTK_display_about ("gnunet_statistics_gtk_about_window.glade");
39} 39}
diff --git a/src/statistics/gnunet-statistics-gtk.c b/src/statistics/gnunet-statistics-gtk.c
index e2115615..3055c4aa 100644
--- a/src/statistics/gnunet-statistics-gtk.c
+++ b/src/statistics/gnunet-statistics-gtk.c
@@ -57,41 +57,42 @@ struct PlotInfo
57 * Name of color to use when plotting. 57 * Name of color to use when plotting.
58 */ 58 */
59 const char *color_name; 59 const char *color_name;
60 60
61}; 61};
62 62
63 63
64static const struct PlotInfo connection_data[] = 64static const struct PlotInfo connection_data[] = {
65 { 65 {"fs", "# peers connected", "file-sharing connections", "blue"},
66 { "fs", "# peers connected", "file-sharing connections", "blue" }, 66 {"core", "# entries in session map", "encrypted connections (core)", "green"},
67 { "core", "# entries in session map", "encrypted connections (core)", "green" }, 67 {"core", "# neighbour entries allocated", "transport connections (core)",
68 { "core", "# neighbour entries allocated", "transport connections (core)", "yellow" }, 68 "yellow"},
69 { "transport", "# peers connected", "total connections (transport)", "orange" }, 69 {"transport", "# peers connected", "total connections (transport)", "orange"},
70 { "transport", "# TCP sessions active", "tcp connections", "red" }, 70 {"transport", "# TCP sessions active", "tcp connections", "red"},
71 { "peerinfo", "# peers known", "peers known", "brown" }, 71 {"peerinfo", "# peers known", "peers known", "brown"},
72 { "nse", "# nodes in the network (estimate)", "network size (estimate)", "purple" }, 72 {"nse", "# nodes in the network (estimate)", "network size (estimate)",
73 { NULL, NULL, NULL} 73 "purple"},
74 }; 74 {NULL, NULL, NULL}
75};
75 76
76 77
77static const struct PlotInfo traffic_data[] = 78static const struct PlotInfo traffic_data[] = {
78 { 79 {"core", "# bytes encrypted", "bytes encrypted", "blue"},
79 { "core", "# bytes encrypted", "bytes encrypted", "blue" }, 80 {"core", "# bytes decrypted", "bytes decrypted", "green"},
80 { "core", "# bytes decrypted", "bytes decrypted", "green" }, 81 {"transport", "# bytes received via TCP", "received via tcp", "yellow"},
81 { "transport", "# bytes received via TCP", "received via tcp", "yellow" }, 82 {"transport", "# bytes transmitted via TCP", "sent via tcp", "brown"},
82 { "transport", "# bytes transmitted via TCP", "sent via tcp", "brown" }, 83 {NULL, NULL, NULL}
83 { NULL, NULL, NULL} 84};
84 };
85 85
86 86
87static const struct PlotInfo storage_data[] = 87static const struct PlotInfo storage_data[] = {
88 { 88 {"datastore", "# quota", "datastore capacity", "blue"},
89 { "datastore", "# quota", "datastore capacity", "blue" }, 89 {"datastore", "# utilization by current datastore", "datastore utilization",
90 { "datastore", "# utilization by current datastore", "datastore utilization", "yellow" }, 90 "yellow"},
91 { "datastore", "# cache size", "reservation for datastore cache", "green" }, 91 {"datastore", "# cache size", "reservation for datastore cache", "green"},
92 { "datastore", "# bytes purged (low-priority)", "discarded due to limited space", "red" }, 92 {"datastore", "# bytes purged (low-priority)",
93 { NULL, NULL, NULL} 93 "discarded due to limited space", "red"},
94 }; 94 {NULL, NULL, NULL}
95};
95 96
96 97
97/** 98/**
@@ -130,19 +131,17 @@ static struct GNUNET_TIME_Absolute start_time;
130 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not 131 * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not
131 * @return GNUNET_OK to continue 132 * @return GNUNET_OK to continue
132 */ 133 */
133static int 134static int
134process_value_update (void *cls, const char *subsystem, 135process_value_update (void *cls, const char *subsystem, const char *name,
135 const char *name, uint64_t value, 136 uint64_t value, int is_persistent)
136 int is_persistent)
137{ 137{
138 GtkStatistics *stats = cls; 138 GtkStatistics *stats = cls;
139 char *id; 139 char *id;
140 140
141 GNUNET_asprintf (&id, "%s: %s", subsystem, name); 141 GNUNET_asprintf (&id, "%s: %s", subsystem, name);
142 gtk_statistics_update_value (stats, 142 gtk_statistics_update_value (stats, id,
143 id, 143 GNUNET_TIME_absolute_get_duration
144 GNUNET_TIME_absolute_get_duration (start_time).rel_value / 1000LL, 144 (start_time).rel_value / 1000LL, value);
145 value);
146 GNUNET_free (id); 145 GNUNET_free (id);
147 return GNUNET_OK; 146 return GNUNET_OK;
148} 147}
@@ -168,8 +167,7 @@ get_object (const char *name)
168 * @param info what to draw 167 * @param info what to draw
169 */ 168 */
170static void 169static void
171create_plot (const char *box_name, 170create_plot (const char *box_name, const struct PlotInfo *info)
172 const struct PlotInfo *info)
173{ 171{
174 GtkBox *box; 172 GtkBox *box;
175 GtkStatistics *ret; 173 GtkStatistics *ret;
@@ -178,27 +176,17 @@ create_plot (const char *box_name,
178 176
179 ret = GTK_STATISTICS (gtk_statistics_new ()); 177 ret = GTK_STATISTICS (gtk_statistics_new ());
180 box = GTK_BOX (get_object (box_name)); 178 box = GTK_BOX (get_object (box_name));
181 179
182 for (i=0; NULL != info[i].subsystem; i++) 180 for (i = 0; NULL != info[i].subsystem; i++)
183 { 181 {
184 GNUNET_asprintf (&id, "%s: %s", info[i].subsystem, info[i].name); 182 GNUNET_asprintf (&id, "%s: %s", info[i].subsystem, info[i].name);
185 gtk_statistics_add_line (ret, 183 gtk_statistics_add_line (ret, id, info[i].label, info[i].color_name);
186 id,
187 info[i].label,
188 info[i].color_name);
189 GNUNET_free (id); 184 GNUNET_free (id);
190 GNUNET_STATISTICS_watch (statistics, 185 GNUNET_STATISTICS_watch (statistics, info[i].subsystem, info[i].name,
191 info[i].subsystem, 186 &process_value_update, ret);
192 info[i].name,
193 &process_value_update,
194 ret);
195 } 187 }
196 gtk_widget_show (GTK_WIDGET (ret)); 188 gtk_widget_show (GTK_WIDGET (ret));
197 gtk_box_pack_start (box, 189 gtk_box_pack_start (box, GTK_WIDGET (ret), TRUE, TRUE, 0);
198 GTK_WIDGET (ret),
199 TRUE,
200 TRUE,
201 0);
202} 190}
203 191
204 192
@@ -253,12 +241,13 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
253 GtkWidget *main_window; 241 GtkWidget *main_window;
254 242
255 ml = cls; 243 ml = cls;
256 statistics = GNUNET_STATISTICS_create ("gnunet-statistics-gtk", 244 statistics =
257 GNUNET_GTK_main_loop_get_configuration (ml)); 245 GNUNET_STATISTICS_create ("gnunet-statistics-gtk",
246 GNUNET_GTK_main_loop_get_configuration (ml));
258 if (NULL == statistics) 247 if (NULL == statistics)
259 { 248 {
260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
261 _("Failed to initiate connection with statistics service\n")); 250 _("Failed to initiate connection with statistics service\n"));
262 return; 251 return;
263 } 252 }
264 GNUNET_GTK_set_icon_search_path (); 253 GNUNET_GTK_set_icon_search_path ();
@@ -271,12 +260,9 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
271 "gnunet-gtk" /* FIXME: different icon? */ , 260 "gnunet-gtk" /* FIXME: different icon? */ ,
272 "gnunet-statistics-gtk"); 261 "gnunet-statistics-gtk");
273 262
274 create_plot ("GNUNET_STATISTICS_GTK_connectivity_box", 263 create_plot ("GNUNET_STATISTICS_GTK_connectivity_box", connection_data);
275 connection_data); 264 create_plot ("GNUNET_STATISTICS_GTK_traffic_box", traffic_data);
276 create_plot ("GNUNET_STATISTICS_GTK_traffic_box", 265 create_plot ("GNUNET_STATISTICS_GTK_storage_box", storage_data);
277 traffic_data);
278 create_plot ("GNUNET_STATISTICS_GTK_storage_box",
279 storage_data);
280 266
281 /* make GUI visible */ 267 /* make GUI visible */
282 if (!tray_only) 268 if (!tray_only)
diff --git a/src/statistics/gtk_statistics.c b/src/statistics/gtk_statistics.c
index 4b75b1ef..fff37cfe 100644
--- a/src/statistics/gtk_statistics.c
+++ b/src/statistics/gtk_statistics.c
@@ -115,19 +115,17 @@ struct _GtkStatisticsPrivate
115}; 115};
116 116
117 117
118static gboolean gtk_statistics_draw (GtkWidget *widget, 118static gboolean
119 cairo_t *cr); 119gtk_statistics_draw (GtkWidget * widget, cairo_t * cr);
120 120
121static void gtk_statistics_finalize (GObject *object); 121static void
122gtk_statistics_finalize (GObject * object);
122 123
123 124
124G_DEFINE_TYPE (GtkStatistics, gtk_statistics, GTK_TYPE_WIDGET) 125G_DEFINE_TYPE (GtkStatistics, gtk_statistics, GTK_TYPE_WIDGET)
125
126
127#if GTK_MAJOR_VERSION < 3 126#if GTK_MAJOR_VERSION < 3
128static gboolean 127 static gboolean statistics_expose (GtkWidget * statistics,
129statistics_expose (GtkWidget *statistics, 128 GdkEventExpose * event)
130 GdkEventExpose *event)
131{ 129{
132 GtkAllocation alloc; 130 GtkAllocation alloc;
133 cairo_t *cr; 131 cairo_t *cr;
@@ -135,53 +133,51 @@ statistics_expose (GtkWidget *statistics,
135 gint y; 133 gint y;
136 134
137 gtk_widget_translate_coordinates (statistics, 135 gtk_widget_translate_coordinates (statistics,
138 GTK_WIDGET (gtk_widget_get_toplevel (statistics)), 136 GTK_WIDGET (gtk_widget_get_toplevel
139 0, 0, 137 (statistics)), 0, 0, &x, &y);
140 &x, &y);
141 gtk_widget_get_allocation (statistics, &alloc); 138 gtk_widget_get_allocation (statistics, &alloc);
142 cr = gdk_cairo_create (statistics->window); 139 cr = gdk_cairo_create (statistics->window);
143 cairo_translate (cr, x, y); 140 cairo_translate (cr, x, y);
144 cairo_rectangle (cr, 141 cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
145 0, 0,
146 alloc.width, alloc.height);
147 cairo_clip (cr); 142 cairo_clip (cr);
148 143
149 gtk_statistics_draw (statistics, cr); 144 gtk_statistics_draw (statistics, cr);
150 cairo_destroy (cr); 145 cairo_destroy (cr);
151 return FALSE; 146 return FALSE;
152} 147}
153#endif 148#endif
154 149
155 150
156static void 151static void
157gtk_statistics_class_init (GtkStatisticsClass *class) 152gtk_statistics_class_init (GtkStatisticsClass * class)
158{ 153{
159 GObjectClass *gobject_class; 154 GObjectClass *gobject_class;
160 GtkWidgetClass *widget_class; 155 GtkWidgetClass *widget_class;
161 156
162 gobject_class = (GObjectClass*) class; 157 gobject_class = (GObjectClass *) class;
163 widget_class = (GtkWidgetClass*) class; 158 widget_class = (GtkWidgetClass *) class;
164 159
165 gobject_class->finalize = gtk_statistics_finalize; 160 gobject_class->finalize = gtk_statistics_finalize;
166#if GTK_MAJOR_VERSION >= 3 161#if GTK_MAJOR_VERSION >= 3
167 widget_class->draw = gtk_statistics_draw; 162 widget_class->draw = gtk_statistics_draw;
168#endif 163#endif
169 164
170 g_type_class_add_private (class, sizeof (GtkStatisticsPrivate)); 165 g_type_class_add_private (class, sizeof (GtkStatisticsPrivate));
171} 166}
172 167
173 168
174static void 169static void
175gtk_statistics_init (GtkStatistics *statistics) 170gtk_statistics_init (GtkStatistics * statistics)
176{ 171{
177 GtkStatisticsPrivate *priv; 172 GtkStatisticsPrivate *priv;
178 173
179 statistics->priv = G_TYPE_INSTANCE_GET_PRIVATE (statistics, 174 statistics->priv =
180 GTK_TYPE_STATISTICS, 175 G_TYPE_INSTANCE_GET_PRIVATE (statistics, GTK_TYPE_STATISTICS,
181 GtkStatisticsPrivate); 176 GtkStatisticsPrivate);
182 priv = statistics->priv; 177 priv = statistics->priv;
183#if GTK_MAJOR_VERSION < 3 178#if GTK_MAJOR_VERSION < 3
184 g_signal_connect (statistics, "expose-event", G_CALLBACK (statistics_expose), statistics); 179 g_signal_connect (statistics, "expose-event", G_CALLBACK (statistics_expose),
180 statistics);
185#endif 181#endif
186 gtk_widget_set_has_window (GTK_WIDGET (statistics), FALSE); 182 gtk_widget_set_has_window (GTK_WIDGET (statistics), FALSE);
187 priv->values = NULL; 183 priv->values = NULL;
@@ -196,7 +192,7 @@ gtk_statistics_init (GtkStatistics *statistics)
196 * 192 *
197 * Returns: the new #GtkStatistics widget. 193 * Returns: the new #GtkStatistics widget.
198 */ 194 */
199GtkWidget* 195GtkWidget *
200gtk_statistics_new () 196gtk_statistics_new ()
201{ 197{
202 GtkStatisticsPrivate *priv; 198 GtkStatisticsPrivate *priv;
@@ -221,10 +217,8 @@ gtk_statistics_new ()
221 * @param color_name name of the color to use 217 * @param color_name name of the color to use
222 */ 218 */
223void 219void
224gtk_statistics_add_line (GtkStatistics *statistics, 220gtk_statistics_add_line (GtkStatistics * statistics, const char *id,
225 const char *id, 221 const char *label, const char *color_name)
226 const char *label,
227 const char *color_name)
228{ 222{
229 GtkStatisticsPrivate *priv; 223 GtkStatisticsPrivate *priv;
230 struct ValueHistory *vh; 224 struct ValueHistory *vh;
@@ -233,10 +227,12 @@ gtk_statistics_add_line (GtkStatistics *statistics,
233 g_return_if_fail (GTK_IS_STATISTICS (statistics)); 227 g_return_if_fail (GTK_IS_STATISTICS (statistics));
234 g_return_if_fail (gdk_color_parse (color_name, &c)); 228 g_return_if_fail (gdk_color_parse (color_name, &c));
235 priv = statistics->priv; 229 priv = statistics->priv;
236 priv->values = g_realloc (priv->values, 230 priv->values =
237 sizeof (struct ValueHistory*) * (1 + priv->num_values)); 231 g_realloc (priv->values,
238 priv->values[priv->num_values++] = vh = g_malloc (sizeof (struct ValueHistory)); 232 sizeof (struct ValueHistory *) * (1 + priv->num_values));
239 vh->id = strdup (id); 233 priv->values[priv->num_values++] = vh =
234 g_malloc (sizeof (struct ValueHistory));
235 vh->id = strdup (id);
240 vh->label = strdup (label); 236 vh->label = strdup (label);
241 vh->red = c.red / 65535.0; 237 vh->red = c.red / 65535.0;
242 vh->green = c.green / 65535.0; 238 vh->green = c.green / 65535.0;
@@ -248,17 +244,15 @@ gtk_statistics_add_line (GtkStatistics *statistics,
248 244
249/** 245/**
250 * Add another value to a data series. 246 * Add another value to a data series.
251 * 247 *
252 * @param statistics widget to update 248 * @param statistics widget to update
253 * @param id identifier of the series 249 * @param id identifier of the series
254 * @param x new x-value 250 * @param x new x-value
255 * @param y new y-value 251 * @param y new y-value
256 */ 252 */
257void 253void
258gtk_statistics_update_value (GtkStatistics *statistics, 254gtk_statistics_update_value (GtkStatistics * statistics, const char *id,
259 const char *id, 255 uint64_t x, uint64_t y)
260 uint64_t x,
261 uint64_t y)
262{ 256{
263 GtkStatisticsPrivate *priv; 257 GtkStatisticsPrivate *priv;
264 GtkWidget *widget; 258 GtkWidget *widget;
@@ -267,7 +261,7 @@ gtk_statistics_update_value (GtkStatistics *statistics,
267 261
268 g_return_if_fail (GTK_IS_STATISTICS (statistics)); 262 g_return_if_fail (GTK_IS_STATISTICS (statistics));
269 priv = statistics->priv; 263 priv = statistics->priv;
270 for (i=0;i<priv->num_values;i++) 264 for (i = 0; i < priv->num_values; i++)
271 { 265 {
272 vh = priv->values[i]; 266 vh = priv->values[i];
273 if (0 != strcmp (id, vh->id)) 267 if (0 != strcmp (id, vh->id))
@@ -278,7 +272,7 @@ gtk_statistics_update_value (GtkStatistics *statistics,
278 if (vh->history_size < MAX_HISTORY) 272 if (vh->history_size < MAX_HISTORY)
279 vh->history_size++; 273 vh->history_size++;
280 vh->history[vh->last_history_offset].x = x; 274 vh->history[vh->last_history_offset].x = x;
281 vh->history[vh->last_history_offset].y = y; 275 vh->history[vh->last_history_offset].y = y;
282 widget = GTK_WIDGET (statistics); 276 widget = GTK_WIDGET (statistics);
283 if (gtk_widget_is_drawable (widget)) 277 if (gtk_widget_is_drawable (widget))
284 gtk_widget_queue_draw (widget); 278 gtk_widget_queue_draw (widget);
@@ -293,8 +287,7 @@ gtk_statistics_update_value (GtkStatistics *statistics,
293 * @param label where to store the string (must be big enough!) 287 * @param label where to store the string (must be big enough!)
294 */ 288 */
295static void 289static void
296num_to_label (unsigned long long num, 290num_to_label (unsigned long long num, char *label)
297 char *label)
298{ 291{
299 if (num > 1000LL * 1000 * 1000 * 1000 * 3) 292 if (num > 1000LL * 1000 * 1000 * 1000 * 3)
300 sprintf (label, "%llu t", num / 1000LL / 1000LL / 1000LL / 1000LL); 293 sprintf (label, "%llu t", num / 1000LL / 1000LL / 1000LL / 1000LL);
@@ -316,8 +309,7 @@ num_to_label (unsigned long long num,
316 * @param cr drawing context 309 * @param cr drawing context
317 */ 310 */
318static gboolean 311static gboolean
319gtk_statistics_draw (GtkWidget *widget, 312gtk_statistics_draw (GtkWidget * widget, cairo_t * cr)
320 cairo_t *cr)
321{ 313{
322 GtkStatistics *statistics = GTK_STATISTICS (widget); 314 GtkStatistics *statistics = GTK_STATISTICS (widget);
323 GtkStatisticsPrivate *priv = statistics->priv; 315 GtkStatisticsPrivate *priv = statistics->priv;
@@ -343,168 +335,199 @@ gtk_statistics_draw (GtkWidget *widget,
343 xmin = UINT64_MAX; 335 xmin = UINT64_MAX;
344 xmax = 0; 336 xmax = 0;
345 ymax = 0; 337 ymax = 0;
346 for (i=0;i<priv->num_values;i++) 338 for (i = 0; i < priv->num_values; i++)
347 { 339 {
348 vh = priv->values[i]; 340 vh = priv->values[i];
349 for (j=0;j<vh->history_size;j++) 341 for (j = 0; j < vh->history_size; j++)
350 { 342 {
351 hv = &vh->history[(vh->last_history_offset - j + MAX_HISTORY) % MAX_HISTORY]; 343 hv = &vh->history[(vh->last_history_offset - j + MAX_HISTORY) %
344 MAX_HISTORY];
352 xmin = GNUNET_MIN (hv->x, xmin); 345 xmin = GNUNET_MIN (hv->x, xmin);
353 xmax = GNUNET_MAX (hv->x, xmax); 346 xmax = GNUNET_MAX (hv->x, xmax);
354 ymax = GNUNET_MAX (hv->y, ymax); 347 ymax = GNUNET_MAX (hv->y, ymax);
355 } 348 }
356 } 349 }
357 /* round to 10x for nicer legends */ 350 /* round to 10x for nicer legends */
358 while (0 != (ymax % 10)) ymax++; 351 while (0 != (ymax % 10))
359 while (0 != (xmax % 10)) xmax++; 352 ymax++;
360 while (0 != (xmin % 10)) xmin--; 353 while (0 != (xmax % 10))
354 xmax++;
355 while (0 != (xmin % 10))
356 xmin--;
361 357
362 gtk_widget_get_allocation (widget, &alloc); 358 gtk_widget_get_allocation (widget, &alloc);
363 width = alloc.width; 359 width = alloc.width;
364 height = alloc.height; 360 height = alloc.height;
365 361
366 /* fill with black background */ 362 /* fill with black background */
367 cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); 363 cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
368 cairo_paint(cr); 364 cairo_paint (cr);
369 365
370 if ( (0 == priv->num_values) || (ymax == 0) ) 366 if ((0 == priv->num_values) || (ymax == 0))
371 return FALSE; /* done */ 367 return FALSE; /* done */
372 /* select font */ 368 /* select font */
373 cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); 369 cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
374 cairo_select_font_face (cr, "Georgia", 370 cairo_select_font_face (cr, "Georgia", CAIRO_FONT_SLANT_NORMAL,
375 CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); 371 CAIRO_FONT_WEIGHT_BOLD);
376 cairo_set_font_size (cr, 372 cairo_set_font_size (cr, GNUNET_MIN (20, height / (2 * XTICKS)));
377 GNUNET_MIN (20, height / (2 * XTICKS)));
378 373
379 /* find out needed space for axis labels */ 374 /* find out needed space for axis labels */
380 tex_max.width = 0; 375 tex_max.width = 0;
381 tex_max.height = 0; 376 tex_max.height = 0;
382 for (i=0;i<XTICKS;i++) 377 for (i = 0; i < XTICKS; i++)
383 { 378 {
384 num_to_label ((unsigned long long) (xmin + (xmax - xmin) * ((uint64_t) i) / (XTICKS - 1)), 379 num_to_label ((unsigned long long) (xmin +
385 label); 380 (xmax -
381 xmin) * ((uint64_t) i) / (XTICKS - 1)),
382 label);
386 cairo_text_extents (cr, label, &te); 383 cairo_text_extents (cr, label, &te);
387 tex_max.width = GNUNET_MAX (te.width, tex_max.width); 384 tex_max.width = GNUNET_MAX (te.width, tex_max.width);
388 tex_max.height = GNUNET_MAX (te.height, tex_max.height); 385 tex_max.height = GNUNET_MAX (te.height, tex_max.height);
389 } 386 }
390 tey_max.width = 0; 387 tey_max.width = 0;
391 tey_max.height = 0; 388 tey_max.height = 0;
392 for (i=0;i<YTICKS;i++) 389 for (i = 0; i < YTICKS; i++)
393 { 390 {
394 num_to_label ((unsigned long long) ymax * ((uint64_t) i) / (YTICKS - 1), 391 num_to_label ((unsigned long long) ymax * ((uint64_t) i) / (YTICKS - 1),
395 label); 392 label);
396 cairo_text_extents (cr, label, &te); 393 cairo_text_extents (cr, label, &te);
397 tey_max.width = GNUNET_MAX (te.width, tey_max.width); 394 tey_max.width = GNUNET_MAX (te.width, tey_max.width);
398 tey_max.height = GNUNET_MAX (te.height, tey_max.height); 395 tey_max.height = GNUNET_MAX (te.height, tey_max.height);
399 } 396 }
400 397
401 /* draw y-axis labels */ 398 /* draw y-axis labels */
402 for (i=0;i<YTICKS;i++) 399 for (i = 0; i < YTICKS; i++)
403 { 400 {
404 num_to_label ((unsigned long long) ymax * ((uint64_t) i) / (YTICKS - 1), 401 num_to_label ((unsigned long long) ymax * ((uint64_t) i) / (YTICKS - 1),
405 label); 402 label);
406 cairo_text_extents (cr, label, &te); 403 cairo_text_extents (cr, label, &te);
407 cairo_move_to (cr, 404 cairo_move_to (cr, BORDER + tey_max.width - te.width,
408 BORDER + tey_max.width - te.width, 405 BORDER + tey_max.height + (YTICKS - i - 1) * (height -
409 BORDER + tey_max.height + (YTICKS - i - 1) * (height - 2.0 * BORDER - tey_max.height - tex_max.height) / (double) (YTICKS - 1)); 406 2.0 * BORDER -
407 tey_max.height
408 -
409 tex_max.height)
410 / (double) (YTICKS - 1));
410 cairo_show_text (cr, label); 411 cairo_show_text (cr, label);
411 412
412 413
413 cairo_move_to (cr, 414 cairo_move_to (cr, 2.0 * BORDER + tey_max.width,
414 2.0 * BORDER + tey_max.width, 415 BORDER + tey_max.height / 2.0 + (YTICKS - i - 1) * (height -
415 BORDER + tey_max.height / 2.0 + (YTICKS - i - 1) * (height - 2.0 * BORDER - tex_max.height - tey_max.height) / (double) (YTICKS - 1)); 416 2.0 *
416 cairo_line_to (cr, 417 BORDER -
417 2.0 * BORDER + tey_max.width + BORDER / 2.0, 418 tex_max.height
418 BORDER + tey_max.height / 2.0 + (YTICKS - i - 1) * (height - 2.0 * BORDER - tex_max.height - tey_max.height) / (double) (YTICKS - 1)); 419 -
420 tey_max.height)
421 / (double) (YTICKS - 1));
422 cairo_line_to (cr, 2.0 * BORDER + tey_max.width + BORDER / 2.0,
423 BORDER + tey_max.height / 2.0 + (YTICKS - i - 1) * (height -
424 2.0 *
425 BORDER -
426 tex_max.height
427 -
428 tey_max.height)
429 / (double) (YTICKS - 1));
419 430
420 cairo_stroke (cr); 431 cairo_stroke (cr);
421 } 432 }
422 433
423 /* draw x-axis labels */ 434 /* draw x-axis labels */
424 for (i=0;i<XTICKS;i++) 435 for (i = 0; i < XTICKS; i++)
425 { 436 {
426 num_to_label ((unsigned long long) (xmin + (xmax - xmin) * ((uint64_t) i) / (XTICKS - 1)), 437 num_to_label ((unsigned long long) (xmin +
427 label); 438 (xmax -
439 xmin) * ((uint64_t) i) / (XTICKS - 1)),
440 label);
428 cairo_text_extents (cr, label, &te); 441 cairo_text_extents (cr, label, &te);
429 if (i != 0) 442 if (i != 0)
430 { 443 {
431 cairo_move_to (cr, 444 cairo_move_to (cr,
432 2.0 * BORDER + tey_max.width + (width - tey_max.width - tex_max.width / 2.0 - 3.0 * BORDER) * i / (XTICKS - 1.0) - te.width / 2.0, 445 2.0 * BORDER + tey_max.width + (width - tey_max.width -
433 height - BORDER / 2.0 - tex_max.height / 2.0); 446 tex_max.width / 2.0 -
447 3.0 * BORDER) * i /
448 (XTICKS - 1.0) - te.width / 2.0,
449 height - BORDER / 2.0 - tex_max.height / 2.0);
434 cairo_show_text (cr, label); 450 cairo_show_text (cr, label);
435 } 451 }
436 cairo_move_to (cr, 452 cairo_move_to (cr,
437 2.0 * BORDER + tey_max.width + (width - tey_max.width - tex_max.width / 2.0 - 3.0 * BORDER) * i / (XTICKS - 1.0), 453 2.0 * BORDER + tey_max.width + (width - tey_max.width -
438 height - BORDER - tey_max.height / 2.0 - tex_max.height); 454 tex_max.width / 2.0 -
439 cairo_line_to (cr, 455 3.0 * BORDER) * i / (XTICKS -
440 2.0 * BORDER + tey_max.width + (width - tey_max.width - tex_max.width / 2.0 - 3.0 * BORDER) * i / (XTICKS - 1.0), 456 1.0),
441 height - BORDER - tey_max.height / 2.0 - tex_max.height - BORDER / 2.0); 457 height - BORDER - tey_max.height / 2.0 - tex_max.height);
458 cairo_line_to (cr,
459 2.0 * BORDER + tey_max.width + (width - tey_max.width -
460 tex_max.width / 2.0 -
461 3.0 * BORDER) * i / (XTICKS -
462 1.0),
463 height - BORDER - tey_max.height / 2.0 - tex_max.height -
464 BORDER / 2.0);
442 465
443 cairo_stroke (cr); 466 cairo_stroke (cr);
444 } 467 }
445 468
446 /* plot border */ 469 /* plot border */
447 cairo_set_line_width (cr, 1.0); 470 cairo_set_line_width (cr, 1.0);
448 cairo_rectangle (cr, 471 cairo_rectangle (cr, tey_max.width + BORDER * 2.0,
449 tey_max.width + BORDER * 2.0, 472 BORDER + tey_max.height / 2.0,
450 BORDER + tey_max.height / 2.0, 473 width - BORDER * 3.0 - tey_max.width - tex_max.width / 2.0,
451 width - BORDER * 3.0 - tey_max.width - tex_max.width / 2.0, 474 height - BORDER * 2.0 - tey_max.height - tex_max.height);
452 height - BORDER * 2.0 - tey_max.height - tex_max.height);
453 cairo_stroke (cr); 475 cairo_stroke (cr);
454 476
455 /* finally, plot lines */ 477 /* finally, plot lines */
456 cairo_set_line_width (cr, 2.0); 478 cairo_set_line_width (cr, 2.0);
457 479
458 cairo_set_font_size (cr, 480 cairo_set_font_size (cr,
459 GNUNET_MIN (20, (height - 3.0 * BORDER - tex_max.height - tey_max.height / 2) / (priv->num_values + 1))); 481 GNUNET_MIN (20,
482 (height - 3.0 * BORDER - tex_max.height -
483 tey_max.height / 2) / (priv->num_values +
484 1)));
460 485
461 h = 2.0 * BORDER + tey_max.height / 2; 486 h = 2.0 * BORDER + tey_max.height / 2;
462 487
463 for (i=0;i<priv->num_values;i++) 488 for (i = 0; i < priv->num_values; i++)
464 { 489 {
465 vh = priv->values[i]; 490 vh = priv->values[i];
466 cairo_set_source_rgb(cr, vh->red, vh->green, vh->blue); 491 cairo_set_source_rgb (cr, vh->red, vh->green, vh->blue);
467 cairo_text_extents (cr, vh->label, &te); 492 cairo_text_extents (cr, vh->label, &te);
468 h += te.height / 2; 493 h += te.height / 2;
469 cairo_move_to (cr, 494 cairo_move_to (cr, 3.0 * BORDER + tey_max.width, h);
470 3.0 * BORDER + tey_max.width,
471 h);
472 h += te.height / 2 + 1.0; 495 h += te.height / 2 + 1.0;
473 cairo_show_text (cr, vh->label); 496 cairo_show_text (cr, vh->label);
474 if (xmax == xmin) 497 if (xmax == xmin)
475 { 498 {
476 hv = &vh->history[vh->last_history_offset % MAX_HISTORY]; 499 hv = &vh->history[vh->last_history_offset % MAX_HISTORY];
477 ry = hv->y / (double) ymax; 500 ry = hv->y / (double) ymax;
478 ry = BORDER + tex_max.height / 2.0 + (1.0 - ry) * (height - BORDER * 2.0 - tey_max.height - tex_max.height); 501 ry = BORDER + tex_max.height / 2.0 + (1.0 - ry) * (height - BORDER * 2.0 -
502 tey_max.height -
503 tex_max.height);
479 /* if y-values are small, offset y-values a bit to allow overlapping curves to still show up */ 504 /* if y-values are small, offset y-values a bit to allow overlapping curves to still show up */
480 if (ymax < height / (priv->num_values * 4)) 505 if (ymax < height / (priv->num_values * 4))
481 ry += priv->num_values * 2 - (4 * i); 506 ry += priv->num_values * 2 - (4 * i);
482 cairo_move_to (cr, 507 cairo_move_to (cr, width - BORDER - tex_max.width / 2.0, ry);
483 width - BORDER - tex_max.width / 2.0, 508 cairo_line_to (cr, rx = tey_max.width + BORDER * 2.0, ry);
484 ry);
485 cairo_line_to (cr,
486 rx = tey_max.width + BORDER * 2.0,
487 ry);
488 cairo_stroke (cr); 509 cairo_stroke (cr);
489 continue; 510 continue;
490 } 511 }
491 512
492 for (j=0;j<vh->history_size;j++) 513 for (j = 0; j < vh->history_size; j++)
493 { 514 {
494 hv = &vh->history[(vh->last_history_offset - j + MAX_HISTORY) % MAX_HISTORY]; 515 hv = &vh->history[(vh->last_history_offset - j + MAX_HISTORY) %
516 MAX_HISTORY];
495 rx = (hv->x - xmin) / (double) (xmax - xmin); 517 rx = (hv->x - xmin) / (double) (xmax - xmin);
496 ry = hv->y / (double) ymax; 518 ry = hv->y / (double) ymax;
497 519
498 rx = tey_max.width + BORDER * 2.0 + (rx * (width - BORDER * 3.0 - tey_max.width - tex_max.width / 2.0)); 520 rx = tey_max.width + BORDER * 2.0 +
499 ry = BORDER + tex_max.height / 2.0 + (1.0 - ry) * (height - BORDER * 2.0 - tey_max.height - tex_max.height); 521 (rx * (width - BORDER * 3.0 - tey_max.width - tex_max.width / 2.0));
522 ry = BORDER + tex_max.height / 2.0 + (1.0 - ry) * (height - BORDER * 2.0 -
523 tey_max.height -
524 tex_max.height);
500 525
501 /* if y-values are small, offset y-values a bit to allow overlapping curves to still show up */ 526 /* if y-values are small, offset y-values a bit to allow overlapping curves to still show up */
502 if (ymax < height / (priv->num_values * 4)) 527 if (ymax < height / (priv->num_values * 4))
503 ry += priv->num_values * 2 - (4 * i); 528 ry += priv->num_values * 2 - (4 * i);
504 if (j == 0) 529 if (j == 0)
505 cairo_move_to (cr, 530 cairo_move_to (cr, width - BORDER - tex_max.width / 2.0, ry);
506 width - BORDER - tex_max.width / 2.0,
507 ry);
508 cairo_line_to (cr, rx, ry); 531 cairo_line_to (cr, rx, ry);
509 } 532 }
510 cairo_stroke (cr); 533 cairo_stroke (cr);
@@ -519,19 +542,19 @@ gtk_statistics_draw (GtkWidget *widget,
519 * @param object object to release 542 * @param object object to release
520 */ 543 */
521static void 544static void
522gtk_statistics_finalize (GObject *object) 545gtk_statistics_finalize (GObject * object)
523{ 546{
524 GtkStatistics *label = GTK_STATISTICS (object); 547 GtkStatistics *label = GTK_STATISTICS (object);
525 GtkStatisticsPrivate *priv = label->priv; 548 GtkStatisticsPrivate *priv = label->priv;
526 unsigned int i; 549 unsigned int i;
527 550
528 for (i=0;i<priv->num_values;i++) 551 for (i = 0; i < priv->num_values; i++)
529 { 552 {
530 g_free (priv->values[i]->label); 553 g_free (priv->values[i]->label);
531 g_free (priv->values[i]->id); 554 g_free (priv->values[i]->id);
532 g_free (priv->values[i]); 555 g_free (priv->values[i]);
533 } 556 }
534 g_free (priv->values); 557 g_free (priv->values);
535 G_OBJECT_CLASS (gtk_statistics_parent_class)->finalize (object); 558 G_OBJECT_CLASS (gtk_statistics_parent_class)->finalize (object);
536} 559}
537 560
diff --git a/src/statistics/gtk_statistics.h b/src/statistics/gtk_statistics.h
index 88a897c8..5dd528b9 100644
--- a/src/statistics/gtk_statistics.h
+++ b/src/statistics/gtk_statistics.h
@@ -31,23 +31,21 @@
31#include <cairo.h> 31#include <cairo.h>
32 32
33G_BEGIN_DECLS 33G_BEGIN_DECLS
34
35#define GTK_TYPE_STATISTICS (gtk_statistics_get_type ()) 34#define GTK_TYPE_STATISTICS (gtk_statistics_get_type ())
36#define GTK_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STATISTICS, GtkStatistics)) 35#define GTK_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_STATISTICS, GtkStatistics))
37#define GTK_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STATISTICS, GtkStatisticsClass)) 36#define GTK_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_STATISTICS, GtkStatisticsClass))
38#define GTK_IS_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STATISTICS)) 37#define GTK_IS_STATISTICS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_STATISTICS))
39#define GTK_IS_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STATISTICS)) 38#define GTK_IS_STATISTICS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STATISTICS))
40#define GTK_STATISTICS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STATISTICS, GtkStatisticsClass)) 39#define GTK_STATISTICS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_STATISTICS, GtkStatisticsClass))
41 40typedef struct _GtkStatistics GtkStatistics;
42typedef struct _GtkStatistics GtkStatistics; 41typedef struct _GtkStatisticsPrivate GtkStatisticsPrivate;
43typedef struct _GtkStatisticsPrivate GtkStatisticsPrivate; 42typedef struct _GtkStatisticsClass GtkStatisticsClass;
44typedef struct _GtkStatisticsClass GtkStatisticsClass;
45 43
46struct _GtkStatistics 44struct _GtkStatistics
47{ 45{
48 GtkWidget widget; 46 GtkWidget widget;
49 47
50 /*< private >*/ 48 /*< private > */
51 GtkStatisticsPrivate *priv; 49 GtkStatisticsPrivate *priv;
52}; 50};
53 51
@@ -63,18 +61,15 @@ struct _GtkStatisticsClass
63}; 61};
64 62
65 63
66GType gtk_statistics_get_type (void) G_GNUC_CONST; 64GType
67GtkWidget* gtk_statistics_new (void); 65gtk_statistics_get_type (void)
68void gtk_statistics_add_line (GtkStatistics *statistics, 66 G_GNUC_CONST;
69 const char *id, 67 GtkWidget *gtk_statistics_new (void);
70 const char *label, 68 void gtk_statistics_add_line (GtkStatistics * statistics, const char *id,
71 const char *color_name); 69 const char *label, const char *color_name);
72void gtk_statistics_update_value (GtkStatistics *statistics, 70 void gtk_statistics_update_value (GtkStatistics * statistics, const char *id,
73 const char *id, 71 uint64_t x, uint64_t y);
74 uint64_t x,
75 uint64_t y);
76 72
77 73
78G_END_DECLS 74G_END_DECLS
79 75#endif
80#endif
diff --git a/src/statistics/gtk_statistics_demo.c b/src/statistics/gtk_statistics_demo.c
index cdd61cd0..efd98e07 100644
--- a/src/statistics/gtk_statistics_demo.c
+++ b/src/statistics/gtk_statistics_demo.c
@@ -7,63 +7,51 @@
7 * Update view (add more points). 7 * Update view (add more points).
8 */ 8 */
9static gboolean 9static gboolean
10update (GtkWidget *widget, GdkEvent *event, gpointer user_data) 10update (GtkWidget * widget, GdkEvent * event, gpointer user_data)
11{ 11{
12 static unsigned int i = 600; 12 static unsigned int i = 600;
13 struct GtkStatistics *statistics = user_data; 13 struct GtkStatistics *statistics = user_data;
14 14
15 gtk_statistics_update_value (GTK_STATISTICS (statistics), 15 gtk_statistics_update_value (GTK_STATISTICS (statistics), "sin", i,
16 "sin", 16 (uint64_t) (500 * (1.0 + sin (i / 100.0))));
17 i, 17 gtk_statistics_update_value (GTK_STATISTICS (statistics), "cos", i * 2,
18 (uint64_t) (500 * (1.0 + sin(i/100.0)))); 18 (uint64_t) (i * (1.0 + cos (i / 100.0))));
19 gtk_statistics_update_value (GTK_STATISTICS (statistics),
20 "cos",
21 i * 2,
22 (uint64_t) (i * (1.0 + cos(i/100.0))));
23 i++; 19 i++;
24 return FALSE; 20 return FALSE;
25} 21}
26 22
27 23
28int main (int argc, char ** argv) 24int
25main (int argc, char **argv)
29{ 26{
30 GtkWidget *window; 27 GtkWidget *window;
31 GtkWidget *statistics; 28 GtkWidget *statistics;
32 unsigned int i; 29 unsigned int i;
33 30
34 gtk_init(&argc, &argv); 31 gtk_init (&argc, &argv);
35 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 32 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
36 gtk_window_set_title(GTK_WINDOW(window), "STATISTICS widget"); 33 gtk_window_set_title (GTK_WINDOW (window), "STATISTICS widget");
37 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); 34 gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
38 gtk_window_set_default_size(GTK_WINDOW(window), 400, 200); 35 gtk_window_set_default_size (GTK_WINDOW (window), 400, 200);
39 g_signal_connect(G_OBJECT(window), "destroy", 36 g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit),
40 G_CALLBACK(gtk_main_quit), NULL); 37 NULL);
41 statistics = gtk_statistics_new(); 38 statistics = gtk_statistics_new ();
42 gtk_statistics_add_line (GTK_STATISTICS (statistics), 39 gtk_statistics_add_line (GTK_STATISTICS (statistics), "sin", "sin", "red");
43 "sin", 40 for (i = 0; i < 600; i++)
44 "sin", 41 gtk_statistics_update_value (GTK_STATISTICS (statistics), "sin", i,
45 "red"); 42 (uint64_t) (500 * (1.0 + sin (i / 100.0))));
46 for (i=0;i<600;i++) 43 gtk_statistics_add_line (GTK_STATISTICS (statistics), "cos", "cos", "blue");
47 gtk_statistics_update_value (GTK_STATISTICS (statistics), 44 for (i = 0; i < 600; i++)
48 "sin", 45 gtk_statistics_update_value (GTK_STATISTICS (statistics), "cos", i * 2,
49 i, 46 (uint64_t) (i * (1.0 + cos (i / 100.0))));
50 (uint64_t) (500 * (1.0 + sin(i/100.0)))); 47 g_signal_connect (G_OBJECT (window), "motion-notify-event",
51 gtk_statistics_add_line (GTK_STATISTICS (statistics), 48 G_CALLBACK (update), statistics);
52 "cos", 49 gtk_container_add (GTK_CONTAINER (window), statistics);
53 "cos",
54 "blue");
55 for (i=0;i<600;i++)
56 gtk_statistics_update_value (GTK_STATISTICS (statistics),
57 "cos",
58 i * 2,
59 (uint64_t) (i * (1.0 + cos(i/100.0))));
60 g_signal_connect (G_OBJECT(window), "motion-notify-event", G_CALLBACK (update), statistics);
61 gtk_container_add(GTK_CONTAINER(window), statistics);
62 gtk_widget_add_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK); 50 gtk_widget_add_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK);
63 51
64 gtk_widget_show(statistics); 52 gtk_widget_show (statistics);
65 gtk_widget_show_all(window); 53 gtk_widget_show_all (window);
66 gtk_main(); 54 gtk_main ();
67 55
68 return 0; 56 return 0;
69} 57}
diff --git a/src/statistics/statistics.c b/src/statistics/statistics.c
index b8dd2cd3..af5f3a06 100644
--- a/src/statistics/statistics.c
+++ b/src/statistics/statistics.c
@@ -84,40 +84,37 @@ load_graph_draw (LoadGraph * g)
84 g->draw_height = g->disp->allocation.height; 84 g->draw_height = g->disp->allocation.height;
85 85
86 if (!g->pixmap) 86 if (!g->pixmap)
87 g->pixmap = gdk_pixmap_new (g->disp->window, 87 g->pixmap =
88 g->draw_width, g->draw_height, 88 gdk_pixmap_new (g->disp->window, g->draw_width, g->draw_height,
89 gtk_widget_get_visual (g->disp)->depth); 89 gtk_widget_get_visual (g->disp)->depth);
90 90
91 /* Create GC if necessary. */ 91 /* Create GC if necessary. */
92 if (!g->gc) 92 if (!g->gc)
93 { 93 {
94 g->gc = gdk_gc_new (g->disp->window); 94 g->gc = gdk_gc_new (g->disp->window);
95 gdk_gc_copy (g->gc, g->disp->style->white_gc); 95 gdk_gc_copy (g->gc, g->disp->style->white_gc);
96 } 96 }
97 97
98 /* Allocate colors. */ 98 /* Allocate colors. */
99 if (!g->colors_allocated) 99 if (!g->colors_allocated)
100 { 100 {
101 GdkColormap *colormap; 101 GdkColormap *colormap;
102 102
103 colormap = gdk_window_get_colormap (g->disp->window); 103 colormap = gdk_window_get_colormap (g->disp->window);
104 for (i = 0; i < 2 + g->count; i++) 104 for (i = 0; i < 2 + g->count; i++)
105 gdk_color_alloc (colormap, &(g->colors[i])); 105 gdk_color_alloc (colormap, &(g->colors[i]));
106 106
107 g->colors_allocated = 1; 107 g->colors_allocated = 1;
108 } 108 }
109 /* Erase Rectangle */ 109 /* Erase Rectangle */
110 gdk_gc_set_foreground (g->gc, &(g->colors[0])); 110 gdk_gc_set_foreground (g->gc, &(g->colors[0]));
111 gdk_draw_rectangle (g->pixmap, 111 gdk_draw_rectangle (g->pixmap, g->gc, TRUE, 0, 0, g->disp->allocation.width,
112 g->gc, 112 g->disp->allocation.height);
113 TRUE, 0, 0,
114 g->disp->allocation.width, g->disp->allocation.height);
115 113
116 /* draw frame */ 114 /* draw frame */
117 gdk_gc_set_foreground (g->gc, &(g->colors[1])); 115 gdk_gc_set_foreground (g->gc, &(g->colors[1]));
118 gdk_draw_rectangle (g->pixmap, 116 gdk_draw_rectangle (g->pixmap, g->gc, FALSE, 0, 0, g->draw_width,
119 g->gc, 117 g->disp->allocation.height);
120 FALSE, 0, 0, g->draw_width, g->disp->allocation.height);
121 118
122 max = 0.26; /* force showing at least the 25% line */ 119 max = 0.26; /* force showing at least the 25% line */
123 for (i = 0; i < g->num_points - 1; i++) 120 for (i = 0; i < g->num_points - 1; i++)
@@ -127,99 +124,94 @@ load_graph_draw (LoadGraph * g)
127 max = max * 1.01; /* leave top 1% free */ 124 max = max * 1.01; /* leave top 1% free */
128 125
129 font = gdk_font_load ("fixed"); /* deprecated, but pango is far more than 126 font = gdk_font_load ("fixed"); /* deprecated, but pango is far more than
130 what we need here -- fix later? */ 127 * what we need here -- fix later? */
131 /* draw lines at 25%, 50%, 75% and 100% of max */ 128 /* draw lines at 25%, 50%, 75% and 100% of max */
132 dely = g->draw_height / max / 4; 129 dely = g->draw_height / max / 4;
133 for (i = 1; i < 5; i++) 130 for (i = 1; i < 5; i++)
131 {
132 gint y1 = g->draw_height + 1 - i * dely;
133
134 if ((dely < 30) && (i != 4))
135 continue; /* only print additional
136 * lines if there is enough space! */
137 if (y1 > 0)
134 { 138 {
135 gint y1 = g->draw_height + 1 - i * dely; 139 const gchar *label[] = {
136 if ((dely < 30) && (i != 4)) 140 NULL,
137 continue; /* only print additional 141 " 25%",
138 lines if there is enough space! */ 142 " 50%",
139 if (y1 > 0) 143 " 75%",
140 { 144 "100%",
141 const gchar *label[] = { 145 };
142 NULL, 146 gdk_draw_string (g->pixmap, font, g->gc, 10, y1 - 8, label[i]);
143 " 25%", 147 gdk_draw_line (g->pixmap, g->gc, 0, y1, g->draw_width, y1);
144 " 50%", 148 if (i == 4)
145 " 75%", 149 {
146 "100%", 150 /* extra-thick line at 100% */
147 }; 151 gdk_draw_line (g->pixmap, g->gc, 0, y1 - 1, g->draw_width, y1 - 1);
148 gdk_draw_string (g->pixmap, font, g->gc, 10, y1 - 8, label[i]); 152 gdk_draw_line (g->pixmap, g->gc, 0, y1 + 1, g->draw_width, y1 + 1);
149 gdk_draw_line (g->pixmap, g->gc, 0, y1, g->draw_width, y1); 153
150 if (i == 4) 154 }
151 {
152 /* extra-thick line at 100% */
153 gdk_draw_line (g->pixmap, g->gc,
154 0, y1 - 1, g->draw_width, y1 - 1);
155 gdk_draw_line (g->pixmap, g->gc,
156 0, y1 + 1, g->draw_width, y1 + 1);
157
158 }
159 }
160 } 155 }
161 gdk_gc_set_line_attributes (g->gc, 156 }
162 2, 157 gdk_gc_set_line_attributes (g->gc, 2, GDK_LINE_SOLID, GDK_CAP_ROUND,
163 GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER); 158 GDK_JOIN_MITER);
164 delx = (float) g->draw_width / (g->num_points - 1); 159 delx = (float) g->draw_width / (g->num_points - 1);
165 160
166 for (j = 0; j < g->count; j++) 161 for (j = 0; j < g->count; j++)
162 {
163 gdk_gc_set_foreground (g->gc, &(g->colors[j + 2]));
164 for (i = 0; i < g->num_points - 1; i++)
167 { 165 {
168 gdk_gc_set_foreground (g->gc, &(g->colors[j + 2])); 166 gint x1 = i * delx;
169 for (i = 0; i < g->num_points - 1; i++) 167 gint x2 = (i + 1) * delx;
168 gint y1 = g->data[i][j] / max * g->draw_height - 1;
169 gint y2 = g->data[i + 1][j] / max * g->draw_height - 1;
170
171 if ((g->data[i][j] != -1) && (g->data[i + 1][j] != -1))
172 {
173 if (stats[g->statIdx].fill <= j)
170 { 174 {
171 gint x1 = i * delx; 175 gdk_draw_line (g->pixmap, g->gc, g->draw_width - x2,
172 gint x2 = (i + 1) * delx; 176 g->draw_height - y2, g->draw_width - x1,
173 gint y1 = g->data[i][j] / max * g->draw_height - 1; 177 g->draw_height - y1);
174 gint y2 = g->data[i + 1][j] / max * g->draw_height - 1;
175
176 if ((g->data[i][j] != -1) && (g->data[i + 1][j] != -1))
177 {
178 if (stats[g->statIdx].fill <= j)
179 {
180 gdk_draw_line (g->pixmap, g->gc,
181 g->draw_width - x2,
182 g->draw_height - y2,
183 g->draw_width - x1, g->draw_height - y1);
184 }
185 else
186 {
187 GdkPoint points[4];
188
189 points[0].x = g->draw_width - x2;
190 points[0].y = g->draw_height - y2;
191 points[1].x = g->draw_width - x1;
192 points[1].y = g->draw_height - y1;
193 points[2].x = g->draw_width - x1;
194 points[3].x = g->draw_width - x2;
195 if (j == 0)
196 {
197 points[2].y = g->draw_height;
198 points[3].y = g->draw_height;
199 }
200 else
201 {
202 gint ly1 = g->data[i][j - 1] / max * g->draw_height - 1;
203 gint ly2 =
204 g->data[i + 1][j - 1] / max * g->draw_height - 1;
205 points[2].y = g->draw_height - ly1;
206 points[3].y = g->draw_height - ly2;
207 }
208 gdk_draw_polygon (g->pixmap, g->gc, 1, points, 4);
209 }
210 }
211 } 178 }
179 else
180 {
181 GdkPoint points[4];
182
183 points[0].x = g->draw_width - x2;
184 points[0].y = g->draw_height - y2;
185 points[1].x = g->draw_width - x1;
186 points[1].y = g->draw_height - y1;
187 points[2].x = g->draw_width - x1;
188 points[3].x = g->draw_width - x2;
189 if (j == 0)
190 {
191 points[2].y = g->draw_height;
192 points[3].y = g->draw_height;
193 }
194 else
195 {
196 gint ly1 = g->data[i][j - 1] / max * g->draw_height - 1;
197 gint ly2 = g->data[i + 1][j - 1] / max * g->draw_height - 1;
198
199 points[2].y = g->draw_height - ly1;
200 points[3].y = g->draw_height - ly2;
201 }
202 gdk_draw_polygon (g->pixmap, g->gc, 1, points, 4);
203 }
204 }
212 } 205 }
206 }
213 207
214 gdk_gc_set_line_attributes (g->gc, 1, 208 gdk_gc_set_line_attributes (g->gc, 1, GDK_LINE_SOLID, GDK_CAP_ROUND,
215 GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_MITER); 209 GDK_JOIN_MITER);
216 210
217 gdk_draw_pixmap (g->disp->window, 211 gdk_draw_pixmap (g->disp->window,
218 g->disp->style->fg_gc[GTK_WIDGET_STATE (g->disp)], 212 g->disp->style->fg_gc[GTK_WIDGET_STATE (g->disp)], g->pixmap,
219 g->pixmap, 213 0, 0, 0, 0, g->disp->allocation.width,
220 0, 0, 214 g->disp->allocation.height);
221 0, 0,
222 g->disp->allocation.width, g->disp->allocation.height);
223} 215}
224 216
225 217
@@ -246,21 +238,22 @@ static void
246load_graph_unalloc (LoadGraph * g) 238load_graph_unalloc (LoadGraph * g)
247{ 239{
248 unsigned int i; 240 unsigned int i;
241
249 if (!g->allocated) 242 if (!g->allocated)
250 return; 243 return;
251 for (i = 0; i < g->num_points; i++) 244 for (i = 0; i < g->num_points; i++)
252 { 245 {
253 GNUNET_free (g->data[i]); 246 GNUNET_free (g->data[i]);
254 GNUNET_free (g->odata[i]); 247 GNUNET_free (g->odata[i]);
255 } 248 }
256 GNUNET_free (g->data); 249 GNUNET_free (g->data);
257 GNUNET_free (g->odata); 250 GNUNET_free (g->odata);
258 g->data = g->odata = NULL; 251 g->data = g->odata = NULL;
259 if (g->pixmap) 252 if (g->pixmap)
260 { 253 {
261 gdk_pixmap_unref (g->pixmap); 254 gdk_pixmap_unref (g->pixmap);
262 g->pixmap = NULL; 255 g->pixmap = NULL;
263 } 256 }
264 g->allocated = FALSE; 257 g->allocated = FALSE;
265} 258}
266 259
@@ -277,10 +270,10 @@ load_graph_alloc (LoadGraph * g)
277 g->odata = GNUNET_malloc (sizeof (gfloat *) * g->num_points); 270 g->odata = GNUNET_malloc (sizeof (gfloat *) * g->num_points);
278 g->data_size = sizeof (gfloat); 271 g->data_size = sizeof (gfloat);
279 for (i = 0; i < g->num_points; i++) 272 for (i = 0; i < g->num_points; i++)
280 { 273 {
281 g->data[i] = GNUNET_malloc (g->data_size * g->count); 274 g->data[i] = GNUNET_malloc (g->data_size * g->count);
282 g->odata[i] = GNUNET_malloc (g->data_size * g->count); 275 g->odata[i] = GNUNET_malloc (g->data_size * g->count);
283 } 276 }
284 for (i = 0; i < g->num_points; i++) 277 for (i = 0; i < g->num_points; i++)
285 for (j = 0; j < g->count; j++) 278 for (j = 0; j < g->count; j++)
286 g->data[i][j] = -1; 279 g->data[i][j] = -1;
@@ -288,48 +281,42 @@ load_graph_alloc (LoadGraph * g)
288} 281}
289 282
290static gint 283static gint
291load_graph_configure (GtkWidget * widget, 284load_graph_configure (GtkWidget * widget, GdkEventConfigure * event,
292 GdkEventConfigure * event, gpointer data_ptr) 285 gpointer data_ptr)
293{ 286{
294 LoadGraph *c = (LoadGraph *) data_ptr; 287 LoadGraph *c = (LoadGraph *) data_ptr;
295 288
296 if (c->pixmap) 289 if (c->pixmap)
297 { 290 {
298 gdk_pixmap_unref (c->pixmap); 291 gdk_pixmap_unref (c->pixmap);
299 c->pixmap = NULL; 292 c->pixmap = NULL;
300 } 293 }
301 294
302 if (!c->pixmap) 295 if (!c->pixmap)
303 c->pixmap = gdk_pixmap_new (widget->window, 296 c->pixmap =
304 widget->allocation.width, 297 gdk_pixmap_new (widget->window, widget->allocation.width,
305 widget->allocation.height, 298 widget->allocation.height,
306 gtk_widget_get_visual (c->disp)->depth); 299 gtk_widget_get_visual (c->disp)->depth);
307 gdk_draw_rectangle (c->pixmap, 300 gdk_draw_rectangle (c->pixmap, widget->style->black_gc, TRUE, 0, 0,
308 widget->style->black_gc,
309 TRUE, 0, 0,
310 widget->allocation.width, widget->allocation.height); 301 widget->allocation.width, widget->allocation.height);
311 gdk_draw_pixmap (widget->window, 302 gdk_draw_pixmap (widget->window,
312 c->disp->style->fg_gc[GTK_WIDGET_STATE (widget)], 303 c->disp->style->fg_gc[GTK_WIDGET_STATE (widget)], c->pixmap,
313 c->pixmap, 304 0, 0, 0, 0, c->disp->allocation.width,
314 0, 0, 305 c->disp->allocation.height);
315 0, 0,
316 c->disp->allocation.width, c->disp->allocation.height);
317 306
318 load_graph_draw (c); 307 load_graph_draw (c);
319 return TRUE; 308 return TRUE;
320} 309}
321 310
322static gint 311static gint
323load_graph_expose (GtkWidget * widget, 312load_graph_expose (GtkWidget * widget, GdkEventExpose * event,
324 GdkEventExpose * event, gpointer data_ptr) 313 gpointer data_ptr)
325{ 314{
326 LoadGraph *g = (LoadGraph *) data_ptr; 315 LoadGraph *g = (LoadGraph *) data_ptr;
327 316
328 gdk_draw_pixmap (widget->window, 317 gdk_draw_pixmap (widget->window,
329 widget->style->fg_gc[GTK_WIDGET_STATE (widget)], 318 widget->style->fg_gc[GTK_WIDGET_STATE (widget)], g->pixmap,
330 g->pixmap, 319 event->area.x, event->area.y, event->area.x, event->area.y,
331 event->area.x, event->area.y,
332 event->area.x, event->area.y,
333 event->area.width, event->area.height); 320 event->area.width, event->area.height);
334 return FALSE; 321 return FALSE;
335} 322}
@@ -340,10 +327,10 @@ load_graph_stop (LoadGraph * g)
340 if (!g) 327 if (!g)
341 return; 328 return;
342 if (g->timer_index != -1) 329 if (g->timer_index != -1)
343 { 330 {
344 gtk_timeout_remove (g->timer_index); 331 gtk_timeout_remove (g->timer_index);
345 g->timer_index = -1; 332 g->timer_index = -1;
346 } 333 }
347 g->draw = FALSE; 334 g->draw = FALSE;
348} 335}
349 336
@@ -351,6 +338,7 @@ static void
351load_graph_destroy (GtkWidget * widget, gpointer data_ptr) 338load_graph_destroy (GtkWidget * widget, gpointer data_ptr)
352{ 339{
353 LoadGraph *g = (LoadGraph *) data_ptr; 340 LoadGraph *g = (LoadGraph *) data_ptr;
341
354 load_graph_stop (g); 342 load_graph_stop (g);
355 if (g->timer_index != -1) 343 if (g->timer_index != -1)
356 gtk_timeout_remove (g->timer_index); 344 gtk_timeout_remove (g->timer_index);
@@ -366,10 +354,10 @@ load_graph_new (int statIdx, const ProcConfig * config)
366 unsigned int i; 354 unsigned int i;
367 355
368 if (stats[statIdx].count > MAX_COLOR) 356 if (stats[statIdx].count > MAX_COLOR)
369 { 357 {
370 GNUNET_GE_BREAK (NULL, 0); 358 GNUNET_GE_BREAK (NULL, 0);
371 return NULL; 359 return NULL;
372 } 360 }
373 361
374 g = GNUNET_malloc (sizeof (LoadGraph)); 362 g = GNUNET_malloc (sizeof (LoadGraph));
375 g->statIdx = statIdx; 363 g->statIdx = statIdx;
@@ -387,13 +375,12 @@ load_graph_new (int statIdx, const ProcConfig * config)
387 gtk_widget_show (g->main_widget); 375 gtk_widget_show (g->main_widget);
388 g->disp = gtk_drawing_area_new (); 376 g->disp = gtk_drawing_area_new ();
389 gtk_widget_show (g->disp); 377 gtk_widget_show (g->disp);
390 gtk_signal_connect (GTK_OBJECT (g->disp), 378 gtk_signal_connect (GTK_OBJECT (g->disp), "expose_event",
391 "expose_event", GTK_SIGNAL_FUNC (load_graph_expose), g); 379 GTK_SIGNAL_FUNC (load_graph_expose), g);
392 gtk_signal_connect (GTK_OBJECT (g->disp), 380 gtk_signal_connect (GTK_OBJECT (g->disp), "configure_event",
393 "configure_event",
394 GTK_SIGNAL_FUNC (load_graph_configure), g); 381 GTK_SIGNAL_FUNC (load_graph_configure), g);
395 gtk_signal_connect (GTK_OBJECT (g->disp), 382 gtk_signal_connect (GTK_OBJECT (g->disp), "destroy",
396 "destroy", GTK_SIGNAL_FUNC (load_graph_destroy), g); 383 GTK_SIGNAL_FUNC (load_graph_destroy), g);
397 gtk_widget_add_events (g->disp, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); 384 gtk_widget_add_events (g->disp, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
398 gtk_box_pack_start (GTK_BOX (g->main_widget), g->disp, TRUE, TRUE, 0); 385 gtk_box_pack_start (GTK_BOX (g->main_widget), g->disp, TRUE, TRUE, 0);
399 load_graph_alloc (g); 386 load_graph_alloc (g);
@@ -419,8 +406,8 @@ create_sys_view (int statIdx, const ProcConfig * config)
419 gtk_container_set_border_width (GTK_CONTAINER (mem_frame), GNOME_PAD_SMALL); 406 gtk_container_set_border_width (GTK_CONTAINER (mem_frame), GNOME_PAD_SMALL);
420 gtk_widget_show (mem_frame); 407 gtk_widget_show (mem_frame);
421 if (mem_graph->timer_index == -1) 408 if (mem_graph->timer_index == -1)
422 mem_graph->timer_index 409 mem_graph->timer_index =
423 = gtk_timeout_add (mem_graph->speed, &load_graph_update, mem_graph); 410 gtk_timeout_add (mem_graph->speed, &load_graph_update, mem_graph);
424 mem_graph->draw = TRUE; 411 mem_graph->draw = TRUE;
425 return mem_frame; 412 return mem_frame;
426} 413}
@@ -430,8 +417,7 @@ create_sys_view (int statIdx, const ProcConfig * config)
430 417
431 418
432void 419void
433init_stats (struct GNUNET_GE_Context *ectx, 420init_stats (struct GNUNET_GE_Context *ectx, struct GNUNET_GC_Configuration *cfg)
434 struct GNUNET_GC_Configuration *cfg)
435{ 421{
436 GtkWidget *statusConnexionsBox; 422 GtkWidget *statusConnexionsBox;
437 GtkWidget *statusConnexionsLabel; 423 GtkWidget *statusConnexionsLabel;
@@ -442,25 +428,22 @@ init_stats (struct GNUNET_GE_Context *ectx,
442 int i; 428 int i;
443 429
444 statusConnexionsLabel = 430 statusConnexionsLabel =
445 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 431 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
446 "statusConnexionsLabel"); 432 "statusConnexionsLabel");
447 gtk_label_set_width_chars (GTK_LABEL (statusConnexionsLabel), 433 gtk_label_set_width_chars (GTK_LABEL (statusConnexionsLabel),
448 g_utf8_strlen (_("Connected to %Lu peers"), 434 g_utf8_strlen (_("Connected to %Lu peers"),
449 40) - 1); 435 40) - 1);
450 statusConnexionsBox = 436 statusConnexionsBox =
451 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), 437 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (),
452 "statusConnexionsBox"); 438 "statusConnexionsBox");
453 gtk_widget_set_sensitive (statusConnexionsBox, TRUE); 439 gtk_widget_set_sensitive (statusConnexionsBox, TRUE);
454 GNUNET_GC_get_configuration_value_number (cfg, 440 GNUNET_GC_get_configuration_value_number (cfg, "GNUNET-GTK", "STATS-INTERVAL",
455 "GNUNET-GTK", 441 1, 99 * GNUNET_CRON_YEARS,
456 "STATS-INTERVAL",
457 1,
458 99 * GNUNET_CRON_YEARS,
459 30 * GNUNET_CRON_SECONDS, 442 30 * GNUNET_CRON_SECONDS,
460 &UPDATE_INTERVAL); 443 &UPDATE_INTERVAL);
461 init_functions (ectx, cfg); 444 init_functions (ectx, cfg);
462 notebook = 445 notebook =
463 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "statsNotebook"); 446 glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "statsNotebook");
464 memset (&config, 0, sizeof (ProcConfig)); 447 memset (&config, 0, sizeof (ProcConfig));
465 gdk_color_parse ("black", &config.bg_color); 448 gdk_color_parse ("black", &config.bg_color);
466 gdk_color_parse ("gray", &config.frame_color); 449 gdk_color_parse ("gray", &config.frame_color);
@@ -473,14 +456,14 @@ init_stats (struct GNUNET_GE_Context *ectx,
473 GNUNET_GE_ASSERT (ectx, MAX_COLOR == 6); 456 GNUNET_GE_ASSERT (ectx, MAX_COLOR == 6);
474 i = -1; 457 i = -1;
475 while (stats[++i].paneName != NULL) 458 while (stats[++i].paneName != NULL)
476 { 459 {
477 sys_box = create_sys_view (i, &config); 460 sys_box = create_sys_view (i, &config);
478 if (sys_box == NULL) 461 if (sys_box == NULL)
479 continue; /* oops */ 462 continue; /* oops */
480 463
481 label = gtk_label_new (gettext (stats[i].paneName)); 464 label = gtk_label_new (gettext (stats[i].paneName));
482 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, label); 465 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, label);
483 } 466 }
484 gtk_widget_show (notebook); 467 gtk_widget_show (notebook);
485} 468}
486 469