changeset 636:ea06356d792b

Show tags ("[!]" and "[*]") in fileinfo selector, if there is additional information for the subtune; Only list subtunes that have _some_ STIL information.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Sep 2007 00:21:03 +0000
parents dcd9d179e217
children dab4cae8d4a8
files src/xs_fileinfo.c
diffstat 1 files changed, 49 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_fileinfo.c	Mon Sep 03 23:10:02 2007 +0000
+++ b/src/xs_fileinfo.c	Tue Sep 04 00:21:03 2007 +0000
@@ -122,7 +122,6 @@
 {
 	t_xs_stil_subnode *tmpNode;
 	GtkWidget *tmpText;
-	gint tmpIndex;
 	gchar *subName, *subAuthor, *subInfo;
 
 	(void) widget;
@@ -137,15 +136,15 @@
 #endif
 
 	/* Get subtune information */
-	tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, gtk_menu_get_active(GTK_MENU(data)));
-	
-	if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes)
-		tmpNode = xs_fileinfostil->subTunes[tmpIndex];
-	else
-		tmpNode = NULL;
+	tmpNode = (t_xs_stil_subnode *) data;
+	if (!tmpNode && xs_fileinfostil)
+		tmpNode = xs_fileinfostil->subTunes[0];
 	
 	if (tmpNode) {
-		subName = tmpNode->pName;
+		if (tmpNode->pName)
+			subName = tmpNode->pName;
+		else
+			subName = tmpNode->pTitle;
 		subAuthor = tmpNode->pAuthor;
 		subInfo = tmpNode->pInfo;
 	} else {
@@ -175,24 +174,34 @@
 {
 	GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
 	t_xs_tuneinfo *tmpInfo;
+	t_xs_stil_subnode *tmpNode;
 	gchar tmpStr[256], *tmpFilename;
 	gint n;
 
 	/* Current implementation leaves old fileinfo window untouched if
 	 * no information can be found for the new file. Hmm...
 	 */
+#ifdef AUDACIOUS_PLUGIN
+	xs_get_trackinfo(pcFilename, &tmpFilename, &n);
+#else
+	tmpFilename = pcFilename;
+#endif	
 
 	/* Get new tune information */
 	XS_MUTEX_LOCK(xs_fileinfowin);
 	XS_MUTEX_LOCK(xs_status);
-	if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) {
+	if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename)) == NULL) {
 		XS_MUTEX_UNLOCK(xs_fileinfowin);
 		XS_MUTEX_UNLOCK(xs_status);
 		return;
 	}
 	XS_MUTEX_UNLOCK(xs_status);
 
-	xs_fileinfostil = xs_stil_get(pcFilename);
+	xs_fileinfostil = xs_stil_get(tmpFilename);
+
+#ifdef AUDACIOUS_PLUGIN
+	g_free(tmpFilename);
+#endif
 
 	/* Check if there already is an open fileinfo window */
 	if (xs_fileinfowin)
@@ -226,38 +235,53 @@
 	tmpMenuItem = gtk_menu_item_new_with_label(_("General info"));
 	gtk_widget_show(tmpMenuItem);
 	gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
-	XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu);
+	if (xs_fileinfostil)
+		tmpNode = xs_fileinfostil->subTunes[0];
+	else
+		tmpNode = NULL;
+	XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode);
 
 	/* Other menu items */
 	for (n = 1; n <= tmpInfo->nsubTunes; n++) {
 		if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) {
-			t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n];
+			gboolean isSet = FALSE;
+			tmpNode = xs_fileinfostil->subTunes[n];
 			
 			g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
 
-			if (tmpNode->pName)
+			if (tmpNode->pName) {
 				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName);
-			else if (tmpNode->pTitle)
-				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pTitle);
-			else if (tmpNode->pInfo)
-				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo);
-			else
+				isSet = TRUE;
+			}
+
+			if (tmpNode->pTitle) {
+				xs_pnstrcat(tmpStr, sizeof(tmpStr),
+					isSet ? " [*]" : tmpNode->pTitle);
+				isSet = TRUE;
+			}
+
+			if (tmpNode->pInfo) {
+				xs_pnstrcat(tmpStr, sizeof(tmpStr),
+					isSet ? " [!]" : tmpNode->pInfo);
+				isSet = TRUE;
+			}
+
+			if (!isSet)
 				xs_pnstrcat(tmpStr, sizeof(tmpStr), "---");
-		} else {
-			g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i"), n);
+
+			tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
+			gtk_widget_show(tmpMenuItem);
+			gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
+			XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode);
 		}
 
-		tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
-		gtk_widget_show(tmpMenuItem);
-		gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
-		XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu);
 	}
 
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu);
 	gtk_widget_show(tmpOptionMenu);
 
 	/* Set the subtune information */
-	xs_fileinfo_subtune(NULL, tmpMenu);
+	xs_fileinfo_subtune(tmpOptionMenu, NULL);
 
 	/* Free temporary tuneinfo */
 	xs_tuneinfo_free(tmpInfo);