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