ui/gtk/menu.c

changeset 101
7b3a3130be44
parent 98
16e84fac48bd
equal deleted inserted replaced
100:d2bd73d28ff1 101:7b3a3130be44
129 129
130 if(i->groups) { 130 if(i->groups) {
131 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups); 131 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups);
132 cxListAddArray(groups, i->groups, i->ngroups); 132 cxListAddArray(groups, i->groups, i->ngroups);
133 uic_add_group_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, groups); 133 uic_add_group_widget(obj->ctx, widget, (ui_enablefunc)ui_set_enabled, groups);
134 cxListDestroy(groups); 134 cxListFree(groups);
135 } 135 }
136 } 136 }
137 137
138 /* 138 /*
139 void add_menuitem_st_widget( 139 void add_menuitem_st_widget(
388 388
389 389
390 390
391 #if GTK_MAJOR_VERSION >= 4 391 #if GTK_MAJOR_VERSION >= 4
392 392
393 393 GtkWidget *ui_create_menubar(UiObject *obj) {
394 UiMenu *menus_begin = uic_get_menu_list();
395 if(menus_begin == NULL) {
396 return NULL;
397 }
398
399 GMenu *menu = g_menu_new();
400 UiMenu *ls = menus_begin;
401 while(ls) {
402 GMenu *sub_menu = g_menu_new();
403 ui_gmenu_add_menu_items(sub_menu, 0, ls, obj);
404 g_menu_append_submenu(menu, ls->label, G_MENU_MODEL(sub_menu));
405 ls = (UiMenu*)ls->item.next;
406 }
407
408
409 // Create a menubar from the menu model
410 return gtk_popover_menu_bar_new_from_model(G_MENU_MODEL(menu));
411 }
394 412
395 static ui_gmenu_add_f createMenuItem[] = { 413 static ui_gmenu_add_f createMenuItem[] = {
396 /* UI_MENU */ ui_gmenu_add_menu, 414 /* UI_MENU */ ui_gmenu_add_menu,
397 /* UI_MENU_ITEM */ ui_gmenu_add_menuitem, 415 /* UI_MENU_ITEM */ ui_gmenu_add_menuitem,
398 /* UI_MENU_CHECK_ITEM */ ui_gmenu_add_checkitem, 416 /* UI_MENU_CHECK_ITEM */ ui_gmenu_add_checkitem,
444 462
445 if(i->groups) { 463 if(i->groups) {
446 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups); 464 CxList *groups = cxArrayListCreateSimple(sizeof(int), i->ngroups);
447 cxListAddArray(groups, i->groups, i->ngroups); 465 cxListAddArray(groups, i->groups, i->ngroups);
448 uic_add_group_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups); 466 uic_add_group_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups);
449 cxListDestroy(groups); 467 cxListFree(groups);
450 } 468 }
451 469
452 if(i->callback != NULL) { 470 if(i->callback != NULL) {
453 UiEventData *event = malloc(sizeof(UiEventData)); 471 UiEventData *event = malloc(sizeof(UiEventData));
454 event->obj = obj; 472 event->obj = obj;

mercurial