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