Mercurial > hg > xmms-sid
comparison src/xs_fileinfo.cc @ 1:183e7cbc1036
Initial revision
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 03 Jun 2003 10:23:04 +0000 |
parents | |
children | 1788f4ce6a44 |
comparison
equal
deleted
inserted
replaced
0:5ce0a94edc2e | 1:183e7cbc1036 |
---|---|
1 /* | |
2 xmms-sid - SIDPlay input plugin for X MultiMedia System (XMMS) | |
3 | |
4 SIDTune file information dialog | |
5 | |
6 Written by Matti "ccr" Hamalainen <mhamalai@ratol.fi> | |
7 (Interface created with Glade, the Gtk+ interface builder) | |
8 | |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with this program; if not, write to the Free Software | |
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 */ | |
23 | |
24 | |
25 #include "xmms-sid.h" | |
26 #include <gtk/gtk.h> | |
27 #include <sidplay/sidtune.h> | |
28 #include <stdio.h> | |
29 #include <string.h> | |
30 | |
31 static GtkWidget *xs_fileinfowin = NULL; | |
32 static GtkWidget *fileinfo_filename, *fileinfo_songname, *fileinfo_composer; | |
33 static GtkWidget *fileinfo_copyright, *fileinfo_ok, *fileinfo_sub_comment; | |
34 static GtkWidget *fileinfo_sub_tune, *fileinfo_sub_tune_menu, *fileinfo_sub_artist, *fileinfo_sub_title; | |
35 | |
36 | |
37 /* | |
38 * Close the fileinfo | |
39 */ | |
40 void xs_fileinfo_ok(void) | |
41 { | |
42 gtk_widget_destroy(xs_fileinfowin); | |
43 } | |
44 | |
45 | |
46 /* | |
47 * Update the sub-tune information | |
48 */ | |
49 void xs_fileinfo_sub_tune(GtkWidget *widget, void *data) | |
50 { | |
51 T_sid_stil_subtune *a_tune; | |
52 GtkWidget *a_item; | |
53 gint a_index; | |
54 | |
55 | |
56 /* Get number of subtune */ | |
57 a_item = gtk_menu_get_active(GTK_MENU(fileinfo_sub_tune_menu)); | |
58 a_index = g_list_index(GTK_MENU_SHELL(fileinfo_sub_tune_menu)->children, a_item); | |
59 | |
60 a_tune = &xs_stil_info.subtune[a_index]; | |
61 | |
62 | |
63 /* Get and set subtune information */ | |
64 if (a_tune->artist != NULL) | |
65 gtk_entry_set_text (GTK_ENTRY (fileinfo_sub_artist), a_tune->artist); | |
66 | |
67 if (a_tune->title != NULL) | |
68 gtk_entry_set_text (GTK_ENTRY (fileinfo_sub_title), a_tune->title); | |
69 | |
70 if (a_tune->comment != NULL) { | |
71 | |
72 /* Freeze the widget for update */ | |
73 gtk_text_freeze(GTK_TEXT(fileinfo_sub_comment)); | |
74 | |
75 /* Delete the old comment */ | |
76 gtk_text_set_point(GTK_TEXT(fileinfo_sub_comment), 0); | |
77 | |
78 gtk_text_forward_delete(GTK_TEXT(fileinfo_sub_comment), | |
79 gtk_text_get_length(GTK_TEXT(fileinfo_sub_comment))); | |
80 | |
81 /* Put in the new comment */ | |
82 gtk_text_insert (GTK_TEXT (fileinfo_sub_comment), NULL, NULL, NULL, | |
83 a_tune->comment, strlen(a_tune->comment)); | |
84 | |
85 /* Un-freeze the widget */ | |
86 gtk_text_thaw(GTK_TEXT(fileinfo_sub_comment)); | |
87 } | |
88 } | |
89 | |
90 | |
91 /* | |
92 * Execute the file-info dialog | |
93 */ | |
94 void xs_file_info_box(char *filename) | |
95 { | |
96 GtkWidget *vbox14, *table1, *label16, *label17, *label18, *label19; | |
97 GtkWidget *frame14, *vbox15, *glade_menuitem, *frame15, *alignment5; | |
98 GtkWidget *table2, *label21, *label22, *scrolledwindow2; | |
99 gint n; | |
100 gchar tempstr[128]; | |
101 | |
102 /* Get sidtune information */ | |
103 sidTune t(filename); | |
104 if (!t) return; | |
105 struct sidTuneInfo sidInf; | |
106 t.getInfo(sidInf); | |
107 | |
108 /* Check if therea already is an open fileinfo window */ | |
109 if (xs_fileinfowin != NULL) { | |
110 gdk_window_raise (xs_fileinfowin->window); | |
111 return; | |
112 } | |
113 | |
114 /* If not, create a new one */ | |
115 xs_fileinfowin = gtk_window_new (GTK_WINDOW_DIALOG); | |
116 gtk_signal_connect(GTK_OBJECT(xs_fileinfowin),"destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &xs_fileinfowin); | |
117 gtk_object_set_data (GTK_OBJECT (xs_fileinfowin), "xs_fileinfowin", xs_fileinfowin); | |
118 gtk_widget_set_usize (xs_fileinfowin, 400, 350); | |
119 gtk_window_set_title (GTK_WINDOW (xs_fileinfowin), "xmms-sid fileinfo"); | |
120 gtk_window_set_position (GTK_WINDOW (xs_fileinfowin), GTK_WIN_POS_MOUSE); | |
121 | |
122 /* Start creating the widgets ! */ | |
123 vbox14 = gtk_vbox_new (FALSE, 0); | |
124 gtk_widget_ref (vbox14); | |
125 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "vbox14", vbox14, (GtkDestroyNotify) gtk_widget_unref); | |
126 gtk_widget_show (vbox14); | |
127 gtk_container_add (GTK_CONTAINER (xs_fileinfowin), vbox14); | |
128 | |
129 | |
130 /* Song information */ | |
131 frame14 = gtk_frame_new ("Song Information:"); | |
132 gtk_widget_ref (frame14); | |
133 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "frame14", frame14, (GtkDestroyNotify) gtk_widget_unref); | |
134 gtk_widget_show (frame14); | |
135 gtk_box_pack_start (GTK_BOX (vbox14), frame14, FALSE, TRUE, 0); | |
136 gtk_container_set_border_width (GTK_CONTAINER (frame14), 4); | |
137 | |
138 table1 = gtk_table_new (4, 2, FALSE); | |
139 gtk_widget_ref (table1); | |
140 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "table1", table1, (GtkDestroyNotify) gtk_widget_unref); | |
141 gtk_widget_show (table1); | |
142 gtk_container_add (GTK_CONTAINER (frame14), table1); | |
143 gtk_container_set_border_width (GTK_CONTAINER (table1), 4); | |
144 gtk_table_set_row_spacings (GTK_TABLE (table1), 2); | |
145 gtk_table_set_col_spacings (GTK_TABLE (table1), 4); | |
146 | |
147 label16 = gtk_label_new ("Filename:"); | |
148 gtk_widget_ref (label16); | |
149 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label16", label16, (GtkDestroyNotify) gtk_widget_unref); | |
150 gtk_widget_show (label16); | |
151 gtk_table_attach (GTK_TABLE (table1), label16, 0, 1, 0, 1, | |
152 (GtkAttachOptions) (0), | |
153 (GtkAttachOptions) (0), 0, 0); | |
154 | |
155 label17 = gtk_label_new ("Songname:"); | |
156 gtk_widget_ref (label17); | |
157 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label17", label17, | |
158 (GtkDestroyNotify) gtk_widget_unref); | |
159 gtk_widget_show (label17); | |
160 gtk_table_attach (GTK_TABLE (table1), label17, 0, 1, 1, 2, | |
161 (GtkAttachOptions) (0), | |
162 (GtkAttachOptions) (0), 0, 0); | |
163 | |
164 label18 = gtk_label_new ("Composer:"); | |
165 gtk_widget_ref (label18); | |
166 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label18", label18, | |
167 (GtkDestroyNotify) gtk_widget_unref); | |
168 gtk_widget_show (label18); | |
169 gtk_table_attach (GTK_TABLE (table1), label18, 0, 1, 2, 3, | |
170 (GtkAttachOptions) (0), | |
171 (GtkAttachOptions) (0), 0, 0); | |
172 | |
173 label19 = gtk_label_new ("Copyright:"); | |
174 gtk_widget_ref (label19); | |
175 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label19", label19, | |
176 (GtkDestroyNotify) gtk_widget_unref); | |
177 gtk_widget_show (label19); | |
178 gtk_table_attach (GTK_TABLE (table1), label19, 0, 1, 3, 4, | |
179 (GtkAttachOptions) (0), | |
180 (GtkAttachOptions) (0), 0, 0); | |
181 | |
182 fileinfo_filename = gtk_entry_new (); | |
183 gtk_widget_ref (fileinfo_filename); | |
184 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_filename", fileinfo_filename, | |
185 (GtkDestroyNotify) gtk_widget_unref); | |
186 gtk_widget_show (fileinfo_filename); | |
187 gtk_table_attach (GTK_TABLE (table1), fileinfo_filename, 1, 2, 0, 1, | |
188 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
189 (GtkAttachOptions) (0), 0, 0); | |
190 gtk_entry_set_editable (GTK_ENTRY (fileinfo_filename), FALSE); | |
191 | |
192 fileinfo_songname = gtk_entry_new (); | |
193 gtk_widget_ref (fileinfo_songname); | |
194 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_songname", fileinfo_songname, | |
195 (GtkDestroyNotify) gtk_widget_unref); | |
196 gtk_widget_show (fileinfo_songname); | |
197 gtk_table_attach (GTK_TABLE (table1), fileinfo_songname, 1, 2, 1, 2, | |
198 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
199 (GtkAttachOptions) (0), 0, 0); | |
200 gtk_entry_set_editable (GTK_ENTRY (fileinfo_songname), FALSE); | |
201 | |
202 fileinfo_composer = gtk_entry_new (); | |
203 gtk_widget_ref (fileinfo_composer); | |
204 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_composer", fileinfo_composer, | |
205 (GtkDestroyNotify) gtk_widget_unref); | |
206 gtk_widget_show (fileinfo_composer); | |
207 gtk_table_attach (GTK_TABLE (table1), fileinfo_composer, 1, 2, 2, 3, | |
208 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
209 (GtkAttachOptions) (0), 0, 0); | |
210 gtk_entry_set_editable (GTK_ENTRY (fileinfo_composer), FALSE); | |
211 | |
212 fileinfo_copyright = gtk_entry_new (); | |
213 gtk_widget_ref (fileinfo_copyright); | |
214 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_copyright", fileinfo_copyright, | |
215 (GtkDestroyNotify) gtk_widget_unref); | |
216 gtk_widget_show (fileinfo_copyright); | |
217 gtk_table_attach (GTK_TABLE (table1), fileinfo_copyright, 1, 2, 3, 4, | |
218 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
219 (GtkAttachOptions) (0), 0, 0); | |
220 gtk_entry_set_editable (GTK_ENTRY (fileinfo_copyright), FALSE); | |
221 | |
222 | |
223 /* Tune information */ | |
224 frame15 = gtk_frame_new ("Tune Information:"); | |
225 gtk_widget_ref (frame15); | |
226 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "frame15", frame15, | |
227 (GtkDestroyNotify) gtk_widget_unref); | |
228 gtk_widget_show (frame15); | |
229 gtk_box_pack_start (GTK_BOX (vbox14), frame15, TRUE, TRUE, 0); | |
230 gtk_container_set_border_width (GTK_CONTAINER (frame15), 4); | |
231 | |
232 vbox15 = gtk_vbox_new (FALSE, 0); | |
233 gtk_widget_ref (vbox15); | |
234 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "vbox15", vbox15, (GtkDestroyNotify) gtk_widget_unref); | |
235 gtk_widget_show (vbox15); | |
236 gtk_container_add (GTK_CONTAINER (frame15), vbox15); | |
237 | |
238 /* Sub-tune selection menu */ | |
239 fileinfo_sub_tune = gtk_option_menu_new (); | |
240 gtk_widget_ref (fileinfo_sub_tune); | |
241 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_sub_tune", fileinfo_sub_tune, (GtkDestroyNotify) gtk_widget_unref); | |
242 gtk_widget_show (fileinfo_sub_tune); | |
243 // gtk_box_pack_start (GTK_BOX (vbox15), fileinfo_sub_tune, FALSE, TRUE, 2); | |
244 gtk_box_pack_start (GTK_BOX (vbox15), fileinfo_sub_tune, FALSE, FALSE, 2); | |
245 | |
246 /* -------------- */ | |
247 table2 = gtk_table_new (2, 2, FALSE); | |
248 gtk_widget_ref (table2); | |
249 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "table2", table2, | |
250 (GtkDestroyNotify) gtk_widget_unref); | |
251 gtk_widget_show (table2); | |
252 gtk_box_pack_start (GTK_BOX (vbox15), table2, FALSE, FALSE, 0); | |
253 gtk_container_set_border_width (GTK_CONTAINER (table2), 4); | |
254 | |
255 label21 = gtk_label_new ("Title:"); | |
256 gtk_widget_ref (label21); | |
257 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label21", label21, | |
258 (GtkDestroyNotify) gtk_widget_unref); | |
259 gtk_widget_show (label21); | |
260 gtk_table_attach (GTK_TABLE (table2), label21, 0, 1, 0, 1, | |
261 (GtkAttachOptions) (0), | |
262 (GtkAttachOptions) (0), 0, 0); | |
263 | |
264 label22 = gtk_label_new ("Artist:"); | |
265 gtk_widget_ref (label22); | |
266 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "label22", label22, | |
267 (GtkDestroyNotify) gtk_widget_unref); | |
268 gtk_widget_show (label22); | |
269 gtk_table_attach (GTK_TABLE (table2), label22, 0, 1, 1, 2, | |
270 (GtkAttachOptions) (0), | |
271 (GtkAttachOptions) (0), 0, 0); | |
272 | |
273 fileinfo_sub_artist = gtk_entry_new (); | |
274 gtk_widget_ref (fileinfo_sub_artist); | |
275 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_sub_artist", fileinfo_sub_artist, | |
276 (GtkDestroyNotify) gtk_widget_unref); | |
277 gtk_widget_show (fileinfo_sub_artist); | |
278 gtk_table_attach (GTK_TABLE (table2), fileinfo_sub_artist, 1, 2, 1, 2, | |
279 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
280 (GtkAttachOptions) (0), 0, 0); | |
281 gtk_entry_set_editable (GTK_ENTRY (fileinfo_sub_artist), FALSE); | |
282 | |
283 fileinfo_sub_title = gtk_entry_new (); | |
284 gtk_widget_ref (fileinfo_sub_title); | |
285 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_sub_title", fileinfo_sub_title, | |
286 (GtkDestroyNotify) gtk_widget_unref); | |
287 gtk_widget_show (fileinfo_sub_title); | |
288 gtk_table_attach (GTK_TABLE (table2), fileinfo_sub_title, 1, 2, 0, 1, | |
289 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
290 (GtkAttachOptions) (0), 0, 0); | |
291 gtk_entry_set_editable (GTK_ENTRY (fileinfo_sub_title), FALSE); | |
292 | |
293 scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); | |
294 gtk_widget_ref (scrolledwindow2); | |
295 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "scrolledwindow2", scrolledwindow2, | |
296 (GtkDestroyNotify) gtk_widget_unref); | |
297 gtk_widget_show (scrolledwindow2); | |
298 gtk_box_pack_start (GTK_BOX (vbox15), scrolledwindow2, TRUE, TRUE, 0); | |
299 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow2), 4); | |
300 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
301 | |
302 fileinfo_sub_comment = gtk_text_new (NULL, NULL); | |
303 gtk_widget_ref (fileinfo_sub_comment); | |
304 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_sub_comment", fileinfo_sub_comment, | |
305 (GtkDestroyNotify) gtk_widget_unref); | |
306 gtk_widget_show (fileinfo_sub_comment); | |
307 gtk_container_add (GTK_CONTAINER (scrolledwindow2), fileinfo_sub_comment); | |
308 | |
309 alignment5 = gtk_alignment_new (0.5, 0.5, 0.1, 1); | |
310 gtk_widget_ref (alignment5); | |
311 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "alignment5", alignment5, | |
312 (GtkDestroyNotify) gtk_widget_unref); | |
313 gtk_widget_show (alignment5); | |
314 gtk_box_pack_start (GTK_BOX (vbox14), alignment5, FALSE, FALSE, 0); | |
315 | |
316 fileinfo_ok = gtk_button_new_with_label ("Close"); | |
317 gtk_widget_ref (fileinfo_ok); | |
318 gtk_object_set_data_full (GTK_OBJECT (xs_fileinfowin), "fileinfo_ok", fileinfo_ok, | |
319 (GtkDestroyNotify) gtk_widget_unref); | |
320 gtk_widget_show (fileinfo_ok); | |
321 gtk_container_add (GTK_CONTAINER (alignment5), fileinfo_ok); | |
322 GTK_WIDGET_SET_FLAGS (fileinfo_ok, GTK_CAN_DEFAULT); | |
323 | |
324 gtk_widget_grab_default (fileinfo_ok); | |
325 | |
326 | |
327 /* Set the song informations */ | |
328 gtk_entry_set_text (GTK_ENTRY (fileinfo_filename), filename); | |
329 gtk_entry_set_text (GTK_ENTRY (fileinfo_songname), sidInf.infoString[0]); | |
330 gtk_entry_set_text (GTK_ENTRY (fileinfo_composer), sidInf.infoString[1]); | |
331 gtk_entry_set_text (GTK_ENTRY (fileinfo_copyright), sidInf.infoString[2]); | |
332 | |
333 | |
334 /* Sub-tune menu items */ | |
335 fileinfo_sub_tune_menu = gtk_menu_new (); | |
336 | |
337 /* "main tune" - the pseudo tune */ | |
338 glade_menuitem = gtk_menu_item_new_with_label ("General info"); | |
339 gtk_widget_show (glade_menuitem); | |
340 gtk_menu_append (GTK_MENU (fileinfo_sub_tune_menu), glade_menuitem); | |
341 gtk_signal_connect (GTK_OBJECT (glade_menuitem), "activate", | |
342 GTK_SIGNAL_FUNC (xs_fileinfo_sub_tune), fileinfo_sub_tune_menu); | |
343 | |
344 /* Other menu items */ | |
345 for (n = 1; n <= sidInf.songs; n++) { | |
346 | |
347 snprintf(tempstr, sizeof(tempstr), "Tune #%i", n); | |
348 glade_menuitem = gtk_menu_item_new_with_label (tempstr); | |
349 gtk_widget_show (glade_menuitem); | |
350 gtk_menu_append (GTK_MENU (fileinfo_sub_tune_menu), glade_menuitem); | |
351 | |
352 gtk_signal_connect (GTK_OBJECT (glade_menuitem), "activate", | |
353 GTK_SIGNAL_FUNC (xs_fileinfo_sub_tune), fileinfo_sub_tune_menu); | |
354 } | |
355 | |
356 gtk_option_menu_set_menu (GTK_OPTION_MENU (fileinfo_sub_tune), fileinfo_sub_tune_menu); | |
357 | |
358 /* Check if user wants STIL info */ | |
359 if (xs_cfg.usestil) | |
360 xs_stil_get(filename); | |
361 | |
362 /* Set the sub-tune information */ | |
363 xs_fileinfo_sub_tune(NULL, fileinfo_sub_tune_menu); | |
364 | |
365 /* Connect the signals */ | |
366 gtk_signal_connect (GTK_OBJECT (fileinfo_ok), "clicked", | |
367 GTK_SIGNAL_FUNC (xs_fileinfo_ok), | |
368 NULL); | |
369 | |
370 /* Show the window */ | |
371 gtk_widget_show(xs_fileinfowin); | |
372 } |