comparison src/xmms-sid.cc @ 57:85811bcd049e

Improved, re-written configuration code and lots of minor fixes
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 22 Jun 2003 11:01:03 +0000
parents 6a3ce7260ae1
children 05220299c6e8
comparison
equal deleted inserted replaced
56:6a3ce7260ae1 57:85811bcd049e
85 void xs_ctrlwin_open(void) 85 void xs_ctrlwin_open(void)
86 { 86 {
87 /* Create sub-song control window */ 87 /* Create sub-song control window */
88 if (xs_ctrlwin != NULL) 88 if (xs_ctrlwin != NULL)
89 { 89 {
90 gdk_window_raise(xs_ctrlwin->window); 90 if (xs_cfg.alwaysRaise)
91 gdk_window_raise(xs_ctrlwin->window);
91 return; 92 return;
92 } 93 }
93 94
94 xs_ctrlwin = create_xs_ctrlwin(); 95 xs_ctrlwin = create_xs_ctrlwin();
95 gtk_widget_show(xs_ctrlwin); 96 gtk_widget_show(xs_ctrlwin);
106 /* Initialize and get configuration */ 107 /* Initialize and get configuration */
107 memset(&xs_cfg, 0, sizeof(xs_cfg)); 108 memset(&xs_cfg, 0, sizeof(xs_cfg));
108 109
109 xs_read_configuration(); 110 xs_read_configuration();
110 111
112 add_pixmap_directory(PACKAGE_DATA_DIR "/pixmaps");
113
114 /* Initialize status */
111 xs_status.isError = FALSE; 115 xs_status.isError = FALSE;
112 xs_status.isPlaying = FALSE; 116 xs_status.isPlaying = FALSE;
113 xs_status.nSongs = 0; 117 xs_status.nSongs = 0;
114 xs_status.currSong = 0; 118 xs_status.currSong = 0;
115 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song 119 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song
136 XSERR("Error initializing song-length database!\n"); 140 XSERR("Error initializing song-length database!\n");
137 } 141 }
138 142
139 /* Initialize STIL structures */ 143 /* Initialize STIL structures */
140 144
141 xs_ctrlwin_open(); 145 // xs_ctrlwin_open();
142 146
143 // FIXME FIXME FIx ME 147 // FIXME FIXME FIx ME
144 148
145 } 149 }
146 150
579 * Create the SID-tune description string from the tune's information 583 * Create the SID-tune description string from the tune's information
580 * formatted by the user-specified format-string. 584 * formatted by the user-specified format-string.
581 */ 585 */
582 gchar *xs_filetitle_get(gchar *pcFilename, void *pfInfo, gint iSubTune) 586 gchar *xs_filetitle_get(gchar *pcFilename, void *pfInfo, gint iSubTune)
583 { 587 {
584 gint i, j, iLength; 588 gint j, iLength;
585 gchar *pcResult; 589 gchar *pcStr, *pcResult;
586 t_xs_tuneinfo *finfo = (t_xs_tuneinfo *) pfInfo; 590 t_xs_tuneinfo *finfo = (t_xs_tuneinfo *) pfInfo;
587 #ifdef HAVE_XMMSEXTRA 591 #ifdef HAVE_XMMSEXTRA
588 TitleInput *ptInput; 592 TitleInput *ptInput;
589 #endif 593 #endif
590 594
633 return 0; 637 return 0;
634 638
635 return g_strdup(finfo->infoString[0]); 639 return g_strdup(finfo->infoString[0]);
636 } 640 }
637 641
638 /* Construct the final result info */ 642 /* Estimate the length of the string */
639 for (j = i = 0; i < strlen(xs_cfg.titleFormat); i++) 643 pcStr = xs_cfg.titleFormat;
644 iLength = 0;
645 while (*pcStr)
646 {
647 if (*pcStr == '%')
640 { 648 {
641 if (xs_cfg.titleFormat[i] == '%') 649 switch (*(++pcStr)) {
642 { 650 case '1': iLength += strlen(finfo->authorString); break;
643 switch (xs_cfg.titleFormat[++i]) { 651 case '2': iLength += strlen(finfo->nameString); break;
644 case '1': 652 case '3': iLength += strlen(finfo->copyrightString); break;
645 xs_strpcat(&pcResult, &j, finfo->authorString); 653 case '4': iLength += strlen(finfo->formatString); break;
646 break; 654 case '%': iLength++;
647
648 case '2':
649 xs_strpcat(&pcResult, &j, finfo->nameString);
650 break;
651
652 case '3':
653 xs_strpcat(&pcResult, &j, finfo->copyrightString);
654 break;
655
656 case '4':
657 xs_strpcat(&pcResult, &j, finfo->formatString);
658 break;
659 } /* case */
660 } else
661 pcResult[j++] = xs_cfg.titleFormat[i];
662 } 655 }
656 } else
657 iLength++;
658 }
659
660 /* Allocate memory */
661 pcResult = (gchar *) g_malloc(iLength + 2);
662 if (pcResult == NULL)
663 return g_strdup(finfo->infoString[0]);
664
665 /* Create the string */
666 pcStr = xs_cfg.titleFormat;
667 j = 0;
668 while (*pcStr)
669 {
670 if (*pcStr == '%')
671 {
672 switch (*(++pcStr)) {
673 case '1': xs_strpcat(pcResult, &j, finfo->authorString); break;
674 case '2': xs_strpcat(pcResult, &j, finfo->nameString); break;
675 case '3': xs_strpcat(pcResult, &j, finfo->copyrightString); break;
676 case '4': xs_strpcat(pcResult, &j, finfo->formatString); break;
677 case '%': pcResult[j++] = '%'; break;
678 }
679 } else
680 pcResult[j++] = *pcStr;
681 }
663 682
664 pcResult[j] = 0; 683 pcResult[j] = 0;
665 #ifdef HAVE_XMMSEXTRA 684 #ifdef HAVE_XMMSEXTRA
666 } 685 }
667 #endif 686 #endif