changeset 1559:6b4e47c5ca67

Fixes to make the fileinfo sub-tune info selector actually work.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 02 Sep 2007 22:58:45 +0300
parents 289fa4cb75db
children e5a0c508c025
files src/sid/xs_fileinfo.c
diffstat 1 files changed, 26 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/src/sid/xs_fileinfo.c	Sun Sep 02 21:34:37 2007 +0300
+++ b/src/sid/xs_fileinfo.c	Sun Sep 02 22:58:45 2007 +0300
@@ -217,9 +217,9 @@
 static void xs_fileinfo_subtune(GtkWidget * widget, void *data)
 {
 	t_xs_stil_subnode *tmpNode;
-	GtkWidget *tmpItem, *tmpText;
+	GtkWidget *tmpText;
 	gint tmpIndex;
-	gchar *subName, *subAuthor;
+	gchar *subName, *subAuthor, *subInfo;
 
 	(void) widget;
 	(void) data;
@@ -228,31 +228,31 @@
 	tmpText = LUW("fileinfo_sub_info");
 
 	/* Get subtune information */
-	tmpItem = gtk_menu_get_active(GTK_MENU(data));
-	tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem);
-
+	if (widget)
+		tmpIndex = gtk_option_menu_get_history(GTK_OPTION_MENU(widget));
+	else
+		tmpIndex = 0;
+	
 	if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes)
 		tmpNode = xs_fileinfostil->subTunes[tmpIndex];
 	else
 		tmpNode = NULL;
-
+	
 	if (tmpNode) {
 		subName = tmpNode->pName;
 		subAuthor = tmpNode->pAuthor;
-
-		if (tmpNode->pInfo) {
-			gtk_text_buffer_set_text(
-				GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmpText))),
-				tmpNode->pInfo, -1);
-		}
+		subInfo = tmpNode->pInfo;
 	} else {
 		subName = NULL;
 		subAuthor = NULL;
+		subInfo = NULL;
 	}
 
 	/* Get and set subtune information */
 	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : "");
 	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : "");
+	gtk_text_buffer_set_text(GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmpText))),
+		subInfo ? subInfo : "", -1);
 }
 
 
@@ -260,7 +260,7 @@
 {
 	GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
 	t_xs_tuneinfo *tmpInfo;
-	gchar *tmpStr;
+	gchar tmpStr[256], *tmpStr2;
 	gint n;
 
 	/* Current implementation leaves old fileinfo window untouched if
@@ -284,8 +284,9 @@
 		gdk_window_raise(xs_fileinfowin->window);
 	else {
 		xs_fileinfowin = create_xs_fileinfowin();
-		g_signal_connect(G_OBJECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))),
-			"value_changed", G_CALLBACK(xs_fileinfo_setsong), NULL);
+		g_signal_connect(G_OBJECT(
+			gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), "value_changed",
+			G_CALLBACK(xs_fileinfo_setsong), NULL);
 	}
 
 	/* Delete current items */
@@ -297,9 +298,9 @@
 
 
 	/* Set the generic song information */
-	tmpStr = g_filename_to_utf8(pcFilename, -1, NULL, NULL, NULL);
-	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), tmpStr);
-	g_free(tmpStr);
+	tmpStr2 = g_filename_to_utf8(pcFilename, -1, NULL, NULL, NULL);
+	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), tmpStr2);
+	g_free(tmpStr2);
 	
 	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), tmpInfo->sidName);
 	gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), tmpInfo->sidComposer);
@@ -310,39 +311,33 @@
 	tmpMenuItem = gtk_menu_item_new_with_label(_("General info"));
 	gtk_widget_show(tmpMenuItem);
 	gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
-	g_signal_connect(G_OBJECT(tmpMenuItem), "activate",
-		G_CALLBACK(xs_fileinfo_subtune), tmpMenu);
 
 	/* 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];
 			
-			tmpStr = g_strdup_printf(_("Tune #%i: "), n);
+			g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
 
 			if (tmpNode->pName)
-				g_strconcat(tmpStr, tmpNode->pName, NULL);
+				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName);
 			else if (tmpNode->pTitle)
-				g_strconcat(tmpStr, tmpNode->pTitle, NULL);
+				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pTitle);
 			else if (tmpNode->pInfo)
-				g_strconcat(tmpStr, tmpNode->pInfo, NULL);
+				xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo);
 			else
-				g_strconcat(tmpStr, "---", NULL);
+				xs_pnstrcat(tmpStr, sizeof(tmpStr), "---");
 		} else {
-			tmpStr = g_strdup_printf(_("Tune #%i"), n);
+			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);
-
-		g_signal_connect(G_OBJECT(tmpMenuItem), "activate",
-			G_CALLBACK(xs_fileinfo_subtune), tmpMenu);
-		
-		g_free(tmpStr);
 	}
 
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu);
+	g_signal_connect(G_OBJECT(tmpOptionMenu), "changed", G_CALLBACK(xs_fileinfo_subtune), tmpMenu);
 	gtk_widget_show(tmpOptionMenu);
 
 	/* Set the subtune information */