void shell_init(void) { if (shell) { g_error("Shell already created"); return; } create_window(); shell->tree = tree_new(); shell->info = info_tree_new(FALSE); shell->moreinfo = info_tree_new(TRUE); shell->loadgraph = load_graph_new(75); gtk_paned_pack1(GTK_PANED(shell->hpaned), shell->tree->scroll, SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); gtk_paned_pack1(GTK_PANED(shell->vpaned), shell->info->scroll, SHELL_PACK_RESIZE, SHELL_PACK_SHRINK); gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook), shell->moreinfo->scroll, NULL); gtk_notebook_append_page(GTK_NOTEBOOK(shell->notebook), load_graph_get_framed(shell->loadgraph), NULL); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(shell->notebook), FALSE); gtk_notebook_set_show_border(GTK_NOTEBOOK(shell->notebook), FALSE); shell_status_set_enabled(TRUE); shell_status_update("Loading modules..."); shell_tree_modules_load(shell->tree); g_slist_foreach(shell->tree->modules, add_modules_to_gui, shell->tree); gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->tree->view)); shell_status_update("Done."); shell_status_set_enabled(FALSE); gtk_widget_show_all(shell->hpaned); load_graph_configure_expose(shell->loadgraph); gtk_widget_hide(shell->notebook); shell_action_set_enabled("RefreshAction", FALSE); shell_action_set_active("LeftPaneAction", TRUE); shell_action_set_active("ToolbarAction", TRUE); shell_action_set_property("RefreshAction", "is-important", TRUE); shell_action_set_property("ReportAction", "is-important", TRUE); }
int main(int argc, char **argv) { LoadGraph *lg; GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); lg = load_graph_new(50); gtk_container_add(GTK_CONTAINER(window), load_graph_get_framed(lg)); gtk_container_set_border_width(GTK_CONTAINER(window), 20); load_graph_configure_expose(lg); lg_update(lg); g_timeout_add(100, lg_update, lg); gtk_main(); return 0; }
static void multiload_create_graphs(MultiloadApplet *ma) { struct { const char *label; const char *name; int num_colours; LoadGraphDataFunc callback; } graph_types[] = { { _("CPU Load"), "cpuload", 5, GetLoad }, { _("Memory Load"), "memload", 5, GetMemory }, { _("Net Load"), "netload2", 6, GetNet }, { _("Swap Load"), "swapload", 2, GetSwap }, { _("Load Average"), "loadavg", 3, GetLoadAvg }, { _("Disk Load"), "diskload", 3, GetDiskLoad } }; gint speed, size; guint net_threshold1; guint net_threshold2; guint net_threshold3; gint i; speed = g_settings_get_int (ma->settings, "speed"); size = g_settings_get_int (ma->settings, "size"); net_threshold1 = g_settings_get_uint (ma->settings, "netthreshold1"); net_threshold2 = g_settings_get_uint (ma->settings, "netthreshold2"); net_threshold3 = g_settings_get_uint (ma->settings, "netthreshold3"); if (net_threshold1 >= net_threshold2) { net_threshold1 = net_threshold2 - 1; } if (net_threshold2 >= net_threshold3) { net_threshold3 = net_threshold2 + 1; } speed = MAX (speed, 50); size = CLAMP (size, 10, 400); for (i = 0; i < G_N_ELEMENTS (graph_types); i++) { gboolean visible; char *key; /* This is a special case to handle migration from an * older version of netload to a newer one in the * 2.25.1 release. */ if (g_strcmp0 ("netload2", graph_types[i].name) == 0) { key = g_strdup ("view-netload"); } else { key = g_strdup_printf ("view-%s", graph_types[i].name); } visible = g_settings_get_boolean (ma->settings, key); g_free (key); ma->graphs[i] = load_graph_new (ma, graph_types[i].num_colours, graph_types[i].label, i, speed, size, visible, graph_types[i].name, graph_types[i].callback); } /* for Network graph, colors[4] is grid line color, it should not be used in loop in load-graph.c */ /* for Network graph, colors[5] is indicator color, it should not be used in loop in load-graph.c */ ma->graphs[2]->n = 4; ma->graphs[2]->net_threshold1 = net_threshold1; ma->graphs[2]->net_threshold2 = net_threshold2; ma->graphs[2]->net_threshold3 = net_threshold3; /* for Load graph, colors[2] is grid line color, it should not be used in loop in load-graph.c */ ma->graphs[4]->n = 2; }