222
|
1 /*
|
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
|
|
3
|
|
4 File information window
|
|
5
|
|
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
|
|
7
|
|
8 This program is free software; you can redistribute it and/or modify
|
|
9 it under the terms of the GNU General Public License as published by
|
|
10 the Free Software Foundation; either version 2 of the License, or
|
|
11 (at your option) any later version.
|
|
12
|
|
13 This program is distributed in the hope that it will be useful,
|
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 GNU General Public License for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with this program; if not, write to the Free Software
|
|
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
21 */
|
|
22 #include <gdk/gdkkeysyms.h>
|
|
23 #include <gtk/gtk.h>
|
|
24
|
|
25 #include "xmms-sid.h"
|
|
26 #include "xs_stil.h"
|
|
27 #include "xs_config.h"
|
|
28 #include "xs_interface.h"
|
|
29 #include "xs_glade.h"
|
|
30
|
|
31 static GtkWidget *xs_fileinfowin = NULL;
|
230
|
32 static t_xs_stil_node *xs_fileinfostil = NULL;
|
|
33 static t_xs_tuneinfo *xs_fileinfotune = NULL;
|
222
|
34
|
|
35 #define LUW(x...) lookup_widget(xs_fileinfowin, ## x)
|
|
36
|
|
37
|
230
|
38 void xs_fileinfo_setsong(void)
|
|
39 {
|
|
40 }
|
|
41
|
|
42
|
222
|
43 void xs_fileinfo_ok(void)
|
|
44 {
|
|
45 gtk_widget_destroy(xs_fileinfowin);
|
|
46 xs_fileinfowin = NULL;
|
|
47 }
|
|
48
|
|
49
|
|
50 void xs_fileinfo_subtune(GtkWidget *widget, void *data)
|
|
51 {
|
|
52 t_xs_stil_subnode *tmpNode;
|
|
53 GtkWidget *tmpItem, *tmpText;
|
|
54 gint tmpIndex;
|
|
55 gchar *subName, *subAuthor;
|
|
56
|
|
57 /* Freeze text-widget and delete the old text */
|
|
58 tmpText = LUW("fileinfo_sub_info");
|
|
59 gtk_text_freeze(GTK_TEXT(tmpText));
|
|
60 gtk_text_set_point(GTK_TEXT(tmpText), 0);
|
|
61 gtk_text_forward_delete(GTK_TEXT(tmpText),
|
|
62 gtk_text_get_length(GTK_TEXT(tmpText)));
|
|
63
|
|
64 if (xs_fileinfostil)
|
|
65 {
|
|
66 /* Get subtune number */
|
|
67 tmpItem = gtk_menu_get_active(GTK_MENU(data));
|
|
68 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem);
|
|
69
|
|
70 /* Get subtune information */
|
|
71 tmpNode = &xs_fileinfostil->subTune[tmpIndex];
|
|
72 subName = tmpNode->pName;
|
|
73 subAuthor = tmpNode->pAuthor;
|
|
74
|
|
75 /* Put in the new text, if available */
|
|
76 if (tmpNode->pInfo)
|
|
77 {
|
|
78 gtk_text_insert (GTK_TEXT (tmpText), NULL, NULL, NULL,
|
|
79 tmpNode->pInfo, strlen(tmpNode->pInfo));
|
|
80 }
|
|
81 } else {
|
|
82 /* We don't have any information */
|
|
83 subName = NULL;
|
|
84 subAuthor = NULL;
|
|
85 }
|
|
86
|
|
87 /* Get and set subtune information */
|
|
88 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : "");
|
|
89 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : "");
|
|
90
|
|
91 /* Un-freeze the widget */
|
|
92 gtk_text_thaw(GTK_TEXT(tmpText));
|
|
93 }
|
|
94
|
|
95
|
|
96 void xs_fileinfo(gchar *pcFilename)
|
|
97 {
|
|
98 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
|
|
99 t_xs_stil_subnode *tmpNode;
|
|
100 gchar tmpStr[32], *tmpS;
|
|
101 gint n;
|
|
102
|
|
103 /* Free old info, if set */
|
|
104 if (xs_fileinfotune)
|
230
|
105 xs_tuneinfo_free(xs_fileinfotune);
|
222
|
106
|
|
107 /* Get new tune information */
|
|
108 if ((xs_fileinfotune = xs_player->plrGetSIDInfo(pcFilename)) == NULL)
|
|
109 return;
|
|
110
|
|
111 if (xs_cfg.stilDBEnable)
|
|
112 xs_fileinfostil = xs_stil_get(pcFilename);
|
|
113 else
|
|
114 xs_fileinfostil = NULL;
|
|
115
|
|
116
|
|
117 /* Check if there already is an open fileinfo window */
|
|
118 if (xs_fileinfowin)
|
|
119 {
|
|
120 /* Raise old window */
|
|
121 gdk_window_raise(xs_fileinfowin->window);
|
|
122
|
|
123 /* Delete items */
|
|
124 tmpOptionMenu = LUW("fileinfo_sub_tune");
|
|
125 gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu);
|
|
126 GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new();
|
|
127 } else {
|
|
128 /* If not, create a new one */
|
|
129 xs_fileinfowin = create_xs_fileinfowin();
|
|
130
|
|
131 /* Connect additional signals */
|
|
132 gtk_signal_connect(GTK_OBJECT(
|
|
133 gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))),
|
|
134 "value_changed", GTK_SIGNAL_FUNC (xs_fileinfo_setsong), NULL);
|
|
135 }
|
|
136
|
|
137
|
|
138 /* Set the generic song information */
|
|
139 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename);
|
|
140 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName);
|
|
141 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer);
|
|
142 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright);
|
|
143
|
|
144
|
|
145 /* Main tune - the pseudo tune */
|
|
146 tmpOptionMenu = LUW("fileinfo_sub_tune");
|
|
147 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu;
|
|
148
|
|
149 tmpMenuItem = gtk_menu_item_new_with_label ("General info");
|
|
150 gtk_widget_show (tmpMenuItem);
|
|
151 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem);
|
|
152 gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate",
|
|
153 GTK_SIGNAL_FUNC (xs_fileinfo_subtune), tmpMenu);
|
|
154
|
|
155 /* Other menu items */
|
|
156 for (n = 1; n <= xs_fileinfotune->nsubTunes; n++)
|
|
157 {
|
|
158 if (xs_fileinfostil)
|
|
159 {
|
|
160 tmpNode = &xs_fileinfostil->subTune[n];
|
|
161 if (tmpNode->pName)
|
|
162 tmpS = tmpNode->pName;
|
|
163 else
|
|
164 if (tmpNode->pInfo)
|
|
165 tmpS = tmpNode->pInfo;
|
|
166 else
|
|
167 tmpS = "---";
|
|
168
|
|
169 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: %s", n, tmpS);
|
|
170 } else
|
|
171 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n);
|
|
172
|
|
173 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
|
|
174 gtk_widget_show (tmpMenuItem);
|
|
175 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem);
|
|
176
|
|
177 gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate",
|
|
178 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
|
|
179 }
|
|
180
|
|
181 /* Set the subtune information */
|
|
182 xs_fileinfo_subtune(NULL, tmpMenu);
|
|
183
|
|
184 /* Show the window */
|
|
185 gtk_widget_show(xs_fileinfowin);
|
|
186 }
|
|
187
|