From 24b759eedadec7987c6c27bff1ced3134eca6bf5 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Wed, 8 Jul 2009 17:05:42 +0000 Subject: [PATCH] fix for sview to sort things correctly and only change grid blocks when they are needed. --- src/sview/block_info.c | 7 ++++--- src/sview/common.c | 4 ++-- src/sview/job_info.c | 38 ++++++++++++++++++-------------------- src/sview/node_info.c | 5 +++-- src/sview/part_info.c | 5 +++-- src/sview/resv_info.c | 13 +++++++------ src/sview/sview.c | 6 +++--- src/sview/sview.h | 3 ++- 8 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/sview/block_info.c b/src/sview/block_info.c index 1429e9359bc..6c7a1e779db 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -927,7 +927,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, display_data_block, SORTID_CNT); + create_treestore(tree_view, display_data_block, + SORTID_CNT, SORTID_BLOCK); } view = INFO_VIEW; _update_info_block(block_list, GTK_TREE_VIEW(display_widget)); @@ -1036,8 +1037,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, - popup_win->display_data, SORTID_CNT); + create_treestore(tree_view, popup_win->display_data, + SORTID_CNT, SORTID_BLOCK); } setup_popup_grid_list(popup_win); diff --git a/src/sview/common.c b/src/sview/common.c index 7fcf70955ab..66fded3a1ec 100644 --- a/src/sview/common.c +++ b/src/sview/common.c @@ -649,7 +649,7 @@ extern GtkTreeView *create_treeview_2cols_attach_to_table(GtkTable *table) extern GtkTreeStore *create_treestore(GtkTreeView *tree_view, display_data_t *display_data, - int count) + int count, int sort_column) { GtkTreeStore *treestore = NULL; GType types[count]; @@ -717,7 +717,7 @@ extern GtkTreeStore *create_treestore(GtkTreeView *tree_view, } } gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(treestore), - 1, + sort_column, GTK_SORT_ASCENDING); g_object_unref(treestore); diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 730f0cd4a7c..9a61636c58d 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -370,7 +370,6 @@ static void _update_info_step(sview_job_info_t *sview_job_info_ptr, GtkTreeIter *step_iter, GtkTreeIter *iter); - /* translate name name to number */ static uint16_t _xlate_signal_name(const char *signal_name) { @@ -2085,10 +2084,11 @@ static void _update_info_job(List info_list, } } } - + itr = list_iterator_create(info_list); while ((sview_job_info = (sview_job_info_t*) list_next(itr))) { job_ptr = sview_job_info->job_ptr; + g_print("here job %d with %d %d\n", job_ptr->job_id, job_ptr->num_procs, sview_job_info->node_cnt); /* get the iter, or find out the list is empty goto add */ if (!gtk_tree_model_get_iter(model, &iter, path)) { goto adding; @@ -2149,16 +2149,16 @@ static int _sview_job_sort_aval_dec(sview_job_info_t* rec_a, int size_a = rec_a->node_cnt; int size_b = rec_b->node_cnt; - if (size_a > size_b) + if (size_a < size_b) return -1; - else if (size_a < size_b) + else if (size_a > size_b) return 1; if(rec_a->nodes && rec_b->nodes) { size_a = strcmp(rec_a->nodes, rec_b->nodes); - if (size_a > 0) + if (size_a < 0) return -1; - else if (size_a < 0) + else if (size_a > 0) return 1; } return 0; @@ -2271,14 +2271,12 @@ static List _create_job_info_list(job_info_msg_t *job_info_ptr, list_append(info_list, sview_job_info_ptr); } + list_sort(info_list, (ListCmpF)_sview_job_sort_aval_dec); - list_sort(info_list, - (ListCmpF)_sview_job_sort_aval_dec); - - list_sort(odd_info_list, - (ListCmpF)_sview_job_sort_aval_dec); + list_sort(odd_info_list, (ListCmpF)_sview_job_sort_aval_dec); update_color: + if(want_odd_states) return odd_info_list; else @@ -2331,7 +2329,7 @@ need_refresh: popup_win->grid_button_list, sview_job_info->job_ptr->node_inx[j], sview_job_info->job_ptr->node_inx[j+1], - i, false, 0); + i, true, 0); j += 2; } _layout_job_record(treeview, sview_job_info, update); @@ -2346,11 +2344,9 @@ need_refresh: j=0; while(step_ptr->node_inx[j] >= 0) { change_grid_color( - popup_win-> - grid_button_list, + popup_win->grid_button_list, step_ptr->node_inx[j], - step_ptr-> - node_inx[j+1], + step_ptr->node_inx[j+1], i, false, 0); j += 2; } @@ -2759,6 +2755,7 @@ display_it: if(!info_list) return; i=0; + /* set up the grid */ itr = list_iterator_create(info_list); while ((sview_job_info_ptr = list_next(itr))) { @@ -2769,7 +2766,7 @@ display_it: change_grid_color(grid_button_list, job_ptr->node_inx[j], job_ptr->node_inx[j+1], - i, false, 0); + i, true, 0); j += 2; } i++; @@ -2795,7 +2792,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, display_data_job, SORTID_CNT); + create_treestore(tree_view, display_data_job, + SORTID_CNT, SORTID_SUBMIT_TIME); } view = INFO_VIEW; @@ -2906,7 +2904,7 @@ display_it: to the treestore we don't really care about the return value */ create_treestore(tree_view, popup_win->display_data, - SORTID_CNT); + SORTID_CNT, SORTID_SUBMIT_TIME); } setup_popup_grid_list(popup_win); @@ -3018,7 +3016,7 @@ display_it: change_grid_color( popup_win->grid_button_list, job_ptr->node_inx[j], - job_ptr->node_inx[j+1], i, false, 0); + job_ptr->node_inx[j+1], i, true, 0); j += 2; } } diff --git a/src/sview/node_info.c b/src/sview/node_info.c index ec0effe777c..ca4fbf65967 100644 --- a/src/sview/node_info.c +++ b/src/sview/node_info.c @@ -946,7 +946,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, display_data_node, SORTID_CNT); + create_treestore(tree_view, display_data_node, + SORTID_CNT, SORTID_NAME); } view = INFO_VIEW; _update_info_node(info_list, GTK_TREE_VIEW(display_widget)); @@ -1031,7 +1032,7 @@ display_it: to the treestore we don't really care about the return value */ create_treestore(tree_view, popup_win->display_data, - SORTID_CNT); + SORTID_CNT, SORTID_NAME); } spec_info->view = INFO_VIEW; diff --git a/src/sview/part_info.c b/src/sview/part_info.c index 3a14f709fe9..14c2451dd02 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -1999,7 +1999,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, display_data_part, SORTID_CNT); + create_treestore(tree_view, display_data_part, + SORTID_CNT, SORTID_NAME); } view = INFO_VIEW; _update_info_part(info_list, GTK_TREE_VIEW(display_widget)); @@ -2131,7 +2132,7 @@ display_it: to the treestore we don't really care about the return value */ create_treestore(tree_view, popup_win->display_data, - SORTID_CNT); + SORTID_CNT, SORTID_NAME); } setup_popup_grid_list(popup_win); diff --git a/src/sview/resv_info.c b/src/sview/resv_info.c index 640ff949c4f..fb2f76bfcde 100644 --- a/src/sview/resv_info.c +++ b/src/sview/resv_info.c @@ -747,7 +747,7 @@ need_refresh: change_grid_color( popup_win->grid_button_list, resv_ptr->node_inx[j], - resv_ptr->node_inx[j+1], i, false, 0); + resv_ptr->node_inx[j+1], i, true, 0); j += 2; } _layout_resv_record(treeview, sview_resv_info, update); @@ -1004,7 +1004,7 @@ display_it: change_grid_color(grid_button_list, resv_ptr->node_inx[j], resv_ptr->node_inx[j+1], - i, false, 0); + i, true, 0); j += 2; } i++; @@ -1030,7 +1030,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, display_data_resv, SORTID_CNT); + create_treestore(tree_view, display_data_resv, + SORTID_CNT, SORTID_START_TIME); } view = INFO_VIEW; _update_info_resv(info_list, GTK_TREE_VIEW(display_widget)); @@ -1113,8 +1114,8 @@ display_it: /* since this function sets the model of the tree_view to the treestore we don't really care about the return value */ - create_treestore(tree_view, - popup_win->display_data, SORTID_CNT); + create_treestore(tree_view, popup_win->display_data, + SORTID_CNT, SORTID_START_TIME); } setup_popup_grid_list(popup_win); @@ -1177,7 +1178,7 @@ display_it: change_grid_color( popup_win->grid_button_list, resv_ptr->node_inx[j], - resv_ptr->node_inx[j+1], i, false, 0); + resv_ptr->node_inx[j+1], i, true, 0); j += 2; } } diff --git a/src/sview/sview.c b/src/sview/sview.c index 8afe467bc3f..7fa6f1da806 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -183,7 +183,7 @@ void *_grid_init_thr(void *arg) GtkTable *table = NULL; int rc = SLURM_SUCCESS; - while(!grid_init) { + while(!grid_init && !fini) { gdk_threads_enter(); page = gtk_notebook_get_current_page( GTK_NOTEBOOK(main_notebook)); @@ -355,10 +355,10 @@ static gboolean _delete(GtkWidget *widget, fini = 1; gtk_main_quit(); ba_fini(); - if(grid_button_list) - list_destroy(grid_button_list); if(popup_list) list_destroy(popup_list); + if(grid_button_list) + list_destroy(grid_button_list); return FALSE; } diff --git a/src/sview/sview.h b/src/sview/sview.h index e7739875b1c..8df9979df8e 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -417,7 +417,8 @@ extern void create_page(GtkNotebook *notebook, display_data_t *display_data); extern GtkTreeView *create_treeview(display_data_t *local); extern GtkTreeView *create_treeview_2cols_attach_to_table(GtkTable *table); extern GtkTreeStore *create_treestore(GtkTreeView *tree_view, - display_data_t *display_data, int count); + display_data_t *display_data, + int count, int sort_column); extern void right_button_pressed(GtkTreeView *tree_view, GtkTreePath *path, GdkEventButton *event, -- GitLab