ui/gtk/menu.c

branch
newapi
changeset 287
5370ea7e45a2
parent 286
f6ca4bbbe2a6
child 293
736c962f1011
equal deleted inserted replaced
286:f6ca4bbbe2a6 287:5370ea7e45a2
290 GtkWidget *widget = gtk_menu_item_new_with_label(label); 290 GtkWidget *widget = gtk_menu_item_new_with_label(label);
291 gtk_menu_shell_insert(list->menu, widget, list->index + i); 291 gtk_menu_shell_insert(list->menu, widget, list->index + i);
292 gtk_widget_show(widget); 292 gtk_widget_show(widget);
293 293
294 if(list->callback) { 294 if(list->callback) {
295 // TODO: use mempool
296 UiEventData *event = malloc(sizeof(UiEventData)); 295 UiEventData *event = malloc(sizeof(UiEventData));
297 event->obj = list->object; 296 event->obj = list->object;
298 event->userdata = list->userdata; 297 event->userdata = list->userdata;
299 event->callback = list->callback; 298 event->callback = list->callback;
300 event->value = i - 1; 299 event->value = i - 1;
301 event->customdata = NULL; 300 event->customdata = elm;
302 301
303 g_signal_connect( 302 g_signal_connect(
304 widget, 303 widget,
305 "activate", 304 "activate",
306 G_CALLBACK(ui_menu_event_wrapper), 305 G_CALLBACK(ui_menu_event_wrapper),
322 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event) { 321 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event) {
323 UiEvent evt; 322 UiEvent evt;
324 evt.obj = event->obj; 323 evt.obj = event->obj;
325 evt.window = event->obj->window; 324 evt.window = event->obj->window;
326 evt.document = event->obj->ctx->document; 325 evt.document = event->obj->ctx->document;
327 evt.eventdata = NULL; 326 evt.eventdata = event->customdata;
328 evt.intval = event->value; 327 evt.intval = event->value;
329 event->callback(&evt, event->userdata); 328 event->callback(&evt, event->userdata);
330 } 329 }
331 330
332 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) { 331 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) {

mercurial