Mercurial > hg > xmms-sid
annotate src/xs_fileinfo.c @ 399:e25d23b07cd2
Use g_snprintf() instead of system snprintf(), because libc snprintf() is
broken in several systems.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 31 May 2006 13:34:04 +0000 |
parents | b09d74eb71e6 |
children | 7f694e5a1493 |
rev | line source |
---|---|
222 | 1 /* |
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) | |
3 | |
4 File information window | |
5 | |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP) | |
222 | 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 #include <gdk/gdkkeysyms.h> | |
24 #include <gtk/gtk.h> | |
25 | |
290
b6bcd62394f3
Include correct headers, typecast returnvalue to gint
Matti Hamalainen <ccr@tnsp.org>
parents:
282
diff
changeset
|
26 #include "xs_fileinfo.h" |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
27 #include "xs_support.h" |
222 | 28 #include "xs_stil.h" |
29 #include "xs_config.h" | |
30 #include "xs_interface.h" | |
31 #include "xs_glade.h" | |
32 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
33 static GtkWidget *xs_fileinfowin = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
34 static t_xs_stil_node *xs_fileinfostil = NULL; |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
35 XS_MUTEX(xs_fileinfowin); |
222 | 36 |
296
4279cc6a3412
No need for variadic macros here.
Matti Hamalainen <ccr@tnsp.org>
parents:
290
diff
changeset
|
37 #define LUW(x) lookup_widget(xs_fileinfowin, x) |
222 | 38 |
39 | |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
40 void xs_fileinfo_update(void) |
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
41 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
42 gboolean isEnabled; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
43 GtkAdjustment *tmpAdj; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
44 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
45 XS_MUTEX_LOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
46 XS_MUTEX_LOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
47 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
48 /* Check if control window exists, we are currently playing and have a tune */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
49 if (xs_fileinfowin) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
50 if (xs_status.tuneInfo && xs_status.isPlaying && (xs_status.tuneInfo->nsubTunes > 1)) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
51 tmpAdj = gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
52 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
53 tmpAdj->value = xs_status.currSong; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
54 tmpAdj->lower = 1; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
55 tmpAdj->upper = xs_status.tuneInfo->nsubTunes; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
56 XS_MUTEX_UNLOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
57 XS_MUTEX_UNLOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
58 gtk_adjustment_value_changed(tmpAdj); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
59 XS_MUTEX_LOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
60 XS_MUTEX_LOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
61 isEnabled = TRUE; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
62 } else |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
63 isEnabled = FALSE; |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
64 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
65 /* Enable or disable subtune-control in fileinfo window */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
66 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_prev"), isEnabled); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
67 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_adj"), isEnabled); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
68 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_next"), isEnabled); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
69 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
70 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
71 XS_MUTEX_UNLOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
72 XS_MUTEX_UNLOCK(xs_fileinfowin); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
73 } |
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
74 |
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
75 |
230 | 76 void xs_fileinfo_setsong(void) |
77 { | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
78 gint n; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
79 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
80 XS_MUTEX_LOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
81 XS_MUTEX_LOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
82 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
83 if (xs_status.tuneInfo && xs_status.isPlaying) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
84 n = (gint) gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))->value; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
85 if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
86 xs_status.currSong = n; |
234
6f9764fbd693
Make the slider in fileinfo window's subtune selector work as expected.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
87 } |
6f9764fbd693
Make the slider in fileinfo window's subtune selector work as expected.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
88 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
89 XS_MUTEX_UNLOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
90 XS_MUTEX_UNLOCK(xs_status); |
230 | 91 } |
92 | |
93 | |
222 | 94 void xs_fileinfo_ok(void) |
95 { | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
96 XS_MUTEX_LOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
97 if (xs_fileinfowin) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
98 gtk_widget_destroy(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
99 xs_fileinfowin = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
100 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
101 XS_MUTEX_UNLOCK(xs_fileinfowin); |
222 | 102 } |
103 | |
104 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
105 gboolean xs_fileinfo_delete(GtkWidget * widget, GdkEvent * event, gpointer user_data) |
282
0d2d379a83c0
Fixed nasty crash when closing fileinfo-window from window's closebutton -
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
106 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
107 (void) widget; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
108 (void) event; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
109 (void) user_data; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
110 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
111 XSDEBUG("delete_event\n"); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
112 xs_fileinfo_ok(); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
113 return FALSE; |
282
0d2d379a83c0
Fixed nasty crash when closing fileinfo-window from window's closebutton -
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
114 } |
0d2d379a83c0
Fixed nasty crash when closing fileinfo-window from window's closebutton -
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
115 |
0d2d379a83c0
Fixed nasty crash when closing fileinfo-window from window's closebutton -
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
116 |
0d2d379a83c0
Fixed nasty crash when closing fileinfo-window from window's closebutton -
Matti Hamalainen <ccr@tnsp.org>
parents:
239
diff
changeset
|
117 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
118 void xs_fileinfo_subtune(GtkWidget * widget, void *data) |
222 | 119 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
120 t_xs_stil_subnode *tmpNode; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
121 GtkWidget *tmpItem, *tmpText; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
122 gint tmpIndex; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
123 gchar *subName, *subAuthor; |
222 | 124 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
125 (void) widget; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
126 (void) data; |
222 | 127 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
128 /* Freeze text-widget and delete the old text */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
129 tmpText = LUW("fileinfo_sub_info"); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
130 gtk_text_freeze(GTK_TEXT(tmpText)); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
131 gtk_text_set_point(GTK_TEXT(tmpText), 0); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
132 gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText))); |
222 | 133 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
134 /* Get subtune information */ |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
135 tmpItem = gtk_menu_get_active(GTK_MENU(data)); |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
136 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem); |
222 | 137 |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
138 if (xs_fileinfostil) |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
139 tmpNode = xs_fileinfostil->subTunes[tmpIndex]; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
140 else |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
141 tmpNode = NULL; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
142 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
143 if (tmpNode) { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
144 subName = tmpNode->pName; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
145 subAuthor = tmpNode->pAuthor; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
146 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
147 if (tmpNode->pInfo) { |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
148 gtk_text_insert(GTK_TEXT(tmpText), NULL, NULL, NULL, |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
149 tmpNode->pInfo, strlen(tmpNode->pInfo)); |
222 | 150 } |
151 } else { | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
152 subName = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
153 subAuthor = NULL; |
222 | 154 } |
155 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
156 /* Get and set subtune information */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
157 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : ""); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
158 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : ""); |
222 | 159 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
160 /* Un-freeze the widget */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
161 gtk_text_thaw(GTK_TEXT(tmpText)); |
222 | 162 } |
163 | |
164 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
165 void xs_fileinfo(gchar * pcFilename) |
222 | 166 { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
167 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
168 t_xs_tuneinfo *tmpInfo; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
169 t_xs_stil_subnode *tmpNode; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
170 gchar tmpStr[64]; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
171 gint n; |
222 | 172 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
173 /* Current implementation leaves old fileinfo window untouched if |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
174 * no information can be found for the new file. Hmm... |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
175 */ |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
176 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
177 /* Get new tune information */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
178 XS_MUTEX_LOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
179 XS_MUTEX_LOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
180 if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
181 XS_MUTEX_UNLOCK(xs_fileinfowin); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
182 XS_MUTEX_UNLOCK(xs_status); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
183 return; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
184 } |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
185 XS_MUTEX_UNLOCK(xs_status); |
222 | 186 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
187 xs_fileinfostil = xs_stil_get(pcFilename); |
222 | 188 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
189 /* Check if there already is an open fileinfo window */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
190 if (xs_fileinfowin) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
191 /* Raise old window */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
192 gdk_window_raise(xs_fileinfowin->window); |
222 | 193 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
194 /* Delete items */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
195 tmpOptionMenu = LUW("fileinfo_sub_tune"); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
196 gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
197 GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new(); |
222 | 198 } else { |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
199 /* If not, create a new one */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
200 xs_fileinfowin = create_xs_fileinfowin(); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
201 |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
202 /* Connect additional signals */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
203 gtk_signal_connect(GTK_OBJECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
204 "value_changed", GTK_SIGNAL_FUNC(xs_fileinfo_setsong), NULL); |
222 | 205 } |
206 | |
207 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
208 /* Set the generic song information */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
209 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), pcFilename); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
210 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), tmpInfo->sidName); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
211 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), tmpInfo->sidComposer); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
212 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), tmpInfo->sidCopyright); |
222 | 213 |
214 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
215 /* Main tune - the pseudo tune */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
216 tmpOptionMenu = LUW("fileinfo_sub_tune"); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
217 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu; |
222 | 218 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
219 tmpMenuItem = gtk_menu_item_new_with_label("General info"); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
220 gtk_widget_show(tmpMenuItem); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
221 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
222 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); |
222 | 223 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
224 /* Other menu items */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
225 for (n = 1; n <= tmpInfo->nsubTunes; n++) { |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
226 if (xs_fileinfostil) { |
399
e25d23b07cd2
Use g_snprintf() instead of system snprintf(), because libc snprintf() is
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
227 g_snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: ", n); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
228 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
229 tmpNode = xs_fileinfostil->subTunes[n]; |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
230 |
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
231 if (tmpNode && tmpNode->pName) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
232 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
359
diff
changeset
|
233 else if (tmpNode && tmpNode->pInfo) |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
234 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo); |
222 | 235 else |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
236 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
237 } else { |
399
e25d23b07cd2
Use g_snprintf() instead of system snprintf(), because libc snprintf() is
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
238 g_snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n); |
239
7833df935239
Added xs_pnstrcat() to ease forming of limited size strings.
Matti Hamalainen <ccr@tnsp.org>
parents:
234
diff
changeset
|
239 } |
222 | 240 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
241 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
242 gtk_widget_show(tmpMenuItem); |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
243 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); |
222 | 244 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
245 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); |
222 | 246 } |
247 | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
248 /* Set the subtune information */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
249 xs_fileinfo_subtune(NULL, tmpMenu); |
222 | 250 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
251 /* Free temporary tuneinfo */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
252 xs_tuneinfo_free(tmpInfo); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
253 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
254 /* Show the window */ |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
255 gtk_widget_show(xs_fileinfowin); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
256 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
257 XS_MUTEX_UNLOCK(xs_fileinfowin); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
258 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
341
diff
changeset
|
259 xs_fileinfo_update(); |
222 | 260 } |