static void _append_block_record(sview_block_info_t *block_ptr, GtkTreeStore *treestore) { gtk_tree_store_append(treestore, &block_ptr->iter_ptr, NULL); gtk_tree_store_set(treestore, &block_ptr->iter_ptr, SORTID_POS, block_ptr->pos, -1); _update_block_record(block_ptr, treestore); }
static void _append_block_record(sview_block_info_t *block_ptr, GtkTreeStore *treestore, GtkTreeIter *iter, int line) { gtk_tree_store_append(treestore, iter, NULL); gtk_tree_store_set(treestore, iter, SORTID_POS, line, -1); _update_block_record(block_ptr, treestore, iter); }
static void _update_info_block(List block_list, GtkTreeView *tree_view) { ListIterator itr; sview_block_info_t *block_ptr = NULL; GtkTreeModel *model = gtk_tree_view_get_model(tree_view); char *name = NULL; if (!block_list) { g_print("No block_list given"); return; } set_for_update(model, SORTID_UPDATED); /* Report the BG Blocks */ itr = list_iterator_create(block_list); while ((block_ptr = (sview_block_info_t*) list_next(itr))) { if (block_ptr->cnode_cnt == 0) block_ptr->cnode_cnt = block_ptr->size; if (!block_ptr->slurm_part_name) block_ptr->slurm_part_name = xstrdup("no part"); /* This means the tree_store changed (added new column or something). */ if (last_model != model) block_ptr->iter_set = false; if (block_ptr->iter_set) { gtk_tree_model_get(model, &block_ptr->iter_ptr, SORTID_BLOCK, &name, -1); if (xstrcmp(name, block_ptr->bg_block_name)) { /* Bad pointer */ block_ptr->iter_set = false; } g_free(name); } if (block_ptr->iter_set) _update_block_record(block_ptr, GTK_TREE_STORE(model)); else { _append_block_record(block_ptr, GTK_TREE_STORE(model)); block_ptr->iter_set = true; } } list_iterator_destroy(itr); /* remove all old blocks */ remove_old(model, SORTID_UPDATED); last_model = model; }
static void _update_info_block(List block_list, GtkTreeView *tree_view) { ListIterator itr; sview_block_info_t *block_ptr = NULL; GtkTreePath *path = gtk_tree_path_new_first(); GtkTreeModel *model = gtk_tree_view_get_model(tree_view); GtkTreeIter iter; char *name = NULL; char *host = NULL; int line = 0; if (!block_list) { g_print("No block_list given"); return; } /* get the iter, or find out the list is empty goto add */ if (gtk_tree_model_get_iter(model, &iter, path)) { /* make sure all the partitions are still here */ while (1) { gtk_tree_store_set(GTK_TREE_STORE(model), &iter, SORTID_UPDATED, 0, -1); if (!gtk_tree_model_iter_next(model, &iter)) { break; } } } /* Report the BG Blocks */ itr = list_iterator_create(block_list); while ((block_ptr = (sview_block_info_t*) list_next(itr))) { if (block_ptr->cnode_cnt == 0) block_ptr->cnode_cnt = block_ptr->size; if (!block_ptr->slurm_part_name) block_ptr->slurm_part_name = xstrdup("no part"); /* get the iter, or find out the list is empty goto add */ if (!gtk_tree_model_get_iter(model, &iter, path)) { goto adding; } line = 0; while (1) { /* search for the jobid and check to see if it is in the list */ gtk_tree_model_get(model, &iter, SORTID_BLOCK, &name, -1); if (!strcmp(name, block_ptr->bg_block_name)) { /* update with new info */ g_free(name); _update_block_record(block_ptr, GTK_TREE_STORE(model), &iter); goto found; } g_free(name); line++; if (!gtk_tree_model_iter_next(model, &iter)) { break; } } adding: _append_block_record(block_ptr, GTK_TREE_STORE(model), &iter, line); found: ; } list_iterator_destroy(itr); if (host) free(host); gtk_tree_path_free(path); /* remove all old blocks */ remove_old(model, SORTID_UPDATED); }