From 9f8d1eda30e8eb0db2ab6f1ba5d2217189f48c7f Mon Sep 17 00:00:00 2001 From: Danny Auble <da@llnl.gov> Date: Fri, 24 Apr 2009 19:44:50 +0000 Subject: [PATCH] ok now we handle dynamic reservations --- src/sview/block_info.c | 16 ++++++++----- src/sview/common.c | 4 +--- src/sview/grid.c | 52 ++++++++++++++++++++++++++++++++++++------ src/sview/job_info.c | 15 +++++++----- src/sview/node_info.c | 6 ++--- src/sview/part_info.c | 15 +++++++----- src/sview/popups.c | 2 +- src/sview/resv_info.c | 19 ++++++++------- src/sview/sview.h | 6 +++-- 9 files changed, 92 insertions(+), 43 deletions(-) diff --git a/src/sview/block_info.c b/src/sview/block_info.c index 53ef5e009b4..6f7ba262f43 100644 --- a/src/sview/block_info.c +++ b/src/sview/block_info.c @@ -1141,7 +1141,6 @@ extern void set_menus_block(void *arg, GtkTreePath *path, extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; - int *node_inx = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; @@ -1149,7 +1148,6 @@ extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id) int i=0; gtk_tree_model_get(model, iter, SORTID_BLOCK, &name, -1); - gtk_tree_model_get(model, iter, SORTID_NODE_INX, &node_inx, -1); switch(id) { case JOB_PAGE: @@ -1186,16 +1184,22 @@ extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id) if(!popup_win) { if(id == INFO_PAGE) - popup_win = create_popup_info( - id, BLOCK_PAGE, title, node_inx); + popup_win = create_popup_info(id, BLOCK_PAGE, title); else - popup_win = create_popup_info( - BLOCK_PAGE, id, title, node_inx); + popup_win = create_popup_info(BLOCK_PAGE, id, title); } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } + + /* Pass the model and the structs from the iter so we can always get + the current node_inx. + */ + popup_win->model = model; + popup_win->iter = *iter; + popup_win->node_inx_id = SORTID_NODE_INX; + switch(id) { case JOB_PAGE: popup_win->spec_info->search_info->gchar_data = name; diff --git a/src/sview/common.c b/src/sview/common.c index ac4989a096e..c30902a39d0 100644 --- a/src/sview/common.c +++ b/src/sview/common.c @@ -702,8 +702,7 @@ extern gboolean row_clicked(GtkTreeView *tree_view, GdkEventButton *event, return did_something; } -extern popup_info_t *create_popup_info(int type, int dest_type, - char *title, int *node_inx) +extern popup_info_t *create_popup_info(int type, int dest_type, char *title) { GtkScrolledWindow *window = NULL; GtkBin *bin = NULL; @@ -770,7 +769,6 @@ extern popup_info_t *create_popup_info(int type, int dest_type, bin = GTK_BIN(&view->bin); popup_win->grid_table = GTK_TABLE(bin->child); popup_win->grid_button_list = NULL; - popup_win->node_inx = node_inx; table = gtk_table_new(1, 2, FALSE); diff --git a/src/sview/grid.c b/src/sview/grid.c index da4983edcc0..51036628729 100644 --- a/src/sview/grid.c +++ b/src/sview/grid.c @@ -87,8 +87,7 @@ static void _open_node(GtkWidget *widget, GdkEventButton *event, list_iterator_destroy(itr); if(!popup_win) { - popup_win = create_popup_info(INFO_PAGE, NODE_PAGE, - title, NULL); + popup_win = create_popup_info(INFO_PAGE, NODE_PAGE, title); popup_win->spec_info->search_info->gchar_data = g_strdup(grid_button->node_name); if (!g_thread_create((gpointer)popup_thr, popup_win, @@ -126,8 +125,7 @@ static void _open_block(GtkWidget *widget, GdkEventButton *event, list_iterator_destroy(itr); if(!popup_win) { - popup_win = create_popup_info(INFO_PAGE, BLOCK_PAGE, - title, NULL); + popup_win = create_popup_info(INFO_PAGE, BLOCK_PAGE, title); popup_win->spec_info->search_info->search_type = SEARCH_BLOCK_NODENAME; popup_win->spec_info->search_info->gchar_data = @@ -172,6 +170,7 @@ void _put_button_as_down(grid_button_t *grid_button, int state) GdkColor color; if(GTK_IS_EVENT_BOX(grid_button->button)) { + //gtk_widget_set_sensitive (grid_button->button, TRUE); return; } gtk_widget_destroy(grid_button->button); @@ -217,6 +216,7 @@ void _put_button_as_down(grid_button_t *grid_button, int state) void _put_button_as_up(grid_button_t *grid_button) { if(GTK_IS_BUTTON(grid_button->button)) { + //gtk_widget_set_sensitive (grid_button->button, TRUE); return; } gtk_widget_destroy(grid_button->button); @@ -242,6 +242,37 @@ void _put_button_as_up(grid_button_t *grid_button) return; } +void _put_button_as_inactive(grid_button_t *grid_button) +{ + if(GTK_IS_BUTTON(grid_button->button)) { + //gtk_widget_set_sensitive (grid_button->button, FALSE); + return; + } + gtk_widget_destroy(grid_button->button); + grid_button->button = gtk_button_new(); + gtk_widget_set_size_request(grid_button->button, 10, 10); + //gtk_widget_set_sensitive (grid_button->button, FALSE); + + gtk_tooltips_set_tip(grid_button->tip, + grid_button->button, + grid_button->node_name, + "click for node stats"); + g_signal_connect(G_OBJECT(grid_button->button), + "button-press-event", + G_CALLBACK(_open_node), + grid_button); + if(grid_button->table) + gtk_table_attach(grid_button->table, grid_button->button, + grid_button->table_x, + (grid_button->table_x+1), + grid_button->table_y, + (grid_button->table_y+1), + GTK_SHRINK, GTK_SHRINK, + 1, 1); + gtk_widget_show_all(grid_button->button); + return; +} + #ifdef HAVE_BG static int _block_in_node(int *bp_inx, int inx) { @@ -295,6 +326,7 @@ extern grid_button_t *create_grid_button_from_another( send_grid_button->table = NULL; if(color_inx == MAKE_BLACK) { send_grid_button->button = gtk_button_new(); + //gtk_widget_set_sensitive (send_grid_button->button, FALSE); gdk_color_parse(blank_color, &color); gtk_widget_modify_bg(send_grid_button->button, GTK_STATE_NORMAL, &color); @@ -387,7 +419,7 @@ extern char *change_grid_color(List button_list, int start, int end, continue; if(color_inx == MAKE_BLACK) { - _put_button_as_up(grid_button); + _put_button_as_inactive(grid_button); grid_button->color = blank_color; gtk_widget_modify_bg(grid_button->button, GTK_STATE_NORMAL, &color); @@ -897,19 +929,25 @@ extern void setup_popup_grid_list(popup_info_t *popup_win) { int def_color = MAKE_BLACK; - if(!popup_win->node_inx || popup_win->spec_info->type == INFO_PAGE) + if(!popup_win->model || popup_win->spec_info->type == INFO_PAGE) def_color = MAKE_WHITE; if(popup_win->grid_button_list) { change_grid_color(popup_win->grid_button_list, -1, -1, def_color); - } else { + } else { popup_win->grid_button_list = copy_main_button_list(def_color); put_buttons_in_table(popup_win->grid_table, popup_win->grid_button_list); popup_win->full_grid = 1; } + /* refresh the pointer */ + if(popup_win->model) + gtk_tree_model_get(popup_win->model, &popup_win->iter, + popup_win->node_inx_id, + &popup_win->node_inx, -1); + if(popup_win->node_inx) { int j=0; while(popup_win->node_inx[j] >= 0) { diff --git a/src/sview/job_info.c b/src/sview/job_info.c index 3d4c67698b2..22308c26783 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -3008,7 +3008,6 @@ extern void popup_all_job(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; - int *node_inx = NULL; ListIterator itr = NULL; popup_info_t *popup_win = NULL; int jobid = NO_VAL; @@ -3017,7 +3016,6 @@ extern void popup_all_job(GtkTreeModel *model, GtkTreeIter *iter, int id) gtk_tree_model_get(model, iter, SORTID_JOBID, &jobid, -1); gtk_tree_model_get(model, iter, SORTID_ALLOC, &stepid, -1); - gtk_tree_model_get(model, iter, SORTID_NODE_INX, &node_inx, -1); if(stepid) stepid = NO_VAL; @@ -3097,16 +3095,21 @@ extern void popup_all_job(GtkTreeModel *model, GtkTreeIter *iter, int id) if(!popup_win) { if(id == INFO_PAGE) - popup_win = create_popup_info( - id, JOB_PAGE, title, node_inx); + popup_win = create_popup_info(id, JOB_PAGE, title); else - popup_win = create_popup_info( - JOB_PAGE, id, title, node_inx); + popup_win = create_popup_info(JOB_PAGE, id, title); } else { gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } + /* Pass the model and the structs from the iter so we can always get + the current node_inx. + */ + popup_win->model = model; + popup_win->iter = *iter; + popup_win->node_inx_id = SORTID_NODE_INX; + switch(id) { case NODE_PAGE: gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1); diff --git a/src/sview/node_info.c b/src/sview/node_info.c index d377e65f032..c9eb292cec4 100644 --- a/src/sview/node_info.c +++ b/src/sview/node_info.c @@ -1123,11 +1123,9 @@ extern void popup_all_node(GtkTreeModel *model, GtkTreeIter *iter, int id) if(!popup_win) { if(id == INFO_PAGE) - popup_win = create_popup_info( - id, NODE_PAGE, title, NULL); + popup_win = create_popup_info(id, NODE_PAGE, title); else - popup_win = create_popup_info( - NODE_PAGE, id, title, NULL); + popup_win = create_popup_info(NODE_PAGE, id, title); popup_win->spec_info->search_info->gchar_data = name; if (!g_thread_create((gpointer)popup_thr, popup_win, FALSE, &error)) diff --git a/src/sview/part_info.c b/src/sview/part_info.c index d36a232ae28..e183201d29a 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -2315,7 +2315,6 @@ extern void popup_all_part(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char *state = NULL; - int *node_inx = NULL; char title[100]; int only_line = 0; ListIterator itr = NULL; @@ -2323,7 +2322,6 @@ extern void popup_all_part(GtkTreeModel *model, GtkTreeIter *iter, int id) GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); - gtk_tree_model_get(model, iter, SORTID_NODE_INX, &node_inx, -1); switch(id) { case JOB_PAGE: @@ -2383,11 +2381,9 @@ extern void popup_all_part(GtkTreeModel *model, GtkTreeIter *iter, int id) if(!popup_win) { if(id == INFO_PAGE) - popup_win = create_popup_info( - id, PART_PAGE, title, node_inx); + popup_win = create_popup_info(id, PART_PAGE, title); else - popup_win = create_popup_info( - PART_PAGE, id, title, node_inx); + popup_win = create_popup_info(PART_PAGE, id, title); } else { g_free(name); g_free(state); @@ -2395,6 +2391,13 @@ extern void popup_all_part(GtkTreeModel *model, GtkTreeIter *iter, int id) return; } + /* Pass the model and the structs from the iter so we can always get + the current node_inx. + */ + popup_win->model = model; + popup_win->iter = *iter; + popup_win->node_inx_id = SORTID_NODE_INX; + switch(id) { case JOB_PAGE: case BLOCK_PAGE: diff --git a/src/sview/popups.c b/src/sview/popups.c index a1e993b6a56..4c83ca03b4f 100644 --- a/src/sview/popups.c +++ b/src/sview/popups.c @@ -174,7 +174,7 @@ void _search_entry(sview_search_info_t *sview_search_info) list_iterator_destroy(itr); if(!popup_win) { - popup_win = create_popup_info(id, id, title, NULL); + popup_win = create_popup_info(id, id, title); } else { gtk_window_present(GTK_WINDOW(popup_win->popup)); return; diff --git a/src/sview/resv_info.c b/src/sview/resv_info.c index 1bc95ed6093..2c05e6f1dc4 100644 --- a/src/sview/resv_info.c +++ b/src/sview/resv_info.c @@ -523,7 +523,7 @@ static void _update_resv_record(sview_resv_info_t *sview_resv_info_ptr, char *tmp_ptr = NULL; char tmp_char[50]; reserve_info_t *resv_ptr = sview_resv_info_ptr->resv_ptr; - + gtk_tree_store_set(treestore, iter, SORTID_UPDATED, 1, -1); gtk_tree_store_set(treestore, iter, @@ -1189,14 +1189,12 @@ extern void set_menus_resv(void *arg, GtkTreePath *path, extern void popup_all_resv(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; - int *node_inx = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); - gtk_tree_model_get(model, iter, SORTID_NODE_INX, &node_inx, -1); switch(id) { case PART_PAGE: @@ -1239,17 +1237,22 @@ extern void popup_all_resv(GtkTreeModel *model, GtkTreeIter *iter, int id) if(!popup_win) { if(id == INFO_PAGE) - popup_win = create_popup_info( - id, RESV_PAGE, title, node_inx); + popup_win = create_popup_info(id, RESV_PAGE, title); else - popup_win = create_popup_info( - RESV_PAGE, id, title, node_inx); + popup_win = create_popup_info(RESV_PAGE, id, title); } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } - + + /* Pass the model and the structs from the iter so we can always get + the current node_inx. + */ + popup_win->model = model; + popup_win->iter = *iter; + popup_win->node_inx_id = SORTID_NODE_INX; + switch(id) { case JOB_PAGE: case INFO_PAGE: diff --git a/src/sview/sview.h b/src/sview/sview.h index 4f5cdd3a8c3..8937363f42f 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -213,6 +213,9 @@ struct popup_info { List grid_button_list; specific_info_t *spec_info; display_data_t *display_data; + GtkTreeModel *model; + GtkTreeIter iter; + int node_inx_id; }; typedef struct { @@ -406,8 +409,7 @@ extern void right_button_pressed(GtkTreeView *tree_view, GtkTreePath *path, int type); extern gboolean row_clicked(GtkTreeView *tree_view, GdkEventButton *event, const display_data_t *display_data); -extern popup_info_t *create_popup_info(int type, int dest_type, char *title, - int *node_inx); +extern popup_info_t *create_popup_info(int type, int dest_type, char *title); extern void setup_popup_info(popup_info_t *popup_win, display_data_t *display_data, int cnt); -- GitLab