Debian Codegraph @

contrib/rplaytool-1.1/rplaytool_stubs.c

raw symbols SCIP
1 /*
2 * rplaytool_stubs.c - Notify and event callback function stubs.
3 * This file was generated by `gxv' from `rplaytool.G'.
4 */
5
6 /*
7 * Copyright (C) 1995 Mark Boyns <[email protected]>
8 *
9 * This file is part of rplaytool.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 #include <stdio.h>
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <xview/xview.h>
30 #include <xview/panel.h>
31 #include <xview/textsw.h>
32 #include <xview/xv_xrect.h>
33 #include <xview/scrollbar.h>
34 #include "rplaytool_ui.h"
35 #include <sys/types.h>
36 #include <sys/errno.h>
37 #include <sys/stat.h>
38 #include <sys/time.h>
39 #include <dirent.h>
40 #include <unistd.h>
41 #include "rptp.h"
42 #include "misc.h"
43 #include "getopt.h"
44
45 static char *rplaytool_version = "1.1";
46
47 #define SOUNDLIST_MESSAGE "Retrieving sound list..."
48
49 void talk ();
50 Notify_value process ();
51 static Notify_value timer_update (/* client, which */);
52
53 /*
54 * Global object definitions.
55 */
56 rplaytool_w_objects *Rplaytool_w;
57 rplaytool_s_objects *Rplaytool_s;
58 rplaytool_f_objects *Rplaytool_f;
59
60 typedef struct
61 {
62 int id;
63 int playlist;
64 }
65 SPOOL;
66
67 static int spool_size = 0;
68 static int soundlist_size = 0;
69 static int disklist_size = 0;
70 static Xv_opaque curr_soundlist;
71
72 static char *rptp_host = NULL;
73 static char *playlist1_file = NULL;
74 static char *playlist2_file = NULL;
75 static char *playlist3_file = NULL;
76 static char *playlist4_file = NULL;
77 static int show_sounds = 0;
78 static int use_disk_sounds = 0;
79 static int use_server_sounds = 1;
80 static int scan_playlist_files = 1;
81 static int scan_playlist_interval = 5; /* seconds */
82 static int countdown = 0;
83 int initial_delay = -1;
84
85 static struct option longopts[] =
86 {
87 {"delay", required_argument, NULL, 4},
88 {"disk-sounds", no_argument, NULL, 3},
89 {"dir", required_argument, NULL, 'd'},
90 {"help", no_argument, NULL, 1},
91 {"host", required_argument, NULL, 'h'},
92 {"playlist1", required_argument, NULL, '1'},
93 {"playlist2", required_argument, NULL, '2'},
94 {"playlist3", required_argument, NULL, '3'},
95 {"playlist4", required_argument, NULL, '4'},
96 {"server-sounds", no_argument, NULL, 2},
97 {"sounds", no_argument, &show_sounds, 1},
98 {"version", no_argument, NULL, 'v'},
99 {NULL, 0, NULL, 0}
100 };
101
102 #ifdef MAIN
103
104 /*
105 * Instance XV_KEY_DATA key. An instance is a set of related
106 * user interface objects. A pointer to an object's instance
107 * is stored under this key in every object. This must be a
108 * global variable.
109 */
110 Attr_attribute INSTANCE;
111
112 main(argc, argv)
113 int argc;
114 char **argv;
115 {
116 int i, c;
117 char title[32];
118 char *disk_dir = NULL;
119 struct itimerval timer;
120 extern char *optarg;
121 extern int optind, opterr;
122
123 /*
124 * Initialize XView.
125 */
126 xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
127 INSTANCE = xv_unique_key();
128
129 rptp_host = rplay_default_host ();
130
131 while ((c = getopt_long (argc, argv, "h:1:2:3:4:", longopts, 0)) != -1)
132 {
133 switch (c)
134 {
135 case 0:
136 /* getopt has processed a long-named option -- do nothing */
137 break;
138
139 case 1: /* --help */
140 usage ();
141
142 case 2: /* --server-sounds */
143 use_server_sounds++;
144 use_disk_sounds = 0;
145 break;
146
147 case 3: /* --disk-sounds */
148 use_server_sounds = 0;
149 use_disk_sounds++;
150 break;
151
152 case 4: /* --delay */
153 initial_delay = atoi (optarg);
154 break;
155
156 case 'd':
157 disk_dir = optarg;
158 use_server_sounds = 0;
159 use_disk_sounds++;
160 show_sounds++;
161 break;
162
163 case 'h':
164 rptp_host = optarg;
165 break;
166
167 case '1':
168 playlist1_file = optarg;
169 break;
170
171 case '2':
172 playlist2_file = optarg;
173 break;
174
175 case '3':
176 playlist3_file = optarg;
177 break;
178
179 case '4':
180 playlist4_file = optarg;
181 break;
182
183 case 'v':
184 printf ("rplaytool %s\n", rplaytool_version);
185 exit (0);
186
187 default:
188 fprintf (stderr, "Try `rplaytool --help' for more information.\n");
189 exit (1);
190 }
191 }
192
193 /*
194 * Initialize user interface components.
195 * Do NOT edit the object initializations by hand.
196 */
197 Rplaytool_w = rplaytool_w_objects_initialize(NULL, NULL);
198 Rplaytool_s = rplaytool_s_objects_initialize(NULL, Rplaytool_w->w);
199 Rplaytool_f = rplaytool_f_objects_initialize(NULL, Rplaytool_w->w);
200
201 /* Initialize the playlists. */
202 for (i = 0; i < NUMBER_OF_PLAYLISTS; i++)
203 {
204 do_playlist_init (i);
205 }
206 playlist[0].list = Rplaytool_s->playlist1;
207 playlist[1].list = Rplaytool_s->playlist2;
208 playlist[2].list = Rplaytool_s->playlist3;
209 playlist[3].list = Rplaytool_s->playlist4;
210 if (playlist1_file)
211 {
212 curr_playlist = 0;
213 file_load_file (playlist1_file);
214 }
215 if (playlist2_file)
216 {
217 curr_playlist = 1;
218 file_load_file (playlist2_file);
219 }
220 if (playlist3_file)
221 {
222 curr_playlist = 2;
223 file_load_file (playlist3_file);
224 }
225 if (playlist4_file)
226 {
227 curr_playlist = 3;
228 file_load_file (playlist4_file);
229 }
230
231 curr_playlist = 0;
232 curr_soundlist = Rplaytool_s->soundlist;
233
234 /* Create the icons. */
235 for (i = 0; i < NUMBER_OF_ICONS; i++)
236 {
237 icons[i].image = (Server_image) xv_create (NULL, SERVER_IMAGE,
238 XV_WIDTH, 16,
239 XV_HEIGHT, 16,
240 SERVER_IMAGE_BITS, icons[i].bits,
241 NULL);
242 }
243
244 /* Update the frame title. */
245 sprintf (title, "rplaytool %s", rplaytool_version);
246 xv_set (Rplaytool_w->w, XV_LABEL, title, NULL);
247
248 /* Connect to the default RPTP server. */
249 client_id = getpid ();
250 talk (rptp_host);
251
252 /* Automatically show the "Sounds" popup. */
253 if (show_sounds)
254 {
255 if (use_server_sounds)
256 {
257 load_soundlist ();
258 }
259 else if (use_disk_sounds)
260 {
261 load_disklist (disk_dir ? disk_dir : 0);
262 }
263 xv_set(Rplaytool_s->s, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
264 xv_set(Rplaytool_s->s, XV_SHOW, TRUE, NULL);
265 xv_set(Rplaytool_s->soundsource, PANEL_VALUE, use_server_sounds ? 0 : 1, NULL);
266 }
267
268
269 /* */
270 timer.it_value.tv_sec = 1;
271 timer.it_value.tv_usec = 0;
272 timer.it_interval.tv_sec = 1;
273 timer.it_interval.tv_usec = 0;
274 notify_set_itimer_func (Rplaytool_w->w, timer_update, ITIMER_REAL, &timer, NULL);
275
276 /*
277 * Turn control over to XView.
278 */
279 xv_main_loop(Rplaytool_w->w);
280
281 exit(0);
282 }
283
284 #endif
285
286 static Notify_value
287 timer_update (client, which)
288 Notify_client client;
289 int which;
290 {
291 static int count;
292 int i;
293
294 count++;
295
296 if (scan_playlist_files)
297 {
298 if ((count % scan_playlist_interval) == 0)
299 {
300 playlist_scan ();
301 }
302 }
303
304 for (i = 0; i < NUMBER_OF_PLAYLISTS; i++)
305 {
306 if (playlist[i].delay >= 0)
307 {
308 if (playlist[i].delay == 0)
309 {
310 play_playlist (i, FALSE);
311 }
312 else
313 {
314 if (countdown)
315 {
316 char line[RPTP_MAX_LINE];
317 sprintf (line, "%d.au", playlist[i].delay);
318 do_rptp_play (line, NULL);
319 }
320 }
321
322 playlist[i].delay--;
323 }
324 }
325 }
326
327 usage ()
328 {
329 printf ("\nrplaytool %s\n\n", rplaytool_version);
330 printf ("usage: rplaytool [options]\n");
331
332 printf ("--delay=N\n");
333 printf ("\tDelay N seconds before playing each sound in a playlist.\n");
334 printf ("\n");
335
336 printf ("--dir=DIR\n");
337 printf ("\tUse DIR as the default disk sounds directory.\n");
338 printf ("\tThis option implies `--disk-sounds' and `--sounds'.\n");
339 printf ("\n");
340
341 printf ("--disk-sounds\n");
342 printf ("\tDisplay disk sounds by default in the `Sounds' popup.\n");
343 printf ("\tThe default is server sounds.\n");
344 printf ("\n");
345
346 printf ("--help\n");
347 printf ("\tDisplay helpful information.\n");
348 printf ("\n");
349
350 printf ("--host=HOST, -h HOST\n");
351 printf ("\tSpecify the rplay host, default = %s.\n", rptp_host);
352 printf ("\n");
353
354 printf ("--playlist1=FILE, -1 FILE\n");
355 printf ("\tFILE used for playlist1.\n");
356 printf ("\n");
357
358 printf ("--playlist2=FILE, -2 FILE\n");
359 printf ("\tFILE used for playlist2.\n");
360 printf ("\n");
361
362 printf ("--playlist3=FILE, -3 FILE\n");
363 printf ("\tFILE used for playlist3.\n");
364 printf ("\n");
365
366 printf ("--playlist4=FILE, -4 FILE\n");
367 printf ("\tFILE used for playlist4.\n");
368 printf ("\n");
369
370 printf ("--server-sounds\n");
371 printf ("\tDisplay server sounds by default in the `Sounds' popup.\n");
372 printf ("\tThe is the default.\n");
373 printf ("\n");
374
375 printf ("--sounds\n");
376 printf ("\tAutomatically show the `Sounds' popup.\n");
377 printf ("\n");
378
379 printf ("--version\n");
380 printf ("\tPrint the rplaytool version and exit.\n");
381 printf ("\n");
382
383 exit (0);
384 }
385
386 Notify_value
387 process_write (client, fd)
388 Notify_client client;
389 int fd;
390 {
391 rptp_async_process (fd, RPTP_ASYNC_WRITE);
392 return NOTIFY_DONE;
393 }
394
395 Notify_value
396 process_read (client, fd)
397 Notify_client client;
398 int fd;
399 {
400 rptp_async_process (fd, RPTP_ASYNC_READ);
401 return NOTIFY_DONE;
402 }
403
404 Notify_client input_client = (Notify_client) 10101;
405 Notify_client output_client = (Notify_client) 20202;
406
407 void
408 enable_notify_write (fd)
409 int fd;
410 {
411 notify_set_output_func(output_client, process_write, fd);
412 }
413
414 void
415 disable_notify_write (fd)
416 int fd;
417 {
418 notify_set_output_func(output_client, NOTIFY_FUNC_NULL, fd);
419 }
420
421 void
422 talk (host)
423 char *host;
424 {
425 static int talking;
426 char buf[1024];
427
428 if (talking)
429 {
430 talking = 0;
431 notify_set_input_func(input_client, NOTIFY_FUNC_NULL, rptp_fd);
432 notify_set_output_func(output_client, NOTIFY_FUNC_NULL, rptp_fd);
433 rptp_close (rptp_fd);
434 rptp_fd = -1;
435 }
436
437 if (!host)
438 {
439 host = rplay_default_host ();
440 }
441
442 xv_set (Rplaytool_w->host, PANEL_VALUE, host, NULL);
443
444 sprintf (buf, "Connecting to %s...", host);
445 xv_set (Rplaytool_w->w, FRAME_LEFT_FOOTER, buf, NULL);
446
447 busy (Rplaytool_w->w, TRUE);
448 do_rptp_open (host);
449 busy (Rplaytool_w->w, FALSE);
450 if (rptp_fd < 0)
451 {
452 rptp_fd = -1;
453 notice (Rplaytool_w->w, NULL, NULL, "Connection to %s failed", host);
454 xv_set (Rplaytool_w->w, FRAME_LEFT_FOOTER, "Not Connected", NULL);
455 }
456 else
457 {
458 notify_set_input_func(input_client, process_read, rptp_fd);
459 talking++;
460 sprintf (buf, "Connected to %s", host);
461 xv_set (Rplaytool_w->w, FRAME_LEFT_FOOTER, buf, NULL);
462 }
463 }
464
465 void
466 process_input (fd, event, line)
467 int fd;
468 int event;
469 char *line;
470 {
471 int i, n, id, data_index = -1, data_id = -1, state = -1;
472 char buf[RPTP_MAX_LINE], *p, *client_data;
473 SPOOL *sp;
474
475 rptp_parse (line, 0);
476 p = rptp_parse (0, "id");
477 if (p)
478 {
479 id = atoi (p+1);
480 }
481
482 client_data = rptp_parse (0, "client-data");
483 if (client_data && *client_data)
484 {
485 n = sscanf (client_data, "%d %d %d", &state, &data_id, &data_index);
486 if (n != 3)
487 {
488 state = -1;
489 data_id = -1;
490 data_index = -1;
491 }
492 }
493
494 switch (event)
495 {
496 case RPTP_EVENT_CLOSE:
497 rptp_async_register (rptp_fd, RPTP_ASYNC_READ, NULL);
498 talk (NULL);
499 break;
500
501 case RPTP_EVENT_OK:
502 /* A playlist-play OK response. */
503 if (state == STATE_PLAY && data_index >= 0)
504 {
505 playlist[data_index].id = id;
506 busy (Rplaytool_s->s, FALSE);
507 }
508 break;
509
510 case RPTP_EVENT_ERROR:
511 /* A playlist-play ERROR response. */
512 if (state == STATE_PLAY && data_index >= 0)
513 {
514 busy (Rplaytool_s->s, FALSE);
515 }
516
517 switch (state)
518 {
519 case STATE_PLAY:
520 case STATE_PAUSE:
521 case STATE_CONTINUE:
522 notice (Rplaytool_w->w, NULL, NULL, rptp_parse (0, "error"));
523 break;
524
525 case STATE_STOP:
526 /* Stops may fail since the sound may finish before the command
527 arrives. Therefore, stop errors are ignored. */
528 break;
529 }
530 break;
531
532 case RPTP_EVENT_PLAY:
533 case RPTP_EVENT_PAUSE:
534 case RPTP_EVENT_CONTINUE:
535 {
536 char *sound_name;
537 int found = 0;
538 int use_icon;
539
540 sound_name = rptp_parse (0, "sound");
541 p = strrchr (sound_name, '/');
542 sound_name = p ? p+1 : sound_name;
543
544 if (event == RPTP_EVENT_CONTINUE || event == RPTP_EVENT_PLAY)
545 {
546 use_icon = ICON_PLAY + ((data_index >= 0) ? data_index+1 : 0);
547 }
548 else
549 {
550 use_icon = ICON_PAUSE + ((data_index >= 0) ? data_index+1 : 0);
551 }
552
553 sprintf (buf, "%s", sound_name);
554
555 n = (int) xv_get (Rplaytool_w->spool, PANEL_LIST_NROWS);
556 for (i = 0; i < n; i++)
557 {
558 sp = (SPOOL *) xv_get(Rplaytool_w->spool, PANEL_LIST_CLIENT_DATA, i);
559 if (sp->id == id)
560 {
561 xv_set (Rplaytool_w->spool,
562 PANEL_LIST_STRING, i, buf,
563 PANEL_LIST_GLYPH, i, icons[use_icon].image,
564 NULL);
565 found++;
566 break;
567 }
568 }
569
570 /* Insert a new sound. */
571 if (!found)
572 {
573 sp = (SPOOL *) malloc (sizeof (SPOOL));
574 sp->id = id;
575 sp->playlist = data_index;
576
577 xv_set (Rplaytool_w->spool,
578 PANEL_LIST_INSERT, spool_size,
579 PANEL_LIST_STRING, spool_size, buf,
580 PANEL_LIST_CLIENT_DATA, spool_size, sp,
581 PANEL_LIST_GLYPH, spool_size, icons[use_icon].image,
582 NULL);
583 spool_size++;
584 }
585
586 if (data_index >= 0)
587 {
588 playlist_update_icons (data_index);
589 }
590 }
591 break;
592
593 case RPTP_EVENT_DONE:
594 n = (int) xv_get (Rplaytool_w->spool, PANEL_LIST_NROWS);
595 for (i = 0; i < n; i++)
596 {
597 sp = (SPOOL *) xv_get(Rplaytool_w->spool, PANEL_LIST_CLIENT_DATA, i);
598 if (sp->id == id)
599 {
600 xv_set (Rplaytool_w->spool, PANEL_LIST_DELETE, i, NULL);
601 spool_size--;
602
603 if (data_id == client_id
604 && sp->playlist >= 0
605 && playlist[sp->playlist].id == id)
606 {
607 playlist[sp->playlist].id = -1;
608 if (playlist[sp->playlist].auto_play)
609 {
610 playlist[sp->playlist].curr++;
611 play_playlist (sp->playlist, TRUE);
612 }
613 }
614
615 free ((char *) sp);
616 break;
617 }
618 }
619 break;
620
621 case RPTP_EVENT_STATE:
622 {
623 int curr_volume, new_volume;
624 int nplaying, npaused;
625
626 curr_volume = (int) xv_get (Rplaytool_w->volume, PANEL_VALUE);
627 new_volume = atoi (rptp_parse (0, "volume"));
628 if (curr_volume != new_volume)
629 {
630 xv_set (Rplaytool_w->volume, PANEL_VALUE, new_volume, NULL);
631 }
632
633 nplaying = atoi (rptp_parse (0, "play"));
634 npaused = atoi (rptp_parse (0, "pause"));
635
636 if (nplaying && !npaused)
637 {
638 xv_set (Rplaytool_w->pause, PANEL_INACTIVE, FALSE, NULL);
639 xv_set (Rplaytool_w->cont, PANEL_INACTIVE, TRUE, NULL);
640 xv_set (Rplaytool_w->stop, PANEL_INACTIVE, FALSE, NULL);
641 }
642 else if (!nplaying && npaused)
643 {
644 xv_set (Rplaytool_w->pause, PANEL_INACTIVE, TRUE, NULL);
645 xv_set (Rplaytool_w->cont, PANEL_INACTIVE, FALSE, NULL);
646 xv_set (Rplaytool_w->stop, PANEL_INACTIVE, FALSE, NULL);
647 }
648 else if (nplaying && npaused)
649 {
650 xv_set (Rplaytool_w->pause, PANEL_INACTIVE, FALSE, NULL);
651 xv_set (Rplaytool_w->cont, PANEL_INACTIVE, FALSE, NULL);
652 xv_set (Rplaytool_w->stop, PANEL_INACTIVE, FALSE, NULL);
653 }
654 else
655 {
656 xv_set (Rplaytool_w->pause, PANEL_INACTIVE, TRUE, NULL);
657 xv_set (Rplaytool_w->cont, PANEL_INACTIVE, TRUE, NULL);
658 xv_set (Rplaytool_w->stop, PANEL_INACTIVE, TRUE, NULL);
659 }
660 }
661 break;
662
663 case RPTP_EVENT_OTHER:
664 if (strcmp (line, ".") == 0)
665 {
666 xv_set (Rplaytool_s->soundlist, XV_SHOW, TRUE, NULL);
667 xv_set (Rplaytool_s->s, FRAME_LEFT_FOOTER, "", NULL);
668 busy (Rplaytool_s->s, FALSE);
669 }
670 else
671 {
672 xv_set (Rplaytool_s->soundlist,
673 PANEL_LIST_INSERT, soundlist_size,
674 PANEL_LIST_STRING, soundlist_size, rptp_parse (0, "sound"),
675 PANEL_LIST_GLYPH, soundlist_size, icons[ICON_SOUND].image,
676 NULL);
677 soundlist_size++;
678
679 if ((soundlist_size % 50) == 0)
680 {
681 sprintf (buf, "%s%d", SOUNDLIST_MESSAGE, soundlist_size);
682 xv_set (Rplaytool_s->s, FRAME_LEFT_FOOTER, buf, NULL);
683 }
684 }
685 break;
686 }
687 }
688
689 load_soundlist ()
690 {
691 busy (Rplaytool_s->s, TRUE);
692 xv_set (Rplaytool_s->s, FRAME_LEFT_FOOTER, SOUNDLIST_MESSAGE, NULL);
693 xv_set (Rplaytool_s->soundlist,
694 PANEL_LIST_DELETE_ROWS, 0,
695 (int) xv_get (Rplaytool_s->soundlist, PANEL_LIST_NROWS), NULL);
696 xv_set (Rplaytool_s->soundlist, XV_SHOW, FALSE, NULL);
697 soundlist_size = 0;
698 do_rptp_sounds ();
699
700 xv_set(Rplaytool_s->controls9, XV_SHOW, TRUE, NULL); /* hack */
701 curr_soundlist = Rplaytool_s->soundlist;
702
703 }
704
705 load_disklist (newdir)
706 char *newdir;
707 {
708 char cwd[MAXPATHLEN];
709 char *p;
710 DIR *dir;
711 struct dirent *dp;
712 struct stat st;
713 int n;
714 Scrollbar scrollbar;
715
716 busy (Rplaytool_s->s, TRUE);
717
718 if (newdir)
719 {
720 chdir (newdir);
721 }
722
723 getcwd (cwd, sizeof (cwd));
724
725 dir = opendir (".");
726 if (dir == NULL)
727 {
728 exit (1);
729 }
730
731 xv_set (Rplaytool_s->disklist,
732 PANEL_LIST_DELETE_ROWS, 0,
733 (int) xv_get (Rplaytool_s->disklist, PANEL_LIST_NROWS),
734 NULL);
735
736 xv_set (Rplaytool_s->disklist, XV_SHOW, FALSE, NULL);
737
738 disklist_size = 0;
739 /* Put `..' first. */
740 xv_set (Rplaytool_s->disklist,
741 PANEL_LIST_INSERT, disklist_size,
742 PANEL_LIST_STRING, disklist_size, "..",
743 PANEL_LIST_CLIENT_DATA, disklist_size, 1, /* a directory */
744 PANEL_LIST_GLYPH, disklist_size, icons[ICON_DIRECTORY].image,
745 NULL);
746 disklist_size++;
747
748 for (;;)
749 {
750 dp = readdir (dir);
751 if (dp == NULL)
752 {
753 closedir (dir);
754 break;
755 }
756 else if (strcmp (dp->d_name, ".") == 0
757 || strcmp (dp->d_name, "..") == 0)
758 {
759 continue;
760 }
761 else
762 {
763 p = strrchr (dp->d_name, '.');
764 stat (dp->d_name, &st);
765
766 if (S_ISDIR (st.st_mode))
767 {
768 xv_set (Rplaytool_s->disklist,
769 PANEL_LIST_INSERT, disklist_size,
770 PANEL_LIST_STRING, disklist_size, dp->d_name,
771 PANEL_LIST_CLIENT_DATA, disklist_size, 1, /* a directory */
772 PANEL_LIST_GLYPH, disklist_size, icons[ICON_DIRECTORY].image,
773 NULL);
774 disklist_size++;
775 }
776 else if (p && (strcmp (p, ".au") == 0
777 || strcmp (p, ".snd") == 0
778 || strcmp (p, ".wav") == 0
779 || strcmp (p, ".aiff") == 0
780 || strcmp (p, ".voc") == 0
781 || strcmp (p, ".ub") == 0
782 || strcmp (p, ".ul") == 0
783 || strcmp (p, ".g721") == 0
784 || strcmp (p, ".g723_3") == 0
785 || strcmp (p, ".g723_5") == 0))
786 {
787 xv_set (Rplaytool_s->disklist,
788 PANEL_LIST_INSERT, disklist_size,
789 PANEL_LIST_STRING, disklist_size, dp->d_name,
790 PANEL_LIST_CLIENT_DATA, disklist_size, 0, /* a file */
791 PANEL_LIST_GLYPH, disklist_size, icons[ICON_SOUND].image,
792 NULL);
793 disklist_size++;
794 }
795 }
796 }
797
798 scrollbar = (Scrollbar) xv_get (Rplaytool_s->disklist, PANEL_LIST_SCROLLBAR);
799 xv_set (scrollbar, SCROLLBAR_VIEW_START, 0, NULL);
800
801 xv_set (Rplaytool_s->disklist, XV_SHOW, TRUE, NULL);
802
803 xv_set (Rplaytool_s->directory, PANEL_VALUE, cwd, NULL);
804
805 xv_set(Rplaytool_s->controls7, XV_SHOW, TRUE, NULL); /* hack */
806
807 curr_soundlist = Rplaytool_s->disklist;
808
809 busy (Rplaytool_s->s, FALSE);
810 }
811
812 /*
813 * Notify callback function for `volume'.
814 */
815 void
816 do_volume(item, value, event)
817 Panel_item item;
818 int value;
819 Event *event;
820 {
821 rplaytool_w_objects *ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
822
823 do_rptp_volume ((int) xv_get (ip->volume, PANEL_VALUE));
824
825 /* gxv_start_connections DO NOT EDIT THIS SECTION */
826
827 /* gxv_end_connections */
828
829 }
830
831 /*
832 * Menu handler for `file_menu (Quit)'.
833 */
834 Menu_item
835 do_quit(item, op)
836 Menu_item item;
837 Menu_generate op;
838 {
839 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
840
841 switch (op) {
842 case MENU_DISPLAY:
843 break;
844
845 case MENU_DISPLAY_DONE:
846 break;
847
848 case MENU_NOTIFY:
849 if (notice (ip->w, "Yes", "No", "Really Quit?") == 1)
850 {
851 xv_destroy_safe (ip->w);
852 exit (0);
853 }
854
855 /* gxv_start_connections DO NOT EDIT THIS SECTION */
856
857 /* gxv_end_connections */
858
859 break;
860
861 case MENU_NOTIFY_DONE:
862 break;
863 }
864 return item;
865 }
866
867 /*
868 * Notify callback function for `host'.
869 */
870 Panel_setting
871 do_host(item, event)
872 Panel_item item;
873 Event *event;
874 {
875 rplaytool_w_objects *ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
876 char * value = (char *) xv_get(item, PANEL_VALUE);
877
878 xv_set (ip->spool, PANEL_LIST_DELETE_ROWS, 0, (int) xv_get (ip->spool, PANEL_LIST_NROWS) - 1, NULL);
879 talk (value);
880
881 /* gxv_start_connections DO NOT EDIT THIS SECTION */
882
883 /* gxv_end_connections */
884
885 return panel_text_notify(item, event);
886 }
887
888 /*
889 * Menu handler for `file_menu (Sounds...)'.
890 */
891 Menu_item
892 rplaytool_file_menu_item0_callback(item, op)
893 Menu_item item;
894 Menu_generate op;
895 {
896 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
897
898 switch (op) {
899 case MENU_DISPLAY:
900 break;
901
902 case MENU_DISPLAY_DONE:
903 break;
904
905 case MENU_NOTIFY:
906
907 if (use_server_sounds)
908 {
909 load_soundlist ();
910 }
911 else if (use_disk_sounds)
912 {
913 load_disklist (0);
914 }
915
916 /* gxv_start_connections DO NOT EDIT THIS SECTION */
917
918 xv_set(Rplaytool_s->s, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
919 xv_set(Rplaytool_s->s, XV_SHOW, TRUE, NULL);
920
921 /* gxv_end_connections */
922
923 break;
924
925 case MENU_NOTIFY_DONE:
926 break;
927 }
928 return item;
929 }
930
931 /*
932 * Notify callback function for `soundlist'.
933 */
934 int
935 do_soundlist(item, string, client_data, op, event, row)
936 Panel_item item;
937 char *string;
938 Xv_opaque client_data;
939 Panel_list_op op;
940 Event *event;
941 int row;
942 {
943 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
944 static long prev_click_time = 0;
945 static int prev_row = -1;
946 struct timeval tv;
947 long click_time;
948
949 if (op == PANEL_LIST_OP_DESELECT
950 || op == PANEL_LIST_OP_SELECT)
951 {
952 gettimeofday (&tv, 0);
953 click_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
954
955 if (prev_row == row && (click_time - prev_click_time < 400))
956 {
957 do_rptp_play (string, NULL);
958 prev_click_time = 0;
959 prev_row = -1;
960 }
961 else
962 {
963 prev_click_time = click_time;
964 prev_row = row;
965 }
966 }
967
968 switch(op) {
969 case PANEL_LIST_OP_DESELECT:
970 xv_set (ip->add, PANEL_INACTIVE, TRUE, NULL);
971 break;
972
973 case PANEL_LIST_OP_SELECT:
974 xv_set (ip->add, PANEL_INACTIVE, FALSE, NULL);
975 break;
976
977 case PANEL_LIST_OP_VALIDATE:
978 break;
979
980 case PANEL_LIST_OP_DELETE:
981 break;
982 }
983
984 /* gxv_start_connections DO NOT EDIT THIS SECTION */
985
986 /* gxv_end_connections */
987
988 return XV_OK;
989 }
990
991 /*
992 * Notify callback function for `close'.
993 */
994 void
995 rplaytool_s_close_notify_callback(item, event)
996 Panel_item item;
997 Event *event;
998 {
999 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1000
1001 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1002
1003 xv_set(Rplaytool_s->s, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
1004 xv_set(Rplaytool_s->s, XV_SHOW, FALSE, NULL);
1005
1006 /* gxv_end_connections */
1007
1008 }
1009
1010 /*
1011 * Menu handler for `cont_menu (Selected sounds)'.
1012 */
1013 Menu_item
1014 do_cont_selected(item, op)
1015 Menu_item item;
1016 Menu_generate op;
1017 {
1018 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1019 int i;
1020 SPOOL *sp;
1021
1022 switch (op) {
1023 case MENU_DISPLAY:
1024 break;
1025
1026 case MENU_DISPLAY_DONE:
1027 break;
1028
1029 case MENU_NOTIFY:
1030 for (i = (int) xv_get (ip->spool, PANEL_LIST_FIRST_SELECTED);
1031 i != -1;
1032 i = (int) xv_get (ip->spool, PANEL_LIST_NEXT_SELECTED, i))
1033 {
1034 sp = (SPOOL *) xv_get(ip->spool, PANEL_LIST_CLIENT_DATA, i);
1035 do_rptp_cont (sp->id, "");
1036 }
1037
1038 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1039
1040 /* gxv_end_connections */
1041
1042 break;
1043
1044 case MENU_NOTIFY_DONE:
1045 break;
1046 }
1047 return item;
1048 }
1049
1050 /*
1051 * Menu handler for `cont_menu (All sounds)'.
1052 */
1053 Menu_item
1054 do_cont_all(item, op)
1055 Menu_item item;
1056 Menu_generate op;
1057 {
1058 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1059
1060 switch (op) {
1061 case MENU_DISPLAY:
1062 break;
1063
1064 case MENU_DISPLAY_DONE:
1065 break;
1066
1067 case MENU_NOTIFY:
1068 do_rptp_cont (0, "");
1069
1070 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1071
1072 /* gxv_end_connections */
1073
1074 break;
1075
1076 case MENU_NOTIFY_DONE:
1077 break;
1078 }
1079 return item;
1080 }
1081
1082 /*
1083 * Menu handler for `pause_menu (Selected sounds)'.
1084 */
1085 Menu_item
1086 do_pause_selected(item, op)
1087 Menu_item item;
1088 Menu_generate op;
1089 {
1090 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1091 int i;
1092 SPOOL *sp;
1093
1094 switch (op) {
1095 case MENU_DISPLAY:
1096 break;
1097
1098 case MENU_DISPLAY_DONE:
1099 break;
1100
1101 case MENU_NOTIFY:
1102 for (i = (int) xv_get (ip->spool, PANEL_LIST_FIRST_SELECTED);
1103 i != -1;
1104 i = (int) xv_get (ip->spool, PANEL_LIST_NEXT_SELECTED, i))
1105 {
1106 sp = (SPOOL *) xv_get(ip->spool, PANEL_LIST_CLIENT_DATA, i);
1107 do_rptp_pause (sp->id, "");
1108 }
1109
1110 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1111
1112 /* gxv_end_connections */
1113
1114 break;
1115
1116 case MENU_NOTIFY_DONE:
1117 break;
1118 }
1119 return item;
1120 }
1121
1122 /*
1123 * Menu handler for `pause_menu (All sounds)'.
1124 */
1125 Menu_item
1126 do_pause_all(item, op)
1127 Menu_item item;
1128 Menu_generate op;
1129 {
1130 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1131
1132 switch (op) {
1133 case MENU_DISPLAY:
1134 break;
1135
1136 case MENU_DISPLAY_DONE:
1137 break;
1138
1139 case MENU_NOTIFY:
1140 do_rptp_pause (0, "");
1141
1142 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1143
1144 /* gxv_end_connections */
1145
1146 break;
1147
1148 case MENU_NOTIFY_DONE:
1149 break;
1150 }
1151 return item;
1152 }
1153
1154 /*
1155 * Menu handler for `stop_menu (Selected sounds)'.
1156 */
1157 Menu_item
1158 do_stop_selected(item, op)
1159 Menu_item item;
1160 Menu_generate op;
1161 {
1162 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1163 int i;
1164 SPOOL *sp;
1165
1166 switch (op) {
1167 case MENU_DISPLAY:
1168 break;
1169
1170 case MENU_DISPLAY_DONE:
1171 break;
1172
1173 case MENU_NOTIFY:
1174 for (i = (int) xv_get (ip->spool, PANEL_LIST_FIRST_SELECTED);
1175 i != -1;
1176 i = (int) xv_get (ip->spool, PANEL_LIST_NEXT_SELECTED, i))
1177 {
1178 sp = (SPOOL *) xv_get(ip->spool, PANEL_LIST_CLIENT_DATA, i);
1179 do_rptp_stop (sp->id, "");
1180 }
1181
1182 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1183
1184 /* gxv_end_connections */
1185
1186 break;
1187
1188 case MENU_NOTIFY_DONE:
1189 break;
1190 }
1191 return item;
1192 }
1193
1194 /*
1195 * Menu handler for `stop_menu (All sounds)'.
1196 */
1197 Menu_item
1198 do_stop_all(item, op)
1199 Menu_item item;
1200 Menu_generate op;
1201 {
1202 rplaytool_w_objects * ip = (rplaytool_w_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1203
1204 switch (op) {
1205 case MENU_DISPLAY:
1206 break;
1207
1208 case MENU_DISPLAY_DONE:
1209 break;
1210
1211 case MENU_NOTIFY:
1212 do_rptp_stop (0, "");
1213
1214 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1215
1216 /* gxv_end_connections */
1217
1218 break;
1219
1220 case MENU_NOTIFY_DONE:
1221 break;
1222 }
1223 return item;
1224 }
1225
1226
1227
1228 /*
1229 * Notify callback function for `whichlist'.
1230 */
1231 void
1232 switch_playlist(item, value, event)
1233 Panel_item item;
1234 int value;
1235 Event *event;
1236 {
1237 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1238
1239 curr_playlist = value;
1240
1241 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1242
1243 if (value == 0)
1244 {
1245 xv_set(Rplaytool_s->controls2, XV_SHOW, TRUE, NULL);
1246 }
1247
1248 if (value == 1)
1249 {
1250 xv_set(Rplaytool_s->controls3, XV_SHOW, TRUE, NULL);
1251 }
1252
1253 if (value == 2)
1254 {
1255 xv_set(Rplaytool_s->controls4, XV_SHOW, TRUE, NULL);
1256 }
1257
1258 if (value == 3)
1259 {
1260 xv_set(Rplaytool_s->controls5, XV_SHOW, TRUE, NULL);
1261 }
1262
1263 /* gxv_end_connections */
1264
1265 }
1266
1267 /*
1268 * Notify callback function for `playit'.
1269 */
1270 void
1271 do_playit(item, event)
1272 Panel_item item;
1273 Event *event;
1274 {
1275 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1276
1277 playlist[curr_playlist].auto_play = 1;
1278 if (playlist[curr_playlist].curr == -1)
1279 {
1280 playlist[curr_playlist].curr = 0;
1281 }
1282 play_playlist (curr_playlist, TRUE);
1283
1284 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1285
1286 /* gxv_end_connections */
1287
1288 }
1289
1290 /*
1291 * Notify callback function for `disklist'.
1292 */
1293 int
1294 do_disklist(item, string, client_data, op, event, row)
1295 Panel_item item;
1296 char *string;
1297 Xv_opaque client_data;
1298 Panel_list_op op;
1299 Event *event;
1300 int row;
1301 {
1302 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1303 static long prev_click_time = 0;
1304 static int prev_row = -1;
1305 struct timeval tv;
1306 long click_time;
1307
1308 if (op == PANEL_LIST_OP_DESELECT
1309 || op == PANEL_LIST_OP_SELECT)
1310 {
1311 gettimeofday (&tv, 0);
1312 click_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
1313
1314 if (prev_row == row && (click_time - prev_click_time < 400))
1315 {
1316 /* See if it's a directory */
1317 if ((int) xv_get(ip->disklist, PANEL_LIST_CLIENT_DATA, row))
1318 {
1319 load_disklist (string);
1320 }
1321 else
1322 {
1323 /* Play the sound */
1324 char buf[RPTP_MAX_LINE];
1325 char *cwd = (char *) xv_get (ip->directory, PANEL_VALUE);
1326 sprintf (buf, "%s/%s", cwd, string);
1327 do_rptp_play (buf, NULL);
1328 }
1329 prev_click_time = 0;
1330 prev_row = -1;
1331 }
1332 else
1333 {
1334 prev_click_time = click_time;
1335 prev_row = row;
1336 }
1337 }
1338
1339 switch(op) {
1340 case PANEL_LIST_OP_DESELECT:
1341 xv_set (ip->add, PANEL_INACTIVE, TRUE, NULL);
1342 break;
1343
1344 case PANEL_LIST_OP_SELECT:
1345 xv_set (ip->add, PANEL_INACTIVE, FALSE, NULL);
1346 break;
1347
1348 case PANEL_LIST_OP_VALIDATE:
1349 break;
1350
1351 case PANEL_LIST_OP_DELETE:
1352 break;
1353 }
1354
1355 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1356
1357 /* gxv_end_connections */
1358
1359 return XV_OK;
1360 }
1361
1362 /*
1363 * Notify callback function for `playlist3'.
1364 */
1365 int
1366 do_playlist3(item, string, client_data, op, event, row)
1367 Panel_item item;
1368 char *string;
1369 Xv_opaque client_data;
1370 Panel_list_op op;
1371 Event *event;
1372 int row;
1373 {
1374 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1375
1376 switch(op) {
1377 case PANEL_LIST_OP_DESELECT:
1378 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1379 xv_set (ip->move, PANEL_INACTIVE, TRUE, NULL);
1380 break;
1381
1382 case PANEL_LIST_OP_SELECT:
1383 xv_set (ip->delete, PANEL_INACTIVE, FALSE, NULL);
1384 xv_set (ip->move, PANEL_INACTIVE, FALSE, NULL);
1385 break;
1386
1387 case PANEL_LIST_OP_VALIDATE:
1388 break;
1389
1390 case PANEL_LIST_OP_DELETE:
1391 break;
1392 }
1393
1394 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1395
1396 /* gxv_end_connections */
1397
1398 return XV_OK;
1399 }
1400
1401 /*
1402 * Notify callback function for `playlist4'.
1403 */
1404 int
1405 do_playlist4(item, string, client_data, op, event, row)
1406 Panel_item item;
1407 char *string;
1408 Xv_opaque client_data;
1409 Panel_list_op op;
1410 Event *event;
1411 int row;
1412 {
1413 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1414
1415 switch(op) {
1416 case PANEL_LIST_OP_DESELECT:
1417 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1418 xv_set (ip->move, PANEL_INACTIVE, TRUE, NULL);
1419 break;
1420
1421 case PANEL_LIST_OP_SELECT:
1422 xv_set (ip->delete, PANEL_INACTIVE, FALSE, NULL);
1423 xv_set (ip->move, PANEL_INACTIVE, FALSE, NULL);
1424 break;
1425
1426 case PANEL_LIST_OP_VALIDATE:
1427 break;
1428
1429 case PANEL_LIST_OP_DELETE:
1430 break;
1431 }
1432
1433 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1434
1435 /* gxv_end_connections */
1436
1437 return XV_OK;
1438 }
1439
1440 /*
1441 * Notify callback function for `playlist1'.
1442 */
1443 int
1444 do_playlist1(item, string, client_data, op, event, row)
1445 Panel_item item;
1446 char *string;
1447 Xv_opaque client_data;
1448 Panel_list_op op;
1449 Event *event;
1450 int row;
1451 {
1452 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1453
1454 switch(op) {
1455 case PANEL_LIST_OP_DESELECT:
1456 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1457 xv_set (ip->move, PANEL_INACTIVE, TRUE, NULL);
1458 break;
1459
1460 case PANEL_LIST_OP_SELECT:
1461 xv_set (ip->delete, PANEL_INACTIVE, FALSE, NULL);
1462 xv_set (ip->move, PANEL_INACTIVE, FALSE, NULL);
1463 break;
1464
1465 case PANEL_LIST_OP_VALIDATE:
1466 break;
1467
1468 case PANEL_LIST_OP_DELETE:
1469 break;
1470 }
1471
1472 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1473
1474 /* gxv_end_connections */
1475
1476 return XV_OK;
1477 }
1478
1479 /*
1480 * Notify callback function for `playlist2'.
1481 */
1482 int
1483 do_playlist2(item, string, client_data, op, event, row)
1484 Panel_item item;
1485 char *string;
1486 Xv_opaque client_data;
1487 Panel_list_op op;
1488 Event *event;
1489 int row;
1490 {
1491 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1492
1493 switch(op) {
1494 case PANEL_LIST_OP_DESELECT:
1495 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1496 xv_set (ip->move, PANEL_INACTIVE, TRUE, NULL);
1497 break;
1498
1499 case PANEL_LIST_OP_SELECT:
1500 xv_set (ip->delete, PANEL_INACTIVE, FALSE, NULL);
1501 xv_set (ip->move, PANEL_INACTIVE, FALSE, NULL);
1502 break;
1503
1504 case PANEL_LIST_OP_VALIDATE:
1505 break;
1506
1507 case PANEL_LIST_OP_DELETE:
1508 break;
1509 }
1510
1511 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1512
1513 /* gxv_end_connections */
1514
1515 return XV_OK;
1516 }
1517
1518 /*
1519 * Notify callback function for `soundsource'.
1520 */
1521 void
1522 rplaytool_s_soundsource_notify_callback(item, value, event)
1523 Panel_item item;
1524 int value;
1525 Event *event;
1526 {
1527 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1528
1529 if (value == 0)
1530 {
1531 curr_soundlist = Rplaytool_s->soundlist;
1532 load_soundlist ();
1533 }
1534 else if (value == 1)
1535 {
1536 curr_soundlist = Rplaytool_s->disklist;
1537 load_disklist (0);
1538 }
1539
1540 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1541
1542 if (value == 0)
1543 {
1544 xv_set(Rplaytool_s->controls9, XV_SHOW, TRUE, NULL);
1545 }
1546
1547 if (value == 1)
1548 {
1549 xv_set(Rplaytool_s->controls7, XV_SHOW, TRUE, NULL);
1550 }
1551
1552 /* gxv_end_connections */
1553
1554 }
1555
1556 /*
1557 * Notify callback function for `directory'.
1558 */
1559 Panel_setting
1560 do_cd(item, event)
1561 Panel_item item;
1562 Event *event;
1563 {
1564 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1565 char * value = (char *) xv_get(item, PANEL_VALUE);
1566
1567 if (value && *value)
1568 {
1569 load_disklist (value);
1570 }
1571
1572 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1573
1574 /* gxv_end_connections */
1575
1576 return panel_text_notify(item, event);
1577 }
1578
1579 /*
1580 * Menu handler for `delete_menu (Selected sounds)'.
1581 */
1582 Menu_item
1583 playlist_delete(item, op)
1584 Menu_item item;
1585 Menu_generate op;
1586 {
1587 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1588 int i;
1589 char *p;
1590
1591 switch (op) {
1592 case MENU_DISPLAY:
1593 break;
1594
1595 case MENU_DISPLAY_DONE:
1596 break;
1597
1598 case MENU_NOTIFY:
1599 for (i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_FIRST_SELECTED);
1600 i != -1;
1601 i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_NEXT_SELECTED, i))
1602 {
1603 do_playlist_delete (curr_playlist, i);
1604 }
1605 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1606
1607 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1608
1609 /* gxv_end_connections */
1610
1611 break;
1612
1613 case MENU_NOTIFY_DONE:
1614 break;
1615 }
1616 return item;
1617 }
1618
1619 /*
1620 * Menu handler for `delete_menu (All sounds)'.
1621 */
1622 Menu_item
1623 playlist_delete_all(item, op)
1624 Menu_item item;
1625 Menu_generate op;
1626 {
1627 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1628 int i;
1629 char *p;
1630
1631 switch (op) {
1632 case MENU_DISPLAY:
1633 break;
1634
1635 case MENU_DISPLAY_DONE:
1636 break;
1637
1638 case MENU_NOTIFY:
1639 xv_set (playlist[curr_playlist].list, XV_SHOW, FALSE, NULL);
1640
1641 do_playlist_delete_all (curr_playlist);
1642
1643 xv_set (ip->delete, PANEL_INACTIVE, TRUE, NULL);
1644
1645 xv_set (playlist[curr_playlist].list, XV_SHOW, TRUE, NULL);
1646
1647 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1648
1649 /* gxv_end_connections */
1650
1651 break;
1652
1653 case MENU_NOTIFY_DONE:
1654 break;
1655 }
1656 return item;
1657 }
1658
1659 /*
1660 * Menu handler for `add_menu (Select sound)'.
1661 */
1662 Menu_item
1663 add_sounds(item, op)
1664 Menu_item item;
1665 Menu_generate op;
1666 {
1667 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1668 int i;
1669 char *sound, *cwd, *p;
1670 char buf[RPTP_MAX_LINE];
1671
1672 switch (op) {
1673 case MENU_DISPLAY:
1674 break;
1675
1676 case MENU_DISPLAY_DONE:
1677 break;
1678
1679 case MENU_NOTIFY:
1680 i = (int) xv_get (curr_soundlist, PANEL_LIST_FIRST_SELECTED);
1681 sound = (char *) xv_get (curr_soundlist, PANEL_LIST_STRING, i);
1682
1683 if (curr_soundlist == Rplaytool_s->disklist)
1684 {
1685 if ((int) xv_get(curr_soundlist, PANEL_LIST_CLIENT_DATA, i) == 0) /* a file */
1686 {
1687 cwd = (char *) xv_get (ip->directory, PANEL_VALUE);
1688 sprintf (buf, "%s", sound);
1689 }
1690 else
1691 {
1692 /* ignore directories */
1693 return item;
1694 }
1695 }
1696 else
1697 {
1698 cwd = "";
1699 sprintf (buf, "%s", sound);
1700 }
1701
1702 do_playlist_append (curr_playlist, cwd, buf);
1703
1704
1705 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1706
1707 /* gxv_end_connections */
1708
1709 break;
1710
1711 case MENU_NOTIFY_DONE:
1712 break;
1713 }
1714 return item;
1715 }
1716
1717 /*
1718 * Menu handler for `add_menu (All sounds)'.
1719 */
1720 Menu_item
1721 add_all_sounds(item, op)
1722 Menu_item item;
1723 Menu_generate op;
1724 {
1725 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1726 int i, n;
1727 char *sound, *cwd, *p;
1728 char buf[RPTP_MAX_LINE];
1729
1730 switch (op) {
1731 case MENU_DISPLAY:
1732 break;
1733
1734 case MENU_DISPLAY_DONE:
1735 break;
1736
1737 case MENU_NOTIFY:
1738 busy (Rplaytool_s->s, TRUE);
1739 xv_set (playlist[curr_playlist].list, XV_SHOW, FALSE, NULL);
1740 n = (int) xv_get (curr_soundlist, PANEL_LIST_NROWS);
1741 for (i = 0; i < n; i++)
1742 {
1743 sound = (char *) xv_get (curr_soundlist, PANEL_LIST_STRING, i);
1744
1745 if (curr_soundlist == Rplaytool_s->disklist)
1746 {
1747 if ((int) xv_get(curr_soundlist, PANEL_LIST_CLIENT_DATA, i) == 0) /* a file */
1748 {
1749 cwd = (char *) xv_get (ip->directory, PANEL_VALUE);
1750 sprintf (buf, "%s", sound);
1751 }
1752 else
1753 {
1754 /* ignore directories */
1755 continue;
1756 }
1757 }
1758 else
1759 {
1760 cwd = "";
1761 sprintf (buf, "%s", sound);
1762 }
1763
1764 do_playlist_append (curr_playlist, cwd, buf);
1765 }
1766
1767 xv_set (playlist[curr_playlist].list, XV_SHOW, TRUE, NULL);
1768 busy (Rplaytool_s->s, FALSE);
1769
1770 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1771
1772 /* gxv_end_connections */
1773
1774 break;
1775
1776 case MENU_NOTIFY_DONE:
1777 break;
1778 }
1779 return item;
1780 }
1781
1782 /*
1783 * Notify callback function for `stopit'.
1784 */
1785 void
1786 do_stopit(item, event)
1787 Panel_item item;
1788 Event *event;
1789 {
1790 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1791
1792 if (playlist[curr_playlist].id > 0)
1793 {
1794 do_playlist_stop (curr_playlist);
1795
1796 playlist[curr_playlist].id = -1;
1797 playlist[curr_playlist].auto_play = 0;
1798 playlist[curr_playlist].curr++;
1799 if (playlist[curr_playlist].curr >= playlist[curr_playlist].size)
1800 {
1801 playlist[curr_playlist].curr = 0;
1802 }
1803
1804 playlist_update_icons (curr_playlist);
1805 }
1806 else if (playlist[curr_playlist].delay > 0)
1807 {
1808 playlist[curr_playlist].delay = -1;
1809
1810 playlist[curr_playlist].id = -1;
1811 playlist[curr_playlist].auto_play = 0;
1812 playlist[curr_playlist].curr++;
1813 if (playlist[curr_playlist].curr >= playlist[curr_playlist].size)
1814 {
1815 playlist[curr_playlist].curr = 0;
1816 }
1817
1818 playlist_update_icons (curr_playlist);
1819 }
1820
1821 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1822
1823 /* gxv_end_connections */
1824
1825 }
1826
1827 /*
1828 * Notify callback function for `sort'.
1829 */
1830 void
1831 do_soundsort(item, event)
1832 Panel_item item;
1833 Event *event;
1834 {
1835 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1836
1837 busy (ip->s, TRUE);
1838 sort_list (curr_soundlist);
1839 busy (ip->s, FALSE);
1840
1841 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1842
1843 /* gxv_end_connections */
1844
1845 }
1846
1847 /*
1848 * Notify callback function for `reload'.
1849 */
1850 void
1851 do_reload(item, event)
1852 Panel_item item;
1853 Event *event;
1854 {
1855 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
1856
1857 if (curr_soundlist == Rplaytool_s->disklist)
1858 {
1859 load_disklist (0);
1860 }
1861 else
1862 {
1863 load_soundlist ();
1864 }
1865
1866 /* gxv_start_connections DO NOT EDIT THIS SECTION */
1867
1868 /* gxv_end_connections */
1869
1870 }
1871
1872 /* Load a file into curr_playlist. */
1873 int
1874 file_load_file (file)
1875 char *file;
1876 {
1877 FILE *fp;
1878
1879 fp = fopen (file, "r");
1880 if (fp == NULL)
1881 {
1882 notice (Rplaytool_f->f, NULL, NULL, "Can't read %s", file);
1883 return -1;
1884 }
1885
1886 /* Make sure playlist files are stored with complete pathnames. */
1887 if (file[0] != '/')
1888 {
1889 char cwd[MAXPATHLEN];
1890
1891 getcwd (cwd, sizeof (cwd));
1892 sprintf (playlist[curr_playlist].filename, "%s/%s", cwd, file);
1893 }
1894 else
1895 {
1896 strcpy (playlist[curr_playlist].filename, file);
1897 }
1898
1899 busy (Rplaytool_f->f, TRUE);
1900 xv_set (playlist[curr_playlist].list, XV_SHOW, FALSE, NULL);
1901
1902 do_playlist_delete_all (curr_playlist);
1903 do_playlist_load (curr_playlist, fp);
1904 fclose (fp);
1905
1906 xv_set (playlist[curr_playlist].list, XV_SHOW, TRUE, NULL);
1907 busy (Rplaytool_f->f, FALSE);
1908
1909 return 0;
1910 }
1911
1912 /* Save curr_playlist in a file. */
1913 file_save_file (file)
1914 char *file;
1915 {
1916 FILE *fp;
1917 INFO *info;
1918 int i;
1919
1920 if (access (file, R_OK) == 0)
1921 {
1922 if (notice (Rplaytool_f->f, "Yes", "No", "Overwrite %s?", file) == 2)
1923 {
1924 return;
1925 }
1926 }
1927
1928 fp = fopen (file, "w");
1929 if (fp == NULL)
1930 {
1931 notice (Rplaytool_f->f, NULL, NULL, "Can't create %s", file);
1932 return;
1933 }
1934
1935 busy (Rplaytool_f->f, TRUE);
1936
1937 do_playlist_save (curr_playlist, fp);
1938 fclose (fp);
1939
1940 busy (Rplaytool_f->f, FALSE);
1941 }
1942
1943 /* Load a directory into the filelist popup. */
1944 file_load_dir (new_dir)
1945 char *new_dir;
1946 {
1947 char cwd[MAXPATHLEN];
1948 DIR *dir;
1949 struct dirent *dp;
1950 struct stat st;
1951 int row;
1952 Scrollbar scrollbar;
1953
1954 busy (Rplaytool_f->f, TRUE);
1955
1956 if (new_dir)
1957 {
1958 chdir (new_dir);
1959 }
1960
1961 getcwd (cwd, sizeof (cwd));
1962
1963 dir = opendir (".");
1964 if (dir == NULL)
1965 {
1966 exit (1);
1967 }
1968
1969 xv_set (Rplaytool_f->filelist,
1970 PANEL_LIST_DELETE_ROWS, 0,
1971 (int) xv_get (Rplaytool_f->filelist, PANEL_LIST_NROWS),
1972 NULL);
1973
1974 xv_set (Rplaytool_f->filelist, XV_SHOW, FALSE, NULL);
1975
1976 row = 0;
1977 xv_set (Rplaytool_f->filelist,
1978 PANEL_LIST_INSERT, row,
1979 PANEL_LIST_STRING, row, "..",
1980 PANEL_LIST_CLIENT_DATA, row, 1, /* a directory */
1981 PANEL_LIST_GLYPH, row, icons[ICON_DIRECTORY].image,
1982 NULL);
1983 row++;
1984
1985 for (;;)
1986 {
1987 dp = readdir (dir);
1988 if (dp == NULL)
1989 {
1990 closedir (dir);
1991 break;
1992 }
1993 else if (strcmp (dp->d_name, ".") == 0
1994 || strcmp (dp->d_name, "..") == 0)
1995 {
1996 continue;
1997 }
1998 else
1999 {
2000 stat (dp->d_name, &st);
2001
2002 if (S_ISDIR (st.st_mode))
2003 {
2004 xv_set (Rplaytool_f->filelist,
2005 PANEL_LIST_INSERT, row,
2006 PANEL_LIST_STRING, row, dp->d_name,
2007 PANEL_LIST_CLIENT_DATA, row, 1, /* a directory */
2008 PANEL_LIST_GLYPH, row, icons[ICON_DIRECTORY].image,
2009 NULL);
2010 }
2011 else
2012 {
2013 xv_set (Rplaytool_f->filelist,
2014 PANEL_LIST_INSERT, row,
2015 PANEL_LIST_STRING, row, dp->d_name,
2016 PANEL_LIST_CLIENT_DATA, row, 0, /* a file */
2017 PANEL_LIST_GLYPH, row, icons[ICON_FILE].image,
2018 NULL);
2019 }
2020 row++;
2021 }
2022
2023 }
2024
2025 scrollbar = (Scrollbar) xv_get (Rplaytool_f->filelist, PANEL_LIST_SCROLLBAR);
2026 xv_set (scrollbar, SCROLLBAR_VIEW_START, 0, NULL);
2027
2028 xv_set (Rplaytool_f->filelist, XV_SHOW, TRUE, NULL);
2029
2030 xv_set (Rplaytool_f->filedir, PANEL_VALUE, cwd, NULL);
2031
2032 busy (Rplaytool_f->f, FALSE);
2033 }
2034
2035 /*
2036 * Notify callback function for `filedir'.
2037 */
2038 Panel_setting
2039 filedir_notify(item, event)
2040 Panel_item item;
2041 Event *event;
2042 {
2043 rplaytool_f_objects *ip = (rplaytool_f_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2044 char * value = (char *) xv_get(item, PANEL_VALUE);
2045
2046 file_load_dir (value);
2047
2048 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2049
2050 /* gxv_end_connections */
2051
2052 return panel_text_notify(item, event);
2053 }
2054
2055 /*
2056 * Notify callback function for `filelist'.
2057 */
2058 int
2059 filelist_notify(item, string, client_data, op, event, row)
2060 Panel_item item;
2061 char *string;
2062 Xv_opaque client_data;
2063 Panel_list_op op;
2064 Event *event;
2065 int row;
2066 {
2067 rplaytool_f_objects *ip = (rplaytool_f_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2068 static long prev_click_time;
2069 struct timeval tv;
2070 long click_time;
2071
2072 gettimeofday (&tv, 0);
2073 click_time = tv.tv_sec * 1000 + tv.tv_usec / 1000;
2074
2075 switch(op) {
2076 case PANEL_LIST_OP_DESELECT:
2077 if (click_time - prev_click_time < 400)
2078 {
2079 /* See if it's a directory */
2080 if ((int) xv_get(ip->filelist, PANEL_LIST_CLIENT_DATA, row))
2081 {
2082 file_load_dir (string);
2083 }
2084 prev_click_time = 0;
2085 }
2086 break;
2087
2088 case PANEL_LIST_OP_SELECT:
2089 if ((int) xv_get(ip->filelist, PANEL_LIST_CLIENT_DATA, row) == 0) /* a file */
2090 {
2091 xv_set (ip->filename, PANEL_VALUE, string, NULL);
2092 }
2093 prev_click_time = click_time;
2094 break;
2095
2096 case PANEL_LIST_OP_VALIDATE:
2097 break;
2098
2099 case PANEL_LIST_OP_DELETE:
2100 break;
2101 }
2102
2103 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2104
2105 /* gxv_end_connections */
2106
2107 return XV_OK;
2108 }
2109
2110 /*
2111 * Notify callback function for `filename'.
2112 */
2113 Panel_setting
2114 filename_notify(item, event)
2115 Panel_item item;
2116 Event *event;
2117 {
2118 rplaytool_f_objects *ip = (rplaytool_f_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2119 char *value = (char *) xv_get(item, PANEL_VALUE);
2120 char *dir = (char *) xv_get (ip->filedir, PANEL_VALUE);
2121 char *label;
2122 char filename[MAXPATHLEN];
2123
2124 sprintf (filename, "%s/%s", dir, value);
2125
2126 label = (char *) xv_get (ip->filedoit, PANEL_LABEL_STRING, NULL);
2127 if (strcmp (label, "Load") == 0)
2128 {
2129 file_load_file (filename);
2130 }
2131 else if (strcmp (label, "Save") == 0)
2132 {
2133 file_save_file (filename);
2134 }
2135
2136 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2137
2138 /* gxv_end_connections */
2139
2140 return panel_text_notify(item, event);
2141 }
2142
2143 /*
2144 * Notify callback function for `filedoit'.
2145 */
2146 void
2147 filedoit_notify(item, event)
2148 Panel_item item;
2149 Event *event;
2150 {
2151 rplaytool_f_objects *ip = (rplaytool_f_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2152 char *value = (char *) xv_get (ip->filename, PANEL_VALUE);
2153 char *dir = (char *) xv_get (ip->filedir, PANEL_VALUE);
2154 char *label;
2155 char filename[MAXPATHLEN];
2156
2157 sprintf (filename, "%s/%s", dir, value);
2158
2159 label = (char *) xv_get (ip->filedoit, PANEL_LABEL_STRING, NULL);
2160 if (strcmp (label, "Load") == 0)
2161 {
2162 file_load_file (filename);
2163 }
2164 else if (strcmp (label, "Save") == 0)
2165 {
2166 file_save_file (filename);
2167 }
2168
2169 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2170
2171 /* gxv_end_connections */
2172
2173 }
2174
2175 /*
2176 * Notify callback function for `fileclose'.
2177 */
2178 void
2179 rplaytool_f_fileclose_notify_callback(item, event)
2180 Panel_item item;
2181 Event *event;
2182 {
2183 rplaytool_f_objects *ip = (rplaytool_f_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2184
2185 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2186
2187 xv_set(Rplaytool_f->f, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
2188 xv_set(Rplaytool_f->f, XV_SHOW, FALSE, NULL);
2189
2190 /* gxv_end_connections */
2191
2192 }
2193
2194 /*
2195 * Menu handler for `playlistfile_menu (Load...)'.
2196 */
2197 Menu_item
2198 playlistfile_load(item, op)
2199 Menu_item item;
2200 Menu_generate op;
2201 {
2202 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2203
2204 switch (op) {
2205 case MENU_DISPLAY:
2206 break;
2207
2208 case MENU_DISPLAY_DONE:
2209 break;
2210
2211 case MENU_NOTIFY:
2212 if (playlist[curr_playlist].filename[0] == '\0')
2213 {
2214 file_load_dir (NULL);
2215 }
2216 else
2217 {
2218 char *p, filename[MAXPATHLEN];
2219
2220 strcpy (filename, playlist[curr_playlist].filename);
2221 p = strrchr (filename, '/');
2222 if (p && p[1])
2223 {
2224 *p++ = '\0';
2225 xv_set (Rplaytool_f->filename, PANEL_VALUE, p);
2226 file_load_dir (filename);
2227 }
2228 else
2229 {
2230 file_load_dir (NULL);
2231 }
2232 }
2233
2234 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2235
2236 xv_set(Rplaytool_f->f, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
2237 xv_set(Rplaytool_f->f, XV_SHOW, TRUE, NULL);
2238
2239 xv_set(Rplaytool_f->f, XV_LABEL, "Load a Play List", NULL);
2240
2241 xv_set(Rplaytool_f->filedoit, PANEL_LABEL_STRING, "Load", NULL);
2242
2243 /* gxv_end_connections */
2244
2245 break;
2246
2247 case MENU_NOTIFY_DONE:
2248 break;
2249 }
2250 return item;
2251 }
2252
2253 /*
2254 * Menu handler for `playlistfile_menu (Save...)'.
2255 */
2256 Menu_item
2257 playlistfile_save(item, op)
2258 Menu_item item;
2259 Menu_generate op;
2260 {
2261 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2262
2263 switch (op) {
2264 case MENU_DISPLAY:
2265 break;
2266
2267 case MENU_DISPLAY_DONE:
2268 break;
2269
2270 case MENU_NOTIFY:
2271 if (playlist[curr_playlist].filename[0] == '\0')
2272 {
2273 file_load_dir (NULL);
2274 }
2275 else
2276 {
2277 char *p, filename[MAXPATHLEN];
2278
2279 strcpy (filename, playlist[curr_playlist].filename);
2280 p = strrchr (filename, '/');
2281 if (p && p[1])
2282 {
2283 *p++ = '\0';
2284 xv_set (Rplaytool_f->filename, PANEL_VALUE, p);
2285 file_load_dir (filename);
2286 }
2287 else
2288 {
2289 file_load_dir (NULL);
2290 }
2291 }
2292
2293 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2294
2295 xv_set(Rplaytool_f->f, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
2296 xv_set(Rplaytool_f->f, XV_SHOW, TRUE, NULL);
2297
2298 xv_set(Rplaytool_f->f, XV_LABEL, "Save a Play List", NULL);
2299
2300 xv_set(Rplaytool_f->filedoit, PANEL_LABEL_STRING, "Save", NULL);
2301
2302 /* gxv_end_connections */
2303
2304 break;
2305
2306 case MENU_NOTIFY_DONE:
2307 break;
2308 }
2309 return item;
2310 }
2311
2312 /*
2313 * Menu handler for `move_menu (Up)'.
2314 */
2315 Menu_item
2316 move_up(item, op)
2317 Menu_item item;
2318 Menu_generate op;
2319 {
2320 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2321 int i;
2322
2323 switch (op) {
2324 case MENU_DISPLAY:
2325 break;
2326
2327 case MENU_DISPLAY_DONE:
2328 break;
2329
2330 case MENU_NOTIFY:
2331 i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_FIRST_SELECTED);
2332 if (i > 0)
2333 {
2334 do_playlist_move (curr_playlist, i, i-1);
2335 xv_set (playlist[curr_playlist].list, PANEL_LIST_SELECT, i-1, TRUE, NULL);
2336 }
2337
2338 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2339
2340 /* gxv_end_connections */
2341
2342 break;
2343
2344 case MENU_NOTIFY_DONE:
2345 break;
2346 }
2347 return item;
2348 }
2349
2350 /*
2351 * Menu handler for `move_menu (Down)'.
2352 */
2353 Menu_item
2354 move_down(item, op)
2355 Menu_item item;
2356 Menu_generate op;
2357 {
2358 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2359 int i;
2360
2361 switch (op) {
2362 case MENU_DISPLAY:
2363 break;
2364
2365 case MENU_DISPLAY_DONE:
2366 break;
2367
2368 case MENU_NOTIFY:
2369 i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_FIRST_SELECTED);
2370 if (i < playlist[curr_playlist].size - 1)
2371 {
2372 do_playlist_move (curr_playlist, i, i+1);
2373 xv_set (playlist[curr_playlist].list, PANEL_LIST_SELECT, i+1, TRUE, NULL);
2374 }
2375
2376 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2377
2378 /* gxv_end_connections */
2379
2380 break;
2381
2382 case MENU_NOTIFY_DONE:
2383 break;
2384 }
2385 return item;
2386 }
2387
2388 /*
2389 * Menu handler for `move_menu (Top)'.
2390 */
2391 Menu_item
2392 move_top(item, op)
2393 Menu_item item;
2394 Menu_generate op;
2395 {
2396 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2397 int i;
2398
2399 switch (op) {
2400 case MENU_DISPLAY:
2401 break;
2402
2403 case MENU_DISPLAY_DONE:
2404 break;
2405
2406 case MENU_NOTIFY:
2407 xv_set (playlist[curr_playlist].list, XV_SHOW, FALSE, NULL);
2408
2409 i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_FIRST_SELECTED);
2410 while (i > 0)
2411 {
2412 do_playlist_move (curr_playlist, i, i-1);
2413 i--;
2414 }
2415 xv_set (playlist[curr_playlist].list, PANEL_LIST_SELECT, 0, TRUE, NULL);
2416
2417 xv_set (playlist[curr_playlist].list, XV_SHOW, TRUE, NULL);
2418
2419 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2420
2421 /* gxv_end_connections */
2422
2423 break;
2424
2425 case MENU_NOTIFY_DONE:
2426 break;
2427 }
2428 return item;
2429 }
2430
2431 /*
2432 * Menu handler for `move_menu (Bottom)'.
2433 */
2434 Menu_item
2435 move_bottom(item, op)
2436 Menu_item item;
2437 Menu_generate op;
2438 {
2439 rplaytool_s_objects * ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2440 int i;
2441
2442 switch (op) {
2443 case MENU_DISPLAY:
2444 break;
2445
2446 case MENU_DISPLAY_DONE:
2447 break;
2448
2449 case MENU_NOTIFY:
2450 xv_set (playlist[curr_playlist].list, XV_SHOW, FALSE, NULL);
2451
2452 i = (int) xv_get (playlist[curr_playlist].list, PANEL_LIST_FIRST_SELECTED);
2453 while (i < playlist[curr_playlist].size-1)
2454 {
2455 do_playlist_move (curr_playlist, i, i+1);
2456 i++;
2457 }
2458 xv_set (playlist[curr_playlist].list,
2459 PANEL_LIST_SELECT, playlist[curr_playlist].size-1, TRUE, NULL);
2460
2461 xv_set (playlist[curr_playlist].list, XV_SHOW, TRUE, NULL);
2462
2463 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2464
2465 /* gxv_end_connections */
2466
2467 break;
2468
2469 case MENU_NOTIFY_DONE:
2470 break;
2471 }
2472 return item;
2473 }
2474
2475 /*
2476 * Notify callback function for `next'.
2477 */
2478 void
2479 do_next(item, event)
2480 Panel_item item;
2481 Event *event;
2482 {
2483 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2484
2485 if (playlist[curr_playlist].id > 0
2486 || playlist[curr_playlist].delay > 0)
2487 {
2488 do_playlist_stop (curr_playlist);
2489 playlist[curr_playlist].auto_play = 1;
2490 playlist[curr_playlist].curr++;
2491 if (playlist[curr_playlist].curr >= playlist[curr_playlist].size)
2492 {
2493 playlist[curr_playlist].curr = 0;
2494 }
2495 play_playlist (curr_playlist, TRUE);
2496 }
2497 else
2498 {
2499 if (playlist[curr_playlist].curr == -1)
2500 {
2501 playlist[curr_playlist].curr = 0;
2502 }
2503 playlist[curr_playlist].curr++;
2504 if (playlist[curr_playlist].curr >= playlist[curr_playlist].size)
2505 {
2506 playlist[curr_playlist].curr = 0;
2507 }
2508 playlist_update_icons (curr_playlist);
2509 }
2510
2511 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2512
2513 /* gxv_end_connections */
2514
2515 }
2516
2517 /*
2518 * Notify callback function for `prev'.
2519 */
2520 void
2521 do_prev(item, event)
2522 Panel_item item;
2523 Event *event;
2524 {
2525 rplaytool_s_objects *ip = (rplaytool_s_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
2526
2527 if (playlist[curr_playlist].id > 0
2528 || playlist[curr_playlist].delay > 0)
2529 {
2530 do_playlist_stop (curr_playlist);
2531 playlist[curr_playlist].auto_play = 1;
2532 playlist[curr_playlist].curr--;
2533 if (playlist[curr_playlist].curr < 0)
2534 {
2535 playlist[curr_playlist].curr = playlist[curr_playlist].size - 1;
2536 }
2537 play_playlist (curr_playlist, TRUE);
2538 }
2539 else
2540 {
2541 playlist[curr_playlist].curr--;
2542 if (playlist[curr_playlist].curr < 0)
2543 {
2544 playlist[curr_playlist].curr = playlist[curr_playlist].size - 1;
2545 }
2546 playlist_update_icons (curr_playlist);
2547 }
2548
2549 /* gxv_start_connections DO NOT EDIT THIS SECTION */
2550
2551 /* gxv_end_connections */
2552
2553 }