Mercurial > audlegacy
annotate Plugins/Input/sid/xs_fileinfo.c @ 553:82346a6312c2 trunk
[svn] make WMA plugin strings translatable
author | nenolod |
---|---|
date | Wed, 01 Feb 2006 13:09:00 -0800 |
parents | d0e9693d2115 |
children | f12d7e208b43 |
rev | line source |
---|---|
269 | 1 /* |
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) | |
3 | |
4 File information window | |
5 | |
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> | |
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP) | |
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 | |
26 #include "xs_fileinfo.h" | |
27 #include "xs_support.h" | |
28 #include "xs_stil.h" | |
29 #include "xs_config.h" | |
30 #include "xs_interface.h" | |
31 #include "xs_glade.h" | |
32 | |
33 static GtkWidget *xs_fileinfowin = NULL; | |
34 static t_xs_stil_node *xs_fileinfostil = NULL; | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
35 GStaticMutex xs_fileinfowin_mutex = G_STATIC_MUTEX_INIT; |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
36 GStaticMutex xs_status_mutex = G_STATIC_MUTEX_INIT; |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
37 extern t_xs_status xs_status; |
269 | 38 |
39 #define LUW(x) lookup_widget(xs_fileinfowin, x) | |
40 | |
41 | |
42 void xs_fileinfo_update(void) | |
43 { | |
44 gboolean isEnabled; | |
45 GtkAdjustment *tmpAdj; | |
46 | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
47 g_static_mutex_lock(&xs_status_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
48 g_static_mutex_lock(&xs_fileinfowin_mutex); |
269 | 49 |
50 /* Check if control window exists, we are currently playing and have a tune */ | |
51 if (xs_fileinfowin) { | |
52 if (xs_status.tuneInfo && xs_status.isPlaying && (xs_status.tuneInfo->nsubTunes > 1)) { | |
53 tmpAdj = gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj"))); | |
54 | |
55 tmpAdj->value = xs_status.currSong; | |
56 tmpAdj->lower = 1; | |
57 tmpAdj->upper = xs_status.tuneInfo->nsubTunes; | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
58 g_static_mutex_unlock(&xs_status_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
59 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
269 | 60 gtk_adjustment_value_changed(tmpAdj); |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
61 g_static_mutex_lock(&xs_status_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
62 g_static_mutex_lock(&xs_fileinfowin_mutex); |
269 | 63 isEnabled = TRUE; |
64 } else | |
65 isEnabled = FALSE; | |
66 | |
67 /* Enable or disable subtune-control in fileinfo window */ | |
68 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_prev"), isEnabled); | |
69 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_adj"), isEnabled); | |
70 gtk_widget_set_sensitive(LUW("fileinfo_subctrl_next"), isEnabled); | |
71 } | |
72 | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
73 g_static_mutex_unlock(&xs_status_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
74 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
269 | 75 } |
76 | |
77 | |
78 void xs_fileinfo_setsong(void) | |
79 { | |
80 gint n; | |
81 | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
82 g_static_mutex_lock(&xs_status_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
83 g_static_mutex_lock(&xs_fileinfowin_mutex); |
269 | 84 |
85 if (xs_status.tuneInfo && xs_status.isPlaying) { | |
86 n = (gint) gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))->value; | |
87 if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes)) | |
88 xs_status.currSong = n; | |
89 } | |
90 | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
91 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
92 g_static_mutex_unlock(&xs_status_mutex); |
269 | 93 } |
94 | |
95 | |
96 void xs_fileinfo_ok(void) | |
97 { | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
98 g_static_mutex_lock(&xs_fileinfowin_mutex); |
269 | 99 if (xs_fileinfowin) { |
100 gtk_widget_destroy(xs_fileinfowin); | |
101 xs_fileinfowin = NULL; | |
102 } | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
103 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
269 | 104 } |
105 | |
106 | |
107 gboolean xs_fileinfo_delete(GtkWidget * widget, GdkEvent * event, gpointer user_data) | |
108 { | |
109 (void) widget; | |
110 (void) event; | |
111 (void) user_data; | |
112 | |
113 XSDEBUG("delete_event\n"); | |
114 xs_fileinfo_ok(); | |
115 return FALSE; | |
116 } | |
117 | |
118 | |
119 | |
120 void xs_fileinfo_subtune(GtkWidget * widget, void *data) | |
121 { | |
122 t_xs_stil_subnode *tmpNode; | |
123 GtkWidget *tmpItem, *tmpText; | |
124 gint tmpIndex; | |
125 gchar *subName, *subAuthor; | |
126 | |
127 (void) widget; | |
128 (void) data; | |
129 | |
130 /* Freeze text-widget and delete the old text */ | |
131 tmpText = LUW("fileinfo_sub_info"); | |
132 | |
133 if (xs_fileinfostil) { | |
134 /* Get subtune number */ | |
135 tmpItem = gtk_menu_get_active(GTK_MENU(data)); | |
136 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem); | |
137 | |
138 /* Get subtune information */ | |
139 tmpNode = &xs_fileinfostil->subTunes[tmpIndex]; | |
140 subName = tmpNode->pName; | |
141 subAuthor = tmpNode->pAuthor; | |
142 | |
143 /* Put in the new text, if available */ | |
144 if (tmpNode->pInfo) { | |
145 gsize pInfo_utf8_size; | |
146 gchar *pInfo_utf8 = g_locale_to_utf8( tmpNode->pInfo , strlen(tmpNode->pInfo) , NULL , &pInfo_utf8_size , NULL ); | |
147 gtk_text_buffer_set_text( GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmpText))), | |
148 pInfo_utf8, pInfo_utf8_size); | |
149 } | |
150 } else { | |
151 /* We don't have any information */ | |
152 subName = NULL; | |
153 subAuthor = NULL; | |
154 } | |
155 | |
156 /* Get and set subtune information */ | |
157 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? g_locale_to_utf8(subName,strlen(subName),NULL,NULL,NULL) : ""); | |
158 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? g_locale_to_utf8(subAuthor,strlen(subAuthor),NULL,NULL,NULL) : ""); | |
159 } | |
160 | |
161 | |
162 void xs_fileinfo(gchar * pcFilename) | |
163 { | |
164 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; | |
165 t_xs_tuneinfo *tmpInfo; | |
166 t_xs_stil_subnode *tmpNode; | |
167 gchar tmpStr[64]; | |
168 gint n; | |
169 | |
170 /* Current implementation leaves old fileinfo window untouched if | |
171 * no information can be found for the new file. Hmm... | |
172 */ | |
173 | |
174 /* Get new tune information */ | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
175 g_static_mutex_lock(&xs_fileinfowin_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
176 g_static_mutex_lock(&xs_status_mutex); |
269 | 177 if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) { |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
178 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
179 g_static_mutex_unlock(&xs_status_mutex); |
269 | 180 return; |
181 } | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
182 g_static_mutex_unlock(&xs_status_mutex); |
269 | 183 |
184 xs_fileinfostil = xs_stil_get(pcFilename); | |
185 | |
186 /* Check if there already is an open fileinfo window */ | |
187 if (xs_fileinfowin) { | |
188 /* Raise old window */ | |
189 gdk_window_raise(xs_fileinfowin->window); | |
190 | |
191 /* Delete items */ | |
192 tmpOptionMenu = LUW("fileinfo_sub_tune"); | |
193 gtk_widget_destroy(GTK_OPTION_MENU(tmpOptionMenu)->menu); | |
194 GTK_OPTION_MENU(tmpOptionMenu)->menu = gtk_menu_new(); | |
195 } else { | |
196 /* If not, create a new one */ | |
197 xs_fileinfowin = create_xs_fileinfowin(); | |
198 | |
199 /* Connect additional signals */ | |
200 gtk_signal_connect(GTK_OBJECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), | |
201 "value_changed", GTK_SIGNAL_FUNC(xs_fileinfo_setsong), NULL); | |
202 } | |
203 | |
204 | |
205 /* Set the generic song information */ | |
206 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_filename")), g_locale_to_utf8(pcFilename,strlen(pcFilename),NULL,NULL,NULL) ); | |
207 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_songname")), g_locale_to_utf8(tmpInfo->sidName,strlen(tmpInfo->sidName),NULL,NULL,NULL) ); | |
208 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_composer")), g_locale_to_utf8(tmpInfo->sidComposer,strlen(tmpInfo->sidComposer),NULL,NULL,NULL) ); | |
209 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_copyright")), g_locale_to_utf8(tmpInfo->sidCopyright,strlen(tmpInfo->sidCopyright),NULL,NULL,NULL) ); | |
210 | |
211 /* Main tune - the pseudo tune */ | |
212 tmpOptionMenu = LUW("fileinfo_sub_tune"); | |
213 tmpMenu = GTK_OPTION_MENU(tmpOptionMenu)->menu; | |
214 | |
215 tmpMenuItem = gtk_menu_item_new_with_label("General info"); | |
216 gtk_widget_show(tmpMenuItem); | |
217 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); | |
218 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); | |
219 | |
220 /* Other menu items */ | |
221 for (n = 1; n <= tmpInfo->nsubTunes; n++) { | |
222 if (xs_fileinfostil) { | |
223 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i: ", n); | |
224 tmpNode = &xs_fileinfostil->subTunes[n]; | |
225 if (tmpNode->pName) | |
226 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); | |
227 else if (tmpNode->pInfo) | |
228 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo); | |
229 else | |
230 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); | |
231 } else { | |
232 snprintf(tmpStr, sizeof(tmpStr), "Tune #%i", n); | |
233 } | |
234 | |
235 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); | |
236 gtk_widget_show(tmpMenuItem); | |
237 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); | |
238 | |
239 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); | |
240 } | |
241 | |
242 /* Set the subtune information */ | |
243 xs_fileinfo_subtune(NULL, tmpMenu); | |
244 | |
245 /* Free temporary tuneinfo */ | |
246 xs_tuneinfo_free(tmpInfo); | |
247 | |
248 /* Show the window */ | |
249 gtk_widget_show(xs_fileinfowin); | |
250 | |
304
d0e9693d2115
[svn] Convert to configdb. GThreadify and peel off layer of threading macro madness.
chainsaw
parents:
269
diff
changeset
|
251 g_static_mutex_unlock(&xs_fileinfowin_mutex); |
269 | 252 |
253 xs_fileinfo_update(); | |
254 } |