1 /*-
2  * Copyright (c) 1999 Thomas Runge (coto@core.de)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  */
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <X11/X.h>
31 #include <X11/Xlib.h>
32 #include <X11/Intrinsic.h>
33 #include <Xm/XmAll.h>
34 
35 #include "radio.h"
36 #include "config.h"
37 
38 #if (XmVERSION < 2)
39 enum { XmUNSET, XmSET, XmINDETERMINATE };
40 #endif
41 
42 #define FRAME_WIDGET   "frame"
43 #define STATION_WIDGET "station"
44 #define FREQ_WIDGET    "freq"
45 #define DEF_WIDGET     "def"
46 
47 static int is_popped;
48 static int is_scanning;
49 static int intern_cnt;
50 static Widget startW;
51 
52 Widget config_dialogW, scrollW, vrowW, targetW, lastTargetFrameW;
53 Widget saveB, applyB, scanB, newEntryB, delEntryB, delAllEntriesB;
54 Pixel fg_color, bg_color, bs_color, ts_color;
55 
56 extern XmString def_label_string;
57 extern char *startStation;
58 extern int startStationPos;
59 
60 static void MakeStationRow(int n, char *name, int freq, int def, int scroll);
61 static void MakeNewEntry(int freq);
62 static void UpdateValues();
63 
EnableWidgets(Boolean b)64 static void EnableWidgets(Boolean b)
65 {
66  XtSetSensitive(delEntryB, b);
67  XtSetSensitive(newEntryB, b);
68  XtSetSensitive(delAllEntriesB, b);
69  XtSetSensitive(saveB, b);
70  XtSetSensitive(applyB, b);
71  XtSetSensitive(scanB, b);
72 }
73 
closeCB(Widget widget,XtPointer clientData,XtPointer callData)74 static void closeCB(Widget widget, XtPointer clientData, XtPointer callData)
75 {
76  ConfigDialogToggle();
77 }
78 
applyCB(Widget widget,XtPointer clientData,XtPointer callData)79 static void applyCB(Widget widget, XtPointer clientData, XtPointer callData)
80 {
81  UpdateValues();
82  ConfigDialogToggle();
83 }
84 
saveCB(Widget widget,XtPointer clientData,XtPointer callData)85 static void saveCB(Widget widget, XtPointer clientData, XtPointer callData)
86 {
87  UpdateValues();
88  SaveRCFile();
89  ConfigDialogToggle();
90 }
91 
scanCB(Widget widget,XtPointer clientData,XtPointer callData)92 static void scanCB(Widget widget, XtPointer clientData, XtPointer callData)
93 {
94  int oldmute, ofreq, nfreq;
95 
96  EnableWidgets(False);
97  XDefineCursor(dpy, XtWindow(config_dialogW), workingCursor);
98  XmUpdateDisplay(config_dialogW);
99 
100  ofreq = nfreq = frequency;
101  oldmute = SetMute(True);
102  is_scanning = True;
103 
104  SetFrequency(MINFREQ);
105  while(True)
106  {
107   nfreq = frequency;
108   SeekChannel(UP);
109   if(nfreq == frequency)
110    break; /* no station at all */
111   if(frequency < nfreq)
112    break; /* scan done */
113   if(is_scanning == False)
114    break; /* stop scan */
115   MakeNewEntry(frequency);
116   nfreq = frequency;
117  }
118 
119  is_scanning = False;
120  SetFrequency(ofreq);
121  SetMute(oldmute);
122 
123  XSync(dpy, True);
124  XUndefineCursor(dpy, XtWindow(config_dialogW));
125  EnableWidgets(True);
126 }
127 
delEntryCB(Widget widget,XtPointer clientData,XtPointer callData)128 static void delEntryCB(Widget widget, XtPointer clientData, XtPointer callData)
129 {
130  int n;
131  char wname[32];
132  Widget tmp;
133 
134  XmPushButtonCallbackStruct *pbcbstr;
135 
136  pbcbstr = (XmPushButtonCallbackStruct*) callData;
137 
138  if(pbcbstr->event->xbutton.state&ShiftMask)
139  {
140   for(n = 0; n < intern_cnt; n++)
141   {
142    sprintf(wname, "*%s%d", FRAME_WIDGET, n);
143    tmp = XtNameToWidget(config_dialogW, wname);
144    if(tmp)
145     XtDestroyWidget(tmp);
146   }
147   startW = NULL;
148  }
149  else
150   if(lastTargetFrameW)
151    XtDestroyWidget(lastTargetFrameW);
152 
153  lastTargetFrameW = NULL;
154 }
155 
delAllEntriesCB(Widget widget,XtPointer clientData,XtPointer callData)156 static void delAllEntriesCB(Widget widget, XtPointer clientData, XtPointer callData)
157 {
158  XmPushButtonCallbackStruct *pbcbstr;
159 
160  pbcbstr = (XmPushButtonCallbackStruct*) callData;
161  pbcbstr->event->xbutton.state |= ShiftMask;
162  delEntryCB(widget, clientData, callData);
163 }
164 
focusInCB(Widget widget,XtPointer clientData,XtPointer callData)165 static void focusInCB(Widget widget, XtPointer clientData, XtPointer callData)
166 {
167  Widget newTargetFrameW;
168 
169  targetW = widget;
170 
171  XtVaGetValues(widget, XmNuserData, &newTargetFrameW, NULL);
172 
173  if(lastTargetFrameW)
174   XtVaSetValues(lastTargetFrameW, XmNbottomShadowColor, bg_color,
175                                   XmNtopShadowColor, bg_color,
176                                   XmNforeground, bg_color,
177                                   NULL);
178 
179  if(newTargetFrameW)
180   XtVaSetValues(newTargetFrameW, XmNbottomShadowColor, bs_color,
181                                  XmNtopShadowColor, ts_color,
182                                  XmNforeground, fg_color,
183                                  NULL);
184 
185  lastTargetFrameW = newTargetFrameW;
186 }
187 
startToggleCB(Widget widget,XtPointer clientData,XtPointer callData)188 static void startToggleCB(Widget widget, XtPointer clientData,
189                                          XtPointer callData)
190 {
191  if(startW)
192   XtVaSetValues(startW, XmNset, XmUNSET, NULL);
193 
194  startW = widget;
195 }
196 
newEntryCB(Widget widget,XtPointer clientData,XtPointer callData)197 static void newEntryCB(Widget widget, XtPointer clientData, XtPointer callData)
198 {
199  MakeNewEntry(frequency);
200 }
201 
202 
MakeNewEntry(int freq)203 static void MakeNewEntry(int freq)
204 {
205  MakeStationRow(intern_cnt, "*unknown*", freq, 0, True);
206  intern_cnt++;
207 }
208 
UpdateValues()209 static void UpdateValues()
210 {
211  int n, cnt, freq;
212  unsigned char set;
213  char wname[32];
214  Widget tmp;
215  String str;
216 
217  cnt = 0;
218  for(n = 0; n < intern_cnt; n++)
219  {
220   sprintf(wname, "*%s%d", FRAME_WIDGET, n);
221   tmp = XtNameToWidget(config_dialogW, wname);
222   if(!tmp)
223    continue;
224 
225   cnt++;
226  }
227 
228  for(n = 0; n < station.cnt; n++)
229   free(station.name[n]);
230  free(station.name);
231  free(station.freq);
232  free(station.def);
233  free(station_buttons.pos);
234 
235  station.name = (char**)calloc(cnt, sizeof(char*));
236  station.freq =   (int*)calloc(cnt, sizeof(int));
237  station.def  =   (int*)calloc(cnt, sizeof(int));
238  station.cnt  = 0;
239  station_buttons.pos = (int*)calloc(n, sizeof(int));
240  station_buttons.cnt = 0;
241 
242  for(n = 0; n < intern_cnt; n++)
243  {
244   sprintf(wname, "*%s%d", FRAME_WIDGET, n);
245   tmp = XtNameToWidget(config_dialogW, wname);
246   if(!tmp)
247    continue;
248 
249   sprintf(wname, "*%s%d", STATION_WIDGET, n);
250   tmp = XtNameToWidget(config_dialogW, wname);
251   if(tmp)
252   {
253    XtVaGetValues(tmp, XmNvalue, &str, NULL);
254    if(str && strlen(str))
255     station.name[station.cnt] = strdup(str);
256    else
257     station.name[station.cnt] = strdup("*unknown*");
258 
259    if(debug)
260     printf("station %d: %s ", n, str);
261   }
262   else
263    station.name[station.cnt] = strdup("*unknown*");
264 
265   sprintf(wname, "*%s%d", FREQ_WIDGET, n);
266   tmp = XtNameToWidget(config_dialogW, wname);
267   if(tmp)
268   {
269    XtVaGetValues(tmp, XmNvalue, &str, NULL);
270    freq = (int)(100. * atof(str) + 0.5);
271    if(freq < MINFREQ || freq > MAXFREQ)
272     freq = MINFREQ;
273    station.freq[station.cnt] = freq;
274 
275    if(debug)
276     printf("(%u.%02u) ", freq / 100, freq % 100);
277   }
278   else
279    station.freq[station.cnt] = MINFREQ;
280 
281   sprintf(wname, "*%s%d", DEF_WIDGET, n);
282   tmp = XtNameToWidget(config_dialogW, wname);
283   if(tmp)
284   {
285    int def = XmUNSET;
286    XtVaGetValues(tmp, XmNset, &set, NULL);
287    def = (set == XmSET ? TRUE : FALSE);
288 
289    station.def[station.cnt] = def;
290    if(def)
291     station_buttons.pos[station_buttons.cnt++] = station.cnt+1;
292 
293    if(debug)
294     printf(" %s ", def ? "defbtn\n" : "\n");
295   }
296   else
297    station.def[station.cnt] = FALSE;
298 
299   station.cnt++;
300  }
301 
302  if(startW)
303  {
304   XtVaGetValues(startW, XmNuserData, &startStationPos, NULL);
305   startStation = station.name[startStationPos];
306  }
307 
308  SortStationList();
309  GeneratePopupMenu(TRUE);
310  MakeStationButtonWidgets(TRUE);
311  UpdateTitle();
312 }
313 
UpdateStations()314 static void UpdateStations()
315 {
316  int i;
317 
318  if(vrowW)
319   XtDestroyWidget(vrowW);
320 
321  vrowW =
322   XtVaCreateManagedWidget("scroll_win",
323                           xmRowColumnWidgetClass,
324                           scrollW,
325                           XmNorientation, XmVERTICAL,
326                           NULL);
327 
328  for(i = 0; i < station.cnt; i++)
329   MakeStationRow(i, station.name[i], station.freq[i], station.def[i], False);
330 
331  intern_cnt = station.cnt;
332 }
333 
MakeStationRow(int n,char * name,int freq,int def,int scroll)334 static void MakeStationRow(int n, char *name, int freq, int def, int scroll)
335 {
336  Widget frameW, rowW, conf_stationW, conf_freqW, conf_defW, conf_startW;
337  char wname[32];
338  char buf[16];
339 
340  sprintf(wname, "%s%d", FRAME_WIDGET, n);
341  frameW =
342   XtVaCreateManagedWidget(wname,
343                           xmFrameWidgetClass,
344                           vrowW,
345                           NULL);
346 
347  XtVaSetValues(frameW, XmNbottomShadowColor, bg_color,
348                        XmNtopShadowColor, bg_color,
349                        XmNforeground, bg_color,
350                        NULL);
351 
352  rowW =
353   XtVaCreateManagedWidget("entry_row",
354                           xmRowColumnWidgetClass,
355                           frameW,
356                           XmNorientation, XmHORIZONTAL,
357                           NULL);
358 
359  sprintf(wname, "%s%d", STATION_WIDGET, n);
360  conf_stationW =
361   XtVaCreateManagedWidget(wname,
362                           xmTextFieldWidgetClass,
363                           rowW,
364                           XmNvalue,    name,
365                           XmNuserData, (XtPointer) frameW,
366                           NULL);
367  XtAddCallback(conf_stationW, XmNfocusCallback, focusInCB, (XtPointer)NULL);
368 
369  sprintf(wname, "%s%d", FREQ_WIDGET, n);
370  sprintf(buf, "%u.%02u ", freq / 100, freq % 100);
371  conf_freqW =
372   XtVaCreateManagedWidget(wname,
373                           xmTextFieldWidgetClass,
374                           rowW,
375                           XmNvalue,    buf,
376                           XmNuserData, (XtPointer) frameW,
377                           NULL);
378  XtAddCallback(conf_freqW, XmNfocusCallback, focusInCB, (XtPointer)NULL);
379 
380  sprintf(wname, "%s%d", DEF_WIDGET, n);
381  conf_defW =
382   XtVaCreateManagedWidget(wname,
383                           xmToggleButtonWidgetClass,
384                           rowW,
385                           XmNset,  def ? XmSET : XmUNSET,
386                           XmNlabelString, def_label_string,
387                           XmNuserData, (XtPointer) frameW,
388                           NULL);
389  XtAddCallback(conf_defW, XmNarmCallback, focusInCB, (XtPointer)NULL);
390 
391  conf_startW =
392   XtVaCreateManagedWidget("start",
393                           xmToggleButtonWidgetClass,
394                           rowW,
395                           XmNindicatorType, XmONE_OF_MANY,
396                           XmNuserData, (XtPointer) n,
397                           NULL);
398  XtAddCallback(conf_startW, XmNarmCallback, startToggleCB, (XtPointer)NULL);
399  if(startStationPos == n)
400  {
401   XtCallCallbacks(conf_startW, XmNarmCallback, (XtPointer)NULL);
402   XtVaSetValues(conf_startW, XmNset, XmSET, NULL);
403  }
404 
405 #ifdef HAS_XPM
406  if(skin)
407   SkinToWidgets(frameW, skin);
408 #endif
409 
410  if(scroll)
411  {
412   XmScrollVisible(scrollW, frameW, 0, 0);
413   XmProcessTraversal(conf_stationW, XmTRAVERSE_CURRENT);
414  }
415 }
416 
MakeInterface(Widget topl)417 static void MakeInterface(Widget topl)
418 {
419  Widget mainW, cancelB, confSepW, label_formW, label_frameW;
420  Widget statLabelW, freqLabelW, defLabelW;
421  Position x, y;
422 
423  extern void _XEditResCheckMessages(Widget, XtPointer, XEvent*, Boolean*);
424 
425  intern_cnt = 0;
426  lastTargetFrameW = NULL;
427  vrowW = NULL;
428 
429  XtVaGetValues(topl, XmNx, &x, XmNy, &y, NULL);
430  config_dialogW = XtVaCreatePopupShell("config_dialog",
431                                transientShellWidgetClass,
432                                topl,
433                                XmNx,              x,
434                                XmNy,              y,
435                                XmNdeleteResponse, XmDO_NOTHING,
436                                XtNiconPixmap,     icon_pm,
437                                XtNiconMask,       icon_pm_mask,
438                                NULL);
439 
440  XtAddEventHandler(config_dialogW, (EventMask)0, True, _XEditResCheckMessages,
441                    NULL);
442 
443  mainW =
444   XtVaCreateManagedWidget("config_main",
445                           xmFormWidgetClass,
446                           config_dialogW,
447                           NULL);
448  saveB =
449   XtVaCreateManagedWidget("save_button",
450                           xmPushButtonWidgetClass,
451                           mainW,
452                           XmNleftAttachment,   XmATTACH_FORM,
453                           XmNleftOffset,       2,
454                           XmNrightAttachment,  XmATTACH_POSITION,
455                           XmNrightPosition,    33,
456                           XmNbottomAttachment, XmATTACH_FORM,
457                           XmNbottomOffset,     2,
458                           NULL);
459  XtAddCallback(saveB, XmNactivateCallback, saveCB, (XtPointer)NULL);
460 
461  applyB =
462   XtVaCreateManagedWidget("apply_button",
463                           xmPushButtonWidgetClass,
464                           mainW,
465                           XmNleftAttachment,   XmATTACH_POSITION,
466                           XmNleftPosition,     33,
467                           XmNrightAttachment,  XmATTACH_POSITION,
468                           XmNrightPosition,    66,
469                           XmNbottomAttachment, XmATTACH_FORM,
470                           XmNbottomOffset,     2,
471                           NULL);
472  XtAddCallback(applyB, XmNactivateCallback, applyCB, (XtPointer)NULL);
473 
474  cancelB =
475   XtVaCreateManagedWidget("cancel_button",
476                           xmPushButtonWidgetClass,
477                           mainW,
478                           XmNleftAttachment,   XmATTACH_POSITION,
479                           XmNleftPosition,     66,
480                           XmNrightAttachment,  XmATTACH_FORM,
481                           XmNrightOffset,      2,
482                           XmNbottomAttachment, XmATTACH_FORM,
483                           XmNbottomOffset,     2,
484                           NULL);
485  XtAddCallback(cancelB, XmNactivateCallback, closeCB, (XtPointer)NULL);
486 
487  confSepW =
488    XtVaCreateManagedWidget("conf_separator",
489                            xmSeparatorWidgetClass,
490                            mainW,
491                            XmNleftAttachment,   XmATTACH_FORM,
492                            XmNleftOffset,       3,
493                            XmNrightAttachment,  XmATTACH_FORM,
494                            XmNrightOffset,      3,
495                            XmNbottomAttachment, XmATTACH_WIDGET,
496                            XmNbottomWidget,     cancelB,
497                            NULL);
498 
499  delAllEntriesB =
500   XtVaCreateManagedWidget("delAllEntries_button",
501                           xmPushButtonWidgetClass,
502                           mainW,
503                           XmNleftAttachment,   XmATTACH_FORM,
504                           XmNleftOffset,       2,
505                           XmNrightAttachment,  XmATTACH_POSITION,
506                           XmNrightPosition,    50,
507                           XmNbottomAttachment, XmATTACH_WIDGET,
508                           XmNbottomWidget,     confSepW,
509                           XmNbottomOffset,     2,
510                           NULL);
511  XtAddCallback(delAllEntriesB, XmNactivateCallback, delAllEntriesCB, (XtPointer)NULL);
512 
513  scanB =
514   XtVaCreateManagedWidget("scan_button",
515                           xmPushButtonWidgetClass,
516                           mainW,
517                           XmNleftAttachment,   XmATTACH_POSITION,
518                           XmNleftPosition,     50,
519                           XmNrightAttachment,  XmATTACH_FORM,
520                           XmNrightOffset,      2,
521                           XmNbottomAttachment, XmATTACH_WIDGET,
522                           XmNbottomWidget,     confSepW,
523                           XmNbottomOffset,     2,
524                           NULL);
525  XtAddCallback(scanB, XmNactivateCallback, scanCB, (XtPointer)NULL);
526 
527 
528  delEntryB =
529   XtVaCreateManagedWidget("delEntry_button",
530                           xmPushButtonWidgetClass,
531                           mainW,
532                           XmNleftAttachment,   XmATTACH_FORM,
533                           XmNleftOffset,       2,
534                           XmNrightAttachment,  XmATTACH_POSITION,
535                           XmNrightPosition,    50,
536                           XmNbottomAttachment, XmATTACH_WIDGET,
537                           XmNbottomWidget,     delAllEntriesB,
538                           XmNbottomOffset,     2,
539                           NULL);
540  XtAddCallback(delEntryB, XmNactivateCallback, delEntryCB, (XtPointer)NULL);
541 
542  newEntryB =
543   XtVaCreateManagedWidget("newEntry_button",
544                           xmPushButtonWidgetClass,
545                           mainW,
546                           XmNleftAttachment,   XmATTACH_POSITION,
547                           XmNleftPosition,     50,
548                           XmNrightAttachment,  XmATTACH_FORM,
549                           XmNrightOffset,      2,
550                           XmNbottomAttachment, XmATTACH_WIDGET,
551                           XmNbottomWidget,     delAllEntriesB,
552                           XmNbottomOffset,     2,
553                           NULL);
554  XtAddCallback(newEntryB, XmNactivateCallback, newEntryCB, (XtPointer)NULL);
555 
556  label_frameW =
557   XtVaCreateManagedWidget("label_frame",
558                           xmFrameWidgetClass,
559                           mainW,
560                           XmNleftAttachment,  XmATTACH_FORM,
561                           XmNleftOffset,      2,
562                           XmNrightAttachment, XmATTACH_FORM,
563                           XmNrightOffset,     2,
564                           XmNtopAttachment,   XmATTACH_FORM,
565                           XmNtopOffset,       2,
566                           NULL);
567 
568  label_formW =
569   XtVaCreateManagedWidget("label_form",
570                           xmFormWidgetClass,
571                           label_frameW,
572                           NULL);
573 
574  statLabelW =
575   XtVaCreateManagedWidget("statLabel",
576                           xmLabelWidgetClass,
577                           label_formW,
578                           XmNalignment,       XmALIGNMENT_CENTER,
579                           XmNleftAttachment,  XmATTACH_FORM,
580                           XmNrightAttachment, XmATTACH_POSITION,
581                           XmNrightPosition,   33,
582                           NULL);
583 
584  freqLabelW =
585   XtVaCreateManagedWidget("freqLabel",
586                           xmLabelWidgetClass,
587                           label_formW,
588                           XmNalignment,       XmALIGNMENT_CENTER,
589                           XmNleftAttachment,  XmATTACH_POSITION,
590                           XmNleftPosition,    33,
591                           XmNrightAttachment, XmATTACH_POSITION,
592                           XmNrightPosition,   66,
593                           NULL);
594 
595  defLabelW =
596   XtVaCreateManagedWidget("defLabel",
597                           xmLabelWidgetClass,
598                           label_formW,
599                           XmNalignment,       XmALIGNMENT_CENTER,
600                           XmNleftAttachment,  XmATTACH_POSITION,
601                           XmNleftPosition,    66,
602                           XmNrightAttachment, XmATTACH_FORM,
603                           NULL);
604 
605  scrollW =
606   XtVaCreateManagedWidget("scroll_w",
607                           xmScrolledWindowWidgetClass,
608                           mainW,
609                           XmNscrollingPolicy,  XmAUTOMATIC,
610                           XmNvisualPolicy,     XmCONSTANT,
611                           XmNleftAttachment,   XmATTACH_FORM,
612                           XmNleftOffset,       2,
613                           XmNrightAttachment,  XmATTACH_FORM,
614                           XmNrightOffset,      2,
615                           XmNtopAttachment,    XmATTACH_WIDGET,
616                           XmNtopWidget,        label_frameW,
617                           XmNbottomAttachment, XmATTACH_WIDGET,
618                           XmNbottomWidget,     newEntryB,
619                           XmNbottomOffset,     2,
620                           NULL);
621 
622  XtVaGetValues(scrollW, XmNforeground, &fg_color,
623                         XmNbackground, &bg_color,
624                         XmNbottomShadowColor, &bs_color,
625                         XmNtopShadowColor, &ts_color,
626                         NULL);
627 }
628 
ConfigDialogToggle()629 void ConfigDialogToggle()
630 {
631  if(!config_dialogW)
632  {
633   Atom wmDeleteAtom;
634 
635   is_popped = False;
636   MakeInterface(toplevel);
637   AddTooltipsToWidgets();
638 #ifdef HAS_XPM
639   if(skin)
640    SkinToWidgets(config_dialogW, skin);
641 #endif
642 
643   wmDeleteAtom = XmInternAtom(dpy, "WM_DELETE_WINDOW", False);
644   XmAddWMProtocolCallback(config_dialogW, wmDeleteAtom, closeCB,
645                           (XtPointer)NULL);
646  }
647 
648  if(is_popped)
649  {
650   is_popped = False;
651   is_scanning = False;
652   XtPopdown(config_dialogW);
653  }
654  else
655  {
656   is_popped = True;
657   UpdateStations();
658   lastTargetFrameW = NULL;
659 #ifdef HAS_XPM
660   if(skin)
661    SkinToWidgets(config_dialogW, skin);
662 #endif
663   XtPopup(config_dialogW, XtGrabNone);
664  }
665 }
666 
conf_scroll_up(Widget w,XEvent * event,String * params,Cardinal * paramscnt)667 void conf_scroll_up(Widget w, XEvent *event, String *params, Cardinal *paramscnt)
668 {
669  if(!is_popped)
670   return;
671 
672  XtCallActionProc(scrollW, "SWUpPage", NULL, NULL, 0);
673 }
674 
conf_scroll_down(Widget w,XEvent * event,String * params,Cardinal * paramscnt)675 void conf_scroll_down(Widget w, XEvent *event, String *params, Cardinal *paramscnt)
676 {
677  if(!is_popped)
678   return;
679 
680  XtCallActionProc(scrollW, "SWDownPage", NULL, NULL, 0);
681 }
682 
683