Mercurial > audlegacy-plugins
annotate src/wavpack/ui.cxx @ 1744:46cda76dcd2a
Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Wed, 19 Sep 2007 09:06:52 -0500 |
parents | f6f5603a0954 |
children | b8da6a0b0da2 |
rev | line source |
---|---|
109 | 1 #include <assert.h> |
2 #include <string.h> | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <pthread.h> | |
6 #include <unistd.h> | |
294 | 7 extern "C" { |
284
72f0de06bb56
[svn] - wavpack/wputils.h is deprecated, wavpack/wavpack.h should be used instead.
nenolod
parents:
246
diff
changeset
|
8 #include <wavpack/wavpack.h> |
109 | 9 #include <audacious/plugin.h> |
10 #include <audacious/configdb.h> | |
11 #include <audacious/util.h> | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
12 #include <audacious/i18n.h> |
109 | 13 } |
14 #include <glib.h> | |
15 #include <gtk/gtk.h> | |
16 #include <iconv.h> | |
17 #include <math.h> | |
18 #include "tags.h" | |
434
7385182ae4b8
[svn] - add missing config.h inclusion for wavpack, null and metronom plugin
giacomo
parents:
294
diff
changeset
|
19 #include "../../config.h" |
109 | 20 #ifndef M_LN10 |
21 #define M_LN10 2.3025850929940456840179914546843642 | |
22 #endif | |
23 | |
24 #define DBG(format, args...) fprintf(stderr, format, ## args) | |
25 | |
26 void load_tag(ape_tag *tag, WavpackContext *ctx); | |
27 gboolean clipPreventionEnabled; | |
28 gboolean dynBitrateEnabled; | |
29 gboolean replaygainEnabled; | |
30 gboolean albumReplaygainEnabled; | |
31 gboolean openedAudio; | |
32 static GtkWidget *window = NULL; | |
33 static GtkWidget *title_entry; | |
34 static GtkWidget *album_entry; | |
35 static GtkWidget *performer_entry; | |
36 static GtkWidget *tracknumber_entry; | |
37 static GtkWidget *date_entry; | |
38 static GtkWidget *genre_entry; | |
39 static GtkWidget *user_comment_entry; | |
40 static char *filename; | |
41 | |
42 void | |
43 wv_about_box() | |
44 { | |
45 static GtkWidget *about_window; | |
46 | |
47 if (about_window) | |
48 gdk_window_raise(about_window->window); | |
49 | |
50 about_window = | |
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1436
diff
changeset
|
51 audacious_info_dialog(g_strdup_printf |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
52 (_("Wavpack Decoder Plugin %s"), VERSION), |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
53 (_("Copyright (c) 2006 William Pitcock <nenolod -at- nenolod.net>\n\n" |
246 | 54 "Some of the plugin code was by Miles Egan\n" |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
55 "Visit the Wavpack site at http://www.wavpack.com/\n")), |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
56 (_("Ok")), FALSE, NULL, NULL); |
109 | 57 gtk_signal_connect(GTK_OBJECT(about_window), "destroy", |
58 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &about_window); | |
59 } | |
60 | |
61 static void | |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
458
diff
changeset
|
62 label_set_text(GtkWidget * label, const char *str, ...) |
109 | 63 { |
64 va_list args; | |
65 gchar *tempstr; | |
66 | |
67 va_start(args, str); | |
68 tempstr = g_strdup_vprintf(str, args); | |
69 va_end(args); | |
70 | |
71 gtk_label_set_text(GTK_LABEL(label), tempstr); | |
72 g_free(tempstr); | |
73 } | |
74 | |
75 static void | |
76 remove_cb(GtkWidget * w, gpointer data) | |
77 { | |
78 DeleteTag(filename); | |
79 g_free(filename); | |
80 gtk_widget_destroy(window); | |
81 } | |
82 | |
83 static void | |
84 save_cb(GtkWidget * w, gpointer data) | |
85 { | |
86 ape_tag Tag; | |
87 | |
458 | 88 strncpy(Tag.title, gtk_entry_get_text(GTK_ENTRY(title_entry)), MAX_LEN); |
89 strncpy(Tag.artist, gtk_entry_get_text(GTK_ENTRY(performer_entry)), MAX_LEN); | |
90 strncpy(Tag.album, gtk_entry_get_text(GTK_ENTRY(album_entry)), MAX_LEN); | |
91 strncpy(Tag.comment, gtk_entry_get_text(GTK_ENTRY(user_comment_entry)), MAX_LEN); | |
92 strncpy(Tag.track, gtk_entry_get_text(GTK_ENTRY(tracknumber_entry)), MAX_LEN2); | |
93 strncpy(Tag.year, gtk_entry_get_text(GTK_ENTRY(date_entry)), MAX_LEN2); | |
94 strncpy(Tag.genre, gtk_entry_get_text(GTK_ENTRY(genre_entry)), MAX_LEN); | |
109 | 95 WriteAPE2Tag(filename, &Tag); |
96 g_free(filename); | |
97 gtk_widget_destroy(window); | |
98 } | |
99 | |
100 static void | |
101 close_window(GtkWidget * w, gpointer data) | |
102 { | |
103 g_free(filename); | |
104 gtk_widget_destroy(window); | |
105 } | |
106 | |
107 void | |
108 wv_file_info_box(char *fn) | |
109 { | |
110 gchar *tmp; | |
111 gint time, minutes, seconds; | |
112 ape_tag tag; | |
113 | |
114 assert(fn != NULL); | |
115 char error_buff[4096]; // TODO: fixme! | |
116 WavpackContext *ctx = WavpackOpenFileInput(fn, error_buff, OPEN_TAGS | OPEN_WVC, 0); | |
117 if (ctx == NULL) { | |
118 printf("wavpack: Error opening file: \"%s: %s\"\n", fn, error_buff); | |
119 return; | |
120 } | |
121 int sample_rate = WavpackGetSampleRate(ctx); | |
122 int num_channels = WavpackGetNumChannels(ctx); | |
123 load_tag(&tag, ctx); | |
124 DBG("opened %s at %d rate with %d channels\n", fn, sample_rate, num_channels); | |
125 | |
126 filename = g_strdup(fn); | |
127 static GtkWidget *info_frame, *info_box, *bitrate_label, *rate_label; | |
128 static GtkWidget *version_label, *bits_per_sample_label; | |
129 static GtkWidget *channel_label, *length_label, *filesize_label; | |
130 static GtkWidget *peakTitle_label, *peakAlbum_label, *gainTitle_label; | |
131 static GtkWidget *gainAlbum_label, *filename_entry, *tag_frame; | |
132 | |
133 if (!window) { | |
134 GtkWidget *hbox, *label, *filename_hbox, *vbox, *left_vbox; | |
135 GtkWidget *table, *bbox, *cancel_button; | |
136 GtkWidget *save_button, *remove_button; | |
137 | |
111 | 138 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
109 | 139 gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); |
140 gtk_signal_connect(GTK_OBJECT(window), "destroy", | |
141 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window); | |
142 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
143 | |
144 vbox = gtk_vbox_new(FALSE, 10); | |
145 gtk_container_add(GTK_CONTAINER(window), vbox); | |
146 | |
147 filename_hbox = gtk_hbox_new(FALSE, 5); | |
148 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
149 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
150 label = gtk_label_new(_("Filename:")); |
109 | 151 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); |
152 filename_entry = gtk_entry_new(); | |
153 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
154 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, | |
155 TRUE, TRUE, 0); | |
156 | |
157 hbox = gtk_hbox_new(FALSE, 10); | |
158 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); | |
159 | |
160 left_vbox = gtk_vbox_new(FALSE, 10); | |
161 gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0); | |
162 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
163 tag_frame = gtk_frame_new(_("Ape2 Tag")); |
109 | 164 gtk_box_pack_start(GTK_BOX(left_vbox), tag_frame, FALSE, FALSE, 0); |
165 | |
166 table = gtk_table_new(5, 5, FALSE); | |
167 gtk_container_set_border_width(GTK_CONTAINER(table), 5); | |
168 gtk_container_add(GTK_CONTAINER(tag_frame), table); | |
169 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
170 label = gtk_label_new(_("Title:")); |
109 | 171 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
172 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, | |
173 GTK_FILL, GTK_FILL, 5, 5); | |
174 | |
175 title_entry = gtk_entry_new(); | |
176 gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1, | |
177 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
178 GTK_SHRINK), | |
179 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
180 GTK_SHRINK), 0, 5); | |
181 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
182 label = gtk_label_new(_("Artist:")); |
109 | 183 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
184 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, | |
185 GTK_FILL, GTK_FILL, 5, 5); | |
186 | |
187 performer_entry = gtk_entry_new(); | |
188 gtk_table_attach(GTK_TABLE(table), performer_entry, 1, 4, 1, 2, | |
189 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
190 GTK_SHRINK), | |
191 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
192 GTK_SHRINK), 0, 5); | |
193 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
194 label = gtk_label_new(_("Album:")); |
109 | 195 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
196 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, | |
197 GTK_FILL, GTK_FILL, 5, 5); | |
198 | |
199 album_entry = gtk_entry_new(); | |
200 gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3, | |
201 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
202 GTK_SHRINK), | |
203 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
204 GTK_SHRINK), 0, 5); | |
205 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
206 label = gtk_label_new(_("Comment:")); |
109 | 207 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
208 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, | |
209 GTK_FILL, GTK_FILL, 5, 5); | |
210 | |
211 user_comment_entry = gtk_entry_new(); | |
212 gtk_table_attach(GTK_TABLE(table), user_comment_entry, 1, 4, 3, | |
213 4, | |
214 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
215 GTK_SHRINK), | |
216 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
217 GTK_SHRINK), 0, 5); | |
218 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
219 label = gtk_label_new(_("Year:")); |
109 | 220 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
221 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, | |
222 GTK_FILL, GTK_FILL, 5, 5); | |
223 | |
224 date_entry = gtk_entry_new(); | |
225 gtk_widget_set_usize(date_entry, 60, -1); | |
226 gtk_table_attach(GTK_TABLE(table), date_entry, 1, 2, 4, 5, | |
227 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
228 GTK_SHRINK), | |
229 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
230 GTK_SHRINK), 0, 5); | |
231 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
232 label = gtk_label_new(_("Track number:")); |
109 | 233 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
234 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, | |
235 GTK_FILL, GTK_FILL, 5, 5); | |
236 | |
237 tracknumber_entry = gtk_entry_new_with_max_length(4); | |
238 gtk_widget_set_usize(tracknumber_entry, 20, -1); | |
239 gtk_table_attach(GTK_TABLE(table), tracknumber_entry, 3, 4, 4, | |
240 5, | |
241 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
242 GTK_SHRINK), | |
243 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
244 GTK_SHRINK), 0, 5); | |
245 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
246 label = gtk_label_new(_("Genre:")); |
109 | 247 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
248 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, | |
249 GTK_FILL, GTK_FILL, 5, 5); | |
250 | |
251 genre_entry = gtk_entry_new(); | |
252 gtk_widget_set_usize(genre_entry, 20, -1); | |
253 gtk_table_attach(GTK_TABLE(table), genre_entry, 1, 4, 5, | |
254 6, | |
255 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
256 GTK_SHRINK), | |
257 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | | |
258 GTK_SHRINK), 0, 5); | |
259 | |
260 bbox = gtk_hbutton_box_new(); | |
261 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
262 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
263 gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0); | |
264 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
265 save_button = gtk_button_new_with_label(_("Save")); |
109 | 266 gtk_signal_connect(GTK_OBJECT(save_button), "clicked", |
267 GTK_SIGNAL_FUNC(save_cb), NULL); | |
268 GTK_WIDGET_SET_FLAGS(save_button, GTK_CAN_DEFAULT); | |
269 gtk_box_pack_start(GTK_BOX(bbox), save_button, TRUE, TRUE, 0); | |
270 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
271 remove_button = gtk_button_new_with_label(_("Remove Tag")); |
109 | 272 gtk_signal_connect_object(GTK_OBJECT(remove_button), |
273 "clicked", | |
274 GTK_SIGNAL_FUNC(remove_cb), NULL); | |
275 GTK_WIDGET_SET_FLAGS(remove_button, GTK_CAN_DEFAULT); | |
276 gtk_box_pack_start(GTK_BOX(bbox), remove_button, TRUE, TRUE, 0); | |
277 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
278 cancel_button = gtk_button_new_with_label(_("Cancel")); |
109 | 279 gtk_signal_connect_object(GTK_OBJECT(cancel_button), |
280 "clicked", | |
281 GTK_SIGNAL_FUNC(close_window), NULL); | |
282 GTK_WIDGET_SET_FLAGS(cancel_button, GTK_CAN_DEFAULT); | |
283 gtk_box_pack_start(GTK_BOX(bbox), cancel_button, TRUE, TRUE, 0); | |
284 gtk_widget_grab_default(cancel_button); | |
285 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
286 info_frame = gtk_frame_new(_("Wavpack Info:")); |
109 | 287 gtk_box_pack_start(GTK_BOX(hbox), info_frame, FALSE, FALSE, 0); |
288 | |
289 info_box = gtk_vbox_new(FALSE, 5); | |
290 gtk_container_add(GTK_CONTAINER(info_frame), info_box); | |
291 gtk_container_set_border_width(GTK_CONTAINER(info_box), 10); | |
292 gtk_box_set_spacing(GTK_BOX(info_box), 0); | |
293 | |
294 version_label = gtk_label_new(""); | |
295 gtk_misc_set_alignment(GTK_MISC(version_label), 0, 0); | |
296 gtk_label_set_justify(GTK_LABEL(version_label), | |
297 GTK_JUSTIFY_LEFT); | |
298 gtk_box_pack_start(GTK_BOX(info_box), version_label, FALSE, | |
299 FALSE, 0); | |
300 | |
301 bits_per_sample_label = gtk_label_new(""); | |
302 gtk_misc_set_alignment(GTK_MISC(bits_per_sample_label), 0, 0); | |
303 gtk_label_set_justify(GTK_LABEL(bits_per_sample_label), GTK_JUSTIFY_LEFT); | |
304 gtk_box_pack_start(GTK_BOX(info_box), bits_per_sample_label, FALSE, FALSE, 0); | |
305 | |
306 bitrate_label = gtk_label_new(""); | |
307 gtk_misc_set_alignment(GTK_MISC(bitrate_label), 0, 0); | |
308 gtk_label_set_justify(GTK_LABEL(bitrate_label), GTK_JUSTIFY_LEFT); | |
309 gtk_box_pack_start(GTK_BOX(info_box), bitrate_label, FALSE, FALSE, 0); | |
310 | |
311 rate_label = gtk_label_new(""); | |
312 gtk_misc_set_alignment(GTK_MISC(rate_label), 0, 0); | |
313 gtk_label_set_justify(GTK_LABEL(rate_label), GTK_JUSTIFY_LEFT); | |
314 gtk_box_pack_start(GTK_BOX(info_box), rate_label, FALSE, FALSE, 0); | |
315 | |
316 channel_label = gtk_label_new(""); | |
317 gtk_misc_set_alignment(GTK_MISC(channel_label), 0, 0); | |
318 gtk_label_set_justify(GTK_LABEL(channel_label), GTK_JUSTIFY_LEFT); | |
319 gtk_box_pack_start(GTK_BOX(info_box), channel_label, FALSE, FALSE, 0); | |
320 | |
321 length_label = gtk_label_new(""); | |
322 gtk_misc_set_alignment(GTK_MISC(length_label), 0, 0); | |
323 gtk_label_set_justify(GTK_LABEL(length_label), GTK_JUSTIFY_LEFT); | |
324 gtk_box_pack_start(GTK_BOX(info_box), length_label, FALSE, FALSE, 0); | |
325 | |
326 filesize_label = gtk_label_new(""); | |
327 gtk_misc_set_alignment(GTK_MISC(filesize_label), 0, 0); | |
328 gtk_label_set_justify(GTK_LABEL(filesize_label), GTK_JUSTIFY_LEFT); | |
329 gtk_box_pack_start(GTK_BOX(info_box), filesize_label, FALSE, | |
330 FALSE, 0); | |
331 | |
332 peakTitle_label = gtk_label_new(""); | |
333 gtk_misc_set_alignment(GTK_MISC(peakTitle_label), 0, 0); | |
334 gtk_label_set_justify(GTK_LABEL(peakTitle_label), GTK_JUSTIFY_LEFT); | |
335 gtk_box_pack_start(GTK_BOX(info_box), peakTitle_label, FALSE, | |
336 FALSE, 0); | |
337 | |
338 peakAlbum_label = gtk_label_new(""); | |
339 gtk_misc_set_alignment(GTK_MISC(peakAlbum_label), 0, 0); | |
340 gtk_label_set_justify(GTK_LABEL(peakAlbum_label), GTK_JUSTIFY_LEFT); | |
341 gtk_box_pack_start(GTK_BOX(info_box), peakAlbum_label, FALSE, | |
342 FALSE, 0); | |
343 | |
344 gainTitle_label = gtk_label_new(""); | |
345 gtk_misc_set_alignment(GTK_MISC(gainTitle_label), 0, 0); | |
346 gtk_label_set_justify(GTK_LABEL(gainTitle_label), GTK_JUSTIFY_LEFT); | |
347 gtk_box_pack_start(GTK_BOX(info_box), gainTitle_label, FALSE, | |
348 FALSE, 0); | |
349 | |
350 gainAlbum_label = gtk_label_new(""); | |
351 gtk_misc_set_alignment(GTK_MISC(gainAlbum_label), 0, 0); | |
352 gtk_label_set_justify(GTK_LABEL(gainAlbum_label), GTK_JUSTIFY_LEFT); | |
353 gtk_box_pack_start(GTK_BOX(info_box), gainAlbum_label, FALSE, | |
354 FALSE, 0); | |
355 | |
356 gtk_widget_show_all(window); | |
357 } | |
358 else | |
359 gdk_window_raise(window->window); | |
360 | |
361 gtk_widget_set_sensitive(tag_frame, TRUE); | |
362 | |
363 gtk_label_set_text(GTK_LABEL(version_label), ""); | |
364 gtk_label_set_text(GTK_LABEL(bits_per_sample_label), ""); | |
365 gtk_label_set_text(GTK_LABEL(bitrate_label), ""); | |
366 gtk_label_set_text(GTK_LABEL(rate_label), ""); | |
367 gtk_label_set_text(GTK_LABEL(channel_label), ""); | |
368 gtk_label_set_text(GTK_LABEL(length_label), ""); | |
369 gtk_label_set_text(GTK_LABEL(filesize_label), ""); | |
370 gtk_label_set_text(GTK_LABEL(peakTitle_label), ""); | |
371 gtk_label_set_text(GTK_LABEL(peakAlbum_label), ""); | |
372 gtk_label_set_text(GTK_LABEL(gainTitle_label), ""); | |
373 gtk_label_set_text(GTK_LABEL(gainAlbum_label), ""); | |
374 | |
375 time = WavpackGetNumSamples(ctx) / WavpackGetSampleRate(ctx); | |
376 minutes = time / 60; | |
377 seconds = time % 60; | |
378 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
379 label_set_text(version_label, _("version %d"), WavpackGetVersion(ctx)); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
380 label_set_text(bitrate_label, _("average bitrate: %6.1f kbps"), WavpackGetAverageBitrate(ctx, 0) / 1000); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
381 label_set_text(rate_label, _("samplerate: %d Hz"), WavpackGetSampleRate(ctx)); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
382 label_set_text(bits_per_sample_label, _("bits per sample: %d"), WavpackGetBitsPerSample(ctx)); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
383 label_set_text(channel_label, _("channels: %d"), WavpackGetNumChannels(ctx)); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
384 label_set_text(length_label, _("length: %d:%.2d"), minutes, seconds); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
385 label_set_text(filesize_label, _("file size: %d Bytes"), WavpackGetFileSize(ctx)); |
109 | 386 /* |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
387 label_set_text(peakTitle_label, _("Title Peak: %5u"), 100); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
388 label_set_text(peakAlbum_label, _("Album Peak: %5u"), 100); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
389 label_set_text(gainTitle_label, _("Title Gain: %-+5.2f dB"), 100.0); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
390 label_set_text(gainAlbum_label, _("Album Gain: %-+5.2f dB"), 100.0); |
109 | 391 */ |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
392 label_set_text(peakTitle_label, _("Title Peak: ?")); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
393 label_set_text(peakAlbum_label, _("Album Peak: ?")); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
394 label_set_text(gainTitle_label, _("Title Gain: ?")); |
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
395 label_set_text(gainAlbum_label, _("Album Gain: ?")); |
109 | 396 |
397 gtk_entry_set_text(GTK_ENTRY(title_entry), tag.title); | |
398 gtk_entry_set_text(GTK_ENTRY(performer_entry), tag.artist); | |
399 gtk_entry_set_text(GTK_ENTRY(album_entry), tag.album); | |
400 gtk_entry_set_text(GTK_ENTRY(user_comment_entry), tag.comment); | |
401 gtk_entry_set_text(GTK_ENTRY(genre_entry), tag.genre); | |
402 gtk_entry_set_text(GTK_ENTRY(tracknumber_entry), tag.track); | |
403 gtk_entry_set_text(GTK_ENTRY(date_entry), tag.year); | |
404 gtk_entry_set_text(GTK_ENTRY(filename_entry), fn); | |
405 gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); | |
406 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
407 tmp = g_strdup_printf(_("File Info - %s"), g_basename(fn)); |
109 | 408 gtk_window_set_title(GTK_WINDOW(window), tmp); |
409 g_free(tmp); | |
410 } | |
411 | |
412 static GtkWidget *wv_configurewin = NULL; | |
413 static GtkWidget *vbox, *notebook; | |
414 static GtkWidget *rg_switch, *rg_clip_switch, *rg_track_gain, *rg_dyn_bitrate; | |
415 | |
416 static void | |
417 wv_configurewin_ok(GtkWidget * widget, gpointer data) | |
418 { | |
419 ConfigDb *cfg; | |
420 GtkToggleButton *tb; | |
421 | |
422 tb = GTK_TOGGLE_BUTTON(rg_switch); | |
423 replaygainEnabled = gtk_toggle_button_get_active(tb); | |
424 tb = GTK_TOGGLE_BUTTON(rg_clip_switch); | |
425 clipPreventionEnabled = gtk_toggle_button_get_active(tb); | |
426 tb = GTK_TOGGLE_BUTTON(rg_dyn_bitrate); | |
427 dynBitrateEnabled = gtk_toggle_button_get_active(tb); | |
428 tb = GTK_TOGGLE_BUTTON(rg_track_gain); | |
429 albumReplaygainEnabled = !gtk_toggle_button_get_active(tb); | |
430 | |
431 cfg = bmp_cfg_db_open(); | |
432 | |
433 bmp_cfg_db_set_bool(cfg, "wavpack", "clip_prevention", | |
434 clipPreventionEnabled); | |
435 bmp_cfg_db_set_bool(cfg, "wavpack", "album_replaygain", | |
436 albumReplaygainEnabled); | |
437 bmp_cfg_db_set_bool(cfg, "wavpack", "dyn_bitrate", dynBitrateEnabled); | |
438 bmp_cfg_db_set_bool(cfg, "wavpack", "replaygain", replaygainEnabled); | |
439 bmp_cfg_db_close(cfg); | |
440 gtk_widget_destroy(wv_configurewin); | |
441 } | |
442 | |
443 static void | |
444 rg_switch_cb(GtkWidget * w, gpointer data) | |
445 { | |
446 gtk_widget_set_sensitive(GTK_WIDGET(data), | |
447 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON | |
448 (w))); | |
449 } | |
450 | |
451 void | |
452 wv_configure(void) | |
453 { | |
454 | |
455 GtkWidget *rg_frame, *rg_vbox; | |
456 GtkWidget *bbox, *ok, *cancel; | |
457 GtkWidget *rg_type_frame, *rg_type_vbox, *rg_album_gain; | |
458 | |
459 if (wv_configurewin != NULL) { | |
460 gdk_window_raise(wv_configurewin->window); | |
461 return; | |
462 } | |
463 | |
111 | 464 wv_configurewin = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
109 | 465 gtk_signal_connect(GTK_OBJECT(wv_configurewin), "destroy", |
466 GTK_SIGNAL_FUNC(gtk_widget_destroyed), | |
467 &wv_configurewin); | |
468 gtk_window_set_title(GTK_WINDOW(wv_configurewin), | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
469 _("Wavpack Configuration")); |
109 | 470 gtk_window_set_policy(GTK_WINDOW(wv_configurewin), FALSE, FALSE, FALSE); |
471 gtk_container_border_width(GTK_CONTAINER(wv_configurewin), 10); | |
472 | |
473 vbox = gtk_vbox_new(FALSE, 10); | |
474 gtk_container_add(GTK_CONTAINER(wv_configurewin), vbox); | |
475 | |
476 notebook = gtk_notebook_new(); | |
477 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); | |
478 | |
479 | |
480 /* Plugin Settings */ | |
481 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
482 rg_frame = gtk_frame_new(_("General Plugin Settings:")); |
109 | 483 gtk_container_border_width(GTK_CONTAINER(rg_frame), 5); |
484 | |
485 rg_vbox = gtk_vbox_new(FALSE, 10); | |
486 gtk_container_border_width(GTK_CONTAINER(rg_vbox), 5); | |
487 gtk_container_add(GTK_CONTAINER(rg_frame), rg_vbox); | |
488 | |
489 rg_dyn_bitrate = | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
490 gtk_check_button_new_with_label(_("Enable Dynamic Bitrate Display")); |
109 | 491 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_dyn_bitrate), |
492 dynBitrateEnabled); | |
493 gtk_box_pack_start(GTK_BOX(rg_vbox), rg_dyn_bitrate, FALSE, FALSE, 0); | |
494 | |
495 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), rg_frame, | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
496 gtk_label_new(_("Plugin"))); |
109 | 497 |
498 /* Replay Gain.. */ | |
499 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
500 rg_frame = gtk_frame_new(_("ReplayGain Settings:")); |
109 | 501 gtk_container_border_width(GTK_CONTAINER(rg_frame), 5); |
502 | |
503 rg_vbox = gtk_vbox_new(FALSE, 10); | |
504 gtk_container_border_width(GTK_CONTAINER(rg_vbox), 5); | |
505 gtk_container_add(GTK_CONTAINER(rg_frame), rg_vbox); | |
506 | |
507 rg_clip_switch = | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
508 gtk_check_button_new_with_label(_("Enable Clipping Prevention")); |
109 | 509 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_clip_switch), |
510 clipPreventionEnabled); | |
511 gtk_box_pack_start(GTK_BOX(rg_vbox), rg_clip_switch, FALSE, FALSE, 0); | |
512 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
513 rg_switch = gtk_check_button_new_with_label(_("Enable ReplayGain")); |
109 | 514 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_switch), |
515 replaygainEnabled); | |
516 gtk_box_pack_start(GTK_BOX(rg_vbox), rg_switch, FALSE, FALSE, 0); | |
517 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
518 rg_type_frame = gtk_frame_new(_("ReplayGain Type:")); |
109 | 519 gtk_box_pack_start(GTK_BOX(rg_vbox), rg_type_frame, FALSE, FALSE, 0); |
520 | |
521 gtk_signal_connect(GTK_OBJECT(rg_switch), "toggled", | |
522 GTK_SIGNAL_FUNC(rg_switch_cb), rg_type_frame); | |
523 | |
524 rg_type_vbox = gtk_vbox_new(FALSE, 5); | |
525 gtk_container_set_border_width(GTK_CONTAINER(rg_type_vbox), 5); | |
526 gtk_container_add(GTK_CONTAINER(rg_type_frame), rg_type_vbox); | |
527 | |
528 rg_track_gain = | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
529 gtk_radio_button_new_with_label(NULL, _("use Track Gain/Peak")); |
109 | 530 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_track_gain), |
531 !albumReplaygainEnabled); | |
532 gtk_box_pack_start(GTK_BOX(rg_type_vbox), rg_track_gain, FALSE, FALSE, 0); | |
533 | |
534 rg_album_gain = | |
535 gtk_radio_button_new_with_label(gtk_radio_button_group | |
536 (GTK_RADIO_BUTTON(rg_track_gain)), | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
537 _("use Album Gain/Peak")); |
109 | 538 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rg_album_gain), |
539 albumReplaygainEnabled); | |
540 gtk_box_pack_start(GTK_BOX(rg_type_vbox), rg_album_gain, FALSE, FALSE, 0); | |
541 | |
542 gtk_widget_set_sensitive(rg_type_frame, replaygainEnabled); | |
543 | |
544 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), rg_frame, | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
545 gtk_label_new(_("ReplayGain"))); |
109 | 546 |
547 /* Buttons */ | |
548 | |
549 bbox = gtk_hbutton_box_new(); | |
550 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
551 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
552 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
553 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
554 ok = gtk_button_new_with_label(_("Ok")); |
109 | 555 gtk_signal_connect(GTK_OBJECT(ok), "clicked", |
556 GTK_SIGNAL_FUNC(wv_configurewin_ok), NULL); | |
557 GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT); | |
558 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0); | |
559 gtk_widget_grab_default(ok); | |
560 | |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1044
diff
changeset
|
561 cancel = gtk_button_new_with_label(_("Cancel")); |
109 | 562 gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", |
563 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
564 GTK_OBJECT(wv_configurewin)); | |
565 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
566 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
567 | |
568 gtk_widget_show_all(wv_configurewin); | |
569 } |