Mercurial > hg > xmms-sid
comparison src/xmms-sid.c @ 177:6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
consistent operation while graying out unavailable settings.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 18 Aug 2004 03:27:00 +0000 |
parents | 505da1389e5c |
children | 4406e91d2da3 |
comparison
equal
deleted
inserted
replaced
176:d109d928ccc3 | 177:6e350784aa57 |
---|---|
301 pthread_mutex_unlock(&xs_mutex); | 301 pthread_mutex_unlock(&xs_mutex); |
302 | 302 |
303 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); | 303 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); |
304 | 304 |
305 songLength = myTune->subTunes[myStatus.currSong - 1].tuneLength; | 305 songLength = myTune->subTunes[myStatus.currSong - 1].tuneLength; |
306 if (xs_cfg.playMinTimeEnable) | |
307 { | |
308 if (songLength < xs_cfg.playMinTime) | |
309 songLength = xs_cfg.playMinTime; | |
310 } | |
306 | 311 |
307 /* Initialize song */ | 312 /* Initialize song */ |
308 if (!xs_player->plrInitSong(&myStatus)) | 313 if (!xs_player->plrInitSong(&myStatus)) |
309 { | 314 { |
310 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", | 315 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", |
488 | 493 |
489 | 494 |
490 /* | 495 /* |
491 * Pop-up subtune selector | 496 * Pop-up subtune selector |
492 */ | 497 */ |
498 #define LUW(x...) lookup_widget(xs_fileinfowin, ## x) | |
499 | |
493 void xs_subctrl_update(void) | 500 void xs_subctrl_update(void) |
494 { | 501 { |
502 GtkAdjustment *tmpAdj; | |
503 | |
495 if (xs_subctrl) | 504 if (xs_subctrl) |
496 { | 505 { |
497 GTK_ADJUSTMENT(xs_subctrl_adj)->value = xs_status.currSong; | 506 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); |
498 gtk_adjustment_value_changed(GTK_ADJUSTMENT(xs_subctrl_adj)); | 507 |
508 tmpAdj->value = xs_status.currSong; | |
509 tmpAdj->lower = 1; | |
510 tmpAdj->upper = (xs_status.pTune) ? xs_status.pTune->nsubTunes : 1; | |
511 gtk_adjustment_value_changed(tmpAdj); | |
499 } | 512 } |
513 | |
514 if (xs_fileinfowin) | |
515 { | |
516 tmpAdj = gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))); | |
517 | |
518 tmpAdj->value = xs_status.currSong; | |
519 tmpAdj->lower = 1; | |
520 tmpAdj->upper = xs_status.pTune->nsubTunes; | |
521 gtk_adjustment_value_changed(tmpAdj); | |
522 } | |
500 } | 523 } |
501 | 524 |
502 | 525 |
503 void xs_subctrl_setsong(void) | 526 void xs_subctrl_setsong(void) |
504 { | 527 { |
662 return -1; | 685 return -1; |
663 | 686 |
664 /* Let's see what we do */ | 687 /* Let's see what we do */ |
665 switch (xs_cfg.subsongControl) { | 688 switch (xs_cfg.subsongControl) { |
666 case XS_SSC_SEEK: | 689 case XS_SSC_SEEK: |
667 xs_status.lastTime = xs_plugin_ip.output->output_time() / 1000; | 690 xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000); |
668 break; | 691 break; |
669 | 692 |
670 #ifdef HAVE_SONG_POSITION | 693 #ifdef HAVE_SONG_POSITION |
671 case XS_SSC_PATCH: | 694 case XS_SSC_PATCH: |
672 pthread_mutex_lock(&xs_mutex); | 695 pthread_mutex_lock(&xs_mutex); |
674 pthread_mutex_unlock(&xs_mutex); | 697 pthread_mutex_unlock(&xs_mutex); |
675 break; | 698 break; |
676 #endif | 699 #endif |
677 } | 700 } |
678 | 701 |
679 /* Else, return output time reported by audio output plugin */ | 702 /* Return output time reported by audio output plugin */ |
680 return xs_plugin_ip.output->output_time(); | 703 return xs_plugin_ip.output->output_time(); |
681 } | 704 } |
682 | 705 |
683 | 706 |
684 /* | 707 /* |
687 void xs_get_song_info(gchar *songFilename, gchar **songTitle, gint *songLength) | 710 void xs_get_song_info(gchar *songFilename, gchar **songTitle, gint *songLength) |
688 { | 711 { |
689 t_xs_tune *pInfo; | 712 t_xs_tune *pInfo; |
690 gint tmpInt; | 713 gint tmpInt; |
691 | 714 |
715 /* Get tune information from emulation engine */ | |
692 pInfo = xs_player->plrGetSIDInfo(songFilename); | 716 pInfo = xs_player->plrGetSIDInfo(songFilename); |
693 if (!pInfo) return; | 717 if (!pInfo) return; |
694 | 718 |
719 /* Get sub-tune information, if available */ | |
695 if ((pInfo->startTune >= 0) && (pInfo->startTune <= pInfo->nsubTunes)) | 720 if ((pInfo->startTune >= 0) && (pInfo->startTune <= pInfo->nsubTunes)) |
696 { | 721 { |
697 (*songTitle) = g_strdup(pInfo->subTunes[pInfo->startTune - 1].tuneTitle); | 722 (*songTitle) = g_strdup(pInfo->subTunes[pInfo->startTune - 1].tuneTitle); |
698 | 723 |
699 tmpInt = pInfo->subTunes[pInfo->startTune - 1].tuneLength; | 724 tmpInt = pInfo->subTunes[pInfo->startTune - 1].tuneLength; |
700 if (tmpInt < 0) | 725 if (tmpInt < 0) |
701 (*songLength) = -1; | 726 (*songLength) = -1; |
702 else | 727 else |
703 (*songLength) = (tmpInt * 1000); | 728 (*songLength) = (tmpInt * 1000); |
704 } | 729 } |
705 | 730 |
731 /* Free tune information */ | |
706 xs_tune_free(pInfo); | 732 xs_tune_free(pInfo); |
707 } | 733 } |
708 | 734 |
709 | 735 |
710 /* | 736 /* |
762 | 788 |
763 | 789 |
764 /* | 790 /* |
765 * File-information window | 791 * File-information window |
766 */ | 792 */ |
767 #define LUW(x...) lookup_widget(xs_fileinfowin, ## x) | |
768 | |
769 void xs_fileinfo_ok(void) | 793 void xs_fileinfo_ok(void) |
770 { | 794 { |
771 gtk_widget_destroy(xs_fileinfowin); | 795 gtk_widget_destroy(xs_fileinfowin); |
772 xs_fileinfowin = NULL; | 796 xs_fileinfowin = NULL; |
773 } | 797 } |
798 | |
774 | 799 |
775 void xs_fileinfo_subtune(GtkWidget *widget, void *data) | 800 void xs_fileinfo_subtune(GtkWidget *widget, void *data) |
776 { | 801 { |
777 t_xs_stil_subnode *tmpNode; | 802 t_xs_stil_subnode *tmpNode; |
778 GtkWidget *tmpItem, *tmpText; | 803 GtkWidget *tmpItem, *tmpText; |
786 gtk_text_forward_delete(GTK_TEXT(tmpText), | 811 gtk_text_forward_delete(GTK_TEXT(tmpText), |
787 gtk_text_get_length(GTK_TEXT(tmpText))); | 812 gtk_text_get_length(GTK_TEXT(tmpText))); |
788 | 813 |
789 if (xs_fileinfostil) | 814 if (xs_fileinfostil) |
790 { | 815 { |
791 /* Get subtune number */ | 816 /* Get subtune number */ |
792 | 817 tmpItem = gtk_menu_get_active(GTK_MENU(data)); |
793 | 818 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem); |
819 | |
794 /* Get subtune information */ | 820 /* Get subtune information */ |
795 tmpNode = &xs_fileinfostil->subTune[tmpIndex]; | 821 tmpNode = &xs_fileinfostil->subTune[tmpIndex]; |
796 subName = tmpNode->pName; | 822 subName = tmpNode->pName; |
797 subAuthor = tmpNode->pAuthor; | 823 subAuthor = tmpNode->pAuthor; |
798 | 824 |
817 } | 843 } |
818 | 844 |
819 | 845 |
820 void xs_fileinfo(gchar *pcFilename) | 846 void xs_fileinfo(gchar *pcFilename) |
821 { | 847 { |
848 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; | |
822 t_xs_stil_subnode *tmpNode; | 849 t_xs_stil_subnode *tmpNode; |
850 gchar tmpStr[32], *tmpS; | |
851 gint n; | |
823 | 852 |
824 /* Free old info, if set */ | 853 /* Free old info, if set */ |
825 if (xs_fileinfotune) | 854 if (xs_fileinfotune) |
826 xs_tune_free(xs_fileinfotune); | 855 xs_tune_free(xs_fileinfotune); |
827 | 856 |
855 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename); | 884 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename); |
856 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName); | 885 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName); |
857 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer); | 886 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer); |
858 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright); | 887 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright); |
859 | 888 |
860 /* Set the sub-tune information */ | 889 |
890 /* Main tune - the pseudo tune */ | |
891 tmpOptionMenu = LUW("fileinfo_sub_tune"); | |
892 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu; | |
893 | |
894 tmpMenuItem = gtk_menu_item_new_with_label ("General info"); | |
895 gtk_widget_show (tmpMenuItem); | |
896 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); | |
897 gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", | |
898 GTK_SIGNAL_FUNC (xs_fileinfo_subtune), tmpMenu); | |
899 | |
900 /* Other menu items */ | |
901 for (n = 1; n <= xs_fileinfotune->nsubTunes; n++) | |
902 { | |
903 if (xs_fileinfostil) | |
904 { | |
905 tmpNode = &xs_fileinfostil->subTune[n]; | |
906 if (tmpNode->pName) | |
907 tmpS = tmpNode->pName; | |
908 else | |
909 if (tmpNode->pInfo) | |
910 tmpS = tmpNode->pInfo; | |
911 else | |
912 tmpS = "---"; | |
913 | |
914 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: %s", n, tmpS); | |
915 } else | |
916 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n); | |
917 | |
918 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); | |
919 gtk_widget_show (tmpMenuItem); | |
920 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); | |
921 | |
922 gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate", | |
923 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); | |
924 } | |
925 | |
926 /* Set the subtune information */ | |
861 xs_fileinfo_subtune(NULL, tmpMenu); | 927 xs_fileinfo_subtune(NULL, tmpMenu); |
928 | |
929 /* Update subtune controls */ | |
930 xs_subctrl_update(); | |
862 | 931 |
863 /* Show the window */ | 932 /* Show the window */ |
864 gtk_widget_show(xs_fileinfowin); | 933 gtk_widget_show(xs_fileinfowin); |
865 } | 934 } |