Menu

#8 read lyrics in txt format from another folder

open
nobody
None
5
2005-05-12
2005-05-12
Anonymous
No

I already have lots of lyrics in txt format in a
special folder.
I just modified the source to look in this folder too:
Just add this code in the two files lyrc.c and window.c
recompile and install.

diff ../lyrc-0.3.org/lyrc.c ./lyrc.c
347c347,369
#define lyrics_dir2 "/your_folder/txt_lyrics/"
g_free(command);
command=g_strdup_printf("%s%s -
%s.txt",lyrics_dir2,play_artist,play_song);
/* to prevent lyrics for which artist/song
contains a "'" to be forgotten */
command=(gchar *) replace(command,"\\'","'");
/* Are we already displaying the lyrics ? */
if (strcmp(lyrics,command)==0 && flag)
return(TRUE); /* yes, we are, goodbye */
/* Does the lyric file exist?? */
if (fexist(command))
{if (fsize(command)!=0)
{
flag=TRUE;
g_free(lyrics); lyrics=command;

lyric_window(lyrics,g_strdup_printf("%s
[%s]",cur_file_info->title,cur_file_info->artist));
active_update(FALSE);
active_submit(FALSE);
return(TRUE); /*yes, show and exit*/
}
}

diff ../lyrc-0.3.org/window.c ./window.c
266a267,295
if (filename && strstr(filename,".txt"))
{ /* txt file */
FILE* fn;
artist = "";
song = title;
source = malloc(3000);
fn = fopen(filename,"r");
fread(source, 1, 3000, fn);
fclose(fn);
lyric1=gtk_text_new(NULL,NULL);

gtk_text_set_word_wrap(GTK_TEXT(lyric1),TRUE);

gtk_text_insert(GTK_TEXT(lyric1),font_title,NULL,NULL,
g_strdup_printf("%s
(%s)\n\n",song,artist),-1);

gtk_text_insert(GTK_TEXT(lyric1),font,NULL,NULL,source,-1);
gtk_widget_modify_style(lyric1, rc_style);

gtk_fixed_put(GTK_FIXED(lyrics_layout),lyric1,10,10);
gtk_widget_show(lyric1);

width=max(get_width(source,font),get_width(g_strdup_printf("%s
(%s)\n\n",song,artist),font_title));

height=get_height(source,font)+get_height(g_strdup_printf("%s
(%s)\n\n",song,artist),font_title);

gtk_widget_set_usize(lyric1,
width+10,height);
/* free(artist); free(song); */
free(source);
return;
}

Discussion


Log in to post a comment.

MongoDB Logo MongoDB