Print.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. /*****************************************************************************
  24. *
  25. * File: Print.c
  26. *
  27. * Project: DT
  28. *
  29. * Description: This file contains the function which prints out the
  30. * front panel contents. It is used as a client for this
  31. * purpose.
  32. *
  33. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  34. * (c) Copyright 1993, 1994 International Business Machines Corp.
  35. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  36. * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of Novell, Inc.
  37. *
  38. ****************************************************************************/
  39. #include <Dt/DtP.h> /* required for DtDirPaths type */
  40. #include <Dt/DbReader.h> /* required for DtDbPathId type */
  41. #include <Dt/WsmM.h>
  42. #include <Dt/IconFile.h>
  43. #include <Dt/Dt.h>
  44. #include "DataBaseLoad.h"
  45. #include "Parse.h"
  46. #include <stdint.h>
  47. #ifdef __STDC__
  48. const char *szWM_TOOL_CLASS = DtWM_TOOL_CLASS;
  49. #else
  50. char *szWM_TOOL_CLASS = DtWM_TOOL_CLASS;
  51. #endif /* __STDC__ */
  52. String unpost_arrow_image;
  53. String unpost_monitor_arrow_image;
  54. /************************************************************************
  55. *
  56. * CheckOtherMonitorsOn
  57. * Due to a dependancy, CheckOtherMonitorsOn must be defined. This
  58. * is a stubbed procedure that ensures that the procedure is defined.
  59. *
  60. ************************************************************************/
  61. Boolean
  62. CheckOtherMonitorsOn(SubpanelData * subpanel_data)
  63. {
  64. return False;
  65. }
  66. /************************************************************************
  67. *
  68. * ToggleDefaultControl
  69. * Due to a dependancy, ToggleDefaultControl must be defined. This
  70. * is a stubbed procedure that ensures that the procedure is defined.
  71. *
  72. ************************************************************************/
  73. void
  74. ToggleDefaultControl (ControlData * main_control_data,
  75. SubpanelData * subpanel_data,
  76. ControlData * control_data)
  77. {
  78. }
  79. /************************************************************************
  80. *
  81. * GetIconName
  82. * Get the file name for an icon by extracting the panel resolution
  83. * and then looking up the image name.
  84. *
  85. ************************************************************************/
  86. String
  87. GetIconName (String image_name,
  88. unsigned int icon_size)
  89. {
  90. String return_name;
  91. Screen * screen = XtScreen (panel.shell);
  92. /* Get name. */
  93. return_name = _DtGetIconFileName (screen, image_name, NULL, NULL, icon_size);
  94. if (return_name == NULL)
  95. return_name = _DtGetIconFileName (screen, image_name, NULL, NULL,
  96. DtUNSPECIFIED);
  97. if (return_name == NULL)
  98. return_name = XtNewString (image_name);
  99. /* Return value to be freed by caller. */
  100. return (return_name);
  101. }
  102. /************************************************************************
  103. *
  104. * PrintFrontPanelContents
  105. * Using the information from the loading of the database
  106. * print out the contents of the database.
  107. *
  108. ************************************************************************/
  109. void
  110. PrintFrontPanelContents(void)
  111. {
  112. BoxData * box_data;
  113. SwitchData * switch_data;
  114. ControlData * control_data, * switch_control_data;
  115. SubpanelData * subpanel_data;
  116. int switch_position = POSITION_FIRST;
  117. int i,j, k;
  118. /* print out the component tree */
  119. printf ("PANEL %s\n", (char *) panel.element_values[0].parsed_value);
  120. for (i = 0; i < panel.box_data_count; i++)
  121. {
  122. box_data = panel.box_data[i];
  123. if (box_data->switch_data != NULL)
  124. {
  125. switch_data = box_data->switch_data;
  126. switch_position = (int) (intptr_t) box_data->switch_data->element_values[SWITCH_POSITION_HINTS].parsed_value;
  127. }
  128. else
  129. switch_data = NULL;
  130. printf (" BOX %s\n",
  131. (char *) box_data->element_values[0].parsed_value);
  132. for (j = 0; j < box_data->control_data_count; j++)
  133. {
  134. control_data = box_data->control_data[j];
  135. if (switch_data != NULL &&
  136. switch_position < (int) (intptr_t) (control_data->element_values[CONTROL_POSITION_HINTS].parsed_value))
  137. {
  138. printf (" SWITCH %s\n",
  139. (char *) switch_data->element_values[0].parsed_value);
  140. switch_position = POSITION_LAST;
  141. for (k = 0; k < switch_data->control_data_count; k++)
  142. {
  143. switch_control_data = switch_data->control_data[k];
  144. printf (" CONTROL %s\n", (char *)
  145. switch_control_data->element_values[0].parsed_value);
  146. }
  147. }
  148. printf (" CONTROL %s\n",
  149. (char *) control_data->element_values[0].parsed_value);
  150. if (control_data->subpanel_data != NULL)
  151. {
  152. subpanel_data = control_data->subpanel_data;
  153. printf(" SUBPANEL %s\n", (char *)
  154. subpanel_data->element_values[0].parsed_value);
  155. for (k = 0; k < subpanel_data->control_data_count; k++)
  156. {
  157. control_data = subpanel_data->control_data[k];
  158. printf (" CONTROL %s\n", (char *)
  159. control_data->element_values[0].parsed_value);
  160. }
  161. }
  162. }
  163. }
  164. }
  165. /************************************************************************
  166. *
  167. * The main program for the fron panel print function.
  168. *
  169. ************************************************************************/
  170. int
  171. main (int argc,
  172. char **argv)
  173. {
  174. XtAppContext appContext;
  175. Widget widget;
  176. /* This call is required to have values to pass to DtAppInitialize */
  177. widget = XtAppInitialize( &appContext, "Dtfplist",
  178. NULL, 0, &argc, argv, NULL, NULL, 0);
  179. /* This is required initialization so that FrontPanelReadDatabases()
  180. * procedure complete successfully.
  181. */
  182. DtAppInitialize( appContext, XtDisplay(widget), widget,
  183. argv[0], (char *)szWM_TOOL_CLASS);
  184. /* Load the database for use in printing. If it is able to load print
  185. * contents of front panel.
  186. */
  187. DtDbLoad();
  188. panel.app_name = strdup(argv[0]);
  189. if (FrontPanelReadDatabases ())
  190. {
  191. /* Print out the contents of the .fp database */
  192. PrintFrontPanelContents ();
  193. }
  194. else
  195. {
  196. /* NEEDS TO BE LOCALIZED */
  197. printf ("PANEL not found. Error in reading database.\n");
  198. }
  199. }