430 GMenu *menu = g_menu_new(); |
430 GMenu *menu = g_menu_new(); |
431 ui_gmenu_add_menu_items(menu, 0, mi, obj); |
431 ui_gmenu_add_menu_items(menu, 0, mi, obj); |
432 g_menu_append_submenu(parent, mi->label, G_MENU_MODEL(menu)); |
432 g_menu_append_submenu(parent, mi->label, G_MENU_MODEL(menu)); |
433 } |
433 } |
434 |
434 |
|
435 static void action_enable(GSimpleAction *action, int enabled) { |
|
436 g_simple_action_set_enabled(action, enabled); |
|
437 } |
|
438 |
435 void ui_gmenu_add_menuitem(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj) { |
439 void ui_gmenu_add_menuitem(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj) { |
436 UiMenuItem *i = (UiMenuItem*)item; |
440 UiMenuItem *i = (UiMenuItem*)item; |
437 |
441 |
438 GSimpleAction *action = g_simple_action_new(item->id, NULL); |
442 GSimpleAction *action = g_simple_action_new(item->id, NULL); |
439 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action)); |
443 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action)); |
|
444 |
|
445 if(i->groups) { |
|
446 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups); |
|
447 cxListAddArray(groups, i->groups, i->ngroups); |
|
448 uic_add_group_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups); |
|
449 cxListDestroy(groups); |
|
450 } |
440 |
451 |
441 if(i->callback != NULL) { |
452 if(i->callback != NULL) { |
442 UiEventData *event = malloc(sizeof(UiEventData)); |
453 UiEventData *event = malloc(sizeof(UiEventData)); |
443 event->obj = obj; |
454 event->obj = obj; |
444 event->userdata = i->userdata; |
455 event->userdata = i->userdata; |