1 /* ===========================================================================
2 * AScd: the AfterStep and WindowMaker CD player
3 * gui_wings.c: window handling using WINGs toolkit
4 * ===========================================================================
5 * Copyright (c) 1999 Denis Bourez and Rob Malda. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Denis Bourez & Rob Malda
19 * 4. Neither the name of the author nor the names of any co-contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY DENIS BOUREZ AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL DENIS BOUREZ, ROB MALDA OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 * ===========================================================================
41 /*int old_track = 0;*/
43 void close_win(WMWidget
*self
, void *data
) {
46 muted_volume
= atoi(WMGetTextFieldText(b_mutedvol
));
47 min_volume
= atoi(WMGetTextFieldText(b_minvol
));
48 max_volume
= atoi(WMGetTextFieldText(b_maxvol
));
49 cue_time
= atoi(WMGetTextFieldText(b_cuetime
));
50 fade_step
= atoi(WMGetTextFieldText(b_fadestep
));
53 void close_aboutwin(WMWidget
*self
, void *data
) {
54 WMCloseWindow(aboutwin
);
58 void close_dbwin(WMWidget
*self
, void *data
) {
63 strcpy(cd
->artist
, WMGetTextFieldText(db_artist
));
64 strcpy(cd
->cdname
, WMGetTextFieldText(db_title
));
65 if (strlen(WMGetTextFieldText(db_track
)) > 0) {
66 cd
->trk
[db_curtrack
- 1].songname
= malloc(strlen(WMGetTextFieldText(db_track
)) + 1);
67 strcpy(cd
->trk
[db_curtrack
- 1].songname
, WMGetTextFieldText(db_track
));
73 if (cd
->artist
!= NULL
) {
74 strcpy(txt
, cd
->artist
);
75 if (strcmp(txt
, "") == 0) strcpy(txt
, "unknown artist");
77 strcpy(txt
, "unknown artist");
82 if (cd
->cdname
!= NULL
) {
83 strcpy(txt2
, cd
->cdname
);
84 if (strcmp(txt2
, "") == 0) strcpy(txt2
, "unknown album");
86 strcpy(txt2
, "unknown album");
90 WMSetButtonText(b_title
, txt
);
95 void quit_ascd(WMWidget
*self
, void *data
) {
99 void save_cb(WMWidget
*self
, void *data
) {
100 muted_volume
= atoi(WMGetTextFieldText(b_mutedvol
));
101 min_volume
= atoi(WMGetTextFieldText(b_minvol
));
102 max_volume
= atoi(WMGetTextFieldText(b_maxvol
));
103 cue_time
= atoi(WMGetTextFieldText(b_cuetime
));
104 fade_step
= atoi(WMGetTextFieldText(b_fadestep
));
105 cd_device
= WMGetTextFieldText(b_device
);
109 void track_select(WMWidget
*self
, void *data
) {
111 direct_track
= WMGetPopUpButtonSelectedItem(self
) + 1;
112 cd_control(DIRECTTRACK
);
114 if (cur_cdmode
== WM_CDM_STOPPED
) cd_control(PLAY
);
117 void theme_pick(WMWidget
*self
, void *data
) {
118 strcpy(theme
, WMGetPopUpButtonItem(self
, WMGetPopUpButtonSelectedItem(self
)));
119 fak_load_theme(theme
, TRUE
);
123 void help_cb(WMWidget
*self
, void *data
) {
127 void mode1_cb(WMWidget
*self
, void *data
) {
128 if (WMGetButtonSelected(b_mode1
)) {
129 WMSetButtonSelected((b_mode2
), FALSE
);
131 WMSetButtonSelected((b_mode2
), TRUE
);
134 if (WMGetButtonSelected(b_mode1
)) {
135 if (WMGetButtonSelected(b_mode3
)) time_mode
= 0;
138 if (WMGetButtonSelected(b_mode3
)) time_mode
= 2;
143 void mode2_cb(WMWidget
*self
, void *data
) {
144 if (WMGetButtonSelected(b_mode2
)) {
145 WMSetButtonSelected((b_mode1
), FALSE
);
147 WMSetButtonSelected((b_mode1
), TRUE
);
150 if (WMGetButtonSelected(b_mode1
)) {
151 if (WMGetButtonSelected(b_mode3
)) time_mode
= 0;
154 if (WMGetButtonSelected(b_mode3
)) time_mode
= 2;
159 void mode3_cb(WMWidget
*self
, void *data
) {
160 if (WMGetButtonSelected(b_mode3
)) {
161 WMSetButtonSelected((b_mode4
), FALSE
);
163 WMSetButtonSelected((b_mode4
), TRUE
);
166 if (WMGetButtonSelected(b_mode1
)) {
167 if (WMGetButtonSelected(b_mode3
)) time_mode
= 0;
170 if (WMGetButtonSelected(b_mode3
)) time_mode
= 2;
175 void mode4_cb(WMWidget
*self
, void *data
) {
176 if (WMGetButtonSelected(b_mode4
)) {
177 WMSetButtonSelected((b_mode3
), FALSE
);
179 WMSetButtonSelected((b_mode3
), TRUE
);
182 if (WMGetButtonSelected(b_mode1
)) {
183 if (WMGetButtonSelected(b_mode3
)) time_mode
= 0;
186 if (WMGetButtonSelected(b_mode3
)) time_mode
= 2;
191 void autoplay_cb(WMWidget
*self
, void *data
) {
192 if (autoplay
) autoplay
= 0;
195 if (WMGetButtonSelected(b_mode1
)) {
196 if (WMGetButtonSelected(b_mode3
)) time_mode
= 0;
199 if (WMGetButtonSelected(b_mode3
)) time_mode
= 2;
204 void autorepeat_cb(WMWidget
*self
, void *data
) {
205 if (autorepeat
) autorepeat
= 0;
209 void ignoreavoid_cb(WMWidget
*self
, void *data
) {
210 if (ignore_avoid
) ignore_avoid
= 0;
211 else ignore_avoid
= 1;
214 void upper_cb(WMWidget
*self
, void *data
) {
215 if (force_upper
) force_upper
= 0;
216 else force_upper
= 1;
219 void scroll_cb(WMWidget
*self
, void *data
) {
220 if (show_db
) show_db
= 0;
224 void artist_cb(WMWidget
*self
, void *data
) {
225 if (show_artist
) show_artist
= 0;
226 else show_artist
= 1;
229 void volume_cb(WMWidget
*self
, void *data
) {
230 if (cur_cdmode
!= WM_CDM_EJECTED
) {
231 volume
= WMGetSliderValue(self
);
232 cd_volume(volume
, 10, max_volume
);
237 /* --------------------------------------------------- */
239 void create_about_window(WMScreen
*scr
) {
241 WMWidget
*lb1
, *lb2
, *lb3
, *lb4
, *lb5
, *lb6
;
244 aboutwin
= WMCreateWindow(scr
, "AScd-about");
245 WMSetWindowCloseAction(aboutwin
, close_aboutwin
, NULL
);
246 WMSetWindowTitle(aboutwin
, "AScd Info");
247 WMResizeWidget(aboutwin
, 350, 170);
249 lb1
= WMCreateLabel(aboutwin
);
250 WMResizeWidget(lb1
, 35, 20);
251 WMMoveWidget(lb1
, 10, 10);
252 font
= WMBoldSystemFontOfSize(scr
, 12);
254 WMSetLabelFont(lb1
, font
);
257 WMSetLabelText(lb1
, "AScd");
259 lb2
= WMCreateLabel(aboutwin
);
260 WMResizeWidget(lb2
, 200, 20);
261 WMMoveWidget(lb2
, 50, 10);
262 sprintf(txt
, "release %s", VERSION
);
263 WMSetLabelText(lb2
, txt
);
265 lb3
= WMCreateLabel(aboutwin
);
266 WMResizeWidget(lb3
, 280, 40);
267 WMMoveWidget(lb3
, 50, 30);
268 font
= WMSystemFontOfSize(scr
, 10);
270 WMSetLabelFont(lb3
, font
);
273 sprintf(txt
, "(c) 1996-1999 Denis Bourez and Rob Malda\nContact: denis@rsn.fdn.fr\nhttp://worldserver.oleane.com/rsn/ascd-en.html");
274 WMSetLabelText(lb3
, txt
);
276 lb5
= WMCreateLabel(aboutwin
);
277 WMResizeWidget(lb5
, 60, 20);
278 WMMoveWidget(lb5
, 10, 70);
279 font
= WMBoldSystemFontOfSize(scr
, 10);
281 WMSetLabelFont(lb5
, font
);
284 WMSetLabelText(lb5
, "Ctrl:");
286 lb4
= WMCreateLabel(aboutwin
);
287 WMResizeWidget(lb4
, 260, 20);
288 WMMoveWidget(lb4
, 50, 70);
289 font
= WMSystemFontOfSize(scr
, 10);
291 WMSetLabelFont(lb4
, font
);
294 sprintf(txt
, "CD Control %s + %s", cd_control_version(), wm_libver_string());
295 WMSetLabelText(lb4
, txt
);
297 lb6
= WMCreateLabel(aboutwin
);
298 WMResizeWidget(lb6
, 60, 20);
299 WMMoveWidget(lb6
, 10, 85);
300 font
= WMBoldSystemFontOfSize(scr
, 10);
302 WMSetLabelFont(lb6
, font
);
305 WMSetLabelText(lb6
, "Theme:");
307 about_th1
= WMCreateLabel(aboutwin
);
308 WMResizeWidget(about_th1
, 280, 12);
309 WMMoveWidget(about_th1
, 50, 89);
310 font
= WMSystemFontOfSize(scr
, 10);
312 WMSetLabelFont(about_th1
, font
);
315 WMSetLabelText(about_th1
, "A");
317 about_th2
= WMCreateLabel(aboutwin
);
318 WMResizeWidget(about_th2
, 280, 12);
319 WMMoveWidget(about_th2
, 50, 101);
320 font
= WMSystemFontOfSize(scr
, 10);
322 WMSetLabelFont(about_th2
, font
);
325 WMSetLabelText(about_th2
, "B");
327 about_th3
= WMCreateLabel(aboutwin
);
328 WMResizeWidget(about_th3
, 280, 12);
329 WMMoveWidget(about_th3
, 50, 113);
330 font
= WMSystemFontOfSize(scr
, 10);
332 WMSetLabelFont(about_th3
, font
);
335 WMSetLabelText(about_th3
, "C");
337 about_th4
= WMCreateLabel(aboutwin
);
338 WMResizeWidget(about_th4
, 280, 12);
339 WMMoveWidget(about_th4
, 50, 125);
340 font
= WMSystemFontOfSize(scr
, 10);
342 WMSetLabelFont(about_th4
, font
);
345 WMSetLabelText(about_th4
, "D");
347 about_th5
= WMCreateLabel(aboutwin
);
348 WMResizeWidget(about_th5
, 280, 12);
349 WMMoveWidget(about_th5
, 50, 137);
350 font
= WMSystemFontOfSize(scr
, 10);
352 WMSetLabelFont(about_th5
, font
);
355 WMSetLabelText(about_th5
, "E");
357 about_th6
= WMCreateLabel(aboutwin
);
358 WMResizeWidget(about_th6
, 280, 12);
359 WMMoveWidget(about_th6
, 50, 149);
360 font
= WMSystemFontOfSize(scr
, 10);
362 WMSetLabelFont(about_th6
, font
);
365 WMSetLabelText(about_th6
, "F");
369 WMRealizeWidget(aboutwin
);
372 void about_window(WMScreen
*scr
) {
375 if (! about_en_vue
) {
376 sprintf(txt
, "%s %s", th_name
, th_release
);
377 WMSetLabelText(about_th1
, txt
);
378 WMSetLabelText(about_th2
, th_author
);
379 WMSetLabelText(about_th3
, th_email
);
380 WMSetLabelText(about_th4
, th_url
);
381 WMSetLabelText(about_th5
, th_comment
);
382 sprintf(txt
, "Faktory: %dx%d (panels: %d Buttons: %d)", backXPM
.attributes
.width
, backXPM
.attributes
.height
, panels
, but_max
);
383 WMSetLabelText(about_th6
, txt
);
385 WMRealizeWidget(aboutwin
);
386 WMMapSubwidgets(aboutwin
);
387 WMMapWidget(aboutwin
);
390 WMCloseWindow(aboutwin
);
391 about_en_vue
= FALSE
;
395 /* --------------------------------------------------- */
397 void db_prev_cb(WMWidget
*self
, void *data
) {
400 if (cur_cdmode
== WM_CDM_EJECTED
) return;
402 strcpy(cd
->artist
, WMGetTextFieldText(db_artist
));
403 strcpy(cd
->cdname
, WMGetTextFieldText(db_title
));
404 if (strlen(WMGetTextFieldText(db_track
)) > 0) {
405 cd
->trk
[db_curtrack
- 1].songname
= malloc(strlen(WMGetTextFieldText(db_track
)) + 1);
406 strcpy(cd
->trk
[db_curtrack
- 1].songname
, WMGetTextFieldText(db_track
));
411 if (db_curtrack
== 1) db_curtrack
= cur_ntracks
;
413 sprintf(txt
, "Tk %d:", db_curtrack
);
414 WMSetLabelText(db_tlabel
, txt
);
416 if (cd
->trk
[db_curtrack
- 1].songname
!= NULL
) {
417 sprintf(txt
, cd
->trk
[db_curtrack
- 1].songname
);
421 WMSetTextFieldText(db_track
, txt
);
423 if (cd
->trk
[db_curtrack
- 1].avoid
) {
424 WMSetButtonSelected(db_avoid
, TRUE
);
426 WMSetButtonSelected(db_avoid
, FALSE
);
429 WMRealizeWidget(dbwin
);
432 void db_next_cb(WMWidget
*self
, void *data
) {
435 if (cur_cdmode
== WM_CDM_EJECTED
) return;
437 strcpy(cd
->artist
, WMGetTextFieldText(db_artist
));
438 strcpy(cd
->cdname
, WMGetTextFieldText(db_title
));
439 if (strlen(WMGetTextFieldText(db_track
)) > 0) {
440 cd
->trk
[db_curtrack
- 1].songname
= malloc(strlen(WMGetTextFieldText(db_track
)) + 1);
441 strcpy(cd
->trk
[db_curtrack
- 1].songname
, WMGetTextFieldText(db_track
));
446 if (db_curtrack
== cur_ntracks
) db_curtrack
= 1;
448 sprintf(txt
, "Tk %d:", db_curtrack
);
449 WMSetLabelText(db_tlabel
, txt
);
451 if (cd
->trk
[db_curtrack
- 1].songname
!= NULL
) {
452 sprintf(txt
, cd
->trk
[db_curtrack
- 1].songname
);
456 WMSetTextFieldText(db_track
, txt
);
458 if (cd
->trk
[db_curtrack
- 1].avoid
) {
459 WMSetButtonSelected(db_avoid
, TRUE
);
461 WMSetButtonSelected(db_avoid
, FALSE
);
464 WMRealizeWidget(dbwin
);
467 void db_avoid_cb(WMWidget
*self
, void *data
) {
468 if (cur_cdmode
== WM_CDM_EJECTED
) return;
469 if (cd
->trk
[db_curtrack
- 1].avoid
) {
470 cd
->trk
[db_curtrack
- 1].avoid
= 0;
472 cd
->trk
[db_curtrack
- 1].avoid
= 1;
478 void db_playauto_cb(WMWidget
*self
, void *data
) {
479 if (cur_cdmode
== WM_CDM_EJECTED
) return;
489 void db_volume_cb(WMWidget
*self
, void *data
) {
490 if (cur_cdmode
!= WM_CDM_EJECTED
) {
491 cd
->volume
= WMGetSliderValue(self
);
495 cd_volume(volume
, 10, max_volume
);
497 WMSetSliderMinValue(b_volume
, min_volume
);
498 WMSetSliderMaxValue(b_volume
, max_volume
);
499 WMSetSliderValue(b_volume
, volume
);
503 void create_db_window(WMScreen
*scr
) {
506 WMWidget
*lb1
, *lb2
, *lb3
;
508 dbwin
= WMCreateWindow(scr
, "AScd-db");
509 WMSetWindowCloseAction(dbwin
, close_dbwin
, NULL
);
510 WMSetWindowTitle(dbwin
, "AScd database edition");
511 WMResizeWidget(dbwin
, 350, 220);
514 fr
= WMCreateFrame(dbwin
);
515 WMMoveWidget(fr
, 10, 05);
516 WMResizeWidget(fr
, 330, 105);
517 WMSetFrameTitle(fr
, "CD info:");
519 lb1
= WMCreateLabel(dbwin
);
520 WMResizeWidget(lb1
, 40, 20);
521 WMMoveWidget(lb1
, 16, 20);
522 WMSetLabelText(lb1
, "Artist:");
524 db_artist
= WMCreateTextField(dbwin
);
525 WMMoveWidget(db_artist
, 70, 20);
526 WMResizeWidget(db_artist
, 255, 20);
528 lb2
= WMCreateLabel(dbwin
);
529 WMResizeWidget(lb2
, 40, 20);
530 WMMoveWidget(lb2
, 16, 40);
531 WMSetLabelText(lb2
, "Title:");
533 db_title
= WMCreateTextField(dbwin
);
534 WMMoveWidget(db_title
, 70, 40);
535 WMResizeWidget(db_title
, 255, 20);
537 db_playauto
= WMCreateButton(dbwin
, WBTSwitch
);
538 WMMoveWidget(db_playauto
, 70, 65);
539 WMResizeWidget(db_playauto
, 255, 20);
540 WMSetButtonText(db_playauto
, "play this CD automatically (WorkMan)");
541 WMSetButtonAction(db_playauto
, db_playauto_cb
, NULL
);
543 lb3
= WMCreateLabel(dbwin
);
544 WMResizeWidget(lb3
, 54, 20);
545 WMMoveWidget(lb3
, 16, 85);
546 WMSetLabelText(lb3
, "Volume:");
548 db_volume
= WMCreateSlider(dbwin
);
549 WMResizeWidget(db_volume
, 255, 15);
550 WMMoveWidget(db_volume
, 70, 88);
551 WMSetSliderKnobThickness(db_volume
, 22);
552 WMSetSliderAction(db_volume
, db_volume_cb
, NULL
);
556 fr2
= WMCreateFrame(dbwin
);
557 WMMoveWidget(fr2
, 10, 115);
558 WMResizeWidget(fr2
, 330, 65);
559 WMSetFrameTitle(fr2
, "Track info:");
561 db_tlabel
= WMCreateLabel(dbwin
);
562 WMResizeWidget(db_tlabel
, 54, 20);
563 WMMoveWidget(db_tlabel
, 16, 130);
564 sprintf(txt
, "Track %d:", db_curtrack
);
565 WMSetLabelText(db_tlabel
, txt
);
567 db_track
= WMCreateTextField(dbwin
);
568 WMMoveWidget(db_track
, 70, 130);
569 WMResizeWidget(db_track
, 255, 20);
571 db_avoid
= WMCreateButton(dbwin
, WBTSwitch
);
572 WMMoveWidget(db_avoid
, 70, 152);
573 WMResizeWidget(db_avoid
, 235, 20);
574 WMSetButtonText(db_avoid
, "don't play this track");
575 WMSetButtonAction(db_avoid
, db_avoid_cb
, NULL
);
579 db_prev
= WMCreateButton(dbwin
, 0);
580 WMResizeWidget(db_prev
, 110, 25);
581 WMMoveWidget(db_prev
, 10, 190);
582 WMSetButtonText(db_prev
, "Previous Track");
583 WMSetButtonAction(db_prev
, db_prev_cb
, NULL
);
585 db_next
= WMCreateButton(dbwin
, 0);
586 WMResizeWidget(db_next
, 110, 25);
587 WMMoveWidget(db_next
, 125, 190);
588 WMSetButtonText(db_next
, "Next Track");
589 WMSetButtonAction(db_next
, db_next_cb
, NULL
);
591 db_close
= WMCreateButton(dbwin
, 0);
592 WMResizeWidget(db_close
, 55, 25);
593 WMMoveWidget(db_close
, 285, 190);
594 WMSetButtonText(db_close
, "Close");
595 WMSetButtonAction(db_close
, close_dbwin
, NULL
);
597 WMRealizeWidget(dbwin
);
600 void db_window(WMScreen
*scr
) {
604 if (cur_cdmode
== WM_CDM_EJECTED
) return;
607 if (db_curtrack
< 1) db_curtrack
= 1;
610 if (cd
->artist
!= NULL
) strcpy(txt
, cd
->artist
);
611 else strcpy(txt
, "");
612 WMSetTextFieldText(db_artist
, txt
);
614 if (cd
->cdname
!= NULL
) strcpy(txt
, cd
->cdname
);
615 else strcpy(txt
, "");
616 WMSetTextFieldText(db_title
, txt
);
619 WMSetButtonSelected(db_playauto
, TRUE
);
621 WMSetButtonSelected(db_playauto
, TRUE
);
624 if (cd
->trk
[db_curtrack
- 1].songname
!= NULL
) {
625 sprintf(txt
, cd
->trk
[db_curtrack
- 1].songname
);
629 WMSetTextFieldText(db_track
, txt
);
631 if (cd
->trk
[db_curtrack
- 1].avoid
) {
632 WMSetButtonSelected(db_avoid
, TRUE
);
634 WMSetButtonSelected(db_avoid
, FALSE
);
637 WMSetSliderMinValue(db_volume
, min_volume
);
638 WMSetSliderMaxValue(db_volume
, max_volume
);
639 if (cd
->volume
> 0) WMSetSliderValue(db_volume
, cd
->volume
);
640 else WMSetSliderValue(db_volume
, max_volume
);
642 WMRealizeWidget(dbwin
);
643 WMMapSubwidgets(dbwin
);
647 WMCloseWindow(dbwin
);
652 void db_cb(WMWidget
*self
, void *data
) {
654 sprintf(txt
, "Tk %d:", db_curtrack
);
655 WMSetLabelText(db_tlabel
, txt
);
656 /*WMRealizeWidget(dbwin);*/
660 void about_cb(WMWidget
*self
, void *data
) {
664 void create_big_window(WMScreen
*scr
) {
665 WMWidget
*fr
, *fr3
, *fr4
, *fr5
;
666 WMWidget
*lb1
, *lb2
, *lb3
, *lb4
, *lb6
;
668 win
= WMCreateWindow(scr
, "AScd");
669 WMSetWindowCloseAction(win
, close_win
, NULL
);
670 WMSetWindowTitle(win
, "AScd");
671 WMResizeWidget(win
, 320, 370);
673 b_title
= WMCreateButton(win
, 0);
674 WMResizeWidget(b_title
, 300, 40);
675 WMMoveWidget(b_title
, 10, 5);
676 WMSetButtonText(b_title
, "1\n2");
677 WMSetButtonAction(b_title
, db_cb
, NULL
);
679 pop
= WMCreatePopUpButton(win
);
680 WMResizeWidget(pop
, 300, 20);
681 WMMoveWidget(pop
, 10, 50);
682 WMSetPopUpButtonPullsDown(pop
, True
);
683 WMSetPopUpButtonText(pop
, "Tracks");
684 WMAddPopUpButtonItem(pop
, "1");
685 WMSetPopUpButtonAction(pop
, track_select
, NULL
);
687 fr
= WMCreateFrame(win
);
688 WMMoveWidget(fr
, 10, 75);
689 WMResizeWidget(fr
, 110, 140);
690 WMSetFrameTitle(fr
, "Playback:");
692 b_autoplay
= WMCreateButton(win
, WBTSwitch
);
693 WMMoveWidget(b_autoplay
, 20, 95);
694 WMResizeWidget(b_autoplay
, 90, 20);
695 WMSetButtonText(b_autoplay
, "autoplay");
696 WMSetButtonAction(b_autoplay
, autoplay_cb
, NULL
);
698 b_autorepeat
= WMCreateButton(win
, WBTSwitch
);
699 WMMoveWidget(b_autorepeat
, 20, 115);
700 WMResizeWidget(b_autorepeat
, 90, 20);
701 WMSetButtonText(b_autorepeat
, "autorepeat");
702 WMSetButtonAction(b_autorepeat
, autorepeat_cb
, NULL
);
704 b_ignoreavoid
= WMCreateButton(win
, WBTSwitch
);
705 WMMoveWidget(b_ignoreavoid
, 20, 135);
706 WMResizeWidget(b_ignoreavoid
, 90, 20);
707 WMSetButtonText(b_ignoreavoid
, "apply skips");
708 WMSetButtonAction(b_ignoreavoid
, ignoreavoid_cb
, NULL
);
710 lb6
= WMCreateLabel(win
);
711 WMResizeWidget(lb6
, 80, 20);
712 WMMoveWidget(lb6
, 15, 165);
713 WMSetLabelText(lb6
, "CD Device:");
715 b_device
= WMCreateTextField(win
);
716 WMResizeWidget(b_device
, 85, 20);
717 WMMoveWidget(b_device
, 20, 185);
720 fr3
= WMCreateFrame(win
);
721 WMMoveWidget(fr3
, 130, 75);
722 WMResizeWidget(fr3
, 180, 140);
723 WMSetFrameTitle(fr3
, "Display:");
725 b_scroll
= WMCreateButton(win
, WBTSwitch
);
726 WMMoveWidget(b_scroll
, 140, 95);
727 WMResizeWidget(b_scroll
, 130, 20);
728 WMSetButtonText(b_scroll
, "scroll song names");
729 WMSetButtonAction(b_scroll
, scroll_cb
, NULL
);
731 b_artist
= WMCreateButton(win
, WBTSwitch
);
732 WMMoveWidget(b_artist
, 140, 115);
733 WMResizeWidget(b_artist
, 130, 20);
734 WMSetButtonText(b_artist
, "add artist name");
735 WMSetButtonAction(b_artist
, artist_cb
, NULL
);
737 b_upper
= WMCreateButton(win
, WBTSwitch
);
738 WMMoveWidget(b_upper
, 140, 135);
739 WMResizeWidget(b_upper
, 130, 20);
740 WMSetButtonText(b_upper
, "force uppercase");
741 WMSetButtonAction(b_upper
, upper_cb
, NULL
);
743 lb4
= WMCreateLabel(win
);
744 WMResizeWidget(lb4
, 80, 20);
745 WMMoveWidget(lb4
, 135, 165);
746 WMSetLabelText(lb4
, "Theme:");
748 pop2
= WMCreatePopUpButton(win
);
749 WMResizeWidget(pop2
, 160, 20);
750 WMMoveWidget(pop2
, 140, 185);
751 WMSetPopUpButtonText(pop2
, theme
);
752 WMAddPopUpButtonItem(pop2
, "1");
753 WMSetPopUpButtonAction(pop2
, theme_pick
, NULL
);
755 b_help
= WMCreateButton(win
, 0);
756 WMResizeWidget(b_help
, 80, 18);
757 WMMoveWidget(b_help
, 220, 165);
758 WMSetButtonText(b_help
, "Quick Ref.");
759 WMSetButtonAction(b_help
, help_cb
, NULL
);
763 fr4
= WMCreateFrame(win
);
764 WMMoveWidget(fr4
, 10, 220);
765 WMResizeWidget(fr4
, 300, 80);
766 WMSetFrameTitle(fr4
, "Volume & Misc:");
768 b_minvol
= WMCreateTextField(win
);
769 WMResizeWidget(b_minvol
, 30, 20);
770 WMMoveWidget(b_minvol
, 20, 240);
772 b_volume
= WMCreateSlider(win
);
773 WMResizeWidget(b_volume
, 220, 20);
774 WMMoveWidget(b_volume
, 50, 240);
775 WMSetSliderKnobThickness(b_volume
, 22);
776 WMSetSliderAction(b_volume
, volume_cb
, NULL
);
778 b_maxvol
= WMCreateTextField(win
);
779 WMResizeWidget(b_maxvol
, 30, 20);
780 WMMoveWidget(b_maxvol
, 270, 240);
782 lb1
= WMCreateLabel(win
);
783 WMResizeWidget(lb1
, 40, 20);
784 WMMoveWidget(lb1
, 15, 270);
785 WMSetLabelText(lb1
, "Muted");
787 b_mutedvol
= WMCreateTextField(win
);
788 WMResizeWidget(b_mutedvol
, 30, 20);
789 WMMoveWidget(b_mutedvol
, 65, 270);
791 lb2
= WMCreateLabel(win
);
792 WMResizeWidget(lb2
, 70, 20);
793 WMMoveWidget(lb2
, 105, 270);
794 WMSetLabelText(lb2
, "Cue Time");
796 b_cuetime
= WMCreateTextField(win
);
797 WMResizeWidget(b_cuetime
, 25, 20);
798 WMMoveWidget(b_cuetime
, 180, 270);
800 lb3
= WMCreateLabel(win
);
801 WMResizeWidget(lb3
, 33, 20);
802 WMMoveWidget(lb3
, 225, 270);
803 WMSetLabelText(lb3
, "Fade");
805 b_fadestep
= WMCreateTextField(win
);
806 WMResizeWidget(b_fadestep
, 25, 20);
807 WMMoveWidget(b_fadestep
, 275, 270);
809 /* the counter modes */
811 fr5
= WMCreateFrame(win
);
812 WMMoveWidget(fr5
, 10, 305);
813 WMResizeWidget(fr5
, 190, 60);
814 WMSetFrameTitle(fr5
, "Counter Mode:");
816 b_mode1
= WMCreateButton(win
, WBTRadio
);
817 WMMoveWidget(b_mode1
, 20, 320);
818 WMResizeWidget(b_mode1
, 55, 20);
819 WMSetButtonText(b_mode1
, "Track");
820 WMSetButtonAction(b_mode1
, mode1_cb
, NULL
);
822 b_mode2
= WMCreateButton(win
, WBTRadio
);
823 WMMoveWidget(b_mode2
, 20, 340);
824 WMResizeWidget(b_mode2
, 55, 20);
825 WMSetButtonText(b_mode2
, "CD");
826 WMSetButtonAction(b_mode2
, mode2_cb
, NULL
);
828 b_mode3
= WMCreateButton(win
, WBTRadio
);
829 WMMoveWidget(b_mode3
, 90, 320);
830 WMResizeWidget(b_mode3
, 85, 20);
831 WMSetButtonText(b_mode3
, "Elapsed");
832 WMSetButtonAction(b_mode3
, mode3_cb
, NULL
);
834 b_mode4
= WMCreateButton(win
, WBTRadio
);
835 WMMoveWidget(b_mode4
, 90, 340);
836 WMResizeWidget(b_mode4
, 85, 20);
837 WMSetButtonText(b_mode4
, "Remaining");
838 WMSetButtonAction(b_mode4
, mode4_cb
, NULL
);
840 /* the global buttons */
842 b_save
= WMCreateButton(win
, 0);
843 WMResizeWidget(b_save
, 50, 25);
844 WMMoveWidget(b_save
, 205, 340);
845 WMSetButtonText(b_save
, "Save");
846 WMSetButtonAction(b_save
, save_cb
, NULL
);
848 b_about
= WMCreateButton(win
, 0);
849 WMResizeWidget(b_about
, 50, 25);
850 WMMoveWidget(b_about
, 205, 310);
851 WMSetButtonText(b_about
, "Info");
852 WMSetButtonAction(b_about
, about_cb
, NULL
);
854 b_save
= WMCreateButton(win
, 0);
855 WMResizeWidget(b_save
, 50, 25);
856 WMMoveWidget(b_save
, 260, 310);
857 WMSetButtonText(b_save
, "Quit");
858 WMSetButtonAction(b_save
, quit_ascd
, NULL
);
860 b_close
= WMCreateButton(win
, 0);
861 WMResizeWidget(b_close
, 50, 25);
862 WMMoveWidget(b_close
, 260, 340);
863 WMSetButtonText(b_close
, "Close");
864 WMSetButtonAction(b_close
, close_win
, NULL
);
866 /* finished, draw everything */
868 WMRealizeWidget(win
);
871 WMMapSubwidgets(win);
876 void update_track() {
882 if (cur_cdmode
!= WM_CDM_EJECTED
) {
884 if (cd
->artist
!= NULL
) {
885 strcpy(txt
, cd
->artist
);
886 if (strcmp(txt
, "") == 0) strcpy(txt
, "unknown artist");
888 strcpy(txt
, "unknown artist");
893 if (cd
->cdname
!= NULL
) {
894 strcpy(txt2
, cd
->cdname
);
895 if (strcmp(txt2
, "") == 0) strcpy(txt2
, "unknown album");
897 strcpy(txt2
, "unknown album");
901 WMSetButtonText(b_title
, txt
);
903 for (i
= WMGetPopUpButtonNumberOfItems(pop
); i
>= 0; i
--) {
904 WMRemovePopUpButtonItem(pop
, i
);
907 for (i
= 0; i
< cur_ntracks
; i
++) {
908 sprintf(txt
, "%2d ", i
+ 1);
909 if (cd
->trk
[i
].songname
!= NULL
) strcat(txt
, cd
->trk
[i
].songname
);
910 WMAddPopUpButtonItem(pop
, txt
);
913 pistes
= cur_ntracks
;
915 if (cur_track
>= 1) {
916 if (cd
->trk
[cur_track
- 1].songname
!= NULL
) {
917 sprintf(txt
, "%s", cd
->trk
[cur_track
- 1].songname
);
918 if (strcmp(txt
, "") == 0) sprintf(txt
, "Track %d", cur_track
);
919 WMSetPopUpButtonText(pop
, txt
);
921 sprintf(txt
, "Track %d", cur_track
);
922 WMSetPopUpButtonText(pop
, txt
);
925 WMSetPopUpButtonText(pop
, "Track 1");
929 WMSetButtonText(b_title
, "No CD in drive\nor the tray is not loaded");
934 void big_window(WMScreen
*scr
) {
938 struct dirent
*dir_pt
;
942 /*if (cur_cdmode == WM_CDM_EJECTED) return;*/
946 sprintf(txt
, "%d", cue_time
);
947 WMSetTextFieldText(b_cuetime
, txt
);
948 sprintf(txt
, "%d", fade_step
);
949 WMSetTextFieldText(b_fadestep
, txt
);
950 sprintf(txt
, "%d", min_volume
);
951 WMSetTextFieldText(b_minvol
, txt
);
952 sprintf(txt
, "%d", max_volume
);
953 WMSetTextFieldText(b_maxvol
, txt
);
954 sprintf(txt
, "%d", muted_volume
);
955 WMSetTextFieldText(b_mutedvol
, txt
);
957 WMSetTextFieldText(b_device
, cd_device
);
959 WMSetSliderMinValue(b_volume
, min_volume
);
960 WMSetSliderMaxValue(b_volume
, max_volume
);
961 WMSetSliderValue(b_volume
, volume
);
963 /* remove everything in the two popups */
965 for (i
= WMGetPopUpButtonNumberOfItems(pop
); i
>= 0; i
--) {
966 WMRemovePopUpButtonItem(pop
, i
);
969 for (i
= WMGetPopUpButtonNumberOfItems(pop2
); i
>= 0; i
--) {
970 WMRemovePopUpButtonItem(pop2
, i
);
973 /* update the database stuff. AScd 0.13: I deleted all this
974 stuff from this function as update_track() do the same! */
978 /* make the theme select menu */
980 sprintf(txt
, "%s/Themes", THDIR
);
981 if ((dir_fd
= opendir(txt
)) != NULL
) {
982 while((dir_pt
= readdir(dir_fd
)) != NULL
) {
983 if (dir_pt
->d_name
[0] != '.') {
984 WMAddPopUpButtonItem(pop2
, dir_pt
->d_name
);
989 WMSetPopUpButtonText(pop2
, theme
);
991 /* several options toggles */
994 WMSetButtonSelected(b_autoplay
, TRUE
);
996 WMSetButtonSelected(b_autoplay
, FALSE
);
1000 WMSetButtonSelected(b_autorepeat
, TRUE
);
1002 WMSetButtonSelected(b_autorepeat
, FALSE
);
1006 WMSetButtonSelected(b_scroll
, TRUE
);
1008 WMSetButtonSelected(b_scroll
, FALSE
);
1012 WMSetButtonSelected(b_artist
, TRUE
);
1014 WMSetButtonSelected(b_artist
, FALSE
);
1018 WMSetButtonSelected(b_ignoreavoid
, FALSE
);
1020 WMSetButtonSelected(b_ignoreavoid
, TRUE
);
1024 WMSetButtonSelected(b_upper
, TRUE
);
1026 WMSetButtonSelected(b_upper
, FALSE
);
1029 /* finally, the counter mode radio buttons */
1033 WMSetButtonSelected((b_mode1
), TRUE
);
1034 WMSetButtonSelected((b_mode2
), FALSE
);
1035 WMSetButtonSelected((b_mode3
), TRUE
);
1036 WMSetButtonSelected((b_mode4
), FALSE
);
1039 WMSetButtonSelected((b_mode1
), TRUE
);
1040 WMSetButtonSelected((b_mode2
), FALSE
);
1041 WMSetButtonSelected((b_mode4
), TRUE
);
1042 WMSetButtonSelected((b_mode3
), FALSE
);
1045 WMSetButtonSelected((b_mode2
), TRUE
);
1046 WMSetButtonSelected((b_mode1
), FALSE
);
1047 WMSetButtonSelected((b_mode3
), TRUE
);
1048 WMSetButtonSelected((b_mode4
), FALSE
);
1051 WMSetButtonSelected((b_mode2
), TRUE
);
1052 WMSetButtonSelected((b_mode1
), FALSE
);
1053 WMSetButtonSelected((b_mode4
), TRUE
);
1054 WMSetButtonSelected((b_mode3
), FALSE
);
1058 WMRealizeWidget(win
);
1059 WMMapSubwidgets(win
);
1063 muted_volume
= atoi(WMGetTextFieldText(b_mutedvol
));
1064 min_volume
= atoi(WMGetTextFieldText(b_minvol
));
1065 max_volume
= atoi(WMGetTextFieldText(b_maxvol
));
1066 cue_time
= atoi(WMGetTextFieldText(b_cuetime
));
1067 fade_step
= atoi(WMGetTextFieldText(b_fadestep
));