DelSel.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuDeleteSelection - Deletes a selection from an XMenu object.
  7. *
  8. * Author: Tony Della Fera, DEC
  9. * 20-Nov-85
  10. *
  11. */
  12. #include "XMenuInt.h"
  13. int
  14. XMenuDeleteSelection(register Display *display, register XMenu *menu, register int p_num, register int s_num)
  15. /* Previously opened display. */
  16. /* Menu object to be modified. */
  17. /* Pane number to be deleted. */
  18. /* Selection number to be deleted. */
  19. {
  20. register XMPane *p_ptr; /* Pointer to pane being deleted. */
  21. register XMSelect *s_ptr; /* Pointer to selections being deleted. */
  22. /*
  23. * Find the right pane.
  24. */
  25. p_ptr = _XMGetPanePtr(menu, p_num);
  26. if (p_ptr == NULL) return(XM_FAILURE);
  27. /*
  28. * Find the right selection.
  29. */
  30. s_ptr = _XMGetSelectionPtr(p_ptr, s_num);
  31. if (s_ptr == NULL) return(XM_FAILURE);
  32. /*
  33. * Remove the selection from the association table.
  34. */
  35. XDeleteAssoc(display, menu->assoc_tab, s_ptr->window);
  36. /*
  37. * Remove the selection from the parent pane's selection
  38. * list and update the selection count.
  39. */
  40. emacs_remque(s_ptr);
  41. p_ptr->s_count--;
  42. /*
  43. * Destroy the selection transparency.
  44. */
  45. if (s_ptr->window) XDestroyWindow(display, s_ptr->window);
  46. /*
  47. * Free the selection's XMSelect structure.
  48. */
  49. free(s_ptr);
  50. /*
  51. * Schedule a recompute.
  52. */
  53. menu->recompute = 1;
  54. /*
  55. * Return the selection number just deleted.
  56. */
  57. _XMErrorCode = XME_NO_ERROR;
  58. return(s_num);
  59. }