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;
|
|
32
|
|
33 #define LUW(x...) lookup_widget(xs_fileinfowin, ## x)
|
|
34
|
|
35
|
|
36 void xs_fileinfo_ok(void)
|
|
37 {
|
|
38 gtk_widget_destroy(xs_fileinfowin);
|
|
39 xs_fileinfowin = NULL;
|
|
40 }
|
|
41
|
|
42
|
|
43 void xs_fileinfo_subtune(GtkWidget *widget, void *data)
|
|
44 {
|
|
45 t_xs_stil_subnode *tmpNode;
|
|
46 GtkWidget *tmpItem, *tmpText;
|
|
47 gint tmpIndex;
|
|
48 gchar *subName, *subAuthor;
|
|
49
|
|
50 /* Freeze text-widget and delete the old text */
|
|
51 tmpText = LUW("fileinfo_sub_info");
|
|
52 gtk_text_freeze(GTK_TEXT(tmpText));
|
|
53 gtk_text_set_point(GTK_TEXT(tmpText), 0);
|
|
54 gtk_text_forward_delete(GTK_TEXT(tmpText),
|
|
55 gtk_text_get_length(GTK_TEXT(tmpText)));
|
|
56
|
|
57 if (xs_fileinfostil)
|
|
58 {
|
|
59 /* Get subtune number */
|
|
60 tmpItem = gtk_menu_get_active(GTK_MENU(data));
|
|
61 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem);
|
|
62
|
|
63 /* Get subtune information */
|
|
64 tmpNode = &xs_fileinfostil->subTune[tmpIndex];
|
|
65 subName = tmpNode->pName;
|
|
66 subAuthor = tmpNode->pAuthor;
|
|
67
|
|
68 /* Put in the new text, if available */
|
|
69 if (tmpNode->pInfo)
|
|
70 {
|
|
71 gtk_text_insert (GTK_TEXT (tmpText), NULL, NULL, NULL,
|
|
72 tmpNode->pInfo, strlen(tmpNode->pInfo));
|
|
73 }
|
|
74 } else {
|
|
75 /* We don't have any information */
|
|
76 subName = NULL;
|
|
77 subAuthor = NULL;
|
|
78 }
|
|
79
|
|
80 /* Get and set subtune information */
|
|
81 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : "");
|
|
82 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : "");
|
|
83
|
|
84 /* Un-freeze the widget */
|
|
85 gtk_text_thaw(GTK_TEXT(tmpText));
|
|
86 }
|
|
87
|
|
88
|
|
89 void xs_fileinfo(gchar *pcFilename)
|
|
90 {
|
|
91 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
|
|
92 t_xs_stil_subnode *tmpNode;
|
|
93 gchar tmpStr[32], *tmpS;
|
|
94 gint n;
|
|
95
|
|
96 /* Free old info, if set */
|
|
97 if (xs_fileinfotune)
|
|
98 xs_tune_free(xs_fileinfotune);
|
|
99
|
|
100 /* Get new tune information */
|
|
101 if ((xs_fileinfotune = xs_player->plrGetSIDInfo(pcFilename)) == NULL)
|
|
102 return;
|
|
103
|
|
104 if (xs_cfg.stilDBEnable)
|
|
105 xs_fileinfostil = xs_stil_get(pcFilename);
|
|
106 else
|
|
107 xs_fileinfostil = NULL;
|
|
108
|
|
109
|
|
110 /* Check if there already is an open fileinfo window */
|
|
111 if (xs_fileinfowin)
|
|
112 {
|
|
113 /* Raise old window */
|
|
114 gdk_window_raise(xs_fileinfowin->window);
|
|
115
|
|
116 /* Delete items */
|
|
117 tmpOptionMenu = LUW("fileinfo_sub_tune");
|
|
118 gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu);
|
|
119 GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new();
|
|
120 } else {
|
|
121 /* If not, create a new one */
|
|
122 xs_fileinfowin = create_xs_fileinfowin();
|
|
123
|
|
124 /* Connect additional signals */
|
|
125 gtk_signal_connect(GTK_OBJECT(
|
|
126 gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))),
|
|
127 "value_changed", GTK_SIGNAL_FUNC (xs_fileinfo_setsong), NULL);
|
|
128 }
|
|
129
|
|
130
|
|
131 /* Set the generic song information */
|
|
132 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename);
|
|
133 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), xs_fileinfotune->tuneName);
|
|
134 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), xs_fileinfotune->tuneComposer);
|
|
135 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), xs_fileinfotune->tuneCopyright);
|
|
136
|
|
137
|
|
138 /* Main tune - the pseudo tune */
|
|
139 tmpOptionMenu = LUW("fileinfo_sub_tune");
|
|
140 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu;
|
|
141
|
|
142 tmpMenuItem = gtk_menu_item_new_with_label ("General info");
|
|
143 gtk_widget_show (tmpMenuItem);
|
|
144 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem);
|
|
145 gtk_signal_connect (GTK_OBJECT (tmpMenuItem), "activate",
|
|
146 GTK_SIGNAL_FUNC (xs_fileinfo_subtune), tmpMenu);
|
|
147
|
|
148 /* Other menu items */
|
|
149 for (n = 1; n <= xs_fileinfotune->nsubTunes; n++)
|
|
150 {
|
|
151 if (xs_fileinfostil)
|
|
152 {
|
|
153 tmpNode = &xs_fileinfostil->subTune[n];
|
|
154 if (tmpNode->pName)
|
|
155 tmpS = tmpNode->pName;
|
|
156 else
|
|
157 if (tmpNode->pInfo)
|
|
158 tmpS = tmpNode->pInfo;
|
|
159 else
|
|
160 tmpS = "---";
|
|
161
|
|
162 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: %s", n, tmpS);
|
|
163 } else
|
|
164 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n);
|
|
165
|
|
166 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
|
|
167 gtk_widget_show (tmpMenuItem);
|
|
168 gtk_menu_append (GTK_MENU(tmpMenu), tmpMenuItem);
|
|
169
|
|
170 gtk_signal_connect (GTK_OBJECT(tmpMenuItem), "activate",
|
|
171 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
|
|
172 }
|
|
173
|
|
174 /* Set the subtune information */
|
|
175 xs_fileinfo_subtune(NULL, tmpMenu);
|
|
176
|
|
177 /* Update subtune controls */
|
|
178 xs_subctrl_update();
|
|
179
|
|
180 /* Show the window */
|
|
181 gtk_widget_show(xs_fileinfowin);
|
|
182 }
|
|
183
|