Beispiel #1
0
int music_directplay(const char *spath, const char *lpath)
{
	int pos;
	int ret;

	music_lock();
	music_add(spath, lpath);
	pos = music_find(spath, lpath);

	if (pos < 0) {
		music_unlock();
		return -1;
	}

	g_list.curr_pos = pos;
	ret = music_play(pos);

	if (ret == 0) {
		g_list.is_list_playing = true;
		g_list.first_time = false;
	}

	music_unlock();
	return 0;
}
Beispiel #2
0
int music_list_load(const char *path)
{
	int ret = 0;
	FILE *fp;
	char fname[PATH_MAX];
	char lfname[PATH_MAX];
	int fid;

	if (path == NULL) {
		ret = -EINVAL;
		goto end;
	}

	fp = fopen(path, "rt");

	if (fp == NULL) {
		ret = -EBADFD;
		goto end;
	}

	fid = freq_enter_hotzone();

	while (fgets(fname, PATH_MAX, fp) != NULL) {
		dword len1, len2;

		if (fgets(lfname, PATH_MAX, fp) == NULL)
			break;

		len1 = strlen(fname);
		len2 = strlen(lfname);

		if (len1 > 1 && len2 > 1) {
			if (fname[len1 - 1] == '\n')
				fname[len1 - 1] = 0;
			if (lfname[len2 - 1] == '\n')
				lfname[len2 - 1] = 0;
		} else
			continue;
		if (!music_is_file_exist(fname))
			continue;
		music_add(fname, lfname);
	}

	fclose(fp);
	freq_leave(fid);

end:
	music_list_refresh();

	return ret;
}
Beispiel #3
0
void
jam_view_settings_changed(JamView *view) {
#ifdef HAVE_GTKSPELL
	GtkSpell *spell;
	GError *err = NULL;
	spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(view->entry));
	if (conf.options.usespellcheck) {
		GtkWindow *toplevel;
		toplevel = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)));
		if (spell) {
			if (!gtkspell_set_language(spell, conf.spell_language, &err)) {
				jam_warning(toplevel,
						_("GtkSpell error: %s"), err->message);
				g_error_free(err);
			}
		} else {
			GError *err = NULL;
			if (gtkspell_new_attach(GTK_TEXT_VIEW(view->entry), conf.spell_language , &err) == NULL) {
				jam_warning(toplevel,
						_("GtkSpell error: %s"), err->message);
				conf.options.usespellcheck = FALSE;
				g_error_free(err);
			}
		}
	} else {
		if (spell)
			gtkspell_detach(spell);
	}
#endif
	if (conf.uifont)
		jam_widget_set_font(view->entry, conf.uifont);

	if (view->musicbar) {
	    /* There are many cleaner ways to add/remove the Refresh button when
	     * the music preference has changed, but this works fine. */
		music_remove(view);
		music_add(view);
	}
}
Beispiel #4
0
int music_add_dir(const char *spath, const char *lpath)
{
	p_fat_info info;
	dword i, count;

	if (spath == NULL || lpath == NULL)
		return -EINVAL;

	count = fat_readdir(lpath, (char *) spath, &info);

	if (count == INVALID)
		return -EBADF;
	for (i = 0; i < count; i++) {
		char sfn[PATH_MAX];
		char lfn[PATH_MAX];
		
		if ((info[i].attr & FAT_FILEATTR_DIRECTORY) > 0) {
			char lpath2[PATH_MAX], spath2[PATH_MAX];

			if (info[i].filename[0] == '.')
				continue;

			SPRINTF_S(lpath2, "%s%s/", lpath, info[i].longname);
			SPRINTF_S(spath2, "%s%s/", spath, info[i].filename);
			music_add_dir(spath2, lpath2);
			continue;
		}

		if (fs_is_music(info[i].filename, info[i].longname) == false)
			continue;

		SPRINTF_S(sfn, "%s%s", spath, info[i].filename);
		SPRINTF_S(lfn, "%s%s", lpath, info[i].longname);
		music_add(sfn, lfn);
	}
	free((void *) info);

	return 0;
}