changeset 222:dcf88b73e4c1

Added fileinfo-dialog module.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 15 Dec 2004 14:02:05 +0000
parents 0a75ea20c122
children 16e3b2446a73
files src/xs_fileinfo.c
diffstat 1 files changed, 183 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/xs_fileinfo.c	Wed Dec 15 14:02:05 2004 +0000
@@ -0,0 +1,183 @@
+/*
+   XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
+
+   File information window
+
+   Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+
+#include "xmms-sid.h"
+#include "xs_stil.h"
+#include "xs_config.h"
+#include "xs_interface.h"
+#include "xs_glade.h"
+
+static GtkWidget		*xs_fileinfowin = NULL;
+
+#define LUW(x...)	lookup_widget(xs_fileinfowin, ## x)
+
+
+void xs_fileinfo_ok(void)
+{
+ gtk_widget_destroy(xs_fileinfowin);
+ xs_fileinfowin = NULL;
+}
+
+
+void xs_fileinfo_subtune(GtkWidget *widget, void *data)
+{
+ t_xs_stil_subnode *tmpNode;
+ GtkWidget *tmpItem, *tmpText;
+ gint tmpIndex;
+ gchar *subName, *subAuthor;
+
+ /* Freeze text-widget and delete the old text */
+ tmpText = LUW("fileinfo_sub_info");
+ gtk_text_freeze(GTK_TEXT(tmpText));
+ gtk_text_set_point(GTK_TEXT(tmpText), 0);
+ gtk_text_forward_delete(GTK_TEXT(tmpText),
+ gtk_text_get_length(GTK_TEXT(tmpText)));
+
+ if (xs_fileinfostil)
+ 	{
+	/* Get subtune number */
+	tmpItem  = gtk_menu_get_active(GTK_MENU(data));
+	tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem);
+
+	/* Get subtune information */
+	tmpNode = &xs_fileinfostil->subTune[tmpIndex];
+	subName = tmpNode->pName;
+	subAuthor = tmpNode->pAuthor;
+
+	/* Put in the new text, if available */
+	if (tmpNode->pInfo)
+		{
+		gtk_text_insert (GTK_TEXT (tmpText), NULL, NULL, NULL,
+		tmpNode->pInfo, strlen(tmpNode->pInfo));
+		}
+	} else {
+	/* We don't have any information */
+	subName = NULL;
+	subAuthor = 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 : "");
+
+ /* Un-freeze the widget */
+ gtk_text_thaw(GTK_TEXT(tmpText));
+}
+
+
+void xs_fileinfo(gchar *pcFilename)
+{
+ GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
+ t_xs_stil_subnode *tmpNode;
+ gchar tmpStr[32], *tmpS;
+ gint n;
+
+ /* Free old info, if set */
+ if (xs_fileinfotune)
+ 	xs_tune_free(xs_fileinfotune);
+ 
+ /* Get new tune information */
+ if ((xs_fileinfotune = xs_player->plrGetSIDInfo(pcFilename)) == NULL)
+ 	return;
+
+ if (xs_cfg.stilDBEnable)
+	xs_fileinfostil = xs_stil_get(pcFilename);
+	else
+	xs_fileinfostil = NULL;
+ 
+
+ /* Check if there already is an open fileinfo window */
+ if (xs_fileinfowin)
+	{
+	/* Raise old window */
+	gdk_window_raise(xs_fileinfowin->window);
+
+	/* Delete items */
+	tmpOptionMenu = LUW("fileinfo_sub_tune");
+	gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu);
+	GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new();	
+	} else {
+	/* If not, create a new one */
+	xs_fileinfowin = create_xs_fileinfowin();
+	
+	/* Connect additional signals */
+	gtk_signal_connect(GTK_OBJECT(
+		gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))),
+		"value_changed", GTK_SIGNAL_FUNC (xs_fileinfo_setsong), NULL);
+	}
+
+
+ /* Set the generic song information */
+ gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename);
+ gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName);
+ gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer);
+ gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright);
+
+
+ /* Main tune - the pseudo tune */
+ tmpOptionMenu = LUW("fileinfo_sub_tune");
+ tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu;
+
+ 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 <= xs_fileinfotune->nsubTunes; n++)
+	{
+	if (xs_fileinfostil)
+		{
+		tmpNode = &xs_fileinfostil->subTune[n];
+		if (tmpNode->pName)
+			tmpS = tmpNode->pName;
+			else
+		if (tmpNode->pInfo)
+			tmpS = tmpNode->pInfo;
+			else
+			tmpS = "---";
+
+		snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: %s", n, tmpS);
+		} else
+		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);
+
+	gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate",
+			GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
+	}
+
+ /* Set the subtune information */
+ xs_fileinfo_subtune(NULL, tmpMenu);
+
+ /* Update subtune controls */
+ xs_subctrl_update();
+
+ /* Show the window */
+ gtk_widget_show(xs_fileinfowin);
+}
+