DelPane.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuDeletePane - Deletes a pane from an XMenu object.
  7. *
  8. * Author: Tony Della Fera, DEC
  9. * 20-Nov-85
  10. *
  11. */
  12. #include "XMenuInt.h"
  13. int
  14. XMenuDeletePane(register Display *display, register XMenu *menu, register int p_num)
  15. /* Previously opened display */
  16. /* Menu object to be modified. */
  17. /* Pane number to be deleted. */
  18. {
  19. register XMPane *p_ptr; /* Pointer to pane being deleted. */
  20. register XMSelect *s_ptr; /* Pointer to selections being deleted. */
  21. register XMSelect *s_next; /* Pointer to next selection to be 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. * Remove the pane from the association table.
  29. */
  30. XDeleteAssoc(display, menu->assoc_tab, p_ptr->window);
  31. /*
  32. * Remove the pane from the pane list and update
  33. * the pane count.
  34. */
  35. emacs_remque(p_ptr);
  36. menu->p_count--;
  37. /*
  38. * Remove all the selections in the pane from the
  39. * association table and free their XMSelect structures.
  40. */
  41. for (
  42. s_ptr = p_ptr->s_list->next;
  43. s_ptr != p_ptr->s_list;
  44. s_ptr = s_next
  45. ) {
  46. XDeleteAssoc(display, menu->assoc_tab, s_ptr->window);
  47. s_next = s_ptr->next;
  48. free(s_ptr);
  49. }
  50. free(p_ptr->s_list);
  51. if (p_ptr->window) {
  52. /*
  53. * Destroy the selection transparencies.
  54. */
  55. XDestroySubwindows(display, p_ptr->window);
  56. /*
  57. * Destroy the pane window.
  58. */
  59. XDestroyWindow(display, p_ptr->window);
  60. }
  61. /*
  62. * Free the pane's XMPane structure.
  63. */
  64. free(p_ptr);
  65. /*
  66. * Schedule a recompute.
  67. */
  68. menu->recompute = 1;
  69. /*
  70. * Return the pane number just deleted.
  71. */
  72. _XMErrorCode = XME_NO_ERROR;
  73. return(p_num);
  74. }