| 35 #include "toolkit.h" |
35 #include "toolkit.h" |
| 36 #include "widget.h" |
36 #include "widget.h" |
| 37 #include "../common/context.h" |
37 #include "../common/context.h" |
| 38 #include "../common/menu.h" |
38 #include "../common/menu.h" |
| 39 #include "../common/types.h" |
39 #include "../common/types.h" |
| |
40 #include "../common/action.h" |
| 40 #include "../ui/properties.h" |
41 #include "../ui/properties.h" |
| 41 #include "../ui/window.h" |
42 #include "../ui/window.h" |
| 42 #include "container.h" |
43 #include "container.h" |
| 43 |
44 |
| 44 #include <cx/linked_list.h> |
45 #include <cx/linked_list.h> |
| 588 cxListAddArray(groups, i->states, i->nstates); |
589 cxListAddArray(groups, i->states, i->nstates); |
| 589 uic_add_state_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups); |
590 uic_add_state_widget(obj->ctx, action, (ui_enablefunc)action_enable, groups); |
| 590 cxListFree(groups); |
591 cxListFree(groups); |
| 591 } |
592 } |
| 592 |
593 |
| 593 if(i->callback != NULL) { |
594 if(i->action) { |
| |
595 uic_bind_action(obj->ctx, i->action, action, (ui_enablefunc)action_enable); |
| |
596 UiAction *ui_action = uic_resolve_action(obj->ctx, i->action); |
| |
597 if(!ui_action) { |
| |
598 action_enable(action, FALSE); |
| |
599 } |
| |
600 } |
| |
601 |
| |
602 if(i->callback != NULL || i->action) { |
| 594 UiEventData *event = malloc(sizeof(UiEventData)); |
603 UiEventData *event = malloc(sizeof(UiEventData)); |
| 595 event->obj = obj; |
604 event->obj = obj; |
| 596 event->userdata = i->userdata; |
605 event->userdata = i->userdata; |
| 597 event->callback = i->callback; |
606 event->callback = i->callback; |
| 598 event->value = 0; |
607 event->value = 0; |
| 599 event->customdata = NULL; |
608 event->customdata = NULL; |
| 600 event->customint = 0; |
609 event->customint = 0; |
| |
610 event->action = i->action ? strdup(i->action) : NULL; |
| 601 |
611 |
| 602 g_signal_connect( |
612 g_signal_connect( |
| 603 action, |
613 action, |
| 604 "activate", |
614 "activate", |
| 605 G_CALLBACK(ui_activate_event_wrapper), |
615 G_CALLBACK(ui_activate_event_wrapper), |
| 606 event); |
616 event); |
| 607 g_signal_connect( |
617 g_signal_connect( |
| 608 obj->widget, |
618 obj->widget, |
| 609 "destroy", |
619 "destroy", |
| 610 G_CALLBACK(ui_destroy_userdata), |
620 G_CALLBACK(ui_destroy_eventdata), |
| 611 event); |
621 event); |
| 612 } |
622 } |
| 613 |
623 |
| 614 char action_name[32]; |
624 char action_name[32]; |
| 615 snprintf(action_name, 32, "win.%s", item->id); |
625 snprintf(action_name, 32, "win.%s", item->id); |
| 616 |
626 |
| 617 g_menu_append(parent, i->label, action_name); |
627 g_menu_append(parent, i->label, action_name); |
| 618 } |
628 } |
| 619 |
629 |
| 620 void ui_gmenu_add_menuseparator(GMenu *p, int index, UiMenuItemI *item, UiObject *obj) { |
630 void ui_gmenu_add_menuseparator(GMenu *p, int index, UiMenuItemI *item, UiObject *obj) { |
| 621 |
631 |
| 886 } else { |
896 } else { |
| 887 evt.eventdata = uic_get_tmp_eventdata(); |
897 evt.eventdata = uic_get_tmp_eventdata(); |
| 888 evt.eventdatatype = uic_get_tmp_eventdata_type(); |
898 evt.eventdatatype = uic_get_tmp_eventdata_type(); |
| 889 } |
899 } |
| 890 evt.intval = intval; |
900 evt.intval = intval; |
| 891 event->callback(&evt, event->userdata); |
901 if(event->callback) { |
| |
902 event->callback(&evt, event->userdata); |
| |
903 } |
| |
904 if(event->action) { |
| |
905 uic_action_callback(&evt, event->action); |
| |
906 } |
| 892 uic_set_tmp_eventdata(NULL, 0); |
907 uic_set_tmp_eventdata(NULL, 0); |
| 893 } |
908 } |
| 894 |
909 |
| 895 void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event) { |
910 void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event) { |
| 896 int index = g_variant_get_int32(parameter); |
911 int index = g_variant_get_int32(parameter); |