ui/gtk/menu.c

changeset 46
31bc86844659
parent 44
473954dc6b74
equal deleted inserted replaced
45:ab71409644b0 46:31bc86844659
520 }; 520 };
521 521
522 void ui_gmenu_add_menu_items(GMenu *parent, int i, UiMenu *menu, UiObject *obj) { 522 void ui_gmenu_add_menu_items(GMenu *parent, int i, UiMenu *menu, UiObject *obj) {
523 UiMenuItemI *it = menu->items_begin; 523 UiMenuItemI *it = menu->items_begin;
524 int index = 0; 524 int index = 0;
525 int index_section = 0;
526 GMenu *section = NULL;
525 while(it) { 527 while(it) {
526 createMenuItem[it->type](parent, index, it, obj); 528 if(it->type == UI_MENU_SEPARATOR) {
529 section = g_menu_new();
530 g_menu_append_section(parent, NULL, G_MENU_MODEL(section));
531 index++;
532 index_section = 0;
533 } else {
534 if(section) {
535 createMenuItem[it->type](section, index_section++, it, obj);
536 } else {
537 createMenuItem[it->type](parent, index++, it, obj);
538 }
539 }
527 it = it->next; 540 it = it->next;
528 index++;
529 } 541 }
530 } 542 }
531 543
532 void ui_gmenu_add_menu(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj) { 544 void ui_gmenu_add_menu(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj) {
533 UiMenu *mi = (UiMenu*)item; 545 UiMenu *mi = (UiMenu*)item;
561 G_CALLBACK(ui_destroy_userdata), 573 G_CALLBACK(ui_destroy_userdata),
562 event); 574 event);
563 } 575 }
564 576
565 char action_name[32]; 577 char action_name[32];
566 snprintf(action_name, 32, "win.%s", item->id); 578 snprintf(action_name, 32, "win.%s", item->id);
567 g_menu_append(parent, i->label, action_name); 579 g_menu_append(parent, i->label, action_name);
568 } 580 }
569 581
570 void ui_gmenu_add_menuseparator(GMenu *p, int index, UiMenuItemI *item, UiObject *obj) { 582 void ui_gmenu_add_menuseparator(GMenu *p, int index, UiMenuItemI *item, UiObject *obj) {
571 583

mercurial