DelSel.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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(display, menu, p_num, s_num)
  15. register Display *display; /* Previously opened display. */
  16. register XMenu *menu; /* Menu object to be modified. */
  17. register int p_num; /* Pane number to be deleted. */
  18. register int s_num; /* 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. }
  60. /* arch-tag: 24ca2bc7-8a37-471a-8095-e6363fc1ed10
  61. (do not change this comment) */