ui/gtk/button.c

branch
newapi
changeset 399
bb3f3fe2d5ee
parent 359
c51e58359db8
child 403
b59935b2de79
equal deleted inserted replaced
398:4d87a137fe70 399:bb3f3fe2d5ee
389 e.eventdata = NULL; 389 e.eventdata = NULL;
390 e.intval = RADIOBUTTON_GET_ACTIVE(widget); 390 e.intval = RADIOBUTTON_GET_ACTIVE(widget);
391 event->callback(&e, event->userdata); 391 event->callback(&e, event->userdata);
392 } 392 }
393 393
394 typedef struct UiRadioButtonData {
395 UiInteger *value;
396 UiVarEventData *eventdata;
397 UiBool first;
398 } UiRadioButtonData;
399
400 static void destroy_radiobutton(GtkWidget *w, UiRadioButtonData *data) {
401 ui_destroy_vardata(w, data->eventdata);
402 if(data->first) {
403 g_slist_free(data->value->obj);
404 data->value->obj = NULL;
405 data->value->get = NULL;
406 data->value->set = NULL;
407 }
408 free(data);
409 }
410
394 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) { 411 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) {
395 UiObject* current = uic_current_obj(obj); 412 UiObject* current = uic_current_obj(obj);
396 413
397 GSList *rg = NULL; 414 GSList *rg = NULL;
398 UiInteger *rgroup; 415 UiInteger *rgroup;
433 event->var = var; 450 event->var = var;
434 event->observers = NULL; 451 event->observers = NULL;
435 event->callback = NULL; 452 event->callback = NULL;
436 event->userdata = NULL; 453 event->userdata = NULL;
437 454
455 UiRadioButtonData *rbdata = malloc(sizeof(UiRadioButtonData));
456 rbdata->value = rgroup;
457 rbdata->eventdata = event;
458 rbdata->first = first;
459
438 g_signal_connect( 460 g_signal_connect(
439 rbutton, 461 rbutton,
440 "toggled", 462 "toggled",
441 G_CALLBACK(ui_radio_obs), 463 G_CALLBACK(ui_radio_obs),
442 event); 464 event);
443 if(first) { 465 g_signal_connect(
444 g_signal_connect(
445 rbutton, 466 rbutton,
446 "destroy", 467 "destroy",
447 G_CALLBACK(ui_destroy_vardata), 468 G_CALLBACK(destroy_radiobutton),
448 event); 469 rbdata);
449 }
450 } 470 }
451 471
452 if(args.onchange) { 472 if(args.onchange) {
453 UiEventData *event = malloc(sizeof(UiEventData)); 473 UiEventData *event = malloc(sizeof(UiEventData));
454 event->obj = obj; 474 event->obj = obj;

mercurial