2
0

SmHelp.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: SmHelp.c /main/4 1995/10/30 09:35:21 rswiston $ */
  24. /* *
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company *
  26. * (c) Copyright 1993, 1994 International Business Machines Corp. *
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  28. * (c) Copyright 1993, 1994 Novell, Inc. *
  29. */
  30. /*************************************<+>*************************************
  31. *****************************************************************************
  32. **
  33. ** File: SmHelp.c
  34. **
  35. ** Project: HP DT Session Manager (dtsession)
  36. **
  37. ** Description:
  38. ** -----------
  39. ** This module is in charge of all interaction between the session
  40. ** manager and the help subsystem. Anytime the user requests help,
  41. ** it goes through this routine.
  42. **
  43. **
  44. **
  45. *******************************************************************
  46. ** (c) Copyright Hewlett-Packard Company, 1990. All rights are
  47. ** reserved. Copying or other reproduction of this program
  48. ** except for archival purposes is prohibited without prior
  49. ** written consent of Hewlett-Packard Company.
  50. ********************************************************************
  51. **
  52. **
  53. **
  54. *****************************************************************************
  55. *************************************<+>*************************************/
  56. #include <stdio.h>
  57. #include <X11/Intrinsic.h>
  58. #include <X11/Shell.h>
  59. #include <Xm/Xm.h>
  60. #include <Xm/MwmUtil.h>
  61. #include <Dt/HelpQuickD.h>
  62. #include "Sm.h"
  63. #include "SmUI.h"
  64. #include "SmHelp.h"
  65. #include "SmGlobals.h"
  66. /*
  67. * #define statements
  68. */
  69. /*
  70. * Global variables
  71. */
  72. /*
  73. * Local Function Declarations
  74. */
  75. static void CloseHelpDialog (Widget, XtPointer, XtPointer);
  76. /*************************************<->*************************************
  77. *
  78. * TopicHelpRequested ()
  79. *
  80. *
  81. * Description:
  82. * -----------
  83. * When a user requests help on a given topic - display that topic in a
  84. * new or cached help dialog
  85. *
  86. *
  87. * Inputs:
  88. * ------
  89. * client_data - the id that is sent to Cache Creek which tells it which
  90. * topic to display
  91. *
  92. *
  93. * Outputs:
  94. * -------
  95. * None.
  96. *
  97. *
  98. * Comments:
  99. * --------
  100. *
  101. *************************************<->***********************************/
  102. void
  103. TopicHelpRequested(
  104. Widget w,
  105. XtPointer client_data,
  106. XtPointer call_data )
  107. {
  108. int i;
  109. char *locationId = (char *) client_data;
  110. Widget transientShell;
  111. Arg setArgs2[5];
  112. int n2;
  113. Widget printButton = NULL;
  114. Widget helpButton = NULL;
  115. Widget backButton = NULL;
  116. Widget okButton = NULL;
  117. /*
  118. * Find the shell to make this a transient for for
  119. */
  120. transientShell = w;
  121. while(!XtIsSubclass(transientShell, shellWidgetClass))
  122. {
  123. transientShell = XtParent(transientShell);
  124. }
  125. if((smDD.smHelpDialog != NULL) &&
  126. (XtIsManaged(smDD.smHelpDialog)))
  127. {
  128. return ;
  129. }
  130. /*
  131. * Use the help dialog already created if it has been - otherwise
  132. * create it
  133. */
  134. if (smDD.smHelpDialog != NULL)
  135. {
  136. i = 0;
  137. XtSetArg(uiArgs[i], DtNlocationId,locationId); i++;
  138. XtSetValues(smDD.smHelpDialog, uiArgs, i);
  139. i = 0;
  140. XtSetArg(uiArgs[i], XmNtransientFor, transientShell); i++;
  141. XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
  142. XtManageChild(smDD.smHelpDialog);
  143. }
  144. else
  145. {
  146. i = 0;
  147. XtSetArg(uiArgs[i], XmNtitle, GETMESSAGE(29, 1,
  148. "Session Manager Help")); i++;
  149. XtSetArg (uiArgs[i],DtNhelpVolume, SM_HELP_VOLUME); i++;
  150. XtSetArg (uiArgs[i],DtNhelpType, DtHELP_TYPE_TOPIC); i++;
  151. XtSetArg (uiArgs[i], DtNlocationId,locationId); i++;
  152. smDD.smHelpDialog = DtCreateHelpQuickDialog(smGD.topLevelWid,
  153. "helpWidget", uiArgs, i);
  154. i = 0;
  155. XtSetArg(uiArgs[i], XmNtransientFor, transientShell); i++;
  156. XtSetValues(XtParent(smDD.smHelpDialog), uiArgs, i);
  157. XtAddCallback(smDD.smHelpDialog, DtNcloseCallback,
  158. CloseHelpDialog, NULL);
  159. okButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
  160. DtHELP_QUICK_CLOSE_BUTTON );
  161. n2=0;
  162. XtSetArg (setArgs2[n2], XmNlabelString, smDD.okString); n2++;
  163. XtSetValues(okButton, setArgs2, n2);
  164. printButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
  165. DtHELP_QUICK_PRINT_BUTTON );
  166. helpButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
  167. DtHELP_QUICK_HELP_BUTTON );
  168. backButton = DtHelpQuickDialogGetChild(smDD.smHelpDialog,
  169. DtHELP_QUICK_BACK_BUTTON );
  170. XtUnmanageChild(printButton);
  171. XtUnmanageChild(helpButton);
  172. XtUnmanageChild(backButton);
  173. XtAddCallback (XtParent(smDD.smHelpDialog), XmNpopupCallback,
  174. DialogUp, NULL);
  175. XtManageChild(smDD.smHelpDialog);
  176. }
  177. }
  178. /*************************************<->*************************************
  179. *
  180. * CloseHelpDialog ()
  181. *
  182. *
  183. * Description:
  184. * -----------
  185. * This callback is called when the user wishes to dismiss the help callback
  186. *
  187. *
  188. * Inputs:
  189. * ------
  190. *
  191. *
  192. * Outputs:
  193. * -------
  194. *
  195. *
  196. * Comments:
  197. * --------
  198. *
  199. *************************************<->***********************************/
  200. static void
  201. CloseHelpDialog (Widget w,
  202. XtPointer clientData,
  203. XtPointer callData)
  204. {
  205. XtUnmanageChild(smDD.smHelpDialog);
  206. }