ui/gtk/menu.c

changeset 115
102fc0b8fe3e
parent 75
efe2f65bea17
child 140
c03c338a7dcf
equal deleted inserted replaced
114:909fe96e5659 115:102fc0b8fe3e
483 } 483 }
484 } 484 }
485 return FALSE; 485 return FALSE;
486 } 486 }
487 487
488 void ui_contextmenu(UiObject *obj) { 488 UIMENU ui_contextmenu(UiObject *obj) {
489 UiContainer *ct = uic_get_current_container(obj); 489 UiContainer *ct = uic_get_current_container(obj);
490 ui_contextmenu_w(obj, ct->current); 490 return ui_contextmenu_w(obj, ct->current);
491 } 491 }
492 492
493 void ui_contextmenu_w(UiObject *obj, UIWIDGET widget) { 493 UIMENU ui_contextmenu_w(UiObject *obj, UIWIDGET widget) {
494 UiContainer *ct = uic_get_current_container(obj); 494 UiContainer *ct = uic_get_current_container(obj);
495 495
496 GtkMenu *menu = GTK_MENU(gtk_menu_new()); 496 GtkMenu *menu = GTK_MENU(gtk_menu_new());
497 g_signal_connect(widget, "button-press-event", (GCallback) ui_button_press_event, menu); 497 g_signal_connect(widget, "button-press-event", (GCallback) ui_button_press_event, menu);
498 498
499 ct->menu = menu; 499 ct->menu = menu;
500 return menu;
501 }
502
503 void ui_contextmenu_popup(UIMENU menu) {
504 gtk_menu_popup(menu, NULL, NULL, 0, 0, 0, gtk_get_current_event_time());
500 } 505 }
501 506
502 void ui_widget_menuitem(UiObject *obj, char *label, ui_callback f, void *userdata) { 507 void ui_widget_menuitem(UiObject *obj, char *label, ui_callback f, void *userdata) {
503 ui_widget_menuitem_gr(obj, label, f, userdata, -1); 508 ui_widget_menuitem_gr(obj, label, f, userdata, -1);
504 } 509 }
519 } 524 }
520 va_end(ap); 525 va_end(ap);
521 526
522 // create menuitem 527 // create menuitem
523 GtkWidget *widget = gtk_menu_item_new_with_mnemonic(label); 528 GtkWidget *widget = gtk_menu_item_new_with_mnemonic(label);
529 gtk_widget_show(widget);
524 530
525 if(f) { 531 if(f) {
526 UiEventData *event = malloc(sizeof(UiEventData)); 532 UiEventData *event = malloc(sizeof(UiEventData));
527 event->obj = obj; 533 event->obj = obj;
528 event->userdata = userdata; 534 event->userdata = userdata;
568 } 574 }
569 va_end(ap); 575 va_end(ap);
570 576
571 // create menuitem 577 // create menuitem
572 GtkWidget *widget = gtk_image_menu_item_new_from_stock(stockid, obj->ctx->accel_group); 578 GtkWidget *widget = gtk_image_menu_item_new_from_stock(stockid, obj->ctx->accel_group);
579 gtk_widget_show(widget);
573 580
574 if(f) { 581 if(f) {
575 UiEventData *event = malloc(sizeof(UiEventData)); 582 UiEventData *event = malloc(sizeof(UiEventData));
576 event->obj = obj; 583 event->obj = obj;
577 event->userdata = userdata; 584 event->userdata = userdata;

mercurial