static gint load_graph_configure (GtkWidget *widget, GdkEventConfigure *event, gpointer data_ptr) { GtkAllocation allocation; LoadGraph *c = (LoadGraph *) data_ptr; load_graph_unalloc (c); gtk_widget_get_allocation (c->disp, &allocation); c->draw_width = allocation.width; c->draw_height = allocation.height; c->draw_width = MAX (c->draw_width, 1); c->draw_height = MAX (c->draw_height, 1); load_graph_alloc (c); if (!c->surface) c->surface = gdk_window_create_similar_surface (gtk_widget_get_window (c->disp), CAIRO_CONTENT_COLOR, c->draw_width, c->draw_height); gtk_widget_queue_draw (widget); return TRUE; }
static void multiload_destroy_cb(GtkWidget *widget, gpointer data) { gint i; MultiloadApplet *ma = data; for (i = 0; i < NGRAPHS; i++) { load_graph_stop(ma->graphs[i]); if (ma->graphs[i]->colors) { g_free (ma->graphs[i]->colors); ma->graphs[i]->colors = NULL; } gtk_widget_destroy(ma->graphs[i]->main_widget); load_graph_unalloc(ma->graphs[i]); g_free(ma->graphs[i]); } if (ma->about_dialog) gtk_widget_destroy (ma->about_dialog); if (ma->prop_dialog) gtk_widget_destroy (ma->prop_dialog); gtk_widget_destroy(GTK_WIDGET(ma->applet)); g_free (ma); return; }
/* remove the old graphs and rebuild them */ void multiload_applet_refresh(MultiloadApplet *ma) { gint i; MatePanelAppletOrient orientation; /* stop and free the old graphs */ for (i = 0; i < NGRAPHS; i++) { if (!ma->graphs[i]) continue; load_graph_stop(ma->graphs[i]); gtk_widget_destroy(ma->graphs[i]->main_widget); load_graph_unalloc(ma->graphs[i]); g_free(ma->graphs[i]); } if (ma->box) gtk_widget_destroy(ma->box); orientation = mate_panel_applet_get_orient(ma->applet); if ( (orientation == MATE_PANEL_APPLET_ORIENT_UP) || (orientation == MATE_PANEL_APPLET_ORIENT_DOWN) ) { ma->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); } else ma->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(ma->applet), ma->box); /* create the NGRAPHS graphs, passing in their user-configurable properties with gsettings. */ multiload_create_graphs (ma); /* only start and display the graphs the user has turned on */ for (i = 0; i < NGRAPHS; i++) { gtk_box_pack_start(GTK_BOX(ma->box), ma->graphs[i]->main_widget, TRUE, TRUE, 1); if (ma->graphs[i]->visible) { gtk_widget_show_all (ma->graphs[i]->main_widget); load_graph_start(ma->graphs[i]); } } gtk_widget_show (ma->box); return; }