| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "xjukebox.h" |
| 20 |
#include <X11/cursorfont.h> |
| 21 |
#include <X11/Shell.h> |
| 22 |
#include <X11/Xaw/Cardinals.h> |
| 23 |
#include <X11/Xaw/List.h> |
| 24 |
#include <X11/Xaw/Form.h> |
| 25 |
#include <X11/Xaw/Paned.h> |
| 26 |
#include <X11/Xaw/Viewport.h> |
| 27 |
#include <X11/Xaw/Label.h> |
| 28 |
#include <X11/Xaw/Command.h> |
| 29 |
#include <X11/Xaw/MenuButton.h> |
| 30 |
#include <X11/Xaw/SimpleMenu.h> |
| 31 |
#include <X11/Xaw/SmeBSB.h> |
| 32 |
#include <X11/Xaw/Dialog.h> |
| 33 |
|
| 34 |
#ifdef __STDC__ |
| 35 |
extern char *rplay_default_host(); |
| 36 |
extern void setSpoolUpdate(Boolean update); |
| 37 |
extern void rptp_connect(char *hostname); |
| 38 |
extern void rptp_get_sound_list(); |
| 39 |
extern void rptp_get_spool_list(); |
| 40 |
extern int alphacompare(char **i, char **j); |
| 41 |
#else |
| 42 |
extern char *rplay_default_host(); |
| 43 |
extern void setSpoolUpdate(); |
| 44 |
extern void rptp_connect(); |
| 45 |
extern void rptp_get_sound_list(); |
| 46 |
extern void rptp_get_spool_list(); |
| 47 |
extern int alphacompare(); |
| 48 |
#endif |
| 49 |
|
| 50 |
extern String *sound_names; |
| 51 |
extern int sound_count; |
| 52 |
extern String *queue_names; |
| 53 |
extern int queue_count; |
| 54 |
extern String *spool_names; |
| 55 |
extern int spool_count; |
| 56 |
extern int return_code; |
| 57 |
|
| 58 |
|
| 59 |
#ifdef __STDC__ |
| 60 |
void wmProtocolsProc(Widget w, XEvent *event, String params[], |
| 61 |
Cardinal *num_params); |
| 62 |
void okProc(Widget w, XEvent *event, String params[], |
| 63 |
Cardinal *num_params); |
| 64 |
void cancelProc(Widget w, XEvent *event, String params[], |
| 65 |
Cardinal *num_params); |
| 66 |
#else |
| 67 |
void wmProtocolsProc(); |
| 68 |
void okProc(); |
| 69 |
void cancelProc(); |
| 70 |
#endif |
| 71 |
|
| 72 |
Widget top_shell, jukebox_shell, sound_list, queue_list, spool_list; |
| 73 |
Atom XA_WM_DELETE_WINDOW; |
| 74 |
XtAppContext app_context; |
| 75 |
static Boolean closing_top_shell = False; |
| 76 |
static int current_dialog = DIALOG_NONE; |
| 77 |
static String default_file = ""; |
| 78 |
static String fallback_resources[] = { |
| 79 |
#include "XJukebox.ad.h" |
| 80 |
NULL |
| 81 |
}; |
| 82 |
#define Offset(field) XtOffsetOf(struct _resources_rec, field) |
| 83 |
static XtResource resources_desc[] = |
| 84 |
{ |
| 85 |
{ |
| 86 |
"jukeboxShown", "JukeboxShown", XtRBoolean, sizeof(Boolean), |
| 87 |
Offset(jukebox_shown), XtRImmediate, (XtPointer)FALSE |
| 88 |
} |
| 89 |
}; |
| 90 |
#undef Offset |
| 91 |
static XrmOptionDescRec options[] = |
| 92 |
{ |
| 93 |
{ |
| 94 |
"-jukeboxShown", ".jukeboxShown", XrmoptionNoArg, "TRUE" |
| 95 |
} |
| 96 |
}; |
| 97 |
static XtActionsRec actions[] = { |
| 98 |
{ |
| 99 |
"WMProtocols", wmProtocolsProc |
| 100 |
}, |
| 101 |
{ |
| 102 |
"Ok", okProc |
| 103 |
}, |
| 104 |
{ |
| 105 |
"Cancel", cancelProc |
| 106 |
} |
| 107 |
}; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
void ringBell() |
| 112 |
{ |
| 113 |
XBell(XtDisplay(top_shell), 50); |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
#ifdef __STDC__ |
| 119 |
void setBusy(Boolean busy) |
| 120 |
#else |
| 121 |
void setBusy(busy) |
| 122 |
Boolean busy; |
| 123 |
#endif |
| 124 |
{ |
| 125 |
static Window win1 = (Window) 0; |
| 126 |
static Window win2 = (Window) 0; |
| 127 |
Display *disp; |
| 128 |
XSetWindowAttributes xswa; |
| 129 |
|
| 130 |
disp = XtDisplay(top_shell); |
| 131 |
if (! win1) |
| 132 |
{ |
| 133 |
xswa.do_not_propagate_mask = (KeyPressMask | KeyReleaseMask | |
| 134 |
ButtonPressMask | ButtonReleaseMask | |
| 135 |
PointerMotionMask); |
| 136 |
xswa.cursor = XCreateFontCursor(disp, XC_watch); |
| 137 |
win1 = XCreateWindow(disp, XtWindow(top_shell), |
| 138 |
0, 0, |
| 139 |
(unsigned int) 8192, |
| 140 |
(unsigned int) 8192, |
| 141 |
(unsigned int) 0, CopyFromParent, |
| 142 |
InputOnly, CopyFromParent, |
| 143 |
CWDontPropagate | CWCursor, |
| 144 |
&xswa); |
| 145 |
win2 = XCreateWindow(disp, XtWindow(jukebox_shell), |
| 146 |
0, 0, |
| 147 |
(unsigned int) 8192, |
| 148 |
(unsigned int) 8192, |
| 149 |
(unsigned int) 0, CopyFromParent, |
| 150 |
InputOnly, CopyFromParent, |
| 151 |
CWDontPropagate | CWCursor, |
| 152 |
&xswa); |
| 153 |
} |
| 154 |
if (busy) |
| 155 |
{ |
| 156 |
XMapRaised(disp, win1); |
| 157 |
XMapRaised(disp, win2); |
| 158 |
} |
| 159 |
else |
| 160 |
{ |
| 161 |
XUnmapWindow(disp, win1); |
| 162 |
XUnmapWindow(disp, win2); |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
#ifdef __STDC__ |
| 168 |
void selectOkProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 169 |
#else |
| 170 |
void selectOkProc(w, client_data, call_data) |
| 171 |
Widget w; |
| 172 |
XtPointer client_data; |
| 173 |
XtPointer call_data; |
| 174 |
#endif |
| 175 |
{ |
| 176 |
Widget dialog; |
| 177 |
String value; |
| 178 |
|
| 179 |
dialog = (Widget) client_data; |
| 180 |
value = (String) XawDialogGetValueString(dialog); |
| 181 |
XtDestroyWidget(XtParent(dialog)); |
| 182 |
switch (current_dialog) |
| 183 |
{ |
| 184 |
case DIALOG_SET_NEW_HOST : |
| 185 |
rptp_connect(value); |
| 186 |
setSpoolUpdate(True); |
| 187 |
break; |
| 188 |
case DIALOG_LOAD_SOUND_FILE : |
| 189 |
load_list(value, &sound_names, &sound_count); |
| 190 |
XawListChange(sound_list, sound_names, sound_count, 0, True); |
| 191 |
default_file = value; |
| 192 |
break; |
| 193 |
case DIALOG_SAVE_SOUND_FILE : |
| 194 |
save_list(value, sound_names, sound_count); |
| 195 |
default_file = value; |
| 196 |
break; |
| 197 |
case DIALOG_GET_SOUND_DIR : |
| 198 |
printf("*** Not implemented : GET_SOUND_DIR : %s\n", value); |
| 199 |
break; |
| 200 |
case DIALOG_LOAD_QUEUE_FILE : |
| 201 |
load_list(value, &queue_names, &queue_count); |
| 202 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 203 |
default_file = value; |
| 204 |
break; |
| 205 |
case DIALOG_SAVE_QUEUE_FILE : |
| 206 |
save_list(value, queue_names, queue_count); |
| 207 |
default_file = value; |
| 208 |
break; |
| 209 |
default : |
| 210 |
printf("*** Congratulations ! You found a bug ! ***\n"); |
| 211 |
} |
| 212 |
current_dialog = DIALOG_NONE; |
| 213 |
setBusy(False); |
| 214 |
} |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
#ifdef __STDC__ |
| 219 |
void selectCancelProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 220 |
#else |
| 221 |
void selectCancelProc(w, client_data, call_data) |
| 222 |
Widget w; |
| 223 |
XtPointer client_data; |
| 224 |
XtPointer call_data; |
| 225 |
#endif |
| 226 |
{ |
| 227 |
Widget dialog; |
| 228 |
|
| 229 |
dialog = (Widget) client_data; |
| 230 |
XtDestroyWidget(XtParent(dialog)); |
| 231 |
current_dialog = DIALOG_NONE; |
| 232 |
setBusy(False); |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
#ifdef __STDC__ |
| 238 |
void popupDialog(Widget button, String message, String default_value, int id) |
| 239 |
#else |
| 240 |
void popupDialog(button, message, default_value, id) |
| 241 |
Widget button; |
| 242 |
String message; |
| 243 |
String default_value; |
| 244 |
int id; |
| 245 |
#endif |
| 246 |
{ |
| 247 |
Arg args[2]; |
| 248 |
Widget popup, dialog; |
| 249 |
Position x, y; |
| 250 |
Dimension width, height; |
| 251 |
|
| 252 |
XtSetArg(args[0], XtNwidth, &width); |
| 253 |
XtSetArg(args[1], XtNheight, &height); |
| 254 |
XtGetValues(button, args, TWO); |
| 255 |
XtTranslateCoords(button, |
| 256 |
(Position)(width / 2 - 64), (Position)(height / 2 - 32), |
| 257 |
&x, &y); |
| 258 |
XtSetArg(args[0], XtNx, x); |
| 259 |
XtSetArg(args[1], XtNy, y); |
| 260 |
popup = XtCreatePopupShell((String) "popup", |
| 261 |
transientShellWidgetClass, button, |
| 262 |
args, TWO); |
| 263 |
XtSetArg(args[0], XtNlabel, message); |
| 264 |
XtSetArg(args[1], XtNvalue, default_value); |
| 265 |
dialog = XtCreateManagedWidget((String) "dialog", |
| 266 |
dialogWidgetClass, popup, |
| 267 |
args, TWO); |
| 268 |
XawDialogAddButton(dialog, "ok", selectOkProc, (XtPointer) dialog); |
| 269 |
XawDialogAddButton(dialog, "cancel", selectCancelProc, (XtPointer) dialog); |
| 270 |
current_dialog = id; |
| 271 |
XtPopup(popup, XtGrabExclusive); |
| 272 |
setBusy(True); |
| 273 |
} |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
#ifdef __STDC__ |
| 278 |
void select_soundProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 279 |
#else |
| 280 |
void select_soundProc(w, client_data, call_data) |
| 281 |
Widget w; |
| 282 |
XtPointer client_data; |
| 283 |
XtPointer call_data; |
| 284 |
#endif |
| 285 |
{ |
| 286 |
|
| 287 |
} |
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
#ifdef __STDC__ |
| 292 |
void select_queueProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 293 |
#else |
| 294 |
void select_queueProc(w, client_data, call_data) |
| 295 |
Widget w; |
| 296 |
XtPointer client_data; |
| 297 |
XtPointer call_data; |
| 298 |
#endif |
| 299 |
{ |
| 300 |
|
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
#ifdef __STDC__ |
| 306 |
void select_spoolProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 307 |
#else |
| 308 |
void select_spoolProc(w, client_data, call_data) |
| 309 |
Widget w; |
| 310 |
XtPointer client_data; |
| 311 |
XtPointer call_data; |
| 312 |
#endif |
| 313 |
{ |
| 314 |
|
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
#ifdef __STDC__ |
| 320 |
void quitProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 321 |
#else |
| 322 |
void quitProc(w, client_data, call_data) |
| 323 |
Widget w; |
| 324 |
XtPointer client_data; |
| 325 |
XtPointer call_data; |
| 326 |
#endif |
| 327 |
{ |
| 328 |
XtDestroyWidget(top_shell); |
| 329 |
exit(return_code); |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
#ifdef __STDC__ |
| 335 |
void jukeboxProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 336 |
#else |
| 337 |
void jukeboxProc(w, client_data, call_data) |
| 338 |
Widget w; |
| 339 |
XtPointer client_data; |
| 340 |
XtPointer call_data; |
| 341 |
#endif |
| 342 |
{ |
| 343 |
if (resources.jukebox_shown) |
| 344 |
{ |
| 345 |
resources.jukebox_shown = False; |
| 346 |
XtPopdown(jukebox_shell); |
| 347 |
} |
| 348 |
else |
| 349 |
{ |
| 350 |
XtPopup(jukebox_shell, XtGrabNone); |
| 351 |
resources.jukebox_shown = True; |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
#ifdef __STDC__ |
| 358 |
void hostProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 359 |
#else |
| 360 |
void hostProc(w, client_data, call_data) |
| 361 |
Widget w; |
| 362 |
XtPointer client_data; |
| 363 |
XtPointer call_data; |
| 364 |
#endif |
| 365 |
{ |
| 366 |
popupDialog(w, (String) "New rplay host :", |
| 367 |
(String) rplay_default_host(), |
| 368 |
DIALOG_SET_NEW_HOST); |
| 369 |
setSpoolUpdate(False); |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
#ifdef __STDC__ |
| 375 |
void aboutProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 376 |
#else |
| 377 |
void aboutProc(w, client_data, call_data) |
| 378 |
Widget w; |
| 379 |
XtPointer client_data; |
| 380 |
XtPointer call_data; |
| 381 |
#endif |
| 382 |
{ |
| 383 |
Arg args[5]; |
| 384 |
XtCallbackRec callback[2]; |
| 385 |
Widget popup, about, label, button; |
| 386 |
Position x, y; |
| 387 |
Dimension width, height; |
| 388 |
char buffer[100]; |
| 389 |
|
| 390 |
XtSetArg(args[0], XtNwidth, &width); |
| 391 |
XtSetArg(args[1], XtNheight, &height); |
| 392 |
XtGetValues(w, args, TWO); |
| 393 |
XtTranslateCoords(w, (Position)(width / 2 - 64), (Position)(height / 2 - 32), |
| 394 |
&x, &y); |
| 395 |
XtSetArg(args[0], XtNx, x); |
| 396 |
XtSetArg(args[1], XtNy, y); |
| 397 |
popup = XtCreatePopupShell((String) "popup", |
| 398 |
transientShellWidgetClass, w, |
| 399 |
args, TWO); |
| 400 |
about = XtCreateManagedWidget((String) "aboutForm", |
| 401 |
formWidgetClass, popup, |
| 402 |
NULL, ZERO); |
| 403 |
sprintf(buffer, "XJukebox %s (C) 1993, Raphael Quinet\n", XJUKEBOX_VERSION); |
| 404 |
XtSetArg(args[0], XtNlabel, buffer); |
| 405 |
XtSetArg(args[1], XtNborderWidth, NULL); |
| 406 |
XtSetArg(args[2], XtNfromHoriz, NULL); |
| 407 |
XtSetArg(args[3], XtNfromVert, NULL); |
| 408 |
label = XtCreateManagedWidget((String) "aboutLabel1", |
| 409 |
labelWidgetClass, about, |
| 410 |
args, FOUR); |
| 411 |
XtSetArg(args[0], XtNlabel, " <[email protected]>"); |
| 412 |
XtSetArg(args[3], XtNfromVert, label); |
| 413 |
XtSetArg(args[4], XtNvertDistance, 0); |
| 414 |
label = XtCreateManagedWidget((String) "aboutLabel2", |
| 415 |
labelWidgetClass, about, |
| 416 |
args, FIVE); |
| 417 |
XtSetArg(args[0], XtNlabel, "Special thanks to :"); |
| 418 |
XtSetArg(args[3], XtNfromVert, label); |
| 419 |
XtSetArg(args[4], XtNvertDistance, 10); |
| 420 |
label = XtCreateManagedWidget((String) "aboutLabel3", |
| 421 |
labelWidgetClass, about, |
| 422 |
args, FIVE); |
| 423 |
XtSetArg(args[0], XtNlabel, "Mark Boyns <[email protected]>"); |
| 424 |
XtSetArg(args[3], XtNfromVert, label); |
| 425 |
XtSetArg(args[4], XtNvertDistance, 0); |
| 426 |
label = XtCreateManagedWidget((String) "aboutLabel4", |
| 427 |
labelWidgetClass, about, |
| 428 |
args, FIVE); |
| 429 |
XtSetArg(args[0], XtNlabel, " for his rplay library"); |
| 430 |
XtSetArg(args[3], XtNfromVert, label); |
| 431 |
label = XtCreateManagedWidget((String) "aboutLabel5", |
| 432 |
labelWidgetClass, about, |
| 433 |
args, FIVE); |
| 434 |
XtSetArg(args[0], XtNlabel, "Alain Nissen <[email protected]>"); |
| 435 |
XtSetArg(args[3], XtNfromVert, label); |
| 436 |
label = XtCreateManagedWidget((String) "aboutLabel6", |
| 437 |
labelWidgetClass, about, |
| 438 |
args, FIVE); |
| 439 |
XtSetArg(args[0], XtNlabel, " for his help and encouragements"); |
| 440 |
XtSetArg(args[3], XtNfromVert, label); |
| 441 |
label = XtCreateManagedWidget((String) "aboutLabel7", |
| 442 |
labelWidgetClass, about, |
| 443 |
args, FIVE); |
| 444 |
callback[0].callback = selectCancelProc; |
| 445 |
callback[0].closure = (XtPointer) about; |
| 446 |
callback[1].callback = NULL; |
| 447 |
callback[1].closure = NULL; |
| 448 |
XtSetArg(args[0], XtNcallback, callback); |
| 449 |
XtSetArg(args[1], XtNlabel, "Done"); |
| 450 |
XtSetArg(args[2], XtNfromHoriz, NULL); |
| 451 |
XtSetArg(args[3], XtNfromVert, label); |
| 452 |
button = XtCreateManagedWidget((String) "doneButton", |
| 453 |
commandWidgetClass, about, |
| 454 |
args, FOUR); |
| 455 |
XtPopup(popup, XtGrabExclusive); |
| 456 |
setBusy(True); |
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
#ifdef __STDC__ |
| 462 |
void stopProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 463 |
#else |
| 464 |
void stopProc(w, client_data, call_data) |
| 465 |
Widget w; |
| 466 |
XtPointer client_data; |
| 467 |
XtPointer call_data; |
| 468 |
#endif |
| 469 |
{ |
| 470 |
XawListReturnStruct *item; |
| 471 |
|
| 472 |
item = XawListShowCurrent(spool_list); |
| 473 |
if (spool_count > 0) |
| 474 |
{ |
| 475 |
if (item->list_index != XAW_LIST_NONE) |
| 476 |
rptp_stop_sound(item->list_index); |
| 477 |
else |
| 478 |
rptp_stop_sound(0); |
| 479 |
} |
| 480 |
else |
| 481 |
ringBell(); |
| 482 |
} |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
#ifdef __STDC__ |
| 487 |
void pauseProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 488 |
#else |
| 489 |
void pauseProc(w, client_data, call_data) |
| 490 |
Widget w; |
| 491 |
XtPointer client_data; |
| 492 |
XtPointer call_data; |
| 493 |
#endif |
| 494 |
{ |
| 495 |
XawListReturnStruct *item; |
| 496 |
|
| 497 |
item = XawListShowCurrent(spool_list); |
| 498 |
if (spool_count > 0) |
| 499 |
{ |
| 500 |
if (item->list_index != XAW_LIST_NONE) |
| 501 |
rptp_pause_sound(item->list_index); |
| 502 |
else |
| 503 |
rptp_pause_sound(0); |
| 504 |
} |
| 505 |
else |
| 506 |
ringBell(); |
| 507 |
} |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
#ifdef __STDC__ |
| 512 |
void continueProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 513 |
#else |
| 514 |
void continueProc(w, client_data, call_data) |
| 515 |
Widget w; |
| 516 |
XtPointer client_data; |
| 517 |
XtPointer call_data; |
| 518 |
#endif |
| 519 |
{ |
| 520 |
XawListReturnStruct *item; |
| 521 |
|
| 522 |
item = XawListShowCurrent(spool_list); |
| 523 |
if (spool_count > 0) |
| 524 |
{ |
| 525 |
if (item->list_index != XAW_LIST_NONE) |
| 526 |
rptp_continue_sound(item->list_index); |
| 527 |
else |
| 528 |
rptp_continue_sound(0); |
| 529 |
} |
| 530 |
else |
| 531 |
ringBell(); |
| 532 |
} |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
#ifdef __STDC__ |
| 537 |
void addProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 538 |
#else |
| 539 |
void addProc(w, client_data, call_data) |
| 540 |
Widget w; |
| 541 |
XtPointer client_data; |
| 542 |
XtPointer call_data; |
| 543 |
#endif |
| 544 |
{ |
| 545 |
XawListReturnStruct *item; |
| 546 |
|
| 547 |
item = XawListShowCurrent(sound_list); |
| 548 |
if ((item->list_index != XAW_LIST_NONE) && (sound_count > 0)) |
| 549 |
add_item(item->string, &queue_names, &queue_count); |
| 550 |
else |
| 551 |
ringBell(); |
| 552 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 553 |
} |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
#ifdef __STDC__ |
| 558 |
void addallProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 559 |
#else |
| 560 |
void addallProc(w, client_data, call_data) |
| 561 |
Widget w; |
| 562 |
XtPointer client_data; |
| 563 |
XtPointer call_data; |
| 564 |
#endif |
| 565 |
{ |
| 566 |
int i; |
| 567 |
|
| 568 |
for (i = 0; i < sound_count; i++) |
| 569 |
add_item(sound_names[i], &queue_names, &queue_count); |
| 570 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 571 |
} |
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
#ifdef __STDC__ |
| 576 |
void sfileMenuSelectProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 577 |
#else |
| 578 |
void sfileMenuSelectProc(w, client_data, call_data) |
| 579 |
Widget w; |
| 580 |
XtPointer client_data; |
| 581 |
XtPointer call_data; |
| 582 |
#endif |
| 583 |
{ |
| 584 |
if (!strcmp(XtName(w), "serverList")) |
| 585 |
{ |
| 586 |
setBusy(True); |
| 587 |
rptp_get_sound_list(); |
| 588 |
} |
| 589 |
if (!strcmp(XtName(w), "loadList")) |
| 590 |
popupDialog(XtParent(XtParent(w)), (String) "Load list from file :", |
| 591 |
default_file, DIALOG_LOAD_SOUND_FILE); |
| 592 |
if (!strcmp(XtName(w), "saveList")) |
| 593 |
popupDialog(XtParent(XtParent(w)), (String) "Save list into file :", |
| 594 |
default_file, DIALOG_SAVE_SOUND_FILE); |
| 595 |
} |
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
#ifdef __STDC__ |
| 600 |
void playProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 601 |
#else |
| 602 |
void playProc(w, client_data, call_data) |
| 603 |
Widget w; |
| 604 |
XtPointer client_data; |
| 605 |
XtPointer call_data; |
| 606 |
#endif |
| 607 |
{ |
| 608 |
if (queue_count >= 1) |
| 609 |
{ |
| 610 |
rptp_play_sound(queue_names[0]); |
| 611 |
delete_item(0, &queue_names, &queue_count); |
| 612 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 613 |
} |
| 614 |
else |
| 615 |
XBell(XtDisplay(w), 50); |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
#ifdef __STDC__ |
| 621 |
void deleteProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 622 |
#else |
| 623 |
void deleteProc(w, client_data, call_data) |
| 624 |
Widget w; |
| 625 |
XtPointer client_data; |
| 626 |
XtPointer call_data; |
| 627 |
#endif |
| 628 |
{ |
| 629 |
XawListReturnStruct *item; |
| 630 |
|
| 631 |
item = XawListShowCurrent(queue_list); |
| 632 |
if (item->list_index != XAW_LIST_NONE) |
| 633 |
delete_item(item->list_index, &queue_names, &queue_count); |
| 634 |
else |
| 635 |
if (queue_count >= 1) |
| 636 |
delete_item(queue_count - 1, &queue_names, &queue_count); |
| 637 |
else |
| 638 |
XBell(XtDisplay(w), 50); |
| 639 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 640 |
} |
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
#ifdef __STDC__ |
| 645 |
void sortMenuSelectProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 646 |
#else |
| 647 |
void sortMenuSelectProc(w, client_data, call_data) |
| 648 |
Widget w; |
| 649 |
XtPointer client_data; |
| 650 |
XtPointer call_data; |
| 651 |
#endif |
| 652 |
{ |
| 653 |
XawListReturnStruct *item; |
| 654 |
|
| 655 |
item = XawListShowCurrent(queue_list); |
| 656 |
if (!strcmp(XtName(w), "moveToTop")) |
| 657 |
{ |
| 658 |
if (item->list_index != XAW_LIST_NONE) |
| 659 |
move_item(item->list_index, 0, &queue_names); |
| 660 |
else |
| 661 |
move_item(queue_count - 1, 0, &queue_names); |
| 662 |
} |
| 663 |
if (!strcmp(XtName(w), "moveToBottom")) |
| 664 |
{ |
| 665 |
if (item->list_index != XAW_LIST_NONE) |
| 666 |
move_item(item->list_index, queue_count - 1, &queue_names); |
| 667 |
else |
| 668 |
move_item(0, queue_count - 1, &queue_names); |
| 669 |
} |
| 670 |
if (!strcmp(XtName(w), "sortByName")) |
| 671 |
{ |
| 672 |
qsort((char *)queue_names, queue_count, sizeof(String), alphacompare); |
| 673 |
} |
| 674 |
if (!strcmp(XtName(w), "sortBySize")) |
| 675 |
{ |
| 676 |
printf("*** Not implemented : Sort by size...\n"); |
| 677 |
} |
| 678 |
if (!strcmp(XtName(w), "shuffle")) |
| 679 |
{ |
| 680 |
printf("*** Not implemented : Shuffle...\n"); |
| 681 |
} |
| 682 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 683 |
} |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
#ifdef __STDC__ |
| 688 |
void qfileMenuSelectProc(Widget w, XtPointer client_data, XtPointer call_data) |
| 689 |
#else |
| 690 |
void qfileMenuSelectProc(w, client_data, call_data) |
| 691 |
Widget w; |
| 692 |
XtPointer client_data; |
| 693 |
XtPointer call_data; |
| 694 |
#endif |
| 695 |
{ |
| 696 |
if (!strcmp(XtName(w), "directoryList")) |
| 697 |
popupDialog(XtParent(XtParent(w)), (String) "Build list from directory :", "", |
| 698 |
DIALOG_GET_SOUND_DIR); |
| 699 |
if (!strcmp(XtName(w), "loadList")) |
| 700 |
popupDialog(XtParent(XtParent(w)), (String) "Load list from file :", |
| 701 |
default_file, DIALOG_LOAD_QUEUE_FILE); |
| 702 |
if (!strcmp(XtName(w), "saveList")) |
| 703 |
popupDialog(XtParent(XtParent(w)), (String) "Save list into file :", |
| 704 |
default_file, DIALOG_SAVE_QUEUE_FILE); |
| 705 |
} |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
#ifdef __STDC__ |
| 710 |
void wmProtocolsProc(Widget w, XEvent *event, String params[], Cardinal *num_params) |
| 711 |
#else |
| 712 |
void wmProtocolsProc(w, event, params, num_params) |
| 713 |
Widget w; |
| 714 |
XEvent *event; |
| 715 |
String params[]; |
| 716 |
Cardinal *num_params; |
| 717 |
#endif |
| 718 |
{ |
| 719 |
if (event -> xclient.data.l[0] == XA_WM_DELETE_WINDOW) |
| 720 |
{ |
| 721 |
if ((w == top_shell) && ! closing_top_shell) |
| 722 |
{ |
| 723 |
closing_top_shell = True; |
| 724 |
quitProc(w, (XtPointer) NULL, (XtPointer) NULL); |
| 725 |
closing_top_shell = False; |
| 726 |
} |
| 727 |
if (w == jukebox_shell) |
| 728 |
{ |
| 729 |
resources.jukebox_shown = False; |
| 730 |
XtPopdown(jukebox_shell); |
| 731 |
} |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
#ifdef __STDC__ |
| 738 |
void okProc(Widget w, XEvent *event, String params[], Cardinal *num_params) |
| 739 |
#else |
| 740 |
void okProc(w, event, params, num_params) |
| 741 |
Widget w; |
| 742 |
XEvent *event; |
| 743 |
String params[]; |
| 744 |
Cardinal *num_params; |
| 745 |
#endif |
| 746 |
{ |
| 747 |
Widget dialog; |
| 748 |
|
| 749 |
dialog = XtParent(w); |
| 750 |
selectOkProc(w, (XtPointer) dialog, (XtPointer) NULL); |
| 751 |
} |
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
#ifdef __STDC__ |
| 756 |
void cancelProc(Widget w, XEvent *event, String params[], Cardinal *num_params) |
| 757 |
#else |
| 758 |
void cancelProc(w, event, params, num_params) |
| 759 |
Widget w; |
| 760 |
XEvent *event; |
| 761 |
String params[]; |
| 762 |
Cardinal *num_params; |
| 763 |
#endif |
| 764 |
{ |
| 765 |
Widget dialog; |
| 766 |
|
| 767 |
dialog = XtParent(w); |
| 768 |
selectCancelProc(w, (XtPointer) dialog, (XtPointer) NULL); |
| 769 |
} |
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
#ifdef __STDC__ |
| 774 |
void create_widgets(Widget top_shell) |
| 775 |
#else |
| 776 |
void create_widgets(top_shell) |
| 777 |
Widget top_shell; |
| 778 |
#endif |
| 779 |
{ |
| 780 |
Widget sound_viewport, queue_viewport, spool_viewport; |
| 781 |
Widget sound_label, queue_label, spool_label; |
| 782 |
Widget spool_form, jukebox_paned, sound_form, queue_form; |
| 783 |
Widget quit_button, jukebox_button, host_button, about_button; |
| 784 |
Widget stop_button, pause_button, continue_button; |
| 785 |
Widget add_button, addall_button, sfile_button; |
| 786 |
Widget play_button, delete_button, sort_button, qfile_button; |
| 787 |
Widget menu, menu_item; |
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
spool_form = XtCreateManagedWidget((String) "spoolForm", |
| 792 |
formWidgetClass, top_shell, |
| 793 |
NULL, ZERO); |
| 794 |
|
| 795 |
quit_button = XtCreateManagedWidget((String) "quitButton", |
| 796 |
commandWidgetClass, spool_form, |
| 797 |
NULL, ZERO); |
| 798 |
XtAddCallback(quit_button, XtNcallback, quitProc, NULL); |
| 799 |
|
| 800 |
jukebox_button = XtCreateManagedWidget((String) "jukeboxButton", |
| 801 |
commandWidgetClass, spool_form, |
| 802 |
NULL, ZERO); |
| 803 |
XtAddCallback(jukebox_button, XtNcallback, jukeboxProc, NULL); |
| 804 |
|
| 805 |
host_button = XtCreateManagedWidget((String) "hostButton", |
| 806 |
commandWidgetClass, spool_form, |
| 807 |
NULL, ZERO); |
| 808 |
XtAddCallback(host_button, XtNcallback, hostProc, NULL); |
| 809 |
|
| 810 |
about_button = XtCreateManagedWidget((String) "aboutButton", |
| 811 |
commandWidgetClass, spool_form, |
| 812 |
NULL, ZERO); |
| 813 |
XtAddCallback(about_button, XtNcallback, aboutProc, NULL); |
| 814 |
|
| 815 |
spool_label = XtCreateManagedWidget((String) "spoolLabel", |
| 816 |
labelWidgetClass, spool_form, |
| 817 |
NULL, ZERO); |
| 818 |
|
| 819 |
spool_viewport = XtCreateManagedWidget((String) "spoolViewport", |
| 820 |
viewportWidgetClass, spool_form, |
| 821 |
NULL, ZERO); |
| 822 |
|
| 823 |
spool_list = XtCreateManagedWidget((String) "spoolList", |
| 824 |
listWidgetClass, spool_viewport, |
| 825 |
NULL, ZERO); |
| 826 |
XtAddCallback(spool_list, XtNcallback, select_spoolProc, NULL); |
| 827 |
XawListChange(spool_list, spool_names, spool_count, 0, True); |
| 828 |
|
| 829 |
stop_button = XtCreateManagedWidget((String) "stopButton", |
| 830 |
commandWidgetClass, spool_form, |
| 831 |
NULL, ZERO); |
| 832 |
XtAddCallback(stop_button, XtNcallback, stopProc, NULL); |
| 833 |
|
| 834 |
pause_button = XtCreateManagedWidget((String) "pauseButton", |
| 835 |
commandWidgetClass, spool_form, |
| 836 |
NULL, ZERO); |
| 837 |
XtAddCallback(pause_button, XtNcallback, pauseProc, NULL); |
| 838 |
|
| 839 |
continue_button = XtCreateManagedWidget((String) "continueButton", |
| 840 |
commandWidgetClass, spool_form, |
| 841 |
NULL, ZERO); |
| 842 |
XtAddCallback(continue_button, XtNcallback, continueProc, NULL); |
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
jukebox_shell = XtCreatePopupShell((String) "jukebox", |
| 847 |
topLevelShellWidgetClass, top_shell, |
| 848 |
NULL, ZERO); |
| 849 |
|
| 850 |
jukebox_paned = XtCreateManagedWidget((String) "jukeboxPaned", |
| 851 |
panedWidgetClass, jukebox_shell, |
| 852 |
NULL, ZERO); |
| 853 |
|
| 854 |
sound_form = XtCreateManagedWidget((String) "soundForm", |
| 855 |
formWidgetClass, jukebox_paned, |
| 856 |
NULL, ZERO); |
| 857 |
|
| 858 |
sound_label = XtCreateManagedWidget((String) "soundLabel", |
| 859 |
labelWidgetClass, sound_form, |
| 860 |
NULL, ZERO); |
| 861 |
|
| 862 |
sound_viewport = XtCreateManagedWidget((String) "soundViewport", |
| 863 |
viewportWidgetClass, sound_form, |
| 864 |
NULL, ZERO); |
| 865 |
|
| 866 |
sound_list = XtCreateManagedWidget((String) "soundList", |
| 867 |
listWidgetClass, sound_viewport, |
| 868 |
NULL, ZERO); |
| 869 |
XtAddCallback(sound_list, XtNcallback, select_soundProc, NULL); |
| 870 |
XawListChange(sound_list, sound_names, sound_count, 0, True); |
| 871 |
|
| 872 |
add_button = XtCreateManagedWidget((String) "addButton", |
| 873 |
commandWidgetClass, sound_form, |
| 874 |
NULL, ZERO); |
| 875 |
XtAddCallback(add_button, XtNcallback, addProc, NULL); |
| 876 |
|
| 877 |
addall_button = XtCreateManagedWidget((String) "addAllButton", |
| 878 |
commandWidgetClass, sound_form, |
| 879 |
NULL, ZERO); |
| 880 |
XtAddCallback(addall_button, XtNcallback, addallProc, NULL); |
| 881 |
|
| 882 |
sfile_button = XtCreateManagedWidget((String) "sfileMenuButton", |
| 883 |
menuButtonWidgetClass, sound_form, |
| 884 |
NULL, ZERO); |
| 885 |
|
| 886 |
|
| 887 |
queue_form = XtCreateManagedWidget((String) "queueForm", |
| 888 |
formWidgetClass, jukebox_paned, |
| 889 |
NULL, ZERO); |
| 890 |
|
| 891 |
queue_label = XtCreateManagedWidget((String) "queueLabel", |
| 892 |
labelWidgetClass, queue_form, |
| 893 |
NULL, ZERO); |
| 894 |
|
| 895 |
queue_viewport = XtCreateManagedWidget((String) "queueViewport", |
| 896 |
viewportWidgetClass, queue_form, |
| 897 |
NULL, ZERO); |
| 898 |
|
| 899 |
queue_list = XtCreateManagedWidget((String) "queueList", |
| 900 |
listWidgetClass, queue_viewport, |
| 901 |
NULL, ZERO); |
| 902 |
|
| 903 |
XtAddCallback(queue_list, XtNcallback, select_queueProc, NULL); |
| 904 |
XawListChange(queue_list, queue_names, queue_count, 0, True); |
| 905 |
|
| 906 |
play_button = XtCreateManagedWidget((String) "playButton", |
| 907 |
commandWidgetClass, queue_form, |
| 908 |
NULL, ZERO); |
| 909 |
XtAddCallback(play_button, XtNcallback, playProc, NULL); |
| 910 |
|
| 911 |
delete_button = XtCreateManagedWidget((String) "deleteButton", |
| 912 |
commandWidgetClass, queue_form, |
| 913 |
NULL, ZERO); |
| 914 |
XtAddCallback(delete_button, XtNcallback, deleteProc, NULL); |
| 915 |
|
| 916 |
sort_button = XtCreateManagedWidget((String) "sortMenuButton", |
| 917 |
menuButtonWidgetClass, queue_form, |
| 918 |
NULL, ZERO); |
| 919 |
|
| 920 |
qfile_button = XtCreateManagedWidget((String) "qfileMenuButton", |
| 921 |
menuButtonWidgetClass, queue_form, |
| 922 |
NULL, ZERO); |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
menu = XtCreatePopupShell((String) "menu", |
| 927 |
simpleMenuWidgetClass, sfile_button, |
| 928 |
NULL, ZERO); |
| 929 |
|
| 930 |
menu_item = XtCreateManagedWidget((String) "serverList", |
| 931 |
smeBSBObjectClass, menu, |
| 932 |
NULL, ZERO); |
| 933 |
XtAddCallback(menu_item, XtNcallback, sfileMenuSelectProc, NULL); |
| 934 |
|
| 935 |
menu_item = XtCreateManagedWidget((String) "loadList", |
| 936 |
smeBSBObjectClass, menu, |
| 937 |
NULL, ZERO); |
| 938 |
XtAddCallback(menu_item, XtNcallback, sfileMenuSelectProc, NULL); |
| 939 |
|
| 940 |
menu_item = XtCreateManagedWidget((String) "saveList", |
| 941 |
smeBSBObjectClass, menu, |
| 942 |
NULL, ZERO); |
| 943 |
XtAddCallback(menu_item, XtNcallback, sfileMenuSelectProc, NULL); |
| 944 |
|
| 945 |
menu = XtCreatePopupShell((String) "menu", |
| 946 |
simpleMenuWidgetClass, sort_button, |
| 947 |
NULL, ZERO); |
| 948 |
|
| 949 |
menu_item = XtCreateManagedWidget((String) "moveToTop", |
| 950 |
smeBSBObjectClass, menu, |
| 951 |
NULL, ZERO); |
| 952 |
XtAddCallback(menu_item, XtNcallback, sortMenuSelectProc, NULL); |
| 953 |
|
| 954 |
menu_item = XtCreateManagedWidget((String) "moveToBottom", |
| 955 |
smeBSBObjectClass, menu, |
| 956 |
NULL, ZERO); |
| 957 |
XtAddCallback(menu_item, XtNcallback, sortMenuSelectProc, NULL); |
| 958 |
|
| 959 |
menu_item = XtCreateManagedWidget((String) "sortByName", |
| 960 |
smeBSBObjectClass, menu, |
| 961 |
NULL, ZERO); |
| 962 |
XtAddCallback(menu_item, XtNcallback, sortMenuSelectProc, NULL); |
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
menu = XtCreatePopupShell((String) "menu", |
| 977 |
simpleMenuWidgetClass, qfile_button, |
| 978 |
NULL, ZERO); |
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
menu_item = XtCreateManagedWidget((String) "loadList", |
| 988 |
smeBSBObjectClass, menu, |
| 989 |
NULL, ZERO); |
| 990 |
XtAddCallback(menu_item, XtNcallback, qfileMenuSelectProc, NULL); |
| 991 |
|
| 992 |
menu_item = XtCreateManagedWidget((String) "saveList", |
| 993 |
smeBSBObjectClass, menu, |
| 994 |
NULL, ZERO); |
| 995 |
XtAddCallback(menu_item, XtNcallback, qfileMenuSelectProc, NULL); |
| 996 |
} |
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
#ifdef __STDC__ |
| 1001 |
void init_application(char *app_name, int argc, char *argv[]) |
| 1002 |
#else |
| 1003 |
void init_application(app_name, argc, argv) |
| 1004 |
char *app_name; |
| 1005 |
int argc; |
| 1006 |
char *argv[]; |
| 1007 |
#endif |
| 1008 |
{ |
| 1009 |
Display *disp; |
| 1010 |
|
| 1011 |
top_shell = XtAppInitialize(&app_context, app_name, |
| 1012 |
options, XtNumber(options), |
| 1013 |
&argc, argv, |
| 1014 |
fallback_resources, NULL, ZERO); |
| 1015 |
disp = XtDisplay(top_shell); |
| 1016 |
XA_WM_DELETE_WINDOW = XInternAtom(disp, "WM_DELETE_WINDOW", False); |
| 1017 |
XtGetApplicationResources(top_shell, (XtPointer) &resources, |
| 1018 |
resources_desc, XtNumber(resources_desc), |
| 1019 |
NULL, ZERO); |
| 1020 |
XtAppAddActions(app_context, actions, XtNumber(actions)); |
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
create_widgets(top_shell); |
| 1026 |
XtRealizeWidget(top_shell); |
| 1027 |
XSetWMProtocols(disp, XtWindow(top_shell), &XA_WM_DELETE_WINDOW, 1); |
| 1028 |
XtRealizeWidget(jukebox_shell); |
| 1029 |
XSetWMProtocols(disp, XtWindow(jukebox_shell), &XA_WM_DELETE_WINDOW, 1); |
| 1030 |
if (resources.jukebox_shown) |
| 1031 |
XtPopup(jukebox_shell, XtGrabNone); |
| 1032 |
} |