243 GtkWidget *widget = gtk_menu_item_new_with_mnemonic(i->label); |
243 GtkWidget *widget = gtk_menu_item_new_with_mnemonic(i->label); |
244 |
244 |
245 if(i->callback != NULL) { |
245 if(i->callback != NULL) { |
246 UiEventData *event = malloc(sizeof(UiEventData)); |
246 UiEventData *event = malloc(sizeof(UiEventData)); |
247 event->obj = obj; |
247 event->obj = obj; |
248 event->user_data = i->userdata; |
248 event->userdata = i->userdata; |
249 event->callback = i->callback; |
249 event->callback = i->callback; |
250 event->value = 0; |
250 event->value = 0; |
251 |
251 |
252 g_signal_connect( |
252 g_signal_connect( |
253 widget, |
253 widget, |
279 GtkWidget *widget = gtk_image_menu_item_new_from_stock(i->stockid, obj->ctx->accel_group); |
279 GtkWidget *widget = gtk_image_menu_item_new_from_stock(i->stockid, obj->ctx->accel_group); |
280 |
280 |
281 if(i->callback != NULL) { |
281 if(i->callback != NULL) { |
282 UiEventData *event = malloc(sizeof(UiEventData)); |
282 UiEventData *event = malloc(sizeof(UiEventData)); |
283 event->obj = obj; |
283 event->obj = obj; |
284 event->user_data = i->userdata; |
284 event->userdata = i->userdata; |
285 event->callback = i->callback; |
285 event->callback = i->callback; |
286 event->value = 0; |
286 event->value = 0; |
287 |
287 |
288 g_signal_connect( |
288 g_signal_connect( |
289 widget, |
289 widget, |
411 |
411 |
412 if(list->callback) { |
412 if(list->callback) { |
413 // TODO: use mempool |
413 // TODO: use mempool |
414 UiEventData *event = malloc(sizeof(UiEventData)); |
414 UiEventData *event = malloc(sizeof(UiEventData)); |
415 event->obj = list->object; |
415 event->obj = list->object; |
416 event->user_data = list->userdata; |
416 event->userdata = list->userdata; |
417 event->callback = list->callback; |
417 event->callback = list->callback; |
418 event->value = i - 1; |
418 event->value = i - 1; |
419 |
419 |
420 g_signal_connect( |
420 g_signal_connect( |
421 widget, |
421 widget, |
441 evt.obj = event->obj; |
441 evt.obj = event->obj; |
442 evt.window = event->obj->window; |
442 evt.window = event->obj->window; |
443 evt.document = event->obj->document; |
443 evt.document = event->obj->document; |
444 evt.eventdata = NULL; |
444 evt.eventdata = NULL; |
445 evt.intval = event->value; |
445 evt.intval = event->value; |
446 event->callback(&evt, event->user_data); |
446 event->callback(&evt, event->userdata); |
447 } |
447 } |
448 |
448 |
449 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) { |
449 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) { |
450 UiEvent evt; |
450 UiEvent evt; |
451 evt.obj = event->obj; |
451 evt.obj = event->obj; |
452 evt.window = event->obj->window; |
452 evt.window = event->obj->window; |
453 evt.document = event->obj->document; |
453 evt.document = event->obj->document; |
454 evt.eventdata = NULL; |
454 evt.eventdata = NULL; |
455 evt.intval = gtk_check_menu_item_get_active(ci); |
455 evt.intval = gtk_check_menu_item_get_active(ci); |
456 event->callback(&evt, event->user_data); |
456 event->callback(&evt, event->userdata); |
457 } |
457 } |
458 |
458 |
459 int ui_checkitem_get(UiInteger *i) { |
459 int ui_checkitem_get(UiInteger *i) { |
460 int state = gtk_check_menu_item_get_active(i->obj); |
460 int state = gtk_check_menu_item_get_active(i->obj); |
461 i->value = state; |
461 i->value = state; |