# HG changeset patch # User Matti Hamalainen # Date 1073862124 0 # Node ID 98a72c44f56b7c6e376d0b756546c0c1c91dba0f # Parent e7e36095fa5acc9652511c998c0ec93704644de9 Fileinfo now working with rudimentary informations. Slightly buggy. diff -r e7e36095fa5a -r 98a72c44f56b src/xmms-sid.c --- a/src/xmms-sid.c Sun Jan 11 23:02:02 2004 +0000 +++ b/src/xmms-sid.c Sun Jan 11 23:02:04 2004 +0000 @@ -251,7 +251,7 @@ { t_xs_status myStatus; t_xs_tune *myTune; - gboolean audioOpen, doPlay; + gboolean audioOpen = FALSE, doPlay = FALSE; guint audioGot; gint audioFreq, audioChannels, songLength, audioFmt; gchar audioBuffer[XS_BUFSIZE]; @@ -271,7 +271,6 @@ #endif audioFreq = xs_cfg.fmtFrequency; audioChannels = (xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2; - audioOpen = FALSE; /* * Main player loop: while not stopped, loop here - play subtunes @@ -333,7 +332,7 @@ /* Wait a little */ while (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong) && - (xs_plugin_ip.output->buffer_free() < audioGot)) + ((guint) xs_plugin_ip.output->buffer_free() < audioGot)) xmms_usleep(10000); /* Output audio */ @@ -404,8 +403,6 @@ if ((xs_status.pTune = xs_player->plrGetSIDInfo(pcFilename)) == NULL) return; - XSDEBUG("tuneinfo %p\n", xs_status.pTune); - /* Initialize the tune */ if (!xs_player->plrLoadSID(&xs_status, pcFilename)) { @@ -567,7 +564,8 @@ /* * Allocate a new tune structure */ -t_xs_tune *xs_tune_new(gchar *pcFilename, gint nsubTunes, gint startTune) +t_xs_tune *xs_tune_new(gchar *pcFilename, gint nsubTunes, gint startTune, + gchar *tuneName, gchar *tuneComposer, gchar *tuneCopyright) { t_xs_tune *pResult; @@ -581,8 +579,11 @@ return NULL; } - pResult->nsubTunes = nsubTunes; - pResult->startTune = startTune; + pResult->tuneName = g_strdup(tuneName); + pResult->tuneComposer = g_strdup(tuneComposer); + pResult->tuneCopyright = g_strdup(tuneCopyright); + pResult->nsubTunes = nsubTunes; + pResult->startTune = startTune; return pResult; } @@ -596,11 +597,10 @@ gint i; if (!pTune) return; - if (pTune->tuneFilename) - { - g_free(pTune->tuneFilename); - pTune->tuneFilename = NULL; - } + g_free(pTune->tuneFilename); pTune->tuneFilename = NULL; + g_free(pTune->tuneName); pTune->tuneName = NULL; + g_free(pTune->tuneComposer); pTune->tuneComposer = NULL; + g_free(pTune->tuneCopyright); pTune->tuneCopyright = NULL; for (i = 0; i < pTune->nsubTunes; i++) { @@ -673,56 +673,65 @@ void xs_fileinfo(gchar *pcFilename) { + t_xs_tune *pInfo; + GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; + gchar tmpStr[32]; + gint n; + + /* Get tune information */ + if ((pInfo = xs_player->plrGetSIDInfo(pcFilename)) == NULL) + { + if (xs_fileinfowin) + { + gtk_widget_destroy(xs_fileinfowin); + xs_fileinfowin = NULL; + } + return; + } + /* Check if there already is an open fileinfo window */ if (xs_fileinfowin) { gdk_window_raise(xs_fileinfowin->window); - return; + } else { + /* If not, create a new one */ + xs_fileinfowin = create_xs_fileinfowin(); } - /* If not, create a new one */ - xs_fileinfowin = create_xs_fileinfowin(); - /* Set the song informations */ - gtk_entry_set_text(GTK_ENTRY (LUW("fileinfo_filename")), pcFilename); - -#if 0 - gtk_entry_set_text(GTK_ENTRY (LUW("fileinfo_songname")), sidInf.infoString[0]); - gtk_entry_set_text(GTK_ENTRY (LUW("fileinfo_composer")), sidInf.infoString[1]); - gtk_entry_set_text(GTK_ENTRY (LUW("fileinfo_copyright")), sidInf.infoString[2]); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), pInfo->tuneName); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), pInfo->tuneComposer); + gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), pInfo->tuneCopyright); - /* "main tune" - the pseudo tune */ - tmpMenuItem = gtk_menu_item_new_with_label ("General info"); - gtk_widget_show (tmpMenuItem); - gtk_menu_append (GTK_MENU (fileinfo_sub_tune_menu), tmpMenuItem); - gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", - GTK_SIGNAL_FUNC (xs_fileinfo_sub_tune), fileinfo_sub_tune_menu); + /* Main tune - the pseudo tune */ + tmpOptionMenu = LUW("fileinfo_sub_tune"); + tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu; - /* Other menu items */ - for (n = 1; n <= sidInf.songs; n++) + tmpMenuItem = gtk_menu_item_new_with_label ("General info"); + gtk_widget_show (tmpMenuItem); + gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); + gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", + GTK_SIGNAL_FUNC (xs_fileinfo_subtune), tmpMenu); + + /* Other menu items */ + for (n = 1; n <= pInfo->nsubTunes; n++) { snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n); tmpMenuItem = gtk_menu_item_new_with_label (tmpStr); gtk_widget_show (tmpMenuItem); - gtk_menu_append (GTK_MENU (fileinfo_sub_tune_menu), tmpMenuItem); + gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem); - gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", - GTK_SIGNAL_FUNC (xs_fileinfo_sub_tune), fileinfo_sub_tune_menu); + gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate", + GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); } - gtk_option_menu_set_menu (GTK_OPTION_MENU (fileinfo_sub_tune), fileinfo_sub_tune_menu); - - /* Check if user wants STIL info */ - if (xs_cfg.usestil) - xs_stil_get(filename); + /* Set the sub-tune information */ + xs_fileinfo_subtune(NULL, tmpMenu); - /* Set the sub-tune information */ - xs_fileinfo_subtune(NULL, fileinfo_sub_tune_menu); -#endif - - /* Show the window */ - gtk_widget_show(xs_fileinfowin); + /* Show the window */ + gtk_widget_show(xs_fileinfowin); } diff -r e7e36095fa5a -r 98a72c44f56b src/xmms-sid.h --- a/src/xmms-sid.h Sun Jan 11 23:02:02 2004 +0000 +++ b/src/xmms-sid.h Sun Jan 11 23:02:04 2004 +0000 @@ -72,7 +72,6 @@ *tuneName, *tuneComposer, *tuneCopyright; - gint nsubTunes, startTune; t_xs_subtune subTunes[XS_STIL_MAXENTRY]; } t_xs_tune; @@ -104,7 +103,7 @@ void xs_fileinfo(gchar *); void xs_about(void); -t_xs_tune *xs_tune_new(gchar *, gint, gint); +t_xs_tune *xs_tune_new(gchar *, gint, gint, gchar *, gchar *, gchar *); void xs_tune_free(t_xs_tune *); diff -r e7e36095fa5a -r 98a72c44f56b src/xs_sidplay.h --- a/src/xs_sidplay.h Sun Jan 11 23:02:02 2004 +0000 +++ b/src/xs_sidplay.h Sun Jan 11 23:02:04 2004 +0000 @@ -164,7 +164,10 @@ tuneLen = xs_songlen_get(pcFilename); /* Allocate tuneinfo structure */ - if ((pResult = xs_tune_new(pcFilename, tuneInfo.songs, tuneInfo.startSong)) == NULL) + pResult = xs_tune_new(pcFilename, tuneInfo.songs, tuneInfo.startSong, + tuneInfo.infoString[0], tuneInfo.infoString[1], tuneInfo.infoString[2]); + + if (!pResult) { delete testTune; return NULL;