static bool _change_button_color(grid_button_t *grid_button, int color_inx, char *new_col, GdkColor color, bool only_change_unused, enum node_states state_override) { enum node_states state; uint16_t node_base_state; bool changed = 0; xassert(grid_button); if (only_change_unused && grid_button->used) return 0; grid_button->used = true; if (color_inx == MAKE_BLACK) { if (grid_button->color_inx != color_inx) { _put_button_as_inactive(grid_button); grid_button->color = new_col; grid_button->color_inx = color_inx; sview_widget_modify_bg(grid_button->button, GTK_STATE_NORMAL, color); /* sview_widget_modify_bg(grid_button->button, */ /* GTK_STATE_ACTIVE, */ /* color); */ changed = 1; } return changed; } if (state_override != NODE_STATE_UNKNOWN) state = state_override; else state = grid_button->state; node_base_state = state & NODE_STATE_BASE; if (node_base_state == NODE_STATE_DOWN) { _put_button_as_down(grid_button, NODE_STATE_DOWN); } else if ((state & NODE_STATE_DRAIN) || (node_base_state == NODE_STATE_ERROR)) { _put_button_as_down(grid_button, NODE_STATE_DRAIN); } else if (grid_button->node_name && !strcmp(grid_button->node_name, "EMPTY")) { grid_button->color_inx = MAKE_BLACK; // _put_button_as_up(grid_button); } else if (grid_button->color_inx != color_inx) { _put_button_as_up(grid_button); grid_button->color = new_col; grid_button->color_inx = color_inx; sview_widget_modify_bg(grid_button->button, GTK_STATE_NORMAL, color); /* sview_widget_modify_bg(grid_button->button, */ /* GTK_STATE_ACTIVE, color); */ changed = 1; } return changed; }
extern grid_button_t *create_grid_button_from_another( grid_button_t *grid_button, char *name, int color_inx) { grid_button_t *send_grid_button = NULL; GdkColor color; uint16_t node_base_state; char *new_col = NULL; if (!grid_button || !name) return NULL; if (color_inx >= 0) { color_inx %= sview_colors_cnt; new_col = sview_colors[color_inx]; } else if (color_inx == MAKE_BLACK) new_col = blank_color; else new_col = white_color; send_grid_button = xmalloc(sizeof(grid_button_t)); memcpy(send_grid_button, grid_button, sizeof(grid_button_t)); node_base_state = send_grid_button->state & NODE_STATE_BASE; send_grid_button->color_inx = color_inx; /* need to set the table to empty because we will want to fill this into the new table later */ 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(new_col, &color); send_grid_button->color = new_col; sview_widget_modify_bg(send_grid_button->button, GTK_STATE_NORMAL, color); /* sview_widget_modify_bg(send_grid_button->button, */ /* GTK_STATE_ACTIVE, color); */ } else if ((color_inx >= 0) && node_base_state == NODE_STATE_DOWN) { GtkWidget *image = gtk_image_new_from_stock( GTK_STOCK_CANCEL, GTK_ICON_SIZE_SMALL_TOOLBAR); send_grid_button->button = gtk_event_box_new(); gtk_event_box_set_above_child( GTK_EVENT_BOX(send_grid_button->button), false); gdk_color_parse("black", &color); sview_widget_modify_bg(send_grid_button->button, GTK_STATE_NORMAL, color); //gdk_color_parse("white", &color); /* sview_widget_modify_bg(send_grid_button->button, */ /* GTK_STATE_ACTIVE, color); */ gtk_container_add( GTK_CONTAINER(send_grid_button->button), image); } else if ((color_inx >= 0) && (send_grid_button->state & NODE_STATE_DRAIN)) { GtkWidget *image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_SMALL_TOOLBAR); send_grid_button->button = gtk_event_box_new(); gtk_event_box_set_above_child( GTK_EVENT_BOX(send_grid_button->button), false); gdk_color_parse("black", &color); /* sview_widget_modify_bg(send_grid_button->button, */ /* GTK_STATE_NORMAL, color); */ //gdk_color_parse("white", &color); /* sview_widget_modify_bg(send_grid_button->button, */ /* GTK_STATE_ACTIVE, color); */ gtk_container_add( GTK_CONTAINER(send_grid_button->button), image); } else { send_grid_button->button = gtk_button_new(); send_grid_button->color = new_col; gdk_color_parse(new_col, &color); sview_widget_modify_bg(send_grid_button->button, GTK_STATE_NORMAL, color); /* sview_widget_modify_bg(send_grid_button->button, */ /* GTK_STATE_ACTIVE, color); */ } gtk_widget_set_size_request(send_grid_button->button, working_sview_config.button_size, working_sview_config.button_size); send_grid_button->node_name = xstrdup(name); return send_grid_button; }