comparison src/audacious/main.c @ 4413:de33c83aa06f

Huge renaming patch, changing BMP references to Audacious.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 31 Mar 2008 06:47:48 +0300
parents 180996fcf12a
children 3dd13b275b4e
comparison
equal deleted inserted replaced
4412:180996fcf12a 4413:de33c83aa06f
108 108
109 AudCmdLineOpt options; 109 AudCmdLineOpt options;
110 110
111 AudConfig cfg; 111 AudConfig cfg;
112 112
113 const gchar *bmp_titlestring_presets[] = { 113 const gchar *aud_titlestring_presets[] = {
114 "${title}", 114 "${title}",
115 "${?artist:${artist} - }${title}", 115 "${?artist:${artist} - }${title}",
116 "${?artist:${artist} - }${?album:${album} - }${title}", 116 "${?artist:${artist} - }${?album:${album} - }${title}",
117 "${?artist:${artist} - }${?album:${album} - }${?track-number:${track-number}. }${title}", 117 "${?artist:${artist} - }${?album:${album} - }${?track-number:${track-number}. }${title}",
118 "${?artist:${artist} }${?album:[ ${album} ] }${?artist:- }${?track-number:${track-number}. }${title}", 118 "${?artist:${artist} }${?album:[ ${album} ] }${?artist:- }${?track-number:${track-number}. }${title}",
119 "${?album:${album} - }${title}" 119 "${?album:${album} - }${title}"
120 }; 120 };
121 121
122 const guint n_titlestring_presets = G_N_ELEMENTS(bmp_titlestring_presets); 122 const guint n_titlestring_presets = G_N_ELEMENTS(aud_titlestring_presets);
123 123
124 const gchar *chardet_detector_presets[] = { 124 const gchar *chardet_detector_presets[] = {
125 N_("None"), 125 N_("None"),
126 N_("Japanese"), 126 N_("Japanese"),
127 N_("Taiwanese"), 127 N_("Taiwanese"),
136 N_("Universal") 136 N_("Universal")
137 #endif 137 #endif
138 }; 138 };
139 139
140 const guint n_chardet_detector_presets = G_N_ELEMENTS(chardet_detector_presets); 140 const guint n_chardet_detector_presets = G_N_ELEMENTS(chardet_detector_presets);
141 gchar *bmp_paths[BMP_PATH_COUNT] = {}; 141 gchar *aud_paths[BMP_PATH_COUNT] = {};
142 142
143 GList *dock_window_list = NULL; 143 GList *dock_window_list = NULL;
144 144
145 145
146 GCond *cond_scan; 146 GCond *cond_scan;
190 get_gentitle_format(void) 190 get_gentitle_format(void)
191 { 191 {
192 guint titlestring_preset = cfg.titlestring_preset; 192 guint titlestring_preset = cfg.titlestring_preset;
193 193
194 if (titlestring_preset < n_titlestring_presets) 194 if (titlestring_preset < n_titlestring_presets)
195 return bmp_titlestring_presets[titlestring_preset]; 195 return aud_titlestring_presets[titlestring_preset];
196 196
197 return cfg.gentitle_format; 197 return cfg.gentitle_format;
198 } 198 }
199 199
200 static void 200 static void
201 bmp_make_user_dir(void) 201 aud_make_user_dir(void)
202 { 202 {
203 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; 203 const mode_t mode755 = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
204 204
205 make_directory(bmp_paths[BMP_PATH_USER_DIR], mode755); 205 make_directory(aud_paths[BMP_PATH_USER_DIR], mode755);
206 make_directory(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], mode755); 206 make_directory(aud_paths[BMP_PATH_USER_PLUGIN_DIR], mode755);
207 make_directory(bmp_paths[BMP_PATH_USER_SKIN_DIR], mode755); 207 make_directory(aud_paths[BMP_PATH_USER_SKIN_DIR], mode755);
208 make_directory(bmp_paths[BMP_PATH_SKIN_THUMB_DIR], mode755); 208 make_directory(aud_paths[BMP_PATH_SKIN_THUMB_DIR], mode755);
209 make_directory(bmp_paths[BMP_PATH_PLAYLISTS_DIR], mode755); 209 make_directory(aud_paths[BMP_PATH_PLAYLISTS_DIR], mode755);
210 } 210 }
211 211
212 static void 212 static void
213 bmp_free_paths(void) 213 aud_free_paths(void)
214 { 214 {
215 int i; 215 int i;
216 216
217 for (i = 0; i < BMP_PATH_COUNT; i++) 217 for (i = 0; i < BMP_PATH_COUNT; i++)
218 { 218 {
219 g_free(bmp_paths[i]); 219 g_free(aud_paths[i]);
220 bmp_paths[i] = 0; 220 aud_paths[i] = 0;
221 } 221 }
222 } 222 }
223 223
224 static void 224 static void
225 bmp_init_paths() 225 aud_init_paths()
226 { 226 {
227 char *xdg_config_home; 227 char *xdg_config_home;
228 char *xdg_data_home; 228 char *xdg_data_home;
229 char *xdg_cache_home; 229 char *xdg_cache_home;
230 230
236 : g_strdup(getenv("XDG_DATA_HOME"))); 236 : g_strdup(getenv("XDG_DATA_HOME")));
237 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL 237 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL
238 ? g_build_filename(g_get_home_dir(), ".cache", NULL) 238 ? g_build_filename(g_get_home_dir(), ".cache", NULL)
239 : g_strdup(getenv("XDG_CACHE_HOME"))); 239 : g_strdup(getenv("XDG_CACHE_HOME")));
240 240
241 bmp_paths[BMP_PATH_USER_DIR] = 241 aud_paths[BMP_PATH_USER_DIR] =
242 g_build_filename(xdg_config_home, "audacious", NULL); 242 g_build_filename(xdg_config_home, "audacious", NULL);
243 bmp_paths[BMP_PATH_USER_SKIN_DIR] = 243 aud_paths[BMP_PATH_USER_SKIN_DIR] =
244 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); 244 g_build_filename(xdg_data_home, "audacious", "Skins", NULL);
245 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = 245 aud_paths[BMP_PATH_USER_PLUGIN_DIR] =
246 g_build_filename(xdg_data_home, "audacious", "Plugins", NULL); 246 g_build_filename(xdg_data_home, "audacious", "Plugins", NULL);
247 247
248 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = 248 aud_paths[BMP_PATH_SKIN_THUMB_DIR] =
249 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); 249 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL);
250 250
251 bmp_paths[BMP_PATH_PLAYLISTS_DIR] = 251 aud_paths[BMP_PATH_PLAYLISTS_DIR] =
252 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "playlists", NULL); 252 g_build_filename(aud_paths[BMP_PATH_USER_DIR], "playlists", NULL);
253 253
254 bmp_paths[BMP_PATH_CONFIG_FILE] = 254 aud_paths[BMP_PATH_CONFIG_FILE] =
255 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "config", NULL); 255 g_build_filename(aud_paths[BMP_PATH_USER_DIR], "config", NULL);
256 #ifdef HAVE_XSPF_PLAYLIST 256 #ifdef HAVE_XSPF_PLAYLIST
257 bmp_paths[BMP_PATH_PLAYLIST_FILE] = 257 aud_paths[BMP_PATH_PLAYLIST_FILE] =
258 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], 258 g_build_filename(aud_paths[BMP_PATH_USER_DIR],
259 "playlist.xspf", NULL); 259 "playlist.xspf", NULL);
260 #else 260 #else
261 bmp_paths[BMP_PATH_PLAYLIST_FILE] = 261 aud_paths[BMP_PATH_PLAYLIST_FILE] =
262 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], 262 g_build_filename(aud_paths[BMP_PATH_USER_DIR],
263 "playlist.m3u", NULL); 263 "playlist.m3u", NULL);
264 #endif 264 #endif
265 bmp_paths[BMP_PATH_ACCEL_FILE] = 265 aud_paths[BMP_PATH_ACCEL_FILE] =
266 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "accels", NULL); 266 g_build_filename(aud_paths[BMP_PATH_USER_DIR], "accels", NULL);
267 bmp_paths[BMP_PATH_LOG_FILE] = 267 aud_paths[BMP_PATH_LOG_FILE] =
268 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "log", NULL); 268 g_build_filename(aud_paths[BMP_PATH_USER_DIR], "log", NULL);
269 269
270 bmp_paths[BMP_PATH_GTKRC_FILE] = 270 aud_paths[BMP_PATH_GTKRC_FILE] =
271 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "gtkrc", NULL); 271 g_build_filename(aud_paths[BMP_PATH_USER_DIR], "gtkrc", NULL);
272 272
273 g_free(xdg_config_home); 273 g_free(xdg_config_home);
274 g_free(xdg_data_home); 274 g_free(xdg_data_home);
275 g_free(xdg_cache_home); 275 g_free(xdg_cache_home);
276 276
277 g_atexit(bmp_free_paths); 277 g_atexit(aud_free_paths);
278 } 278 }
279 279
280 280
281 static void 281 static void
282 bmp_set_default_icon(void) 282 aud_set_default_icon(void)
283 { 283 {
284 GdkPixbuf *icon; 284 GdkPixbuf *icon;
285 285
286 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm); 286 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_player_xpm);
287 gtk_window_set_default_icon(icon); 287 gtk_window_set_default_icon(icon);
597 drct_activate(); 597 drct_activate();
598 } /* !is_running */ 598 } /* !is_running */
599 } 599 }
600 600
601 static void 601 static void
602 bmp_setup_logger(void) 602 aud_setup_logger(void)
603 { 603 {
604 if (!bmp_logger_start(bmp_paths[BMP_PATH_LOG_FILE])) 604 if (!aud_logger_start(aud_paths[BMP_PATH_LOG_FILE]))
605 return; 605 return;
606 606
607 g_atexit(bmp_logger_stop); 607 g_atexit(aud_logger_stop);
608 } 608 }
609 609
610 static void 610 static void
611 run_load_skin_error_dialog(const gchar * skin_path) 611 run_load_skin_error_dialog(const gchar * skin_path)
612 { 612 {
711 textdomain(PACKAGE_NAME); 711 textdomain(PACKAGE_NAME);
712 712
713 #ifndef _WIN32 713 #ifndef _WIN32
714 egg_set_desktop_file(AUDACIOUS_DESKTOP_FILE); 714 egg_set_desktop_file(AUDACIOUS_DESKTOP_FILE);
715 #endif 715 #endif
716 bmp_init_paths(); 716 aud_init_paths();
717 bmp_make_user_dir(); 717 aud_make_user_dir();
718 718
719 cond_scan = g_cond_new(); 719 cond_scan = g_cond_new();
720 mutex_scan = g_mutex_new(); 720 mutex_scan = g_mutex_new();
721 gtk_rc_add_default_file(bmp_paths[BMP_PATH_GTKRC_FILE]); 721 gtk_rc_add_default_file(aud_paths[BMP_PATH_GTKRC_FILE]);
722 722
723 parse_cmd_line_options(&argc, &argv); 723 parse_cmd_line_options(&argc, &argv);
724 724
725 if (options.no_log == FALSE) 725 if (options.no_log == FALSE)
726 bmp_setup_logger(); 726 aud_setup_logger();
727 727
728 if (!gtk_init_check(&argc, &argv) && options.headless == FALSE) { 728 if (!gtk_init_check(&argc, &argv) && options.headless == FALSE) {
729 /* GTK check failed, and no arguments passed to indicate 729 /* GTK check failed, and no arguments passed to indicate
730 that user is intending to only remote control a running 730 that user is intending to only remote control a running
731 session */ 731 session */
759 plugin_system_init(); 759 plugin_system_init();
760 760
761 /* Initialize the playlist system. */ 761 /* Initialize the playlist system. */
762 playlist_init(); 762 playlist_init();
763 playlist = playlist_get_active(); 763 playlist = playlist_get_active();
764 playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); 764 playlist_load(playlist, aud_paths[BMP_PATH_PLAYLIST_FILE]);
765 playlist_set_position(playlist, cfg.playlist_position); 765 playlist_set_position(playlist, cfg.playlist_position);
766 766
767 /* Load extra playlists */ 767 /* Load extra playlists */
768 if (!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, 768 if (!dir_foreach(aud_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist,
769 playlist, NULL)) 769 playlist, NULL))
770 g_warning("Could not load extra playlists\n"); 770 g_warning("Could not load extra playlists\n");
771 771
772 handle_cmd_line_options(); 772 handle_cmd_line_options();
773 773
777 777
778 playlist_start_get_info_thread(); 778 playlist_start_get_info_thread();
779 779
780 if (options.headless == FALSE) 780 if (options.headless == FALSE)
781 { 781 {
782 bmp_set_default_icon(); 782 aud_set_default_icon();
783 #ifdef GDK_WINDOWING_QUARTZ 783 #ifdef GDK_WINDOWING_QUARTZ
784 set_dock_icon(); 784 set_dock_icon();
785 #endif 785 #endif
786 786
787 gtk_accel_map_load(bmp_paths[BMP_PATH_ACCEL_FILE]); 787 gtk_accel_map_load(aud_paths[BMP_PATH_ACCEL_FILE]);
788 788
789 if (!init_skins(cfg.skin)) { 789 if (!init_skins(cfg.skin)) {
790 run_load_skin_error_dialog(cfg.skin); 790 run_load_skin_error_dialog(cfg.skin);
791 exit(EXIT_FAILURE); 791 exit(EXIT_FAILURE);
792 } 792 }