static bool voice_files(void) { int oldval = global_settings.talk_file; bool ret; ret = set_option( str(LANG_VOICE_FILE), &global_settings.talk_file, INT, voice_names, 4, NULL); if (oldval != 3 && global_settings.talk_file == 3) { /* force reload if newly talking thumbnails, because the clip presence is cached only if enabled */ reload_directory(); } return ret; }
static bool sort_dir(void) { int oldval = global_settings.sort_dir; bool ret; static const struct opt_items names[] = { { STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE_REVERSE) } }; ret = set_option( str(LANG_SORT_DIR), &global_settings.sort_dir, INT, names, 3, NULL ); if (global_settings.sort_dir != oldval) reload_directory(); /* force reload if this has changed */ return ret; }
static int fileview_callback(int action,const struct menu_item_ex *this_item) { static int oldval; int *variable = this_item->variable; switch (action) { case ACTION_ENTER_MENUITEM: /* on entering an item */ oldval = *variable; break; case ACTION_EXIT_MENUITEM: /* on exit */ if (*variable != oldval) reload_directory(); /* force reload if this has changed */ break; } return action; }
static int talk_callback(int action,const struct menu_item_ex *this_item) { static int oldval = 0; switch (action) { case ACTION_ENTER_MENUITEM: oldval = global_settings.talk_file_clip; break; case ACTION_EXIT_MENUITEM: #ifdef HAVE_CROSSFADE audio_set_crossfade(global_settings.crossfade); #endif if (this_item == &talk_dir_clip_item) break; if (!oldval && global_settings.talk_file_clip) { /* force reload if newly talking thumbnails, because the clip presence is cached only if enabled */ reload_directory(); } break; } return action; }
/* Add "sel" file into specified "playlist". How to insert depends on type of file */ static int add_to_playlist(const char* playlist, bool new_playlist, const char* sel, int sel_attr) { int fd; int result = -1; if (new_playlist) fd = open_utf8(playlist, O_CREAT|O_WRONLY|O_TRUNC); else fd = open(playlist, O_CREAT|O_WRONLY|O_APPEND, 0666); if(fd < 0) return result; /* In case we're in the playlist directory */ reload_directory(); if ((sel_attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO) { /* append the selected file */ if (fdprintf(fd, "%s\n", sel) > 0) result = 0; } else if ((sel_attr & FILE_ATTR_MASK) == FILE_ATTR_M3U) { /* append playlist */ int f, fs, i; char buf[1024]; if(strcasecmp(playlist, sel) == 0) goto exit; f = open_utf8(sel, O_RDONLY); if (f < 0) goto exit; i = lseek(f, 0, SEEK_CUR); fs = filesize(f); while (i < fs) { int n; n = read(f, buf, sizeof(buf)); if (n < 0) break; if (write(fd, buf, n) < 0) break; i += n; } if (i >= fs) result = 0; close(f); } else if (sel_attr & ATTR_DIRECTORY) { /* search directory for tracks and append to playlist */ bool recurse = false; const char *lines[] = { ID2P(LANG_RECURSE_DIRECTORY_QUESTION), sel}; const struct text_message message={lines, 2}; struct add_track_context context; if (global_settings.recursive_dir_insert != RECURSE_ASK) recurse = (bool)global_settings.recursive_dir_insert; else { /* Ask if user wants to recurse directory */ recurse = (gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES); } context.fd = fd; context.count = 0; display_insert_count(0); result = playlist_directory_tracksearch(sel, recurse, add_track_to_playlist, &context); display_insert_count(context.count); } exit: close(fd); return result; }