1 /*
2 * Copyright (C) 2000-2005 Heikki Orsila
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include <assert.h>
22 #include <strings.h>
23 #include <limits.h>
24 #include <libgen.h>
25
26
27 #include <glib.h>
28 #include <gtk/gtk.h>
29 #include <xmms/plugin.h>
30 #include <xmms/configfile.h>
31 #include <xmms/util.h>
32
33 #include "ossupport.h"
34 #include "songinfo.h"
35 #include "fileinfo.h"
36 #include "plugin.h"
37
38
39 static char module_filename[PATH_MAX];
40 static char player_filename[PATH_MAX];
41
42 static GtkWidget *fileinfowin = NULL;
43 static GtkWidget *playerinfowin = NULL;
44 static GtkWidget *modinfowin = NULL;
45 static GtkTooltips *fileinfo_tooltips;
46 static GtkWidget *fileinfo_hexinfo_button;
47 static GtkWidget *fileinfo_moduleinfo_button;
48
49 static GtkWidget *fileinfo_modulename_txt;
50 static GtkWidget *fileinfo_playername_txt;
51 static GtkWidget *fileinfo_maxsubsong_txt;
52 static GtkWidget *fileinfo_minsubsong_txt;
53 static GtkWidget *fileinfo_subsong_txt;
54
55
56 static void uade_mod_info(int modinfo_mode);
57 static void uade_mod_info_hex(void);
58 static void uade_mod_info_module(void);
59
60 static void uade_player_info(void);
61
62 /* File Info Window */
63
uade_gui_file_info(char * filename,char * gui_player_filename,char * modulename,char * playername,char * formatname)64 void uade_gui_file_info(char *filename, char *gui_player_filename,
65 char *modulename, char *playername, char *formatname)
66 {
67 GtkWidget *fileinfo_base_vbox;
68 GtkWidget *fileinfo_frame;
69 GtkWidget *fileinfo_table;
70
71 GtkWidget *fileinfo_modulename_label;
72 GtkWidget *fileinfo_modulename_hbox;
73 GtkWidget *fileinfo_hrule1;
74 GtkWidget *fileinfo_playername_hbox;
75 GtkWidget *fileinfo_playername_label;
76 GtkWidget *fileinfo_playerinfo_button;
77 GtkWidget *fileinfo_hrule2;
78 GtkWidget *fileinfo_subsong_label;
79 GtkWidget *fileinfo_minsubsong_label;
80 GtkWidget *fileinfo_maxsubsong_label;
81 GtkWidget *fileinfo_hrule3;
82 GtkWidget *fileinfo_hrule4;
83
84 GtkWidget *fileinfo_button_box;
85 GtkWidget *ok_button;
86
87 strlcpy(module_filename, filename, sizeof module_filename);
88 strlcpy(player_filename, gui_player_filename, sizeof player_filename);
89
90 if (fileinfowin == NULL) {
91 fileinfo_tooltips = gtk_tooltips_new();
92 fileinfowin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
93 gtk_window_set_title(GTK_WINDOW(fileinfowin), "UADE file info");
94 gtk_window_set_position(GTK_WINDOW(fileinfowin),
95 GTK_WIN_POS_MOUSE);
96 gtk_container_set_border_width(GTK_CONTAINER(fileinfowin), 10);
97 gtk_window_set_policy(GTK_WINDOW(fileinfowin), FALSE, FALSE,
98 FALSE);
99 gtk_signal_connect(GTK_OBJECT(fileinfowin), "destroy",
100 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
101 &fileinfowin);
102
103 /* Start of Contents Box */
104
105 fileinfo_base_vbox = gtk_vbox_new(FALSE, 10);
106
107 gtk_container_set_border_width(GTK_CONTAINER
108 (fileinfo_base_vbox), 5);
109 gtk_container_add(GTK_CONTAINER(fileinfowin),
110 fileinfo_base_vbox);
111
112 /* Start of File info frame, text and option widgets */
113
114 fileinfo_frame = gtk_frame_new("File info: ");
115 gtk_box_pack_start(GTK_BOX(fileinfo_base_vbox), fileinfo_frame,
116 TRUE, TRUE, 0);
117
118 /* Start of Fileinfotable */
119
120 fileinfo_table = gtk_table_new(12, 2, FALSE);
121
122 gtk_widget_show(fileinfo_table);
123 gtk_container_add(GTK_CONTAINER(fileinfo_frame),
124 fileinfo_table);
125 gtk_container_set_border_width(GTK_CONTAINER(fileinfo_table), 5);
126
127 /* 1x1 */
128
129 fileinfo_modulename_label = gtk_label_new("Module: ");
130 gtk_misc_set_padding(GTK_MISC(fileinfo_modulename_label), 5,
131 5);
132 /* gtk_misc_set_alignment (GTK_MISC (fileinfo_modulename_label), 1, 0); */
133 gtk_table_attach(GTK_TABLE(fileinfo_table),
134 fileinfo_modulename_label, 0, 1, 0, 1,
135 (GtkAttachOptions) (GTK_FILL),
136 (GtkAttachOptions) (GTK_FILL), 0, 0);
137
138 /* 1x2 */
139 /* 1x3 */
140
141 fileinfo_hrule1 = gtk_hseparator_new();
142 gtk_table_attach(GTK_TABLE(fileinfo_table), fileinfo_hrule1, 0,
143 1, 2, 3, (GtkAttachOptions) (GTK_FILL),
144 (GtkAttachOptions) (0), 0, 0);
145
146 /* 1x4 */
147
148 fileinfo_playername_label = gtk_label_new("Playerformat: ");
149 gtk_misc_set_padding(GTK_MISC(fileinfo_playername_label), 5,
150 5);
151 /* gtk_misc_set_alignment (GTK_MISC (fileinfo_playername_label), 1, 0); */
152 gtk_table_attach(GTK_TABLE(fileinfo_table),
153 fileinfo_playername_label, 0, 1, 3, 4,
154 (GtkAttachOptions) (GTK_FILL),
155 (GtkAttachOptions) (GTK_FILL), 0, 0);
156
157
158 fileinfo_hrule2 = gtk_hseparator_new();
159 gtk_table_attach(GTK_TABLE(fileinfo_table), fileinfo_hrule2, 0,
160 1, 6, 7, (GtkAttachOptions) (GTK_FILL),
161 (GtkAttachOptions) (0), 0, 0);
162
163 /* 1x8*/
164
165 fileinfo_subsong_label = gtk_label_new("Curr. subsong: ");
166 gtk_misc_set_padding(GTK_MISC(fileinfo_subsong_label), 5, 5);
167 /* gtk_misc_set_alignment (GTK_MISC (fileinfo_subsong_label), 1, 0); */
168 gtk_table_attach(GTK_TABLE(fileinfo_table),
169 fileinfo_subsong_label, 0, 1, 7, 8,
170 (GtkAttachOptions) (GTK_FILL),
171 (GtkAttachOptions) (GTK_FILL), 0, 0);
172
173 /* 1x9*/
174
175 fileinfo_minsubsong_label = gtk_label_new("Min. subsong: ");
176 gtk_misc_set_padding(GTK_MISC(fileinfo_minsubsong_label), 5,
177 5);
178 /* gtk_misc_set_alignment (GTK_MISC (fileinfo_minsubsong_label), 1, 0); */
179 gtk_table_attach(GTK_TABLE(fileinfo_table),
180 fileinfo_minsubsong_label, 0, 1, 8, 9,
181 (GtkAttachOptions) (GTK_FILL),
182 (GtkAttachOptions) (GTK_FILL), 0, 0);
183
184 /* 1x10*/
185
186 fileinfo_maxsubsong_label = gtk_label_new("Max. subsong: ");
187 gtk_misc_set_padding(GTK_MISC(fileinfo_maxsubsong_label), 5,
188 5);
189 /* gtk_misc_set_alignment (GTK_MISC (fileinfo_maxsubsong_label), 1, 0); */
190 gtk_table_attach(GTK_TABLE(fileinfo_table),
191 fileinfo_maxsubsong_label, 0, 1, 9, 10,
192 (GtkAttachOptions) (GTK_FILL),
193 (GtkAttachOptions) (GTK_FILL), 0, 0);
194
195 /* 2nd Column */
196 /* 2x1*/
197 fileinfo_modulename_hbox = gtk_hbox_new(FALSE, 10);
198 gtk_table_attach(GTK_TABLE(fileinfo_table),
199 fileinfo_modulename_hbox, 1, 2, 0, 1,
200 (GtkAttachOptions) (GTK_FILL),
201 (GtkAttachOptions) (0), 0, 0);
202
203 if (modulename[0] == 0) {
204 fileinfo_modulename_txt = gtk_label_new(basename(filename));
205 } else {
206 fileinfo_modulename_txt = gtk_label_new(g_strdup_printf("%s\n(%s)",
207 modulename,
208 basename(filename)
209 ));
210 }
211
212 gtk_label_set_justify(GTK_LABEL(fileinfo_modulename_txt),
213 GTK_JUSTIFY_LEFT);
214 gtk_label_set_line_wrap(GTK_LABEL(fileinfo_modulename_txt),
215 TRUE);
216 gtk_misc_set_alignment(GTK_MISC(fileinfo_modulename_txt), 0,
217 0.5);
218 gtk_misc_set_padding(GTK_MISC(fileinfo_modulename_txt), 5, 5);
219
220
221 fileinfo_hexinfo_button = gtk_button_new_with_label("hex");
222 GTK_WIDGET_SET_FLAGS(fileinfo_hexinfo_button,
223 GTK_CAN_DEFAULT);
224 gtk_widget_ref(fileinfo_hexinfo_button);
225 gtk_object_set_data_full(GTK_OBJECT(fileinfowin),
226 "fileinfo_hexinfo_button",
227 fileinfo_hexinfo_button,
228 (GtkDestroyNotify) gtk_widget_unref);
229 gtk_tooltips_set_tip(fileinfo_tooltips,
230 fileinfo_hexinfo_button,
231 g_strdup_printf("%s", filename),
232 NULL);
233
234 gtk_signal_connect_object(GTK_OBJECT
235 (fileinfo_hexinfo_button),
236 "clicked",
237 GTK_SIGNAL_FUNC(uade_mod_info_hex), NULL);
238
239
240 fileinfo_moduleinfo_button = gtk_button_new_with_label("Info");
241 GTK_WIDGET_SET_FLAGS(fileinfo_moduleinfo_button,
242 GTK_CAN_DEFAULT);
243
244 gtk_widget_ref(fileinfo_moduleinfo_button);
245 gtk_object_set_data_full(GTK_OBJECT(fileinfowin),
246 "fileinfo_moduleinfo_button",
247 fileinfo_moduleinfo_button,
248 (GtkDestroyNotify) gtk_widget_unref);
249 gtk_tooltips_set_tip(fileinfo_tooltips,
250 fileinfo_moduleinfo_button,
251 g_strdup_printf("%s", filename),
252 NULL);
253
254
255 gtk_signal_connect_object(GTK_OBJECT
256 (fileinfo_moduleinfo_button),
257 "clicked",
258 GTK_SIGNAL_FUNC(uade_mod_info_module), NULL);
259
260
261 gtk_box_pack_start(GTK_BOX(fileinfo_modulename_hbox),
262 fileinfo_modulename_txt, TRUE, TRUE, 0);
263 gtk_box_pack_start_defaults(GTK_BOX(fileinfo_modulename_hbox),
264 fileinfo_hexinfo_button);
265 gtk_box_pack_start_defaults(GTK_BOX(fileinfo_modulename_hbox),
266 fileinfo_moduleinfo_button);
267
268 /* 2x2*/
269 /* 2x3*/
270 fileinfo_hrule3 = gtk_hseparator_new();
271 gtk_table_attach(GTK_TABLE(fileinfo_table), fileinfo_hrule3, 1,
272 2, 2, 3, (GtkAttachOptions) (GTK_FILL),
273 (GtkAttachOptions) (0), 0, 0);
274
275
276 /* 2x4*/
277
278 fileinfo_playername_hbox = gtk_hbox_new(FALSE, 10);
279 gtk_table_attach(GTK_TABLE(fileinfo_table),
280 fileinfo_playername_hbox, 1, 2, 3, 4,
281 (GtkAttachOptions) (GTK_FILL),
282 (GtkAttachOptions) (0), 0, 0);
283
284
285 if (formatname[0] == 0) {
286 fileinfo_playername_txt = gtk_label_new(g_strdup_printf("%s", playername));
287 } else {
288 /* memory leaks using g_strdup_printf? */
289 fileinfo_playername_txt = gtk_label_new(g_strdup_printf("%s\n%s", playername, formatname));
290 }
291
292 /* fileinfo_playername_txt = gtk_label_new (get_playername()); */
293 gtk_label_set_justify(GTK_LABEL(fileinfo_playername_txt),
294 GTK_JUSTIFY_LEFT);
295 gtk_label_set_line_wrap(GTK_LABEL(fileinfo_playername_txt),
296 TRUE);
297 gtk_misc_set_alignment(GTK_MISC(fileinfo_playername_txt), 0,
298 0.5);
299 gtk_misc_set_padding(GTK_MISC(fileinfo_playername_txt), 5, 5);
300
301 fileinfo_playerinfo_button = gtk_button_new_with_label("?");
302 GTK_WIDGET_SET_FLAGS(fileinfo_playerinfo_button,
303 GTK_CAN_DEFAULT);
304 gtk_signal_connect_object(GTK_OBJECT
305 (fileinfo_playerinfo_button),
306 "clicked",
307 GTK_SIGNAL_FUNC(uade_player_info),
308 NULL);
309
310
311 gtk_box_pack_start(GTK_BOX(fileinfo_playername_hbox),
312 fileinfo_playername_txt, TRUE, TRUE, 0);
313 gtk_box_pack_start_defaults(GTK_BOX(fileinfo_playername_hbox),
314 fileinfo_playerinfo_button);
315
316
317 fileinfo_hrule4 = gtk_hseparator_new();
318 gtk_table_attach(GTK_TABLE(fileinfo_table), fileinfo_hrule4, 1,
319 2, 6, 7, (GtkAttachOptions) (GTK_FILL),
320 (GtkAttachOptions) (0), 0, 0);
321
322
323 fileinfo_subsong_txt =
324 gtk_label_new(g_strdup_printf("%d", uade_get_cur_subsong(0)));
325
326 /* gtk_widget_setusize for this widget is a bit of a cludge to set
327 a minimal size for the FileinfoWindow. I can't get it to work either with
328 setting the usize for the window or the table... weird */
329
330 gtk_widget_set_usize(fileinfo_subsong_txt, 176, -2);
331
332
333 gtk_table_attach(GTK_TABLE(fileinfo_table),
334 fileinfo_subsong_txt, 1, 2, 7, 8,
335 (GtkAttachOptions) (GTK_FILL),
336 (GtkAttachOptions) (0), 0, 0);
337 gtk_label_set_justify(GTK_LABEL(fileinfo_subsong_txt),
338 GTK_JUSTIFY_LEFT);
339 gtk_label_set_line_wrap(GTK_LABEL(fileinfo_subsong_txt), TRUE);
340 gtk_misc_set_alignment(GTK_MISC(fileinfo_subsong_txt), 0, 0.5);
341 gtk_misc_set_padding(GTK_MISC(fileinfo_subsong_txt), 5, 5);
342
343 /* 2x9*/
344 fileinfo_minsubsong_txt =
345 gtk_label_new(g_strdup_printf("%d", uade_get_min_subsong(0)));
346 gtk_table_attach(GTK_TABLE(fileinfo_table),
347 fileinfo_minsubsong_txt, 1, 2, 8, 9,
348 (GtkAttachOptions) (GTK_FILL),
349 (GtkAttachOptions) (0), 0, 0);
350 gtk_label_set_justify(GTK_LABEL(fileinfo_minsubsong_txt),
351 GTK_JUSTIFY_LEFT);
352 gtk_label_set_line_wrap(GTK_LABEL(fileinfo_subsong_txt), TRUE);
353 gtk_misc_set_alignment(GTK_MISC(fileinfo_minsubsong_txt), 0,
354 0.5);
355 gtk_misc_set_padding(GTK_MISC(fileinfo_minsubsong_txt), 5, 5);
356
357 /* 2x10*/
358 fileinfo_maxsubsong_txt =
359 gtk_label_new(g_strdup_printf("%d", uade_get_max_subsong(0)));
360 gtk_table_attach(GTK_TABLE(fileinfo_table),
361 fileinfo_maxsubsong_txt, 1, 2, 9, 10,
362 (GtkAttachOptions) (GTK_FILL),
363 (GtkAttachOptions) (0), 0, 0);
364 gtk_label_set_justify(GTK_LABEL(fileinfo_maxsubsong_txt),
365 GTK_JUSTIFY_LEFT);
366 gtk_label_set_line_wrap(GTK_LABEL(fileinfo_maxsubsong_txt),
367 TRUE);
368 gtk_misc_set_alignment(GTK_MISC(fileinfo_maxsubsong_txt), 0,
369 0.5);
370 gtk_misc_set_padding(GTK_MISC(fileinfo_maxsubsong_txt), 5, 5);
371
372 /* end of frame. */
373
374 /* Start of Ok and Cancel Button Box */
375
376 fileinfo_button_box = gtk_hbutton_box_new();
377
378
379 gtk_button_box_set_layout(GTK_BUTTON_BOX(fileinfo_button_box),
380 GTK_BUTTONBOX_END);
381 gtk_button_box_set_spacing(GTK_BUTTON_BOX(fileinfo_button_box),
382 5);
383 gtk_box_pack_start(GTK_BOX(fileinfo_base_vbox),
384 fileinfo_button_box, FALSE, FALSE, 0);
385
386
387 ok_button = gtk_button_new_with_label("Close");
388 GTK_WIDGET_SET_FLAGS(ok_button, GTK_CAN_DEFAULT);
389 gtk_signal_connect_object(GTK_OBJECT(ok_button), "clicked",
390 GTK_SIGNAL_FUNC(gtk_widget_destroy),
391 GTK_OBJECT(fileinfowin));
392
393 gtk_box_pack_start_defaults(GTK_BOX(fileinfo_button_box),
394 ok_button);
395
396 /* End of Button Box */
397
398 gtk_widget_show_all(fileinfowin);
399
400 } else {
401 gdk_window_raise(fileinfowin->window);
402 }
403 }
404
file_info_update(char * gui_module_filename,char * gui_player_filename,char * gui_modulename,char * gui_playername,char * gui_formatname)405 void file_info_update(char *gui_module_filename, char *gui_player_filename,
406 char *gui_modulename, char *gui_playername,
407 char *gui_formatname)
408 {
409
410 if (fileinfowin != NULL) {
411 strlcpy(module_filename, gui_module_filename, sizeof module_filename);
412 strlcpy(player_filename, gui_player_filename, sizeof player_filename);
413
414 gdk_window_raise(fileinfowin->window);
415
416 if (gui_modulename[0] == 0) {
417 gtk_label_set_text(GTK_LABEL(fileinfo_modulename_txt),
418 g_strdup_printf("%s", basename(gui_module_filename)));
419 } else {
420 gtk_label_set_text(GTK_LABEL(fileinfo_modulename_txt),
421 g_strdup_printf("%s\n(%s)", gui_modulename,
422 basename(gui_module_filename)));
423 }
424
425 gtk_widget_show(fileinfo_modulename_txt);
426
427 if (gui_formatname[0] == 0) {
428 gtk_label_set_text(GTK_LABEL(fileinfo_playername_txt),
429 g_strdup_printf("%s", gui_playername));
430 } else {
431 gtk_label_set_text(GTK_LABEL(fileinfo_playername_txt),
432 g_strdup_printf("%s\n%s", gui_playername,
433 gui_formatname));
434 }
435
436 gtk_widget_show(fileinfo_playername_txt);
437 gtk_label_set_text(GTK_LABEL(fileinfo_subsong_txt),
438 g_strdup_printf("%d", uade_get_cur_subsong(0)));
439 gtk_widget_show(fileinfo_subsong_txt);
440
441 gtk_label_set_text(GTK_LABEL(fileinfo_minsubsong_txt),
442 g_strdup_printf("%d", uade_get_min_subsong(0)));
443 gtk_widget_show(fileinfo_minsubsong_txt);
444
445 gtk_label_set_text(GTK_LABEL(fileinfo_maxsubsong_txt),
446 g_strdup_printf("%d", uade_get_max_subsong(0)));
447 gtk_widget_show(fileinfo_maxsubsong_txt);
448
449 gtk_tooltips_set_tip(fileinfo_tooltips,
450 fileinfo_hexinfo_button,
451 g_strdup_printf("%s", gui_module_filename),
452 NULL);
453
454 gtk_tooltips_set_tip(fileinfo_tooltips,
455 fileinfo_moduleinfo_button,
456 g_strdup_printf("%s", gui_module_filename),
457 NULL);
458
459 gtk_widget_show(fileinfo_moduleinfo_button);
460 }
461 }
462
uade_player_info(void)463 static void uade_player_info(void)
464 {
465 char credits[16384];
466 GtkWidget *playerinfo_button_box;
467 GtkWidget *close_button;
468 GtkWidget *playerinfo_base_vbox;
469
470 GtkWidget *uadeplay_scrolledwindow;
471 GtkWidget *uadeplay_txt;
472 GtkStyle *style;
473
474
475 if (!playerinfowin) {
476 style = gtk_style_new();
477 gdk_font_unref (style->font);
478 style->font = gdk_font_load ("fixed");
479
480
481 playerinfowin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
482 gtk_window_set_title(GTK_WINDOW(playerinfowin), "UADE Playerinfo");
483 gtk_window_set_position(GTK_WINDOW(playerinfowin),
484 GTK_WIN_POS_MOUSE);
485 gtk_container_set_border_width(GTK_CONTAINER(playerinfowin), 10);
486 gtk_window_set_policy(GTK_WINDOW(playerinfowin), FALSE, FALSE,
487 FALSE);
488 gtk_signal_connect(GTK_OBJECT(playerinfowin), "destroy",
489 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
490 &playerinfowin);
491 //Start of Contents Box
492
493 playerinfo_base_vbox = gtk_vbox_new(FALSE, 10);
494
495 gtk_container_set_border_width(GTK_CONTAINER(playerinfo_base_vbox),
496 5);
497 gtk_container_add(GTK_CONTAINER(playerinfowin),
498 playerinfo_base_vbox);
499
500
501 if ((uade_song_info(credits, sizeof credits, player_filename, UADE_HEX_DUMP_INFO))) {
502 strcpy(credits, "No info for player.\n");
503 }
504
505 uadeplay_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
506 gtk_container_add(GTK_CONTAINER(playerinfo_base_vbox),
507 uadeplay_scrolledwindow);
508 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
509 (uadeplay_scrolledwindow),
510 GTK_POLICY_NEVER,
511 GTK_POLICY_ALWAYS);
512
513 uadeplay_txt = gtk_text_new(NULL, NULL);
514 gtk_widget_set_style (uadeplay_txt, style);
515
516 gtk_container_add(GTK_CONTAINER(uadeplay_scrolledwindow),
517 uadeplay_txt);
518 gtk_text_insert(GTK_TEXT(uadeplay_txt), NULL, NULL, NULL, credits,
519 -1);
520
521 gtk_text_set_word_wrap(GTK_TEXT(uadeplay_txt), TRUE);
522 gtk_widget_set_usize(uadeplay_scrolledwindow, 600, 240);
523
524
525 // Start of Close Button Box
526
527 playerinfo_button_box = gtk_hbutton_box_new();
528
529 gtk_button_box_set_layout(GTK_BUTTON_BOX(playerinfo_button_box),
530 GTK_BUTTONBOX_END);
531 gtk_button_box_set_spacing(GTK_BUTTON_BOX(playerinfo_button_box),
532 5);
533 gtk_box_pack_start(GTK_BOX(playerinfo_base_vbox),
534 playerinfo_button_box, FALSE, FALSE, 0);
535
536 close_button = gtk_button_new_with_label("Close");
537 GTK_WIDGET_SET_FLAGS(close_button, GTK_CAN_DEFAULT);
538 gtk_signal_connect_object(GTK_OBJECT(close_button), "clicked",
539 GTK_SIGNAL_FUNC(gtk_widget_destroy),
540 GTK_OBJECT(playerinfowin));
541
542 gtk_box_pack_start_defaults(GTK_BOX(playerinfo_button_box),
543 close_button);
544 gtk_widget_show_all(playerinfowin);
545 } else {
546 gdk_window_raise(playerinfowin->window);
547 }
548 }
549
uade_mod_info_hex(void)550 static void uade_mod_info_hex(void)
551 {
552 uade_mod_info(UADE_HEX_DUMP_INFO);
553 }
554
uade_mod_info_module(void)555 static void uade_mod_info_module(void)
556 {
557 uade_mod_info(UADE_MODULE_INFO);
558 }
559
uade_mod_info(int modinfo_mode)560 static void uade_mod_info(int modinfo_mode)
561 {
562 char credits[16384];
563 GtkWidget *modinfo_button_box;
564 GtkWidget *close_button;
565 GtkWidget *modinfo_base_vbox;
566
567 GtkWidget *uadeplay_scrolledwindow;
568 GtkWidget *uadeplay_txt;
569 GtkStyle *style;
570
571
572 if (!modinfowin) {
573 style=gtk_style_new();
574 gdk_font_unref (style->font);
575 style->font = gdk_font_load ("fixed");
576
577 modinfowin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
578 gtk_window_set_title(GTK_WINDOW(modinfowin), "UADE Modinfo");
579 gtk_window_set_position(GTK_WINDOW(modinfowin), GTK_WIN_POS_MOUSE);
580 gtk_container_set_border_width(GTK_CONTAINER(modinfowin), 10);
581 gtk_window_set_policy(GTK_WINDOW(modinfowin), FALSE, FALSE, FALSE);
582 gtk_signal_connect(GTK_OBJECT(modinfowin), "destroy",
583 GTK_SIGNAL_FUNC(gtk_widget_destroyed),
584 &modinfowin);
585 //Start of Contents Box
586
587 modinfo_base_vbox = gtk_vbox_new(FALSE, 10);
588
589 gtk_container_set_border_width(GTK_CONTAINER(modinfo_base_vbox),
590 5);
591 gtk_container_add(GTK_CONTAINER(modinfowin), modinfo_base_vbox);
592
593
594 if (uade_song_info(credits, sizeof credits, module_filename, modinfo_mode))
595 snprintf(credits, sizeof credits, "Unable to process file %s\n", module_filename);
596
597 uadeplay_scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
598
599 gtk_container_add(GTK_CONTAINER(modinfo_base_vbox),
600 uadeplay_scrolledwindow);
601 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
602 (uadeplay_scrolledwindow),
603 GTK_POLICY_NEVER,
604 GTK_POLICY_ALWAYS);
605
606 uadeplay_txt = gtk_text_new(NULL, NULL);
607 gtk_widget_set_style (uadeplay_txt, style);
608 gtk_container_add(GTK_CONTAINER(uadeplay_scrolledwindow),
609 uadeplay_txt);
610 gtk_text_insert(GTK_TEXT(uadeplay_txt), NULL, NULL, NULL, credits,
611 -1);
612
613 gtk_text_set_word_wrap(GTK_TEXT(uadeplay_txt), TRUE);
614 //gtk_widget_set_usize(uadeplay_scrolledwindow, 400, 240);
615 gtk_widget_set_usize(uadeplay_scrolledwindow, 600, 240);
616
617
618 // Start of Close Button Box
619
620 modinfo_button_box = gtk_hbutton_box_new();
621
622 gtk_button_box_set_layout(GTK_BUTTON_BOX(modinfo_button_box),
623 GTK_BUTTONBOX_END);
624 gtk_button_box_set_spacing(GTK_BUTTON_BOX(modinfo_button_box), 5);
625 gtk_box_pack_start(GTK_BOX(modinfo_base_vbox), modinfo_button_box,
626 FALSE, FALSE, 0);
627
628 close_button = gtk_button_new_with_label("Close");
629 GTK_WIDGET_SET_FLAGS(close_button, GTK_CAN_DEFAULT);
630 gtk_signal_connect_object(GTK_OBJECT(close_button), "clicked",
631 GTK_SIGNAL_FUNC(gtk_widget_destroy),
632 GTK_OBJECT(modinfowin));
633
634 gtk_box_pack_start_defaults(GTK_BOX(modinfo_button_box),
635 close_button);
636 gtk_widget_show_all(modinfowin);
637 } else {
638 gdk_window_raise(modinfowin->window);
639 }
640 }
641