Skip to content
Snippets Groups Projects
Commit a4f75cc7 authored by Danny Auble's avatar Danny Auble
Browse files

tooltips for the grid

parent 4fcad8e7
No related branches found
No related tags found
No related merge requests found
......@@ -642,6 +642,9 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title)
popup_win->event_box, FALSE, FALSE, 0);
window = create_scrolled_window();
gtk_scrolled_window_set_policy(window,
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
bin = GTK_BIN(&window->container);
view = GTK_VIEWPORT(bin->child);
bin = GTK_BIN(&view->bin);
......
......@@ -132,6 +132,10 @@ void _put_button_as_down(grid_button_t *grid_button)
gtk_widget_destroy(grid_button->button);
grid_button->button = gtk_event_box_new();
gtk_tooltips_set_tip(grid_button->tip,
grid_button->button,
grid_button->node_name,
"click for node stats");
gtk_widget_set_size_request(grid_button->button, 10, 10);
gtk_event_box_set_above_child(GTK_EVENT_BOX(grid_button->button),
FALSE);
......@@ -167,6 +171,10 @@ void _put_button_as_up(grid_button_t *grid_button)
gtk_widget_destroy(grid_button->button);
grid_button->button = gtk_button_new();
gtk_widget_set_size_request(grid_button->button, 10, 10);
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),
......@@ -188,6 +196,7 @@ extern void destroy_grid_button(void *arg)
gtk_widget_destroy(grid_button->button);
grid_button->button = NULL;
}
xfree(grid_button->node_name);
xfree(grid_button);
}
}
......@@ -260,7 +269,6 @@ extern void get_button_list_from_main(List *button_list, int start, int end,
*button_list = list_create(NULL);
color_inx %= sview_colors_cnt;
gdk_color_parse(sview_colors[color_inx], &color);
itr = list_iterator_create(grid_button_list);
while((grid_button = list_next(itr))) {
......@@ -300,14 +308,22 @@ extern void get_button_list_from_main(List *button_list, int start, int end,
} else {
send_grid_button->button = gtk_button_new();
gdk_color_parse(sview_colors[color_inx], &color);
gtk_widget_modify_bg(send_grid_button->button,
GTK_STATE_NORMAL, &color);
}
gtk_widget_set_size_request(send_grid_button->button, 10, 10);
send_grid_button->tip = gtk_tooltips_new();
send_grid_button->node_name = xstrdup(grid_button->node_name);
g_signal_connect(G_OBJECT(send_grid_button->button),
"button-press-event",
G_CALLBACK(_open_node),
send_grid_button);
gtk_tooltips_set_tip(send_grid_button->tip,
send_grid_button->button,
send_grid_button->node_name,
"click for node stats");
grid_button->color = sview_colors[color_inx];
list_append(*button_list, send_grid_button);
......@@ -419,12 +435,14 @@ extern int get_system_stats()
{
int error_code = SLURM_SUCCESS;
node_info_msg_t *node_info_ptr = NULL;
List node_list = NULL;
int changed = 1;
#ifdef HAVE_BG
int y=0, z=0;
#endif
if((error_code = get_new_info_node(&node_info_ptr, force_refresh))
== SLURM_NO_CHANGE_IN_DATA) {
changed = 0;
goto update_it;
}
if (error_code != SLURM_SUCCESS) {
......@@ -436,19 +454,29 @@ update_it:
if(grid_button_list)
return SLURM_SUCCESS;
grid_button_list = list_create(destroy_grid_button);
setup_grid_table(main_grid_table, grid_button_list, DIM_SIZE[X]);
node_list = create_node_info_list(node_info_ptr, changed);
setup_grid_table(main_grid_table, grid_button_list, node_list);
return SLURM_SUCCESS;
}
extern int setup_grid_table(GtkTable *table, List button_list, int node_count)
extern int setup_grid_table(GtkTable *table, List button_list, List node_list)
{
int error_code = SLURM_SUCCESS;
int x=0, table_x=0, table_y=0;
int coord_x=0, coord_y=0, i=0;
grid_button_t *grid_button = NULL;
int node_count = 0;
ListIterator itr = NULL;
sview_node_info_t *sview_node_info_ptr = NULL;
if(!node_list) {
g_print("setup_grid_table: no node_list given\n");
return SLURM_ERROR;
}
#ifndef HAVE_BG
node_count = list_count(node_list);
if(node_count < 50) {
table_x = 1;
} else if(node_count < 500) {
......@@ -466,7 +494,7 @@ extern int setup_grid_table(GtkTable *table, List button_list, int node_count)
#endif
gtk_table_resize(table, table_y, table_x);
itr = list_iterator_create(node_list);
for (x=0; x<node_count; x++) {
#ifdef HAVE_BG
for (y=0; y<DIM_SIZE[Y]; y++) {
......@@ -480,6 +508,19 @@ extern int setup_grid_table(GtkTable *table, List button_list, int node_count)
grid_button->table_x = coord_x;
grid_button->table_y = coord_y;
grid_button->button = gtk_button_new();
grid_button->tip = gtk_tooltips_new();
if(!(sview_node_info_ptr = list_next(itr))) {
g_print("no node for this "
"inx %d!!!!\n",
grid_button->inx);
goto end_it;
}
grid_button->node_name = xstrdup(
sview_node_info_ptr->node_ptr->name);
gtk_tooltips_set_tip(grid_button->tip,
grid_button->button,
grid_button->node_name,
"click for node stats");
gtk_widget_set_size_request(
grid_button->button, 10, 10);
g_signal_connect(G_OBJECT(grid_button->button),
......@@ -527,6 +568,19 @@ extern int setup_grid_table(GtkTable *table, List button_list, int node_count)
grid_button->table_y = coord_y;
grid_button->button = gtk_button_new();
grid_button->tip = gtk_tooltips_new();
if(!(sview_node_info_ptr = list_next(itr))) {
g_print("no node for this "
"inx %d!!!!\n",
grid_button->inx);
goto end_it;
}
grid_button->node_name = xstrdup(
sview_node_info_ptr->node_ptr->name);
gtk_tooltips_set_tip(grid_button->tip,
grid_button->button,
grid_button->node_name,
"click for node stats");
gtk_widget_set_size_request(grid_button->button, 10, 10);
g_signal_connect(G_OBJECT(grid_button->button),
"button-press-event",
......@@ -561,6 +615,8 @@ extern int setup_grid_table(GtkTable *table, List button_list, int node_count)
#endif
}
end_it:
list_iterator_destroy(itr);
list_sort(button_list, (ListCmpF) _sort_button_inx);
return error_code;
......
......@@ -31,11 +31,6 @@
#define _DEBUG 0
DEF_TIMERS;
typedef struct {
node_info_t *node_ptr;
char *color;
} sview_node_info_t;
enum {
SORTID_POS = POS_LOC,
SORTID_NAME,
......@@ -256,43 +251,6 @@ static void _node_info_list_del(void *object)
}
}
static List _create_node_info_list(node_info_msg_t *node_info_ptr,
int changed)
{
static List info_list = NULL;
int i = 0;
sview_node_info_t *sview_node_info_ptr = NULL;
node_info_t *node_ptr = NULL;
if(!changed && info_list) {
goto update_color;
}
if(info_list) {
list_destroy(info_list);
}
info_list = list_create(_node_info_list_del);
if (!info_list) {
g_print("malloc error\n");
return NULL;
}
for (i=0; i<node_info_ptr->record_count; i++) {
node_ptr = &(node_info_ptr->node_array[i]);
if (!node_ptr->name || (node_ptr->name[0] == '\0'))
continue; /* bad node */
sview_node_info_ptr = xmalloc(sizeof(sview_node_info_t));
list_append(info_list, sview_node_info_ptr);
sview_node_info_ptr->node_ptr = node_ptr;
}
update_color:
return info_list;
}
void _display_info_node(List info_list, popup_info_t *popup_win)
{
specific_info_t *spec_info = popup_win->spec_info;
......@@ -372,6 +330,42 @@ extern void refresh_node(GtkAction *action, gpointer user_data)
specific_info_node(popup_win);
}
/* don't destroy the list from this function */
extern List create_node_info_list(node_info_msg_t *node_info_ptr, int changed)
{
static List info_list = NULL;
int i = 0;
sview_node_info_t *sview_node_info_ptr = NULL;
node_info_t *node_ptr = NULL;
if(!changed && info_list) {
goto update_color;
}
if(info_list) {
list_destroy(info_list);
}
info_list = list_create(_node_info_list_del);
if (!info_list) {
g_print("malloc error\n");
return NULL;
}
for (i=0; i<node_info_ptr->record_count; i++) {
node_ptr = &(node_info_ptr->node_array[i]);
if (!node_ptr->name || (node_ptr->name[0] == '\0'))
continue; /* bad node */
sview_node_info_ptr = xmalloc(sizeof(sview_node_info_t));
list_append(info_list, sview_node_info_ptr);
sview_node_info_ptr->node_ptr = node_ptr;
}
update_color:
return info_list;
}
extern int get_new_info_node(node_info_msg_t **info_ptr, int force)
{
static node_info_msg_t *node_info_ptr = NULL, *new_node_ptr = NULL;
......@@ -571,7 +565,7 @@ extern void get_info_node(GtkTable *table, display_data_t *display_data)
goto end_it;
}
display_it:
info_list = _create_node_info_list(node_info_ptr, changed);
info_list = create_node_info_list(node_info_ptr, changed);
if(!info_list)
return;
......@@ -662,7 +656,7 @@ extern void specific_info_node(popup_info_t *popup_win)
return;
}
display_it:
info_list = _create_node_info_list(node_info_ptr, changed);
info_list = create_node_info_list(node_info_ptr, changed);
if(!info_list)
return;
......
......@@ -177,15 +177,22 @@ typedef struct {
typedef struct {
GtkWidget *button;
GtkTooltips *tip;
GtkTable *table;
int coord[BA_SYSTEM_DIMENSIONS];
char *node_name;
char *color;
int inx;
int state;
char *color;
int table_x;
int table_y;
int coord[BA_SYSTEM_DIMENSIONS];
} grid_button_t;
typedef struct {
node_info_t *node_ptr;
char *color;
} sview_node_info_t;
extern sview_parameters_t params;
extern int text_line_cnt;
......@@ -234,7 +241,7 @@ extern void get_button_list_from_main(List *button_list, int start, int end,
int color_inx);
extern void put_buttons_in_table(GtkTable *table, List button_list);
extern int get_system_stats();
extern int setup_grid_table(GtkTable *table, List button_list, int node_count);
extern int setup_grid_table(GtkTable *table, List button_list, List node_list);
extern void sview_init_grid();
extern void sview_reset_grid();
......@@ -285,6 +292,8 @@ extern void popup_all_job(GtkTreeModel *model, GtkTreeIter *iter, int id);
// node_info.c
extern void refresh_node(GtkAction *action, gpointer user_data);
/* don't destroy the list from this function */
extern List create_node_info_list(node_info_msg_t *node_info_ptr, int changed);
extern int update_state_node(GtkTreeStore *treestore, GtkTreeIter *iter,
int text_column, int num_column,
const char *new_text,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment