ui/gtk/menu.c

changeset 1016
ccde46662db7
parent 973
aa39a986da78
equal deleted inserted replaced
1015:b459361d98ad 1016:ccde46662db7
128 } 128 }
129 129
130 gtk_menu_shell_append(GTK_MENU_SHELL(parent), widget); 130 gtk_menu_shell_append(GTK_MENU_SHELL(parent), widget);
131 131
132 if(i->states) { 132 if(i->states) {
133 CxList *states = cxArrayListCreateSimple(sizeof(int), i->nstates); 133 CxList *states = cxArrayListCreate(NULL, sizeof(int), i->nstates);
134 cxListAddArray(states, i->states, i->nstates); 134 cxListAddArray(states, i->states, i->nstates);
135 uic_add_state_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, states); 135 uic_add_state_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, states);
136 cxListFree(states); 136 cxListFree(states);
137 } 137 }
138 } 138 }
218 // It is possible, that the UiVar is from a global shared context, 218 // It is possible, that the UiVar is from a global shared context,
219 // used by multiple windows. To support this usecase, the list->obj 219 // used by multiple windows. To support this usecase, the list->obj
220 // binding object is a list of all connected UiActiveMenuItemList. 220 // binding object is a list of all connected UiActiveMenuItemList.
221 CxList *bindings = list->obj; 221 CxList *bindings = list->obj;
222 if(!bindings) { 222 if(!bindings) {
223 bindings = cxLinkedListCreate(var->from_ctx->mp->allocator, NULL, CX_STORE_POINTERS); 223 bindings = cxLinkedListCreate(var->from_ctx->mp->allocator, CX_STORE_POINTERS);
224 list->obj = bindings; 224 list->obj = bindings;
225 } 225 }
226 cxListAdd(bindings, ls); 226 cxListAdd(bindings, ls);
227 227
228 // The destruction of the toplevel obj must remove the menulist binding 228 // The destruction of the toplevel obj must remove the menulist binding
461 GSimpleAction *action = g_simple_action_new(item->id, NULL); 461 GSimpleAction *action = g_simple_action_new(item->id, NULL);
462 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action)); 462 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action));
463 g_object_unref(action); 463 g_object_unref(action);
464 464
465 if(i->states) { 465 if(i->states) {
466 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->nstates); 466 CxList *groups = cxArrayListCreate(NULL, sizeof(int), i->nstates);
467 cxListAddArray(groups, i->states, i->nstates); 467 cxListAddArray(groups, i->states, i->nstates);
468 uic_add_state_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups); 468 uic_add_state_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups);
469 cxListFree(groups); 469 cxListFree(groups);
470 } 470 }
471 471
567 return i->value; 567 return i->value;
568 } 568 }
569 569
570 static UiMenuRadioGroup* create_radio_group(UiObject *obj, UiMenuRadioItem *item, GSimpleAction *action) { 570 static UiMenuRadioGroup* create_radio_group(UiObject *obj, UiMenuRadioItem *item, GSimpleAction *action) {
571 UiMenuRadioGroup *group = cxZalloc(obj->ctx->allocator, sizeof(UiMenuRadioGroup)); 571 UiMenuRadioGroup *group = cxZalloc(obj->ctx->allocator, sizeof(UiMenuRadioGroup));
572 group->callbacks = cxArrayListCreate(obj->ctx->allocator, NULL, sizeof(UiCallbackData), 8); 572 group->callbacks = cxArrayListCreate(obj->ctx->allocator, sizeof(UiCallbackData), 8);
573 group->var = uic_create_var(ui_global_context(), item->varname, UI_VAR_INTEGER); 573 group->var = uic_create_var(ui_global_context(), item->varname, UI_VAR_INTEGER);
574 group->obj = obj; 574 group->obj = obj;
575 group->action = action; 575 group->action = action;
576 if(group->var) { 576 if(group->var) {
577 UiInteger *i = group->var->value; 577 UiInteger *i = group->var->value;
578 CxList *bindings = i->obj; 578 CxList *bindings = i->obj;
579 if(!bindings) { 579 if(!bindings) {
580 bindings = cxLinkedListCreate(group->var->from_ctx->mp->allocator, NULL, CX_STORE_POINTERS); 580 bindings = cxLinkedListCreate(group->var->from_ctx->mp->allocator, CX_STORE_POINTERS);
581 i->obj = bindings; 581 i->obj = bindings;
582 i->set = ui_action_set_state; 582 i->set = ui_action_set_state;
583 i->get = ui_action_get_state; 583 i->get = ui_action_get_state;
584 } 584 }
585 cxListAdd(bindings, group); 585 cxListAdd(bindings, group);
709 // It is possible, that the UiVar is from a global shared context, 709 // It is possible, that the UiVar is from a global shared context,
710 // used by multiple windows. To support this usecase, the list->obj 710 // used by multiple windows. To support this usecase, the list->obj
711 // binding object is a list of all connected UiActiveMenuItemList. 711 // binding object is a list of all connected UiActiveMenuItemList.
712 CxList *bindings = list->obj; 712 CxList *bindings = list->obj;
713 if(!bindings) { 713 if(!bindings) {
714 bindings = cxLinkedListCreate(var->from_ctx->mp->allocator, NULL, CX_STORE_POINTERS); 714 bindings = cxLinkedListCreate(var->from_ctx->mp->allocator, CX_STORE_POINTERS);
715 list->obj = bindings; 715 list->obj = bindings;
716 } 716 }
717 cxListAdd(bindings, ls); 717 cxListAdd(bindings, ls);
718 718
719 // The destruction of the toplevel obj must remove the menulist binding 719 // The destruction of the toplevel obj must remove the menulist binding

mercurial