static int click_accept_yes(widget_list *w, int mx, int my, Uint32 flags) { char string[255]; int window_id = w->window_id; int i; //TODO: get rid of this when the widget handlers can take custom arguments /* Find the position of the window clicked in the accept_windows array */ for(i = 0; i < MAX_ACCEPT_BUDDY_WINDOWS; i++) { if(accept_windows[i].window_id == window_id) { break; } } if(i == MAX_ACCEPT_BUDDY_WINDOWS) { /* We didn't find it */ return 0; } safe_snprintf(string, sizeof(string), "%c#accept_buddy %s", RAW_TEXT, accept_windows[i].name); my_tcp_send(my_socket, (Uint8*)string, strlen(string+1)+1); if(accept_windows[i].checkbox >= 0 && checkbox_get_checked(accept_windows[i].window_id, accept_windows[i].checkbox) > 0) { safe_snprintf(string, sizeof(string), "%c#add_buddy %s", RAW_TEXT, accept_windows[i].name); my_tcp_send(my_socket, (Uint8*)string, strlen(string+1)+1); } destroy_window(accept_windows[i].window_id); accept_windows[i].window_id = -1; accept_windows[i].checkbox = -1; free(accept_windows[i].text); accept_windows[i].text = NULL; accept_windows[i].name[0] = '\0'; return 1; }
static int click_accept_checkbox_label(widget_list *w, int mx, int my, Uint32 flags) { int current_window; for(current_window = 0; current_window < MAX_ACCEPT_BUDDY_WINDOWS; current_window++) if(accept_windows[current_window].window_id == w->window_id) break; if(current_window == MAX_ACCEPT_BUDDY_WINDOWS) return 0; checkbox_set_checked(w->window_id, accept_windows[current_window].checkbox, !checkbox_get_checked(w->window_id, accept_windows[current_window].checkbox)); return 1; }
// checkbox A events void bToggleChecked_pushed(object_t *object, event_t *event, void *data) { object_t *c = (object_t*)data; checkbox_set_checked(c, 1-checkbox_get_checked(c)); }
void cCheck_changed(object_t *object, event_t *event, void *data) { object_t *lStatus = (object_t*)data; label_set_text(lStatus, (checkbox_get_checked(object) == 0 ? "Not checked" : "Checked!")); }