ui/gtk/menu.c

changeset 110
c00e968d018b
parent 108
77254bd6dccb
child 112
c3f2f16fa4b8
equal deleted inserted replaced
109:c3dfcb8f0be7 110:c00e968d018b
574 ls->menu = p; 574 ls->menu = p;
575 ls->index = index; 575 ls->index = index;
576 ls->oldcount = 0; 576 ls->oldcount = 0;
577 ls->getvalue = il->getvalue; 577 ls->getvalue = il->getvalue;
578 578
579 //UiVar* var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST); 579 GSimpleAction *action = g_simple_action_new(item->id, g_variant_type_new("i"));
580 UiVar* var = uic_create_var(obj->ctx, il->varname, UI_VAR_LIST); 580 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action));
581 snprintf(ls->action, 32, "win.%s", item->id);
582
583 UiVar* var = uic_create_var(ui_global_context(), il->varname, UI_VAR_LIST);
584 //UiVar* var = uic_create_var(obj->ctx, il->varname, UI_VAR_LIST);
581 ls->var = var; 585 ls->var = var;
582 if(var) { 586 if(var) {
583 UiList *list = var->value; 587 UiList *list = var->value;
584 list->update = ui_menulist_update; 588 list->update = ui_menulist_update;
585 list->getselection = NULL; 589 list->getselection = NULL;
601 ui_update_gmenu_item_list(ls); 605 ui_update_gmenu_item_list(ls);
602 } 606 }
603 607
604 ls->callback = il->callback; 608 ls->callback = il->callback;
605 ls->userdata = il->userdata; 609 ls->userdata = il->userdata;
606
607 GSimpleAction *action = g_simple_action_new(item->id, g_variant_type_new("i"));
608 g_action_map_add_action(obj->ctx->action_map, G_ACTION(action));
609 snprintf(ls->action, 32, "win.%s", item->id);
610 610
611 611
612 UiEventData *event = malloc(sizeof(UiEventData)); 612 UiEventData *event = malloc(sizeof(UiEventData));
613 event->obj = obj; 613 event->obj = obj;
614 event->userdata = il->userdata; 614 event->userdata = il->userdata;
648 void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event) { 648 void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event) {
649 int index = g_variant_get_int32(parameter); 649 int index = g_variant_get_int32(parameter);
650 UiVar *var = event->customdata; 650 UiVar *var = event->customdata;
651 UiList *list = var->value; 651 UiList *list = var->value;
652 652
653 if(!event->callback) {
654 return;
655 }
656
653 UiEvent evt; 657 UiEvent evt;
654 evt.obj = event->obj; 658 evt.obj = event->obj;
655 evt.window = event->obj->window; 659 evt.window = event->obj->window;
656 evt.document = event->obj->ctx->document; 660 evt.document = event->obj->ctx->document;
657 evt.eventdata = ui_list_get(list, index); 661 evt.eventdata = ui_list_get(list, index);

mercurial