| File: | multiload/load-graph.c |
| Warning: | line 127, column 20 Division by zero |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | #include <config.h> | |||
| 2 | #include <stdio.h> | |||
| 3 | #include <sys/stat.h> | |||
| 4 | #include <unistd.h> | |||
| 5 | #include <signal.h> | |||
| 6 | #include <dirent.h> | |||
| 7 | #include <string.h> | |||
| 8 | #include <time.h> | |||
| 9 | #include <glib.h> | |||
| 10 | #include <cdk/cdkx.h> | |||
| 11 | #include <ctk/ctk.h> | |||
| 12 | #include <gio/gio.h> | |||
| 13 | #include <cafe-panel-applet.h> | |||
| 14 | #include <cafe-panel-applet-gsettings.h> | |||
| 15 | #include <math.h> | |||
| 16 | ||||
| 17 | #include "global.h" | |||
| 18 | ||||
| 19 | /* | |||
| 20 | Shifts data right | |||
| 21 | ||||
| 22 | data[i+1] = data[i] | |||
| 23 | ||||
| 24 | data[i] are int*, so we just move the pointer, not the data. | |||
| 25 | But moving data loses data[n-1], so we save data[n-1] and reuse | |||
| 26 | it as new data[0]. In fact, we rotate data[]. | |||
| 27 | ||||
| 28 | */ | |||
| 29 | ||||
| 30 | static void | |||
| 31 | shift_right(LoadGraph *g) | |||
| 32 | { | |||
| 33 | unsigned i; | |||
| 34 | int* last_data; | |||
| 35 | ||||
| 36 | /* data[g->draw_width - 1] becomes data[0] */ | |||
| 37 | last_data = g->data[g->draw_width - 1]; | |||
| 38 | ||||
| 39 | /* data[i+1] = data[i] */ | |||
| 40 | for(i = g->draw_width - 1; i != 0; --i) | |||
| 41 | g->data[i] = g->data[i - 1]; | |||
| 42 | ||||
| 43 | g->data[0] = last_data; | |||
| 44 | } | |||
| 45 | ||||
| 46 | ||||
| 47 | /* Redraws the backing pixmap for the load graph and updates the window */ | |||
| 48 | static void | |||
| 49 | load_graph_draw (LoadGraph *g) | |||
| 50 | { | |||
| 51 | guint i, j, k; | |||
| 52 | cairo_t *cr; | |||
| 53 | int load; | |||
| 54 | ||||
| 55 | /* we might get called before the configure event so that | |||
| 56 | * g->disp->allocation may not have the correct size | |||
| 57 | * (after the user resized the applet in the prop dialog). */ | |||
| 58 | ||||
| 59 | if (!g->surface) | |||
| 60 | g->surface = cdk_window_create_similar_surface (ctk_widget_get_window (g->disp), | |||
| 61 | CAIRO_CONTENT_COLOR, | |||
| 62 | g->draw_width, g->draw_height); | |||
| 63 | ||||
| 64 | cr = cairo_create (g->surface); | |||
| 65 | cairo_set_line_width (cr, 1.0); | |||
| 66 | cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); | |||
| 67 | cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); | |||
| 68 | ||||
| 69 | /* all graphs except Load and Net go this path */ | |||
| 70 | if (g->id != 4 && g->id != 2) | |||
| 71 | { | |||
| 72 | for (i = 0; i < g->draw_width; i++) | |||
| 73 | g->pos [i] = g->draw_height - 1; | |||
| 74 | ||||
| 75 | for (j = 0; j < g->n; j++) | |||
| 76 | { | |||
| 77 | cdk_cairo_set_source_rgba (cr, &(g->colors [j])); | |||
| 78 | ||||
| 79 | for (i = 0; i < g->draw_width; i++) | |||
| 80 | { | |||
| 81 | if (g->data [i][j] != 0) | |||
| 82 | { | |||
| 83 | cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); | |||
| 84 | cairo_line_to (cr, g->draw_width - i - 0.5, g->pos[i] - (g->data [i][j] - 0.5)); | |||
| 85 | } | |||
| 86 | g->pos [i] -= g->data [i][j]; | |||
| 87 | } | |||
| 88 | cairo_stroke (cr); | |||
| 89 | } | |||
| 90 | } | |||
| 91 | /* This is for network graph */ | |||
| 92 | else if (g->id
| |||
| 93 | { | |||
| 94 | guint maxnet = 1; | |||
| 95 | gint segments = 1; | |||
| 96 | gint combined = 0; | |||
| 97 | for (i = 0; i < g->draw_width; i++) | |||
| 98 | { | |||
| 99 | g->pos [i] = g->draw_height - 1; | |||
| 100 | combined = 0; | |||
| 101 | combined += g->data[i][0]; | |||
| 102 | combined += g->data[i][1]; | |||
| 103 | combined += g->data[i][2]; | |||
| 104 | if (combined > maxnet) | |||
| 105 | maxnet = combined; | |||
| 106 | } | |||
| 107 | //printf("max = %d ", maxnet); | |||
| 108 | guint level = 0; | |||
| 109 | CdkRGBA grid_color; | |||
| 110 | if (maxnet > g->net_threshold3) { | |||
| 111 | g->net_threshold = g->net_threshold3; | |||
| 112 | level = 3; | |||
| 113 | } | |||
| 114 | else | |||
| 115 | if (maxnet > g->net_threshold2) { | |||
| 116 | g->net_threshold = g->net_threshold2; | |||
| 117 | level = 2; | |||
| 118 | } | |||
| 119 | else { | |||
| 120 | g->net_threshold = g->net_threshold1; | |||
| 121 | level = 1; | |||
| 122 | if (maxnet < g->net_threshold1) | |||
| 123 | level = 0; | |||
| 124 | } | |||
| 125 | ||||
| 126 | //printf("level %d maxnet = %d ", level, maxnet); | |||
| 127 | maxnet = maxnet/g->net_threshold; | |||
| ||||
| 128 | segments = MAX (maxnet+1,1)(((maxnet+1) > (1)) ? (maxnet+1) : (1)); | |||
| 129 | float ratio = (float)g->draw_height/g->net_threshold/segments; | |||
| 130 | //printf("segments %d ratio = %f t1=%ld t2=%ld t3=%ld t=%ld\n", segments, ratio, g->net_threshold1, g->net_threshold2, g->net_threshold3, g->net_threshold); | |||
| 131 | ||||
| 132 | for (j = 0; j < g->n-1; j++) | |||
| 133 | { | |||
| 134 | cdk_cairo_set_source_rgba (cr, &(g->colors [j])); | |||
| 135 | ||||
| 136 | for (i = 0; i < g->draw_width; i++) | |||
| 137 | { | |||
| 138 | cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); | |||
| 139 | cairo_line_to (cr, g->draw_width - i - 0.5, g->pos[i] - 0.5 - ((g->data [i][j] * ratio))); | |||
| 140 | g->pos [i] -= ((g->data [i][j] * ratio)); | |||
| 141 | } | |||
| 142 | cairo_stroke (cr); | |||
| 143 | } | |||
| 144 | ||||
| 145 | for (j = g->n-1; j < g->n; j++) | |||
| 146 | { | |||
| 147 | cdk_cairo_set_source_rgba (cr, &(g->colors [j])); | |||
| 148 | for (i = 0; i < g->draw_width; i++) | |||
| 149 | { | |||
| 150 | cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); | |||
| 151 | cairo_line_to (cr, g->draw_width - i - 0.5, 0.5); | |||
| 152 | } | |||
| 153 | cairo_stroke (cr); | |||
| 154 | } | |||
| 155 | ||||
| 156 | /* draw grid lines if needed */ | |||
| 157 | cdk_cairo_set_source_rgba (cr, &(g->colors [4])); | |||
| 158 | double spacing = 0; | |||
| 159 | for (k = 0; k < segments -1; k++) | |||
| 160 | { | |||
| 161 | spacing = ((double) g->draw_height/segments) * (k+1); | |||
| 162 | cairo_move_to (cr, 0.5, spacing); | |||
| 163 | cairo_line_to (cr, g->draw_width-0.5, spacing); | |||
| 164 | } | |||
| 165 | cairo_stroke (cr); | |||
| 166 | /* draw indicator if needed */ | |||
| 167 | if (level > 0) | |||
| 168 | { | |||
| 169 | cdk_cairo_set_source_rgba (cr, &(g->colors [5])); | |||
| 170 | for (k = 0; k< level; k++ ) | |||
| 171 | cairo_rectangle(cr, 0.5, (k*2) * g->draw_height/5, 5, g->draw_height/5); | |||
| 172 | cairo_fill(cr); | |||
| 173 | } | |||
| 174 | cairo_stroke (cr); | |||
| 175 | } | |||
| 176 | /* this is Load graph */ | |||
| 177 | else | |||
| 178 | { | |||
| 179 | guint maxload = 1; | |||
| 180 | for (i = 0; i < g->draw_width; i++) | |||
| 181 | { | |||
| 182 | g->pos [i] = g->draw_height - 1; | |||
| 183 | /* find maximum value */ | |||
| 184 | if (g->data[i][0] > maxload) | |||
| 185 | maxload = g->data[i][0]; | |||
| 186 | } | |||
| 187 | load = ceil ((double) (maxload/g->draw_height)) + 1; | |||
| 188 | load = MAX (load,1)(((load) > (1)) ? (load) : (1)); | |||
| 189 | ||||
| 190 | for (j = 0; j < g->n; j++) | |||
| 191 | { | |||
| 192 | cdk_cairo_set_source_rgba (cr, &(g->colors [j])); | |||
| 193 | ||||
| 194 | for (i = 0; i < g->draw_width; i++) | |||
| 195 | { | |||
| 196 | cairo_move_to (cr, g->draw_width - i - 0.5, g->pos[i] + 0.5); | |||
| 197 | if (j == 0) | |||
| 198 | { | |||
| 199 | cairo_line_to (cr, g->draw_width - i - 0.5, g->pos[i] - ((g->data [i][j] - 0.5)/load)); | |||
| 200 | } | |||
| 201 | else | |||
| 202 | { | |||
| 203 | cairo_line_to (cr, g->draw_width - i - 0.5, 0.5); | |||
| 204 | } | |||
| 205 | g->pos [i] -= g->data [i][j] / load; | |||
| 206 | } | |||
| 207 | cairo_stroke (cr); | |||
| 208 | } | |||
| 209 | ||||
| 210 | /* draw grid lines in Load graph if needed */ | |||
| 211 | cdk_cairo_set_source_rgba (cr, &(g->colors [2])); | |||
| 212 | ||||
| 213 | double spacing = 0; | |||
| 214 | for (k = 0; k < load - 1; k++) | |||
| 215 | { | |||
| 216 | spacing = ((double) g->draw_height/load) * (k+1); | |||
| 217 | cairo_move_to (cr, 0.5, spacing); | |||
| 218 | cairo_line_to (cr, g->draw_width-0.5, spacing); | |||
| 219 | } | |||
| 220 | ||||
| 221 | cairo_stroke (cr); | |||
| 222 | } | |||
| 223 | ctk_widget_queue_draw (g->disp); | |||
| 224 | ||||
| 225 | cairo_destroy (cr); | |||
| 226 | } | |||
| 227 | ||||
| 228 | /* Updates the load graph when the timeout expires */ | |||
| 229 | static gboolean | |||
| 230 | load_graph_update (LoadGraph *g) | |||
| 231 | { | |||
| 232 | if (g->data == NULL((void*)0)) | |||
| ||||
| 233 | return TRUE(!(0)); | |||
| 234 | ||||
| 235 | shift_right(g); | |||
| 236 | ||||
| 237 | if (g->tooltip_update) | |||
| 238 | multiload_applet_tooltip_update(g); | |||
| 239 | ||||
| 240 | g->get_data (g->draw_height, g->data [0], g); | |||
| 241 | ||||
| 242 | load_graph_draw (g); | |||
| 243 | return TRUE(!(0)); | |||
| 244 | } | |||
| 245 | ||||
| 246 | void | |||
| 247 | load_graph_unalloc (LoadGraph *g) | |||
| 248 | { | |||
| 249 | guint i; | |||
| 250 | ||||
| 251 | if (!g->allocated) | |||
| 252 | return; | |||
| 253 | ||||
| 254 | for (i = 0; i < g->draw_width; i++) | |||
| 255 | { | |||
| 256 | g_free (g->data [i]); | |||
| 257 | } | |||
| 258 | ||||
| 259 | g_free (g->data); | |||
| 260 | g_free (g->pos); | |||
| 261 | ||||
| 262 | g->pos = NULL((void*)0); | |||
| 263 | g->data = NULL((void*)0); | |||
| 264 | ||||
| 265 | g->size = g_settings_get_int(g->multiload->settings, "size"); | |||
| 266 | g->size = MAX (g->size, 10)(((g->size) > (10)) ? (g->size) : (10)); | |||
| 267 | ||||
| 268 | if (g->surface) { | |||
| 269 | cairo_surface_destroy (g->surface); | |||
| 270 | g->surface = NULL((void*)0); | |||
| 271 | } | |||
| 272 | ||||
| 273 | g->allocated = FALSE(0); | |||
| 274 | } | |||
| 275 | ||||
| 276 | static void | |||
| 277 | load_graph_alloc (LoadGraph *g) | |||
| 278 | { | |||
| 279 | guint i; | |||
| 280 | ||||
| 281 | if (g->allocated) | |||
| 282 | return; | |||
| 283 | ||||
| 284 | g->data = g_new0 (gint *, g->draw_width)((gint * *) g_malloc0_n ((g->draw_width), sizeof (gint *)) ); | |||
| 285 | g->pos = g_new0 (guint, g->draw_width)((guint *) g_malloc0_n ((g->draw_width), sizeof (guint))); | |||
| 286 | ||||
| 287 | g->data_size = sizeof (guint) * g->n; | |||
| 288 | ||||
| 289 | for (i = 0; i < g->draw_width; i++) { | |||
| 290 | g->data [i] = g_malloc0 (g->data_size); | |||
| 291 | } | |||
| 292 | ||||
| 293 | g->allocated = TRUE(!(0)); | |||
| 294 | } | |||
| 295 | ||||
| 296 | static gint | |||
| 297 | load_graph_configure (CtkWidget *widget, CdkEventConfigure *event, | |||
| 298 | gpointer data_ptr) | |||
| 299 | { | |||
| 300 | CtkAllocation allocation; | |||
| 301 | LoadGraph *c = (LoadGraph *) data_ptr; | |||
| 302 | ||||
| 303 | load_graph_unalloc (c); | |||
| 304 | ||||
| 305 | ctk_widget_get_allocation (c->disp, &allocation); | |||
| 306 | ||||
| 307 | c->draw_width = allocation.width; | |||
| 308 | c->draw_height = allocation.height; | |||
| 309 | c->draw_width = MAX (c->draw_width, 1)(((c->draw_width) > (1)) ? (c->draw_width) : (1)); | |||
| 310 | c->draw_height = MAX (c->draw_height, 1)(((c->draw_height) > (1)) ? (c->draw_height) : (1)); | |||
| 311 | ||||
| 312 | load_graph_alloc (c); | |||
| 313 | ||||
| 314 | if (!c->surface) | |||
| 315 | c->surface = cdk_window_create_similar_surface (ctk_widget_get_window (c->disp), | |||
| 316 | CAIRO_CONTENT_COLOR, | |||
| 317 | c->draw_width, c->draw_height); | |||
| 318 | ctk_widget_queue_draw (widget); | |||
| 319 | ||||
| 320 | return TRUE(!(0)); | |||
| 321 | } | |||
| 322 | ||||
| 323 | static gint | |||
| 324 | load_graph_expose (CtkWidget *widget, | |||
| 325 | cairo_t *cr, | |||
| 326 | gpointer data_ptr) | |||
| 327 | { | |||
| 328 | LoadGraph *g = (LoadGraph *) data_ptr; | |||
| 329 | ||||
| 330 | cairo_set_source_surface (cr, g->surface, 0, 0); | |||
| 331 | cairo_paint (cr); | |||
| 332 | ||||
| 333 | return FALSE(0); | |||
| 334 | } | |||
| 335 | ||||
| 336 | static void | |||
| 337 | load_graph_destroy (CtkWidget *widget, gpointer data_ptr) | |||
| 338 | { | |||
| 339 | LoadGraph *g = (LoadGraph *) data_ptr; | |||
| 340 | ||||
| 341 | load_graph_stop (g); | |||
| 342 | netspeed_delete(g->netspeed_in); | |||
| 343 | netspeed_delete(g->netspeed_out); | |||
| 344 | ||||
| 345 | ctk_widget_destroy(widget); | |||
| 346 | } | |||
| 347 | ||||
| 348 | static gboolean | |||
| 349 | load_graph_clicked (CtkWidget *widget, CdkEventButton *event, LoadGraph *load) | |||
| 350 | { | |||
| 351 | load->multiload->last_clicked = load->id; | |||
| 352 | ||||
| 353 | return FALSE(0); | |||
| 354 | } | |||
| 355 | ||||
| 356 | static gboolean | |||
| 357 | load_graph_enter_cb(CtkWidget *widget, CdkEventCrossing *event, gpointer data) | |||
| 358 | { | |||
| 359 | LoadGraph *graph; | |||
| 360 | graph = (LoadGraph *)data; | |||
| 361 | ||||
| 362 | graph->tooltip_update = TRUE(!(0)); | |||
| 363 | multiload_applet_tooltip_update(graph); | |||
| 364 | ||||
| 365 | return TRUE(!(0)); | |||
| 366 | } | |||
| 367 | ||||
| 368 | static gboolean | |||
| 369 | load_graph_leave_cb(CtkWidget *widget, CdkEventCrossing *event, gpointer data) | |||
| 370 | { | |||
| 371 | LoadGraph *graph; | |||
| 372 | graph = (LoadGraph *)data; | |||
| 373 | ||||
| 374 | graph->tooltip_update = FALSE(0); | |||
| 375 | ||||
| 376 | return TRUE(!(0)); | |||
| 377 | } | |||
| 378 | ||||
| 379 | static void | |||
| 380 | load_graph_load_config (LoadGraph *g) | |||
| 381 | { | |||
| 382 | gchar *name, *temp; | |||
| 383 | guint i; | |||
| 384 | ||||
| 385 | if (!g->colors) | |||
| 386 | g->colors = g_new0(CdkRGBA, g->n)((CdkRGBA *) g_malloc0_n ((g->n), sizeof (CdkRGBA))); | |||
| 387 | ||||
| 388 | for (i = 0; i < g->n; i++) | |||
| 389 | { | |||
| 390 | name = g_strdup_printf ("%s-color%u", g->name, i); | |||
| 391 | temp = g_settings_get_string(g->multiload->settings, name); | |||
| 392 | if (!temp) | |||
| 393 | temp = g_strdup ("#000000")g_strdup_inline ("#000000"); | |||
| 394 | cdk_rgba_parse(&(g->colors[i]), temp); | |||
| 395 | g_free(temp); | |||
| 396 | g_free(name); | |||
| 397 | } | |||
| 398 | } | |||
| 399 | ||||
| 400 | LoadGraph * | |||
| 401 | load_graph_new (MultiloadApplet *ma, guint n, const gchar *label, | |||
| 402 | guint id, guint speed, guint size, gboolean visible, | |||
| 403 | const gchar *name, LoadGraphDataFunc get_data) | |||
| 404 | { | |||
| 405 | LoadGraph *g; | |||
| 406 | CafePanelAppletOrient orient; | |||
| 407 | ||||
| 408 | g = g_new0 (LoadGraph, 1)((LoadGraph *) g_malloc0_n ((1), sizeof (LoadGraph))); | |||
| 409 | g->netspeed_in = netspeed_new(g); | |||
| 410 | g->netspeed_out = netspeed_new(g); | |||
| 411 | g->visible = visible; | |||
| 412 | g->name = name; | |||
| 413 | g->n = n; | |||
| 414 | g->id = id; | |||
| 415 | g->speed = MAX (speed, 50)(((speed) > (50)) ? (speed) : (50)); | |||
| 416 | g->size = MAX (size, 10)(((size) > (10)) ? (size) : (10)); | |||
| 417 | g->pixel_size = cafe_panel_applet_get_size (ma->applet); | |||
| 418 | g->tooltip_update = FALSE(0); | |||
| 419 | g->show_frame = TRUE(!(0)); | |||
| 420 | g->multiload = ma; | |||
| 421 | ||||
| 422 | g->main_widget = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
| 423 | ||||
| 424 | g->box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); | |||
| 425 | ||||
| 426 | orient = cafe_panel_applet_get_orient (g->multiload->applet); | |||
| 427 | switch (orient) | |||
| 428 | { | |||
| 429 | case CAFE_PANEL_APPLET_ORIENT_UP: | |||
| 430 | case CAFE_PANEL_APPLET_ORIENT_DOWN: | |||
| 431 | { | |||
| 432 | g->orient = FALSE(0); | |||
| 433 | break; | |||
| 434 | } | |||
| 435 | case CAFE_PANEL_APPLET_ORIENT_LEFT: | |||
| 436 | case CAFE_PANEL_APPLET_ORIENT_RIGHT: | |||
| 437 | { | |||
| 438 | g->orient = TRUE(!(0)); | |||
| 439 | break; | |||
| 440 | } | |||
| 441 | default: | |||
| 442 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "load-graph.c", 442 , ((const char*) (__func__)), ((void*)0)); } while (0); | |||
| 443 | } | |||
| 444 | ||||
| 445 | if (g->show_frame) | |||
| 446 | { | |||
| 447 | g->frame = ctk_frame_new (NULL((void*)0)); | |||
| 448 | ctk_frame_set_shadow_type (CTK_FRAME (g->frame)((((CtkFrame*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g->frame)), ((ctk_frame_get_type ())))))), CTK_SHADOW_IN); | |||
| 449 | ctk_container_add (CTK_CONTAINER (g->frame)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g->frame)), ((ctk_container_get_type ())))))), g->box); | |||
| 450 | ctk_box_pack_start (CTK_BOX (g->main_widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g->main_widget)), ((ctk_box_get_type ())))))), g->frame, TRUE(!(0)), TRUE(!(0)), 0); | |||
| 451 | } | |||
| 452 | else | |||
| 453 | { | |||
| 454 | g->frame = NULL((void*)0); | |||
| 455 | ctk_box_pack_start (CTK_BOX (g->main_widget)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g->main_widget)), ((ctk_box_get_type ())))))), g->box, TRUE(!(0)), TRUE(!(0)), 0); | |||
| 456 | } | |||
| 457 | ||||
| 458 | load_graph_load_config (g); | |||
| 459 | ||||
| 460 | g->get_data = get_data; | |||
| 461 | ||||
| 462 | g->timer_index = -1; | |||
| 463 | ||||
| 464 | if (g->orient) | |||
| 465 | ctk_widget_set_size_request (g->main_widget, -1, g->size); | |||
| 466 | else | |||
| 467 | ctk_widget_set_size_request (g->main_widget, g->size, -1); | |||
| 468 | ||||
| 469 | g->disp = ctk_drawing_area_new (); | |||
| 470 | ctk_widget_set_events (g->disp, CDK_EXPOSURE_MASK | | |||
| 471 | CDK_ENTER_NOTIFY_MASK | | |||
| 472 | CDK_LEAVE_NOTIFY_MASK | | |||
| 473 | CDK_BUTTON_PRESS_MASK); | |||
| 474 | ||||
| 475 | g_signal_connect (G_OBJECT (g->disp), "draw",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("draw"), (((GCallback) (load_graph_expose))), (g ), ((void*)0), (GConnectFlags) 0) | |||
| 476 | G_CALLBACK (load_graph_expose), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("draw"), (((GCallback) (load_graph_expose))), (g ), ((void*)0), (GConnectFlags) 0); | |||
| 477 | g_signal_connect (G_OBJECT(g->disp), "configure_event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("configure_event"), (((GCallback) (load_graph_configure ))), (g), ((void*)0), (GConnectFlags) 0) | |||
| 478 | G_CALLBACK (load_graph_configure), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("configure_event"), (((GCallback) (load_graph_configure ))), (g), ((void*)0), (GConnectFlags) 0); | |||
| 479 | g_signal_connect (G_OBJECT(g->disp), "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("destroy"), (((GCallback) (load_graph_destroy))) , (g), ((void*)0), (GConnectFlags) 0) | |||
| 480 | G_CALLBACK (load_graph_destroy), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("destroy"), (((GCallback) (load_graph_destroy))) , (g), ((void*)0), (GConnectFlags) 0); | |||
| 481 | g_signal_connect (G_OBJECT(g->disp), "button-press-event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("button-press-event"), (((GCallback) (load_graph_clicked ))), (g), ((void*)0), (GConnectFlags) 0) | |||
| 482 | G_CALLBACK (load_graph_clicked), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("button-press-event"), (((GCallback) (load_graph_clicked ))), (g), ((void*)0), (GConnectFlags) 0); | |||
| 483 | g_signal_connect (G_OBJECT(g->disp), "enter-notify-event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("enter-notify-event"), (((GCallback) (load_graph_enter_cb ))), (g), ((void*)0), (GConnectFlags) 0) | |||
| 484 | G_CALLBACK(load_graph_enter_cb), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("enter-notify-event"), (((GCallback) (load_graph_enter_cb ))), (g), ((void*)0), (GConnectFlags) 0); | |||
| 485 | g_signal_connect (G_OBJECT(g->disp), "leave-notify-event",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("leave-notify-event"), (((GCallback) (load_graph_leave_cb ))), (g), ((void*)0), (GConnectFlags) 0) | |||
| 486 | G_CALLBACK(load_graph_leave_cb), g)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((g->disp)), (((GType) ((20) << ( 2))))))))), ("leave-notify-event"), (((GCallback) (load_graph_leave_cb ))), (g), ((void*)0), (GConnectFlags) 0); | |||
| 487 | ||||
| 488 | ctk_box_pack_start (CTK_BOX (g->box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g->box)), ((ctk_box_get_type ())))))), g->disp, TRUE(!(0)), TRUE(!(0)), 0); | |||
| 489 | ctk_widget_show_all(g->box); | |||
| 490 | ||||
| 491 | return g; | |||
| 492 | } | |||
| 493 | ||||
| 494 | void | |||
| 495 | load_graph_start (LoadGraph *g) | |||
| 496 | { | |||
| 497 | if (g->timer_index != -1) | |||
| 498 | g_source_remove (g->timer_index); | |||
| 499 | ||||
| 500 | g->timer_index = g_timeout_add (g->speed, | |||
| 501 | (GSourceFunc) load_graph_update, g); | |||
| 502 | } | |||
| 503 | ||||
| 504 | void | |||
| 505 | load_graph_stop (LoadGraph *g) | |||
| 506 | { | |||
| 507 | if (g->timer_index != -1) | |||
| 508 | g_source_remove (g->timer_index); | |||
| 509 | ||||
| 510 | g->timer_index = -1; | |||
| 511 | } |