~ubuntu-branches/ubuntu/trusty/libcdk5/trusty

« back to all changes in this revision

Viewing changes to cli/cdkfselect.c

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2007-06-06 03:54:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070606035431-ba4gdvw0h6ybffsu
Tags: 5.0.20060507-1
* New upstream release.
* Fixed header patching.  Patch from Robert Schiele.
  Closes: #402978, #416336.
* Update widget count in description.  Closes: #294709.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: cdkfselect.c,v 1.7 2005/03/08 19:54:14 tom Exp $ */
 
1
/* $Id: cdkfselect.c,v 1.10 2005/12/27 17:52:02 tom Exp $ */
2
2
 
3
 
#include <cdk.h>
 
3
#include <cdk_test.h>
4
4
 
5
5
#ifdef XCURSES
6
6
char *XCursesProgramName="cdkfselect";
27
27
   int buttonCount              = 0;
28
28
   FILE *fp                     = stderr;
29
29
   char **buttonList            = 0;
30
 
   int x, j1, j2;
 
30
   int j1, j2;
31
31
 
32
32
   CDK_PARAMS params;
33
33
   boolean boxWidget;
63
63
      if ((fp = fopen (outputFile, "w")) == 0)
64
64
      {
65
65
         fprintf (stderr, "%s: Can not open output file %s\n", argv[0], outputFile);
66
 
         exit (-1);
 
66
         ExitProgram (CLI_ERROR);
67
67
      }
68
68
   }
69
69
 
106
106
                                title, label, A_NORMAL, '.', A_REVERSE,
107
107
                                "", "", "", "",
108
108
                                boxWidget, shadowWidget);
 
109
   freeChar (label);
109
110
 
110
111
   /* Check to make sure we created the file selector. */
111
112
   if (widget == 0)
112
113
   {
113
 
      /* Clean up used memory. */
114
 
      for (x=0; x < buttonCount; x++)
115
 
      {
116
 
         freeChar (buttonList[x]);
117
 
      }
 
114
      CDKfreeStrings (buttonList);
118
115
 
119
 
      /* Shut down curses and CDK. */
120
116
      destroyCDKScreen (cdkScreen);
121
117
      endCDK();
122
118
 
123
 
      /* Spit out the message. */
124
119
      fprintf (stderr, "Error: Could not create the file selector. Is the window too small?\n");
125
120
 
126
 
      /* Exit with an error. */
127
 
      exit (-1);
 
121
      ExitProgram (CLI_ERROR);
128
122
   }
129
123
 
130
124
   /* Split the buttons if they supplied some. */
131
125
   if (buttons != 0)
132
126
   {
133
 
      /* Split the button list up. */
134
127
      buttonList = CDKsplitString (buttons, '\n');
135
128
      buttonCount = CDKcountStrings (buttonList);
136
129
 
142
135
                                        0, 1, buttonCount,
143
136
                                        buttonList, buttonCount,
144
137
                                        A_REVERSE, boxWidget, FALSE);
 
138
      CDKfreeStrings (buttonList);
 
139
 
145
140
      setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
146
141
      setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
147
142
 
148
 
     /*
149
 
      * We need to set the lower left and right
150
 
      * characters of the widget.
151
 
      */
 
143
      /*
 
144
       * We need to set the lower left and right
 
145
       * characters of the widget.
 
146
       */
152
147
      setCDKFselectLLChar (widget, ACS_LTEE);
153
148
      setCDKFselectLRChar (widget, ACS_RTEE);
154
149
 
155
 
     /*
156
 
      * Bind the Tab key in the widget to send a
157
 
      * Tab key to the button box widget.
158
 
      */
 
150
      /*
 
151
       * Bind the Tab key in the widget to send a
 
152
       * Tab key to the button box widget.
 
153
       */
159
154
      bindCDKObject (vFSELECT, widget, KEY_TAB, widgetCB, buttonWidget);
160
155
      bindCDKObject (vFSELECT, widget, CDK_NEXT, widgetCB, buttonWidget);
161
156
      bindCDKObject (vFSELECT, widget, CDK_PREV, widgetCB, buttonWidget);
167
162
      drawCDKButtonbox (buttonWidget, boxWidget);
168
163
   }
169
164
 
170
 
  /*
171
 
   * If the user asked for a shadow, we need to create one.
172
 
   * I do this instead of using the shadow parameter because
173
 
   * the button widget sin't part of the main widget and if
174
 
   * the user asks for both buttons and a shadow, we need to
175
 
   * create a shadow big enough for both widgets. We'll create
176
 
   * the shadow window using the widgets shadowWin element, so
177
 
   * screen refreshes will draw them as well.
178
 
   */
 
165
   /*
 
166
    * If the user asked for a shadow, we need to create one.  Do this instead
 
167
    * of using the shadow parameter because the button widget is not part of
 
168
    * the main widget and if the user asks for both buttons and a shadow, we
 
169
    * need to create a shadow big enough for both widgets.  Create the shadow
 
170
    * window using the widgets shadowWin element, so screen refreshes will draw
 
171
    * them as well.
 
172
    */
179
173
   if (shadowWidget == TRUE)
180
174
   {
181
175
      /* Determine the height of the shadow window. */
194
188
      {
195
189
         widget->shadow = TRUE;
196
190
 
197
 
        /*
198
 
         * We force the widget and buttonWidget to be drawn so the
199
 
         * buttonbox widget will be drawn when the widget is activated.
200
 
         * Otherwise the shadow window will draw over the button widget.
201
 
         */
 
191
         /*
 
192
          * We force the widget and buttonWidget to be drawn so the
 
193
          * buttonbox widget will be drawn when the widget is activated.
 
194
          * Otherwise the shadow window will draw over the button widget.
 
195
          */
202
196
         drawCDKFselect (widget, ObjOf(widget)->box);
203
197
         eraseCDKButtonbox (buttonWidget);
204
198
         drawCDKButtonbox (buttonWidget, ObjOf(buttonWidget)->box);
221
215
      destroyCDKButtonbox (buttonWidget);
222
216
   }
223
217
 
224
 
   /* Clean up. */
225
218
   destroyCDKFselect (widget);
226
219
   destroyCDKScreen (cdkScreen);
227
220
   endCDK();
228
221
 
229
 
   /* Print out the filename selected. */
 
222
   /* Print the filename selected. */
230
223
   fprintf (fp, "%s\n", filename);
231
224
   freeChar (filename);
232
 
   exit (selection);
 
225
   fclose (fp);
 
226
 
 
227
   ExitProgram (selection);
233
228
}
234
229
 
235
230
static int widgetCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)