Mercurial > audlegacy
comparison src/audacious/main.c @ 3526:56e2a8704164 trunk
Automated merge with ssh://hg.atheme.org//hg/audacious.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 13 Sep 2007 01:12:43 -0500 |
parents | 540e49d1d87c 308e5fb348db |
children | 08dae20c75f0 |
comparison
equal
deleted
inserted
replaced
3525:540e49d1d87c | 3526:56e2a8704164 |
---|---|
205 FALSE, /* resume playback on startup */ | 205 FALSE, /* resume playback on startup */ |
206 -1, /* resume playback on startup time */ | 206 -1, /* resume playback on startup time */ |
207 TRUE, /* show seperators in pl */ | 207 TRUE, /* show seperators in pl */ |
208 NULL, /* chardet_detector */ | 208 NULL, /* chardet_detector */ |
209 NULL, /* chardet_fallback */ | 209 NULL, /* chardet_fallback */ |
210 3000, /* audio buffer size */ | 210 500, /* audio buffer size */ |
211 FALSE, /* whether or not to postpone format detection on initial add */ | 211 FALSE, /* whether or not to postpone format detection on initial add */ |
212 TRUE, /* show filepopup for tuple */ | 212 TRUE, /* show filepopup for tuple */ |
213 NULL, /* words identifying covers */ | 213 NULL, /* words identifying covers */ |
214 NULL, /* words that might not show up in cover names */ | 214 NULL, /* words that might not show up in cover names */ |
215 FALSE, | 215 FALSE, |
674 /* at least one of these should be true */ | 674 /* at least one of these should be true */ |
675 if ((!cfg.get_info_on_demand) && (!cfg.get_info_on_load)) | 675 if ((!cfg.get_info_on_demand) && (!cfg.get_info_on_load)) |
676 cfg.get_info_on_demand = TRUE; | 676 cfg.get_info_on_demand = TRUE; |
677 } | 677 } |
678 | 678 |
679 static gboolean | |
680 save_extra_playlist(const gchar * path, const gchar * basename, | |
681 gpointer savedlist) | |
682 { | |
683 GList *playlists, *iter; | |
684 GList **saved; | |
685 Playlist *playlist; | |
686 int found; | |
687 gchar *filename; | |
688 | |
689 playlists = playlist_get_playlists(); | |
690 saved = (GList **) savedlist; | |
691 | |
692 found = 0; | |
693 for (iter = playlists; iter; iter = iter->next) { | |
694 playlist = (Playlist *) iter->data; | |
695 if (g_list_find(*saved, playlist)) continue; | |
696 filename = playlist_filename_get(playlist); | |
697 if (!filename) continue; | |
698 if (strcmp(filename, path) == 0) { | |
699 /* Save playlist */ | |
700 playlist_save(playlist, path); | |
701 *saved = g_list_prepend(*saved, playlist); | |
702 found = 1; | |
703 g_free(filename); | |
704 break; | |
705 } | |
706 g_free(filename); | |
707 } | |
708 | |
709 if(!found) { | |
710 /* Remove playlist */ | |
711 unlink(path); | |
712 } | |
713 | |
714 return FALSE; /* process other playlists */ | |
715 } | |
716 | |
717 static void | |
718 save_other_playlists(GList *saved) | |
719 { | |
720 GList *playlists, *iter; | |
721 Playlist *playlist; | |
722 gchar *pos, *ext, *basename, *filename, *newbasename; | |
723 int i, num, isdigits; | |
724 | |
725 playlists = playlist_get_playlists(); | |
726 for(iter = playlists; iter; iter = iter->next) { | |
727 playlist = (Playlist *) iter->data; | |
728 if (g_list_find(saved, playlist)) continue; | |
729 filename = playlist_filename_get(playlist); | |
730 if (!filename || !filename[0] | |
731 || g_file_test(filename, G_FILE_TEST_IS_DIR)) { | |
732 /* default basename */ | |
733 #ifdef HAVE_XSPF_PLAYLIST | |
734 basename = g_strdup("playlist_01.xspf"); | |
735 #else | |
736 basename = g_strdup("playlist_01.m3u"); | |
737 #endif | |
738 } else { | |
739 basename = g_path_get_basename(filename); | |
740 } | |
741 g_free(filename); | |
742 if ((pos = strrchr(basename, '.'))) { | |
743 *pos = '\0'; | |
744 } | |
745 #ifdef HAVE_XSPF_PLAYLIST | |
746 ext = ".xspf"; | |
747 #else | |
748 ext = ".m3u"; | |
749 #endif | |
750 num = -1; | |
751 if ((pos = strrchr(basename, '_'))) { | |
752 isdigits = 0; | |
753 for (i=1; pos[i]; i++) { | |
754 if (!g_ascii_isdigit(pos[i])) { | |
755 isdigits = 0; | |
756 break; | |
757 } | |
758 isdigits = 1; | |
759 } | |
760 if (isdigits) { | |
761 num = atoi(pos+1) + 1; | |
762 *pos = '\0'; | |
763 } | |
764 } | |
765 /* attempt to generate unique filename */ | |
766 filename = NULL; | |
767 do { | |
768 g_free(filename); | |
769 if (num < 0) { | |
770 /* try saving without number first */ | |
771 newbasename = g_strdup_printf("%s%s", basename, ext); | |
772 num = 1; | |
773 } else { | |
774 newbasename = g_strdup_printf("%s_%02d%s", basename, num, ext); | |
775 num++; | |
776 if (num < 0) { | |
777 g_warning("Playlist number in filename overflowed." | |
778 " Not saving playlist.\n"); | |
779 goto cleanup; | |
780 } | |
781 } | |
782 filename = g_build_filename(bmp_paths[BMP_PATH_PLAYLISTS_DIR], | |
783 newbasename, NULL); | |
784 g_free(newbasename); | |
785 } while (g_file_test(filename, G_FILE_TEST_EXISTS)); | |
786 | |
787 playlist_save(playlist, filename); | |
788 cleanup: | |
789 g_free(filename); | |
790 g_free(basename); | |
791 } | |
792 } | |
679 | 793 |
680 void | 794 void |
681 bmp_config_save(void) | 795 bmp_config_save(void) |
682 { | 796 { |
683 GList *node; | 797 GList *node; |
684 gchar *str; | 798 gchar *str; |
685 gint i, cur_pb_time; | 799 gint i, cur_pb_time; |
686 ConfigDb *db; | 800 ConfigDb *db; |
801 GList *saved; | |
687 Playlist *playlist = playlist_get_active(); | 802 Playlist *playlist = playlist_get_active(); |
688 | 803 |
689 cfg.disabled_iplugins = input_stringify_disabled_list(); | 804 cfg.disabled_iplugins = input_stringify_disabled_list(); |
690 | 805 |
691 | 806 |
818 cfg.resume_playback_on_startup_time); | 933 cfg.resume_playback_on_startup_time); |
819 | 934 |
820 bmp_cfg_db_close(db); | 935 bmp_cfg_db_close(db); |
821 | 936 |
822 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | 937 playlist_save(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); |
938 | |
939 /* Save extra playlists that were loaded from PLAYLISTS_DIR */ | |
940 saved = NULL; | |
941 if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], save_extra_playlist, | |
942 &saved, NULL)) { | |
943 g_warning("Could not save extra playlists\n"); | |
944 } | |
945 | |
946 /* Save other playlists to PLAYLISTS_DIR */ | |
947 save_other_playlists(saved); | |
823 } | 948 } |
824 | 949 |
825 static void | 950 static void |
826 bmp_set_default_icon(void) | 951 bmp_set_default_icon(void) |
827 { | 952 { |
1152 { | 1277 { |
1153 free_vis_data(); | 1278 free_vis_data(); |
1154 return TRUE; | 1279 return TRUE; |
1155 } | 1280 } |
1156 | 1281 |
1282 static gboolean | |
1283 load_extra_playlist(const gchar * path, const gchar * basename, | |
1284 gpointer def) | |
1285 { | |
1286 const gchar *title; | |
1287 Playlist *playlist; | |
1288 Playlist *deflist; | |
1289 | |
1290 deflist = (Playlist *)def; | |
1291 playlist = playlist_new(); | |
1292 if (!playlist) { | |
1293 g_warning("Couldn't create new playlist\n"); | |
1294 return FALSE; | |
1295 } | |
1296 | |
1297 playlist_add_playlist(playlist); | |
1298 playlist_load(playlist, path); | |
1299 | |
1300 title = playlist_get_current_name(playlist); | |
1301 | |
1302 if (playlist_playlists_equal(playlist, deflist)) { | |
1303 /* same as default playlist */ | |
1304 playlist_remove_playlist(playlist); | |
1305 playlist_filename_set(deflist, path); | |
1306 } | |
1307 | |
1308 return FALSE; /* keep loading other playlists */ | |
1309 } | |
1310 | |
1157 gint | 1311 gint |
1158 main(gint argc, gchar ** argv) | 1312 main(gint argc, gchar ** argv) |
1159 { | 1313 { |
1160 gboolean gtk_init_check_ok; | 1314 gboolean gtk_init_check_ok; |
1161 Playlist *playlist; | 1315 Playlist *playlist; |
1277 | 1431 |
1278 /* Load the default playlist in. */ | 1432 /* Load the default playlist in. */ |
1279 playlist = playlist_get_active(); | 1433 playlist = playlist_get_active(); |
1280 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); | 1434 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); |
1281 playlist_set_position(playlist, cfg.playlist_position); | 1435 playlist_set_position(playlist, cfg.playlist_position); |
1436 | |
1437 /* Load extra playlists */ | |
1438 if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, | |
1439 playlist, NULL)) { | |
1440 g_warning("Could not load extra playlists\n"); | |
1441 } | |
1282 | 1442 |
1283 /* this needs to be called after all 3 windows are created and | 1443 /* this needs to be called after all 3 windows are created and |
1284 * input plugins are setup'ed | 1444 * input plugins are setup'ed |
1285 * but not if we're running headless --nenolod | 1445 * but not if we're running headless --nenolod |
1286 */ | 1446 */ |