Mercurial > hg > xmms-sid
view src/xs_fileinfo.cc @ 50:dae6d3c2268d
Minor fixes, updated to support default XMMS configfile
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Jun 2003 21:11:02 +0000 |
parents | 1788f4ce6a44 |
children |
line wrap: on
line source
/* xmms-sid - SIDPlay input plugin for X MultiMedia System (XMMS) SIDTune file information dialog 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 "xmms-sid.h" #include <gtk/gtk.h> #include <sidplay/sidtune.h> #include <stdio.h> #include <string.h> static GtkWidget *xs_fileinfowin = NULL; /* * Close the fileinfo */ void xs_fileinfo_ok(void) { gtk_widget_destroy(xs_fileinfowin); xs_fileinfowin = NULL; } /* * Update the sub-tune information */ void xs_fileinfo_sub_tune(GtkWidget *widget, void *data) { T_sid_stil_subtune *a_tune; GtkWidget *a_item; gint a_index; /* Get number of subtune */ a_item = gtk_menu_get_active(GTK_MENU(fileinfo_sub_tune_menu)); a_index = g_list_index(GTK_MENU_SHELL(fileinfo_sub_tune_menu)->children, a_item); a_tune = &xs_stil_info.subtune[a_index]; /* Get and set subtune information */ if (a_tune->artist != NULL) gtk_entry_set_text (GTK_ENTRY (fileinfo_sub_artist), a_tune->artist); if (a_tune->title != NULL) gtk_entry_set_text (GTK_ENTRY (fileinfo_sub_title), a_tune->title); if (a_tune->comment != NULL) { /* Freeze the widget for update */ gtk_text_freeze(GTK_TEXT(fileinfo_sub_comment)); /* Delete the old comment */ gtk_text_set_point(GTK_TEXT(fileinfo_sub_comment), 0); gtk_text_forward_delete(GTK_TEXT(fileinfo_sub_comment), gtk_text_get_length(GTK_TEXT(fileinfo_sub_comment))); /* Put in the new comment */ gtk_text_insert (GTK_TEXT (fileinfo_sub_comment), NULL, NULL, NULL, a_tune->comment, strlen(a_tune->comment)); /* Un-freeze the widget */ gtk_text_thaw(GTK_TEXT(fileinfo_sub_comment)); } } /* * Execute the file-info dialog */ void xs_fileinfo(gchar *pcFilename) { gint n; gchar tempstr[128]; /* Get sidtune information */ sidTune t(filename); if (!t) return; struct sidTuneInfo sidInf; t.getInfo(sidInf); /* Check if there already is an open fileinfo window */ if (xs_fileinfowin != NULL) { gdk_window_raise(xs_fileinfowin->window); return; } /* If not, create a new one */ xs_fileinfowin = gtk_window_new (GTK_WINDOW_DIALOG); /* Set the song informations */ gtk_entry_set_text (GTK_ENTRY (LUW("fileinfo_filename")), pcFilename); 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]); /* "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); /* Other menu items */ for (n = 1; n <= sidInf.songs; 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_signal_connect (GTK_OBJECT (tmpMenuItem), "activate", GTK_SIGNAL_FUNC (xs_fileinfo_sub_tune), fileinfo_sub_tune_menu); } 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_sub_tune(NULL, fileinfo_sub_tune_menu); /* Show the window */ gtk_widget_show(xs_fileinfowin); }