Mercurial > audlegacy
annotate src/audacious/ui_equalizer.c @ 2551:cea3528b2996 trunk
[svn] Fix --play-pause commandline option, by Alex "Monkey" Maclean in #gentoo-x86
author | chainsaw |
---|---|
date | Mon, 19 Feb 2007 06:11:23 -0800 |
parents | 7aac1b5ef85d |
children | 50098faf1cdf |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 2 of the License. | |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #include "ui_equalizer.h" | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <gtk/gtk.h> | |
33 #include <stdio.h> | |
34 #include <math.h> | |
35 #include <string.h> | |
36 | |
37 #include "platform/smartinclude.h" | |
38 #include "widgets/widgetcore.h" | |
39 #include "dock.h" | |
40 #include "hints.h" | |
41 #include "input.h" | |
42 #include "main.h" | |
43 #include "ui_manager.h" | |
44 #include "actions-equalizer.h" | |
45 #include "playlist.h" | |
46 #include "ui_playlist.h" | |
47 #include "util.h" | |
48 #include "output.h" | |
49 | |
2537 | 50 #include "rcfile.h" |
2313 | 51 #include "vfs.h" |
52 | |
53 #include "images/audacious_eq.xpm" | |
54 | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
55 #include "ui_skinned_window.h" |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
56 |
2313 | 57 enum PresetViewCols { |
58 PRESET_VIEW_COL_NAME, | |
59 PRESET_VIEW_N_COLS | |
60 }; | |
61 | |
62 struct _EqualizerPreset { | |
63 gchar *name; | |
64 gfloat preamp, bands[10]; | |
65 }; | |
66 | |
67 typedef struct _EqualizerPreset EqualizerPreset; | |
68 | |
69 | |
70 GtkWidget *equalizerwin; | |
71 | |
72 static GtkWidget *equalizerwin_load_window = NULL; | |
73 static GtkWidget *equalizerwin_load_auto_window = NULL; | |
74 static GtkWidget *equalizerwin_save_window = NULL; | |
75 static GtkWidget *equalizerwin_save_entry = NULL; | |
76 static GtkWidget *equalizerwin_save_auto_window = NULL; | |
77 static GtkWidget *equalizerwin_save_auto_entry = NULL; | |
78 static GtkWidget *equalizerwin_delete_window = NULL; | |
79 static GtkWidget *equalizerwin_delete_auto_window = NULL; | |
80 | |
81 static GdkPixmap *equalizerwin_bg, *equalizerwin_bg_x2; | |
82 | |
83 static GList *equalizerwin_wlist = NULL; | |
84 | |
85 static TButton *equalizerwin_on, *equalizerwin_auto; | |
86 | |
87 static PButton *equalizerwin_presets, *equalizerwin_shade; | |
88 PButton *equalizerwin_close; | |
89 static EqGraph *equalizerwin_graph; | |
90 static EqSlider *equalizerwin_preamp, *equalizerwin_bands[10]; | |
91 static HSlider *equalizerwin_volume, *equalizerwin_balance; | |
92 | |
93 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL; | |
94 | |
95 | |
96 EqualizerPreset * | |
97 equalizer_preset_new(const gchar * name) | |
98 { | |
99 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); | |
100 preset->name = g_strdup(name); | |
101 return preset; | |
102 } | |
103 | |
104 void | |
105 equalizer_preset_free(EqualizerPreset * preset) | |
106 { | |
107 if (!preset) | |
108 return; | |
109 | |
110 g_free(preset->name); | |
111 g_free(preset); | |
112 } | |
113 | |
114 | |
115 static void | |
116 equalizerwin_set_shape_mask(void) | |
117 { | |
118 if (cfg.show_wm_decorations) | |
119 return; | |
120 | |
121 if (cfg.doublesize == FALSE) | |
122 gtk_widget_shape_combine_mask(equalizerwin, | |
123 skin_get_mask(bmp_active_skin, | |
124 SKIN_MASK_EQ), 0, 0); | |
125 else | |
126 gtk_widget_shape_combine_mask(equalizerwin, NULL, 0, 0); | |
127 } | |
128 | |
129 void | |
130 equalizerwin_set_doublesize(gboolean ds) | |
131 { | |
132 gint height; | |
133 | |
134 if (cfg.equalizer_shaded) | |
135 height = 14; | |
136 else | |
137 height = 116; | |
138 | |
139 equalizerwin_set_shape_mask(); | |
140 | |
141 if (ds) { | |
142 dock_window_resize(GTK_WINDOW(equalizerwin), 550, height * 2, 550, height * 2); | |
143 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg_x2, | |
144 0); | |
145 } | |
146 else { | |
147 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height, 275, height); | |
148 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg, 0); | |
149 } | |
150 | |
151 draw_equalizer_window(TRUE); | |
152 } | |
153 | |
154 void | |
155 equalizerwin_set_shade_menu_cb(gboolean shaded) | |
156 { | |
157 cfg.equalizer_shaded = shaded; | |
158 | |
159 equalizerwin_set_shape_mask(); | |
160 | |
161 if (shaded) { | |
162 dock_shade(dock_window_list, GTK_WINDOW(equalizerwin), | |
163 14 * (EQUALIZER_DOUBLESIZE + 1)); | |
164 pbutton_set_button_data(equalizerwin_shade, -1, 3, -1, 47); | |
165 pbutton_set_skin_index1(equalizerwin_shade, SKIN_EQ_EX); | |
166 pbutton_set_button_data(equalizerwin_close, 11, 38, 11, 47); | |
167 pbutton_set_skin_index(equalizerwin_close, SKIN_EQ_EX); | |
168 widget_show(WIDGET(equalizerwin_volume)); | |
169 widget_show(WIDGET(equalizerwin_balance)); | |
170 } | |
171 else { | |
172 dock_shade(dock_window_list, GTK_WINDOW(equalizerwin), | |
173 116 * (EQUALIZER_DOUBLESIZE + 1)); | |
174 pbutton_set_button_data(equalizerwin_shade, -1, 137, -1, 38); | |
175 pbutton_set_skin_index1(equalizerwin_shade, SKIN_EQMAIN); | |
176 pbutton_set_button_data(equalizerwin_close, 0, 116, 0, 125); | |
177 pbutton_set_skin_index(equalizerwin_close, SKIN_EQMAIN); | |
178 widget_hide(WIDGET(equalizerwin_volume)); | |
179 widget_hide(WIDGET(equalizerwin_balance)); | |
180 } | |
181 | |
182 draw_equalizer_window(TRUE); | |
183 } | |
184 | |
185 static void | |
186 equalizerwin_set_shade(gboolean shaded) | |
187 { | |
188 GtkAction *action = gtk_action_group_get_action( | |
189 toggleaction_group_others , "roll up equalizer" ); | |
190 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
191 } | |
192 | |
193 static void | |
194 equalizerwin_shade_toggle(void) | |
195 { | |
196 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
197 } | |
198 | |
199 static void | |
200 equalizerwin_raise(void) | |
201 { | |
202 if (cfg.equalizer_visible) | |
203 gtk_window_present(GTK_WINDOW(equalizerwin)); | |
204 } | |
205 | |
206 void | |
207 equalizerwin_eq_changed(void) | |
208 { | |
209 gint i; | |
210 | |
211 cfg.equalizer_preamp = eqslider_get_position(equalizerwin_preamp); | |
212 for (i = 0; i < 10; i++) | |
213 cfg.equalizer_bands[i] = eqslider_get_position(equalizerwin_bands[i]); | |
214 /* um .. i think we need both of these for xmms compatibility .. | |
215 not sure. -larne */ | |
216 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
217 cfg.equalizer_bands); | |
218 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
219 cfg.equalizer_bands); | |
220 | |
221 widget_draw(WIDGET(equalizerwin_graph)); | |
222 } | |
223 | |
224 static void | |
225 equalizerwin_on_pushed(gboolean toggled) | |
226 { | |
227 cfg.equalizer_active = toggled; | |
228 equalizerwin_eq_changed(); | |
229 } | |
230 | |
231 static void | |
232 equalizerwin_presets_pushed(void) | |
233 { | |
234 GdkModifierType modmask; | |
235 gint x, y; | |
236 | |
237 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
238 ui_manager_popup_menu_show(GTK_MENU(equalizerwin_presets_menu), x, y, 1, GDK_CURRENT_TIME); | |
239 } | |
240 | |
241 static void | |
242 equalizerwin_auto_pushed(gboolean toggled) | |
243 { | |
244 cfg.equalizer_autoload = toggled; | |
245 } | |
246 | |
247 void | |
248 draw_equalizer_window(gboolean force) | |
249 { | |
250 GdkImage *img, *img2; | |
251 GList *wl; | |
252 Widget *w; | |
253 gboolean redraw; | |
254 | |
255 widget_list_lock(equalizerwin_wlist); | |
256 | |
257 if (force) { | |
2526 | 258 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, SKINNED_WINDOW(equalizerwin)->gc, |
2313 | 259 SKIN_EQMAIN, 0, 0, 0, 0, 275, 116); |
260 if (gtk_window_has_toplevel_focus(GTK_WINDOW(equalizerwin)) || | |
261 !cfg.dim_titlebar) { | |
262 if (!cfg.equalizer_shaded) | |
263 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 264 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 134, 0, |
2313 | 265 0, 275, 14); |
266 else | |
267 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 268 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 0, 0, 0, |
2313 | 269 275, 14); |
270 } | |
271 else { | |
272 if (!cfg.equalizer_shaded) | |
273 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 274 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 149, 0, |
2313 | 275 0, 275, 14); |
276 else | |
277 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 278 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 15, 0, 0, |
2313 | 279 275, 14); |
280 | |
281 } | |
282 } | |
283 | |
284 widget_list_draw(equalizerwin_wlist, &redraw, force); | |
285 | |
286 if (force || redraw) { | |
287 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
288 if (force) { | |
289 img = gdk_drawable_get_image(equalizerwin_bg, 0, 0, 275, 116); | |
290 img2 = create_dblsize_image(img); | |
2526 | 291 gdk_draw_image(equalizerwin_bg_x2, SKINNED_WINDOW(equalizerwin)->gc, |
2313 | 292 img2, 0, 0, 0, 0, 550, 232); |
293 g_object_unref(img2); | |
294 g_object_unref(img); | |
295 } | |
296 else { | |
297 for (wl = equalizerwin_wlist; wl; wl = g_list_next(wl)) { | |
298 w = WIDGET(wl->data); | |
299 if (w->redraw && w->visible) { | |
300 img = gdk_drawable_get_image(equalizerwin_bg, | |
301 w->x, w->y, | |
302 w->width, w->height); | |
303 img2 = create_dblsize_image(img); | |
304 gdk_draw_image(equalizerwin_bg_x2, | |
2526 | 305 SKINNED_WINDOW(equalizerwin)->gc, img2, 0, 0, |
2313 | 306 w->x << 1, w->y << 1, w->width << 1, |
307 w->height << 1); | |
308 g_object_unref(img2); | |
309 g_object_unref(img); | |
310 w->redraw = FALSE; | |
311 } | |
312 } | |
313 } | |
314 } | |
315 else | |
316 widget_list_clear_redraw(equalizerwin_wlist); | |
317 gdk_window_clear(equalizerwin->window); | |
318 gdk_flush(); | |
319 } | |
320 | |
321 widget_list_unlock(equalizerwin_wlist); | |
322 } | |
323 | |
324 gboolean | |
325 equalizerwin_press(GtkWidget * widget, GdkEventButton * event, | |
326 gpointer callback_data) | |
327 { | |
328 gint mx, my; | |
329 gboolean grab = TRUE; | |
330 | |
331 mx = event->x; | |
332 my = event->y; | |
333 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
334 event->x /= 2; | |
335 event->y /= 2; | |
336 } | |
337 | |
338 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
339 ((cfg.easy_move || cfg.equalizer_shaded || event->y < 14) && | |
2524 | 340 !ui_skinned_window_widgetlist_contained(equalizerwin, event->x, event->y))) { |
2497
204d1bab71f9
[svn] - if (0 && hint_move_resize_available()) -- i'm not sure how this linked as we do not have a hint_move_resize_available().
nenolod
parents:
2495
diff
changeset
|
341 equalizerwin_raise(); |
204d1bab71f9
[svn] - if (0 && hint_move_resize_available()) -- i'm not sure how this linked as we do not have a hint_move_resize_available().
nenolod
parents:
2495
diff
changeset
|
342 dock_move_press(dock_window_list, GTK_WINDOW(equalizerwin), event, |
204d1bab71f9
[svn] - if (0 && hint_move_resize_available()) -- i'm not sure how this linked as we do not have a hint_move_resize_available().
nenolod
parents:
2495
diff
changeset
|
343 FALSE); |
2313 | 344 } |
345 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS | |
346 && event->y < 14) { | |
347 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
348 if (dock_is_moving(GTK_WINDOW(equalizerwin))) | |
349 dock_move_release(GTK_WINDOW(equalizerwin)); | |
350 } | |
351 else if (event->button == 3 && | |
352 !(widget_contains(WIDGET(equalizerwin_on), event->x, event->y) || | |
353 widget_contains(WIDGET(equalizerwin_auto), event->x, event->y))) { | |
354 /* | |
355 * Pop up the main menu a few pixels down to avoid | |
356 * anything to be selected initially. | |
357 */ | |
358 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
359 event->y_root + 2, 3, event->time); | |
360 grab = FALSE; | |
361 } | |
362 else { | |
363 handle_press_cb(equalizerwin_wlist, widget, event); | |
364 draw_equalizer_window(FALSE); | |
365 } | |
366 if (grab) | |
367 gdk_pointer_grab(GDK_WINDOW(equalizerwin->window), FALSE, | |
368 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
369 NULL, NULL, GDK_CURRENT_TIME); | |
370 | |
371 return FALSE; | |
372 } | |
373 | |
374 static void | |
375 equalizerwin_scroll(GtkWidget * widget, GdkEventScroll * event, gpointer data) | |
376 { | |
377 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
378 event->x /= 2; | |
379 event->y /= 2; | |
380 } | |
381 | |
382 handle_scroll_cb(equalizerwin_wlist, widget, event); | |
383 draw_equalizer_window(FALSE); | |
384 } | |
385 | |
386 static gboolean | |
387 equalizerwin_motion(GtkWidget * widget, | |
388 GdkEventMotion * event, gpointer callback_data) | |
389 { | |
390 GdkEvent *gevent; | |
391 | |
392 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
393 event->x /= 2; | |
394 event->y /= 2; | |
395 } | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
396 |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
397 handle_motion_cb(equalizerwin_wlist, widget, event); |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
398 draw_equalizer_window(FALSE); |
2313 | 399 |
400 gdk_flush(); | |
401 | |
402 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); | |
403 | |
404 return FALSE; | |
405 } | |
406 | |
407 static gboolean | |
408 equalizerwin_release(GtkWidget * widget, | |
409 GdkEventButton * event, gpointer callback_data) | |
410 { | |
411 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
412 gdk_flush(); | |
413 | |
414 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
415 event->x /= 2; | |
416 event->y /= 2; | |
417 } | |
418 if (dock_is_moving(GTK_WINDOW(equalizerwin))) { | |
419 dock_move_release(GTK_WINDOW(equalizerwin)); | |
420 } | |
421 else { | |
422 handle_release_cb(equalizerwin_wlist, widget, event); | |
423 draw_equalizer_window(FALSE); | |
424 } | |
425 | |
426 return FALSE; | |
427 } | |
428 | |
429 static gboolean | |
430 equalizerwin_focus_in(GtkWidget * widget, | |
431 GdkEvent * event, | |
432 gpointer data) | |
433 { | |
434 equalizerwin_close->pb_allow_draw = TRUE; | |
435 equalizerwin_shade->pb_allow_draw = TRUE; | |
436 draw_equalizer_window(TRUE); | |
437 return TRUE; | |
438 } | |
439 | |
440 static gboolean | |
441 equalizerwin_focus_out(GtkWidget * widget, | |
442 GdkEventButton * event, | |
443 gpointer data) | |
444 { | |
445 equalizerwin_close->pb_allow_draw = FALSE; | |
446 equalizerwin_shade->pb_allow_draw = FALSE; | |
447 draw_equalizer_window(TRUE); | |
448 return TRUE; | |
449 } | |
450 | |
451 static gboolean | |
452 equalizerwin_keypress(GtkWidget * widget, | |
453 GdkEventKey * event, | |
454 gpointer data) | |
455 { | |
456 if (!cfg.equalizer_shaded) { | |
457 gtk_widget_event(mainwin, (GdkEvent *) event); | |
458 return TRUE; | |
459 } | |
460 | |
461 switch (event->keyval) { | |
462 case GDK_Left: | |
463 case GDK_KP_Left: | |
464 mainwin_set_balance_diff(-4); | |
465 break; | |
466 case GDK_Right: | |
467 case GDK_KP_Right: | |
468 mainwin_set_balance_diff(4); | |
469 break; | |
470 default: | |
471 gtk_widget_event(mainwin, (GdkEvent *) event); | |
472 break; | |
473 } | |
474 | |
475 return FALSE; | |
476 } | |
477 | |
478 static gboolean | |
479 equalizerwin_configure(GtkWidget * window, | |
480 GdkEventConfigure * event, | |
481 gpointer data) | |
482 { | |
483 if (!GTK_WIDGET_VISIBLE(window)) | |
484 return FALSE; | |
485 | |
486 cfg.equalizer_x = event->x; | |
487 cfg.equalizer_y = event->y; | |
488 return FALSE; | |
489 } | |
490 | |
491 static void | |
492 equalizerwin_set_back_pixmap(void) | |
493 { | |
494 if (cfg.doublesize && cfg.eq_doublesize_linked) | |
495 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg_x2, | |
496 0); | |
497 else | |
498 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg, 0); | |
499 gdk_window_clear(equalizerwin->window); | |
500 } | |
501 | |
502 static void | |
503 equalizerwin_close_cb(void) | |
504 { | |
505 equalizerwin_show(FALSE); | |
506 } | |
507 | |
508 static gboolean | |
509 equalizerwin_delete(GtkWidget * widget, | |
510 gpointer data) | |
511 { | |
512 equalizerwin_show(FALSE); | |
513 return TRUE; | |
514 } | |
515 | |
516 static GList * | |
517 equalizerwin_read_presets(const gchar * basename) | |
518 { | |
519 gchar *filename, *name; | |
520 RcFile *rcfile; | |
521 GList *list = NULL; | |
522 gint i, p = 0; | |
523 EqualizerPreset *preset; | |
524 | |
525 filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); | |
526 | |
527 if ((rcfile = bmp_rcfile_open(filename)) == NULL) { | |
528 g_free(filename); | |
529 return NULL; | |
530 } | |
531 | |
532 g_free(filename); | |
533 | |
534 for (;;) { | |
535 gchar section[21]; | |
536 | |
537 g_snprintf(section, sizeof(section), "Preset%d", p++); | |
538 if (bmp_rcfile_read_string(rcfile, "Presets", section, &name)) { | |
539 preset = g_new0(EqualizerPreset, 1); | |
540 preset->name = name; | |
541 bmp_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); | |
542 for (i = 0; i < 10; i++) { | |
543 gchar band[7]; | |
544 g_snprintf(band, sizeof(band), "Band%d", i); | |
545 bmp_rcfile_read_float(rcfile, name, band, &preset->bands[i]); | |
546 } | |
547 list = g_list_prepend(list, preset); | |
548 } | |
549 else | |
550 break; | |
551 } | |
552 list = g_list_reverse(list); | |
553 bmp_rcfile_free(rcfile); | |
554 return list; | |
555 } | |
556 | |
557 gint | |
558 equalizerwin_volume_frame_cb(gint pos) | |
559 { | |
560 if (equalizerwin_volume) { | |
561 if (pos < 32) | |
562 equalizerwin_volume->hs_knob_nx = | |
563 equalizerwin_volume->hs_knob_px = 1; | |
564 else if (pos < 63) | |
565 equalizerwin_volume->hs_knob_nx = | |
566 equalizerwin_volume->hs_knob_px = 4; | |
567 else | |
568 equalizerwin_volume->hs_knob_nx = | |
569 equalizerwin_volume->hs_knob_px = 7; | |
570 } | |
571 return 1; | |
572 } | |
573 | |
574 static void | |
575 equalizerwin_volume_motion_cb(gint pos) | |
576 { | |
577 gint v = (gint) rint(pos * 100 / 94.0); | |
578 mainwin_adjust_volume_motion(v); | |
579 mainwin_set_volume_slider(v); | |
580 } | |
581 | |
582 static void | |
583 equalizerwin_volume_release_cb(gint pos) | |
584 { | |
585 mainwin_adjust_volume_release(); | |
586 } | |
587 | |
588 static gint | |
589 equalizerwin_balance_frame_cb(gint pos) | |
590 { | |
591 if (equalizerwin_balance) { | |
592 if (pos < 13) | |
593 equalizerwin_balance->hs_knob_nx = | |
594 equalizerwin_balance->hs_knob_px = 11; | |
595 else if (pos < 26) | |
596 equalizerwin_balance->hs_knob_nx = | |
597 equalizerwin_balance->hs_knob_px = 14; | |
598 else | |
599 equalizerwin_balance->hs_knob_nx = | |
600 equalizerwin_balance->hs_knob_px = 17; | |
601 } | |
602 | |
603 return 1; | |
604 } | |
605 | |
606 static void | |
607 equalizerwin_balance_motion_cb(gint pos) | |
608 { | |
609 gint b; | |
610 pos = MIN(pos, 38); /* The skin uses a even number of pixels | |
611 for the balance-slider *sigh* */ | |
612 b = (gint) rint((pos - 19) * 100 / 19.0); | |
613 mainwin_adjust_balance_motion(b); | |
614 mainwin_set_balance_slider(b); | |
615 } | |
616 | |
617 static void | |
618 equalizerwin_balance_release_cb(gint pos) | |
619 { | |
620 mainwin_adjust_balance_release(); | |
621 } | |
622 | |
623 void | |
624 equalizerwin_set_balance_slider(gint percent) | |
625 { | |
626 hslider_set_position(equalizerwin_balance, | |
627 (gint) rint((percent * 19 / 100.0) + 19)); | |
628 } | |
629 | |
630 void | |
631 equalizerwin_set_volume_slider(gint percent) | |
632 { | |
633 hslider_set_position(equalizerwin_volume, | |
634 (gint) rint(percent * 94 / 100.0)); | |
635 } | |
636 | |
637 static void | |
638 equalizerwin_create_widgets(void) | |
639 { | |
640 gint i; | |
641 | |
642 equalizerwin_on = | |
643 create_tbutton(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 644 SKINNED_WINDOW(equalizerwin)->gc, 14, 18, 25, 12, 10, 119, 128, 119, |
2313 | 645 69, 119, 187, 119, equalizerwin_on_pushed, |
646 SKIN_EQMAIN); | |
647 tbutton_set_toggled(equalizerwin_on, cfg.equalizer_active); | |
2524 | 648 ui_skinned_window_widgetlist_associate(equalizerwin, |
649 WIDGET(equalizerwin_on)); | |
650 | |
2313 | 651 equalizerwin_auto = |
652 create_tbutton(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 653 SKINNED_WINDOW(equalizerwin)->gc, 39, 18, 33, 12, 35, 119, 153, 119, |
2313 | 654 94, 119, 212, 119, equalizerwin_auto_pushed, |
655 SKIN_EQMAIN); | |
656 tbutton_set_toggled(equalizerwin_auto, cfg.equalizer_autoload); | |
2524 | 657 ui_skinned_window_widgetlist_associate(equalizerwin, |
658 WIDGET(equalizerwin_auto)); | |
659 | |
2313 | 660 equalizerwin_presets = |
661 create_pbutton(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 662 SKINNED_WINDOW(equalizerwin)->gc, 217, 18, 44, 12, 224, 164, 224, |
2313 | 663 176, equalizerwin_presets_pushed, SKIN_EQMAIN); |
2524 | 664 ui_skinned_window_widgetlist_associate(equalizerwin, |
665 WIDGET(equalizerwin_presets)); | |
666 | |
2313 | 667 equalizerwin_close = |
668 create_pbutton(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 669 SKINNED_WINDOW(equalizerwin)->gc, 264, 3, 9, 9, 0, 116, 0, 125, |
2313 | 670 equalizerwin_close_cb, SKIN_EQMAIN); |
671 equalizerwin_close->pb_allow_draw = FALSE; | |
2524 | 672 ui_skinned_window_widgetlist_associate(equalizerwin, |
673 WIDGET(equalizerwin_close)); | |
2313 | 674 |
675 equalizerwin_shade = | |
676 create_pbutton_ex(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 677 SKINNED_WINDOW(equalizerwin)->gc, 254, 3, 9, 9, 254, 137, 1, 38, |
2313 | 678 equalizerwin_shade_toggle, NULL, SKIN_EQMAIN, SKIN_EQ_EX); |
679 equalizerwin_shade->pb_allow_draw = FALSE; | |
2524 | 680 ui_skinned_window_widgetlist_associate(equalizerwin, |
681 WIDGET(equalizerwin_shade)); | |
2313 | 682 |
683 equalizerwin_graph = | |
684 create_eqgraph(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 685 SKINNED_WINDOW(equalizerwin)->gc, 86, 17); |
2524 | 686 ui_skinned_window_widgetlist_associate(equalizerwin, |
687 WIDGET(equalizerwin_graph)); | |
688 | |
2313 | 689 equalizerwin_preamp = |
690 create_eqslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 691 SKINNED_WINDOW(equalizerwin)->gc, 21, 38); |
2313 | 692 eqslider_set_position(equalizerwin_preamp, cfg.equalizer_preamp); |
2524 | 693 ui_skinned_window_widgetlist_associate(equalizerwin, |
694 WIDGET(equalizerwin_preamp)); | |
695 | |
2313 | 696 for (i = 0; i < 10; i++) { |
697 equalizerwin_bands[i] = | |
698 create_eqslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 699 SKINNED_WINDOW(equalizerwin)->gc, 78 + (i * 18), 38); |
2313 | 700 eqslider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]); |
2524 | 701 ui_skinned_window_widgetlist_associate(equalizerwin, |
702 WIDGET(equalizerwin_bands[i])); | |
2313 | 703 } |
704 | |
705 equalizerwin_volume = | |
706 create_hslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 707 SKINNED_WINDOW(equalizerwin)->gc, 61, 4, 97, 8, 1, 30, 1, 30, 3, 7, |
2313 | 708 4, 61, 0, 94, equalizerwin_volume_frame_cb, |
709 equalizerwin_volume_motion_cb, | |
710 equalizerwin_volume_release_cb, SKIN_EQ_EX); | |
2524 | 711 ui_skinned_window_widgetlist_associate(equalizerwin, |
712 WIDGET(equalizerwin_volume)); | |
713 | |
2313 | 714 equalizerwin_balance = |
715 create_hslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 716 SKINNED_WINDOW(equalizerwin)->gc, 164, 4, 42, 8, 11, 30, 11, 30, 3, |
2313 | 717 7, 4, 164, 0, 39, equalizerwin_balance_frame_cb, |
718 equalizerwin_balance_motion_cb, | |
719 equalizerwin_balance_release_cb, SKIN_EQ_EX); | |
2524 | 720 ui_skinned_window_widgetlist_associate(equalizerwin, |
721 WIDGET(equalizerwin_balance)); | |
2313 | 722 |
723 if (!cfg.equalizer_shaded) { | |
724 widget_hide(WIDGET(equalizerwin_volume)); | |
725 widget_hide(WIDGET(equalizerwin_balance)); | |
726 } | |
727 else { | |
728 pbutton_set_button_data(equalizerwin_shade, -1, 3, -1, 47); | |
729 pbutton_set_skin_index1(equalizerwin_shade, SKIN_EQ_EX); | |
730 pbutton_set_button_data(equalizerwin_close, 11, 38, 11, 47); | |
731 pbutton_set_skin_index(equalizerwin_close, SKIN_EQ_EX); | |
732 } | |
733 } | |
734 | |
735 | |
736 static void | |
737 equalizerwin_create_window(void) | |
738 { | |
739 GdkPixbuf *icon; | |
740 gint width, height; | |
741 | |
2515
319b10203d7c
[svn] gtk_window_set_wmclass() has to be called before gtk_widget_realize(). Patched by Christian "Joker" Birchinger from Gentoo.
chainsaw
parents:
2514
diff
changeset
|
742 equalizerwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL, "equalizer"); |
2313 | 743 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer")); |
744 gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer"); | |
745 | |
746 width = 275; | |
747 height = cfg.equalizer_shaded ? 14 : 116; | |
748 | |
749 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
750 width *= 2; | |
751 height *= 2; | |
752 } | |
753 | |
754 gtk_window_set_default_size(GTK_WINDOW(equalizerwin), width, height); | |
755 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE); | |
756 | |
757 /* this will hide only mainwin. it's annoying! yaz */ | |
758 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin), | |
759 GTK_WINDOW(mainwin)); | |
760 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE); | |
761 | |
762 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_eq_icon); | |
763 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon); | |
764 g_object_unref(icon); | |
765 | |
766 gtk_widget_set_app_paintable(equalizerwin, TRUE); | |
767 | |
768 if (cfg.equalizer_x != -1 && cfg.save_window_position) | |
769 gtk_window_move(GTK_WINDOW(equalizerwin), | |
770 cfg.equalizer_x, cfg.equalizer_y); | |
771 | |
772 g_signal_connect(equalizerwin, "delete_event", | |
773 G_CALLBACK(equalizerwin_delete), NULL); | |
774 g_signal_connect(equalizerwin, "button_press_event", | |
775 G_CALLBACK(equalizerwin_press), NULL); | |
776 g_signal_connect(equalizerwin, "button_release_event", | |
777 G_CALLBACK(equalizerwin_release), NULL); | |
778 g_signal_connect(equalizerwin, "motion_notify_event", | |
779 G_CALLBACK(equalizerwin_motion), NULL); | |
780 g_signal_connect_after(equalizerwin, "focus_in_event", | |
781 G_CALLBACK(equalizerwin_focus_in), NULL); | |
782 g_signal_connect_after(equalizerwin, "focus_out_event", | |
783 G_CALLBACK(equalizerwin_focus_out), NULL); | |
784 g_signal_connect(equalizerwin, "configure_event", | |
785 G_CALLBACK(equalizerwin_configure), NULL); | |
786 g_signal_connect(equalizerwin, "style_set", | |
787 G_CALLBACK(equalizerwin_set_back_pixmap), NULL); | |
788 g_signal_connect(equalizerwin, "key_press_event", | |
789 G_CALLBACK(equalizerwin_keypress), NULL); | |
790 g_signal_connect(equalizerwin, "scroll_event", | |
791 G_CALLBACK(equalizerwin_scroll), NULL); | |
792 } | |
793 | |
794 void | |
795 equalizerwin_create(void) | |
796 { | |
797 equalizer_presets = equalizerwin_read_presets("eq.preset"); | |
798 equalizer_auto_presets = equalizerwin_read_presets("eq.auto_preset"); | |
799 | |
800 equalizerwin_create_window(); | |
801 | |
802 gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); | |
803 | |
804 equalizerwin_bg = gdk_pixmap_new(equalizerwin->window, 275, 116, -1); | |
805 equalizerwin_bg_x2 = gdk_pixmap_new(equalizerwin->window, 550, 232, -1); | |
806 | |
807 equalizerwin_create_widgets(); | |
808 | |
809 equalizerwin_set_back_pixmap(); | |
810 if (cfg.doublesize && cfg.eq_doublesize_linked) | |
811 gdk_window_set_back_pixmap(equalizerwin->window, | |
812 equalizerwin_bg_x2, 0); | |
813 else | |
814 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg, 0); | |
815 } | |
816 | |
817 | |
818 void | |
819 equalizerwin_show(gboolean show) | |
820 { | |
821 GtkAction *action = gtk_action_group_get_action( | |
822 toggleaction_group_others , "show equalizer" ); | |
823 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , show ); | |
824 | |
825 if (show) | |
826 equalizerwin_real_show(); | |
827 else | |
828 equalizerwin_real_hide(); | |
829 } | |
830 | |
831 void | |
832 equalizerwin_real_show(void) | |
833 { | |
834 /* | |
835 * This function should only be called from the | |
836 * main menu signal handler | |
837 */ | |
838 | |
839 gint x, y; | |
840 | |
841 gtk_window_get_position(GTK_WINDOW(equalizerwin), &x, &y); | |
842 gtk_window_move(GTK_WINDOW(equalizerwin), x, y); | |
843 if (cfg.doublesize && cfg.eq_doublesize_linked) | |
844 gtk_widget_set_size_request(equalizerwin, 550, | |
845 (cfg.equalizer_shaded ? 28 : 232)); | |
846 else | |
847 gtk_widget_set_size_request(equalizerwin, 275, | |
848 (cfg.equalizer_shaded ? 14 : 116)); | |
849 gdk_flush(); | |
850 draw_equalizer_window(TRUE); | |
851 cfg.equalizer_visible = TRUE; | |
852 tbutton_set_toggled(mainwin_eq, TRUE); | |
853 | |
854 gtk_widget_show(equalizerwin); | |
855 } | |
856 | |
857 void | |
858 equalizerwin_real_hide(void) | |
859 { | |
860 /* | |
861 * This function should only be called from the | |
862 * main menu signal handler | |
863 */ | |
864 gtk_widget_hide(equalizerwin); | |
865 cfg.equalizer_visible = FALSE; | |
866 tbutton_set_toggled(mainwin_eq, FALSE); | |
867 } | |
868 | |
869 static EqualizerPreset * | |
870 equalizerwin_find_preset(GList * list, const gchar * name) | |
871 { | |
872 GList *node = list; | |
873 EqualizerPreset *preset; | |
874 | |
875 while (node) { | |
876 preset = node->data; | |
877 if (!strcasecmp(preset->name, name)) | |
878 return preset; | |
879 node = g_list_next(node); | |
880 } | |
881 return NULL; | |
882 } | |
883 | |
884 static void | |
885 equalizerwin_write_preset_file(GList * list, const gchar * basename) | |
886 { | |
887 gchar *filename, *tmp; | |
888 gint i, p; | |
889 EqualizerPreset *preset; | |
890 RcFile *rcfile; | |
891 GList *node; | |
892 | |
893 rcfile = bmp_rcfile_new(); | |
894 p = 0; | |
895 for (node = list; node; node = g_list_next(node)) { | |
896 preset = node->data; | |
897 tmp = g_strdup_printf("Preset%d", p++); | |
898 bmp_rcfile_write_string(rcfile, "Presets", tmp, preset->name); | |
899 g_free(tmp); | |
900 bmp_rcfile_write_float(rcfile, preset->name, "Preamp", | |
901 preset->preamp); | |
902 for (i = 0; i < 10; i++) { | |
903 tmp = g_strdup_printf("Band%d\n", i); | |
904 bmp_rcfile_write_float(rcfile, preset->name, tmp, | |
905 preset->bands[i]); | |
906 g_free(tmp); | |
907 } | |
908 } | |
909 | |
910 filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); | |
911 bmp_rcfile_write(rcfile, filename); | |
912 bmp_rcfile_free(rcfile); | |
913 g_free(filename); | |
914 } | |
915 | |
916 static gboolean | |
917 equalizerwin_load_preset(GList * list, const gchar * name) | |
918 { | |
919 EqualizerPreset *preset; | |
920 gint i; | |
921 | |
922 if ((preset = equalizerwin_find_preset(list, name)) != NULL) { | |
923 eqslider_set_position(equalizerwin_preamp, preset->preamp); | |
924 for (i = 0; i < 10; i++) | |
925 eqslider_set_position(equalizerwin_bands[i], preset->bands[i]); | |
926 equalizerwin_eq_changed(); | |
927 return TRUE; | |
928 } | |
929 return FALSE; | |
930 } | |
931 | |
932 static GList * | |
933 equalizerwin_save_preset(GList * list, const gchar * name, | |
934 const gchar * filename) | |
935 { | |
936 gint i; | |
937 EqualizerPreset *preset; | |
938 | |
939 if (!(preset = equalizerwin_find_preset(list, name))) { | |
940 preset = g_new0(EqualizerPreset, 1); | |
941 preset->name = g_strdup(name); | |
942 list = g_list_append(list, preset); | |
943 } | |
944 | |
945 preset->preamp = eqslider_get_position(equalizerwin_preamp); | |
946 for (i = 0; i < 10; i++) | |
947 preset->bands[i] = eqslider_get_position(equalizerwin_bands[i]); | |
948 | |
949 equalizerwin_write_preset_file(list, filename); | |
950 | |
951 return list; | |
952 } | |
953 | |
954 static GList * | |
955 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename) | |
956 { | |
957 EqualizerPreset *preset; | |
958 GList *node; | |
959 | |
960 if (!(preset = equalizerwin_find_preset(list, name))) | |
961 return list; | |
962 | |
963 if (!(node = g_list_find(list, preset))) | |
964 return list; | |
965 | |
966 list = g_list_remove_link(list, node); | |
967 equalizer_preset_free(preset); | |
968 g_list_free_1(node); | |
969 | |
970 equalizerwin_write_preset_file(list, filename); | |
971 | |
972 return list; | |
973 } | |
974 | |
975 static void | |
976 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename) | |
977 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
978 gchar *text; |
2313 | 979 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
980 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
981 GtkTreeModel *model = gtk_tree_view_get_model(view); |
2313 | 982 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
983 /* |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
984 * first we are making a list of the selected rows, then we convert this |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
985 * list into a list of GtkTreeRowReferences, so that when you delete an |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
986 * item you can still access the other items |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
987 * finally we iterate through all GtkTreeRowReferences, convert them to |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
988 * GtkTreeIters and delete those one after the other |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
989 */ |
2313 | 990 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
991 GList *list = gtk_tree_selection_get_selected_rows(selection, &model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
992 GList *rrefs = NULL; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
993 GList *litr; |
2313 | 994 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
995 for (litr = list; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
996 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
997 GtkTreePath *path = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
998 rrefs = g_list_append(rrefs, gtk_tree_row_reference_new(model, path)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
999 } |
2313 | 1000 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1001 for (litr = rrefs; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1002 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1003 GtkTreeRowReference *ref = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1004 GtkTreePath *path = gtk_tree_row_reference_get_path(ref); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1005 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1006 gtk_tree_model_get_iter(model, &iter, path); |
2313 | 1007 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1008 gtk_tree_model_get(model, &iter, 0, &text, -1); |
2313 | 1009 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1010 if (filename == "eq.preset") |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1011 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1012 else if (filename == "eq.auto_preset") |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1013 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename); |
2313 | 1014 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1015 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1016 } |
2313 | 1017 } |
1018 | |
1019 | |
1020 static GList * | |
1021 import_winamp_eqf(VFSFile * file) | |
1022 { | |
1023 gchar header[31]; | |
1024 gchar name[257]; | |
1025 gchar bands[11]; | |
1026 gint i = 0; | |
1027 GList *list = NULL; | |
1028 EqualizerPreset *preset; | |
1029 | |
1030 vfs_fread(header, 1, 31, file); | |
1031 if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { | |
1032 while (vfs_fread(name, 1, 257, file)) { | |
1033 preset = equalizer_preset_new(name); | |
1034 preset->preamp = 20.0 - ((bands[10] * 40.0) / 64); | |
1035 | |
1036 vfs_fread(bands, 1, 11, file); | |
1037 | |
1038 for (i = 0; i < 10; i++) | |
1039 preset->bands[i] = 20.0 - ((bands[i] * 40.0) / 64); | |
1040 | |
1041 list = g_list_prepend(list, preset); | |
1042 } | |
1043 } | |
1044 | |
1045 list = g_list_reverse(list); | |
1046 return list; | |
1047 } | |
1048 | |
1049 static void | |
1050 equalizerwin_read_winamp_eqf(VFSFile * file) | |
1051 { | |
1052 gchar header[31]; | |
1053 guchar bands[11]; | |
1054 gint i; | |
1055 | |
1056 vfs_fread(header, 1, 31, file); | |
1057 | |
1058 if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { | |
1059 /* Skip name */ | |
1060 if (vfs_fseek(file, 257, SEEK_CUR) == -1) | |
1061 return; | |
1062 | |
1063 if (vfs_fread(bands, 1, 11, file) != 11) | |
1064 return; | |
1065 | |
1066 eqslider_set_position(equalizerwin_preamp, | |
1067 20.0 - ((bands[10] * 40.0) / 63.0)); | |
1068 | |
1069 for (i = 0; i < 10; i++) | |
1070 eqslider_set_position(equalizerwin_bands[i], | |
1071 20.0 - ((bands[i] * 40.0) / 64.0)); | |
1072 } | |
1073 | |
1074 equalizerwin_eq_changed(); | |
1075 } | |
1076 | |
1077 static void | |
1078 equalizerwin_read_bmp_preset(RcFile * rcfile) | |
1079 { | |
1080 gfloat val; | |
1081 gint i; | |
1082 | |
1083 if (bmp_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) | |
1084 eqslider_set_position(equalizerwin_preamp, val); | |
1085 for (i = 0; i < 10; i++) { | |
1086 gchar tmp[7]; | |
1087 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
1088 if (bmp_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) | |
1089 eqslider_set_position(equalizerwin_bands[i], val); | |
1090 } | |
1091 equalizerwin_eq_changed(); | |
1092 } | |
1093 | |
1094 static void | |
1095 equalizerwin_save_ok(GtkWidget * widget, gpointer data) | |
1096 { | |
1097 const gchar *text; | |
1098 | |
1099 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry)); | |
1100 if (strlen(text) != 0) | |
1101 equalizer_presets = | |
1102 equalizerwin_save_preset(equalizer_presets, text, "eq.preset"); | |
1103 gtk_widget_destroy(equalizerwin_save_window); | |
1104 } | |
1105 | |
1106 static void | |
1107 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1108 GtkTreeViewColumn *col, gpointer data) |
2313 | 1109 { |
1110 gchar *text; | |
1111 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1112 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1113 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1114 GtkTreeIter iter; |
2313 | 1115 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1116 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1117 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1118 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1119 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1120 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1121 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1122 equalizerwin_save_ok(NULL, NULL); |
2313 | 1123 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1124 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1125 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1126 } |
2313 | 1127 } |
1128 | |
1129 static void | |
1130 equalizerwin_load_ok(GtkWidget *widget, gpointer data) | |
1131 { | |
1132 gchar *text; | |
1133 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1134 GtkTreeView* view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1135 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1136 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1137 GtkTreeIter iter; |
2313 | 1138 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1139 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1140 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1141 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1142 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1143 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1144 equalizerwin_load_preset(equalizer_presets, text); |
2313 | 1145 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1146 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1147 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1148 } |
2313 | 1149 gtk_widget_destroy(equalizerwin_load_window); |
1150 } | |
1151 | |
1152 static void | |
1153 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1154 GtkTreeViewColumn *col, gpointer data) |
2313 | 1155 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1156 equalizerwin_load_ok(NULL, treeview); |
2313 | 1157 } |
1158 | |
1159 static void | |
1160 equalizerwin_delete_delete(GtkWidget *widget, gpointer data) | |
1161 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1162 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset"); |
2313 | 1163 } |
1164 | |
1165 static void | |
1166 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data) | |
1167 { | |
1168 const gchar *text; | |
1169 | |
1170 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry)); | |
1171 if (strlen(text) != 0) | |
1172 equalizer_auto_presets = | |
1173 equalizerwin_save_preset(equalizer_auto_presets, text, | |
1174 "eq.auto_preset"); | |
1175 gtk_widget_destroy(equalizerwin_save_auto_window); | |
1176 } | |
1177 | |
1178 static void | |
1179 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1180 GtkTreeViewColumn *col, gpointer data) |
2313 | 1181 { |
1182 gchar *text; | |
1183 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1184 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1185 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1186 GtkTreeIter iter; |
2313 | 1187 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1188 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1189 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1190 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1191 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1192 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1193 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1194 equalizerwin_save_auto_ok(NULL, NULL); |
2313 | 1195 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1196 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1197 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1198 } |
2313 | 1199 } |
1200 | |
1201 static void | |
1202 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data) | |
1203 { | |
1204 gchar *text; | |
1205 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1206 GtkTreeView *view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1207 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1208 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1209 GtkTreeIter iter; |
2313 | 1210 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1211 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1212 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1213 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1214 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1215 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1216 equalizerwin_load_preset(equalizer_auto_presets, text); |
2313 | 1217 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1218 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1219 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1220 } |
2313 | 1221 gtk_widget_destroy(equalizerwin_load_auto_window); |
1222 } | |
1223 | |
1224 static void | |
1225 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1226 GtkTreeViewColumn *col, gpointer data) |
2313 | 1227 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1228 equalizerwin_load_auto_ok(NULL, treeview); |
2313 | 1229 } |
1230 | |
1231 static void | |
1232 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data) | |
1233 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1234 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset"); |
2313 | 1235 } |
1236 | |
1237 | |
1238 static void | |
1239 load_preset_file(const gchar *filename) | |
1240 { | |
1241 RcFile *rcfile; | |
1242 | |
1243 if ((rcfile = bmp_rcfile_open(filename)) != NULL) { | |
1244 equalizerwin_read_bmp_preset(rcfile); | |
1245 bmp_rcfile_free(rcfile); | |
1246 } | |
1247 } | |
1248 | |
1249 static void | |
1250 load_winamp_file(const gchar * filename) | |
1251 { | |
1252 VFSFile *file; | |
1253 gchar *tmp; | |
1254 | |
1255 if (!(file = vfs_fopen(filename, "rb"))) { | |
1256 tmp = g_strconcat("Failed to load WinAmp file: ",filename,"\n",NULL); | |
1257 report_error(tmp); | |
1258 g_free(tmp); | |
1259 return; | |
1260 } | |
1261 | |
1262 equalizerwin_read_winamp_eqf(file); | |
1263 vfs_fclose(file); | |
1264 } | |
1265 | |
1266 static void | |
1267 import_winamp_file(const gchar * filename) | |
1268 { | |
1269 VFSFile *file; | |
1270 gchar *tmp; | |
1271 | |
1272 if (!(file = vfs_fopen(filename, "rb"))) { | |
1273 tmp = g_strconcat("Failed to import WinAmp file: ",filename,"\n",NULL); | |
1274 report_error(tmp); | |
1275 g_free(tmp); | |
1276 return; | |
1277 } | |
1278 | |
1279 equalizer_presets = g_list_concat(equalizer_presets, | |
1280 import_winamp_eqf(file)); | |
1281 equalizerwin_write_preset_file(equalizer_presets, "eq.preset"); | |
1282 | |
1283 vfs_fclose(file); | |
1284 } | |
1285 | |
1286 static void | |
1287 save_preset_file(const gchar * filename) | |
1288 { | |
1289 RcFile *rcfile; | |
1290 gint i; | |
1291 | |
1292 rcfile = bmp_rcfile_new(); | |
1293 bmp_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", | |
1294 eqslider_get_position(equalizerwin_preamp)); | |
1295 | |
1296 for (i = 0; i < 10; i++) { | |
1297 gchar tmp[7]; | |
1298 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
1299 bmp_rcfile_write_float(rcfile, "Equalizer preset", tmp, | |
1300 eqslider_get_position(equalizerwin_bands[i])); | |
1301 } | |
1302 | |
1303 bmp_rcfile_write(rcfile, filename); | |
1304 bmp_rcfile_free(rcfile); | |
1305 } | |
1306 | |
1307 static void | |
1308 save_winamp_file(const gchar * filename) | |
1309 { | |
1310 VFSFile *file; | |
1311 | |
1312 gchar name[257]; | |
1313 gint i; | |
1314 guchar bands[11]; | |
1315 gchar *tmp; | |
1316 | |
1317 if (!(file = vfs_fopen(filename, "wb"))) { | |
1318 tmp = g_strconcat("Failed to save WinAmp file: ",filename,"\n",NULL); | |
1319 report_error(tmp); | |
1320 g_free(tmp); | |
1321 return; | |
1322 } | |
1323 | |
1324 vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file); | |
1325 | |
1326 memset(name, 0, 257); | |
1327 strcpy(name, "Entry1"); | |
1328 vfs_fwrite(name, 1, 257, file); | |
1329 | |
1330 for (i = 0; i < 10; i++) | |
1331 bands[i] = 63 - (((eqslider_get_position(equalizerwin_bands[i]) + 20) * 63) / 40); | |
1332 bands[10] = 63 - (((eqslider_get_position(equalizerwin_preamp) + 20) * 63) / 40); | |
1333 vfs_fwrite(bands, 1, 11, file); | |
1334 | |
1335 vfs_fclose(file); | |
1336 } | |
1337 | |
1338 static GtkWidget * | |
1339 equalizerwin_create_list_window(GList *preset_list, | |
1340 const gchar *title, | |
1341 GtkWidget **window, | |
1342 GtkSelectionMode sel_mode, | |
1343 GtkWidget **entry, | |
1344 const gchar *action_name, | |
1345 GCallback action_func, | |
1346 GCallback select_row_func) | |
1347 { | |
1348 GtkWidget *vbox, *scrolled_window, *bbox, *view; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1349 GtkWidget *button_cancel, *button_action; |
2313 | 1350 GList *node; |
1351 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1352 GtkListStore *store; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1353 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1354 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1355 GtkCellRenderer *renderer; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1356 GtkTreeSelection *selection; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1357 GtkTreeSortable *sortable; |
2313 | 1358 |
1359 | |
1360 | |
1361 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1362 gtk_window_set_title(GTK_WINDOW(*window), title); | |
1363 gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
1364 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300); | |
1365 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER); | |
1366 gtk_container_set_border_width(GTK_CONTAINER(*window), 10); | |
1367 gtk_window_set_transient_for(GTK_WINDOW(*window), | |
1368 GTK_WINDOW(equalizerwin)); | |
1369 g_signal_connect(*window, "destroy", | |
1370 G_CALLBACK(gtk_widget_destroyed), window); | |
1371 | |
1372 vbox = gtk_vbox_new(FALSE, 10); | |
1373 gtk_container_add(GTK_CONTAINER(*window), vbox); | |
1374 | |
1375 scrolled_window = gtk_scrolled_window_new(NULL, NULL); | |
1376 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), | |
1377 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1378 | |
1379 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1380 /* fill the store with the names of all available presets */ |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1381 store = gtk_list_store_new(1, G_TYPE_STRING); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1382 for (node = preset_list; node; node = g_list_next(node)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1383 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1384 gtk_list_store_append(store, &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1385 gtk_list_store_set(store, &iter, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1386 0, ((EqualizerPreset*)node->data)->name, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1387 -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1388 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1389 model = GTK_TREE_MODEL(store); |
2313 | 1390 |
1391 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1392 sortable = GTK_TREE_SORTABLE(store); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1393 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING); |
2313 | 1394 |
1395 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1396 view = gtk_tree_view_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1397 renderer = gtk_cell_renderer_text_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1398 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1399 _("Presets"), renderer, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1400 "text", 0, NULL); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1401 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1402 g_object_unref(model); |
2313 | 1403 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1404 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1405 gtk_tree_selection_set_mode(selection, sel_mode); |
2313 | 1406 |
1407 | |
1408 | |
1409 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1410 gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
2313 | 1411 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); |
1412 | |
1413 if (entry) { | |
1414 *entry = gtk_entry_new(); | |
1415 g_signal_connect(*entry, "activate", action_func, NULL); | |
1416 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0); | |
1417 } | |
1418 | |
1419 bbox = gtk_hbutton_box_new(); | |
1420 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1421 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1422 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1423 | |
1424 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1425 g_signal_connect_swapped(button_cancel, "clicked", | |
1426 G_CALLBACK(gtk_widget_destroy), | |
1427 GTK_OBJECT(*window)); | |
1428 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0); | |
1429 | |
1430 button_action = gtk_button_new_from_stock(action_name); | |
1431 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view); | |
1432 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT); | |
1433 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1434 if (select_row_func) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1435 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL); |
2313 | 1436 |
1437 | |
1438 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0); | |
1439 | |
1440 gtk_widget_grab_default(button_action); | |
1441 | |
1442 | |
1443 gtk_widget_show_all(*window); | |
1444 | |
1445 return *window; | |
1446 } | |
1447 | |
1448 void | |
1449 equalizerwin_load_auto_preset(const gchar * filename) | |
1450 { | |
1451 gchar *presetfilename, *directory; | |
1452 RcFile *rcfile; | |
1453 | |
1454 g_return_if_fail(filename != NULL); | |
1455 | |
1456 if (!cfg.equalizer_autoload) | |
1457 return; | |
1458 | |
1459 presetfilename = g_strconcat(filename, ".", cfg.eqpreset_extension, NULL); | |
1460 | |
1461 /* First try to find a per file preset file */ | |
1462 if (strlen(cfg.eqpreset_extension) > 0 && | |
1463 (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { | |
1464 g_free(presetfilename); | |
1465 equalizerwin_read_bmp_preset(rcfile); | |
1466 bmp_rcfile_free(rcfile); | |
1467 return; | |
1468 } | |
1469 | |
1470 g_free(presetfilename); | |
1471 | |
1472 directory = g_path_get_dirname(filename); | |
1473 presetfilename = g_build_filename(directory, cfg.eqpreset_default_file, | |
1474 NULL); | |
1475 g_free(directory); | |
1476 | |
1477 /* Try to find a per directory preset file */ | |
1478 if (strlen(cfg.eqpreset_default_file) > 0 && | |
1479 (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { | |
1480 equalizerwin_read_bmp_preset(rcfile); | |
1481 bmp_rcfile_free(rcfile); | |
1482 } | |
1483 else if (!equalizerwin_load_preset | |
1484 (equalizer_auto_presets, g_basename(filename))) { | |
1485 /* Fall back to the oldstyle auto presets */ | |
1486 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1487 } | |
1488 | |
1489 g_free(presetfilename); | |
1490 } | |
1491 | |
1492 void | |
1493 equalizerwin_set_preamp(gfloat preamp) | |
1494 { | |
1495 eqslider_set_position(equalizerwin_preamp, preamp); | |
1496 equalizerwin_eq_changed(); | |
1497 } | |
1498 | |
1499 void | |
1500 equalizerwin_set_band(gint band, gfloat value) | |
1501 { | |
1502 g_return_if_fail(band >= 0 && band < 10); | |
1503 eqslider_set_position(equalizerwin_bands[band], value); | |
1504 } | |
1505 | |
1506 gfloat | |
1507 equalizerwin_get_preamp(void) | |
1508 { | |
1509 return eqslider_get_position(equalizerwin_preamp); | |
1510 } | |
1511 | |
1512 gfloat | |
1513 equalizerwin_get_band(gint band) | |
1514 { | |
1515 g_return_val_if_fail(band >= 0 && band < 10, 0); | |
1516 return eqslider_get_position(equalizerwin_bands[band]); | |
1517 } | |
1518 | |
1519 void | |
1520 action_equ_load_preset(void) | |
1521 { | |
1522 if (equalizerwin_load_window) { | |
1523 gtk_window_present(GTK_WINDOW(equalizerwin_load_window)); | |
1524 return; | |
1525 } | |
1526 | |
1527 equalizerwin_create_list_window(equalizer_presets, | |
1528 Q_("Load preset"), | |
1529 &equalizerwin_load_window, | |
1530 GTK_SELECTION_SINGLE, NULL, | |
1531 GTK_STOCK_OK, | |
1532 G_CALLBACK(equalizerwin_load_ok), | |
1533 G_CALLBACK(equalizerwin_load_select)); | |
1534 } | |
1535 | |
1536 void | |
1537 action_equ_load_auto_preset(void) | |
1538 { | |
1539 if (equalizerwin_load_auto_window) { | |
1540 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window)); | |
1541 return; | |
1542 } | |
1543 | |
1544 equalizerwin_create_list_window(equalizer_auto_presets, | |
1545 Q_("Load auto-preset"), | |
1546 &equalizerwin_load_auto_window, | |
1547 GTK_SELECTION_SINGLE, NULL, | |
1548 GTK_STOCK_OK, | |
1549 G_CALLBACK(equalizerwin_load_auto_ok), | |
1550 G_CALLBACK(equalizerwin_load_auto_select)); | |
1551 } | |
1552 | |
1553 void | |
1554 action_equ_load_default_preset(void) | |
1555 { | |
1556 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1557 } | |
1558 | |
1559 void | |
1560 action_equ_zero_preset(void) | |
1561 { | |
1562 gint i; | |
1563 | |
1564 eqslider_set_position(equalizerwin_preamp, 0); | |
1565 for (i = 0; i < 10; i++) | |
1566 eqslider_set_position(equalizerwin_bands[i], 0); | |
1567 | |
1568 equalizerwin_eq_changed(); | |
1569 } | |
1570 | |
1571 void | |
1572 action_equ_load_preset_file(void) | |
1573 { | |
1574 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1575 gchar *filename; |
2313 | 1576 |
1577 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1578 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1579 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1580 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1581 load_preset_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1582 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1583 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1584 gtk_widget_destroy(dialog); |
2313 | 1585 } |
1586 | |
1587 void | |
1588 action_equ_load_preset_eqf(void) | |
1589 { | |
1590 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1591 gchar *filename; |
2313 | 1592 |
1593 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1594 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1595 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1596 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1597 load_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1598 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1599 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1600 gtk_widget_destroy(dialog); |
2313 | 1601 } |
1602 | |
1603 void | |
1604 action_equ_import_winamp_presets(void) | |
1605 { | |
1606 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1607 gchar *filename; |
2313 | 1608 |
1609 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1610 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1611 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1612 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1613 import_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1614 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1615 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1616 gtk_widget_destroy(dialog); |
2313 | 1617 } |
1618 | |
1619 void | |
1620 action_equ_save_preset(void) | |
1621 { | |
1622 if (equalizerwin_save_window) { | |
1623 gtk_window_present(GTK_WINDOW(equalizerwin_save_window)); | |
1624 return; | |
1625 } | |
1626 | |
1627 equalizerwin_create_list_window(equalizer_presets, | |
1628 Q_("Save preset"), | |
1629 &equalizerwin_save_window, | |
1630 GTK_SELECTION_SINGLE, | |
1631 &equalizerwin_save_entry, | |
1632 GTK_STOCK_OK, | |
1633 G_CALLBACK(equalizerwin_save_ok), | |
1634 G_CALLBACK(equalizerwin_save_select)); | |
1635 } | |
1636 | |
1637 void | |
1638 action_equ_save_auto_preset(void) | |
1639 { | |
1640 gchar *name; | |
1641 Playlist *playlist = playlist_get_active(); | |
1642 | |
1643 if (equalizerwin_save_auto_window) | |
1644 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window)); | |
1645 else | |
1646 equalizerwin_create_list_window(equalizer_auto_presets, | |
1647 Q_("Save auto-preset"), | |
1648 &equalizerwin_save_auto_window, | |
1649 GTK_SELECTION_SINGLE, | |
1650 &equalizerwin_save_auto_entry, | |
1651 GTK_STOCK_OK, | |
1652 G_CALLBACK(equalizerwin_save_auto_ok), | |
1653 G_CALLBACK(equalizerwin_save_auto_select)); | |
1654 | |
1655 name = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1656 if (name) { | |
1657 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), | |
1658 g_basename(name)); | |
1659 g_free(name); | |
1660 } | |
1661 } | |
1662 | |
1663 void | |
1664 action_equ_save_default_preset(void) | |
1665 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1666 equalizer_presets = |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1667 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset"); |
2313 | 1668 } |
1669 | |
1670 void | |
1671 action_equ_save_preset_file(void) | |
1672 { | |
1673 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1674 gchar *filename; |
2313 | 1675 gchar *songname; |
1676 Playlist *playlist = playlist_get_active(); | |
1677 | |
1678 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1679 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1680 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1681 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1682 save_preset_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1683 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1684 } |
2313 | 1685 |
1686 songname = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1687 if (songname) { | |
1688 gchar *eqname = g_strdup_printf("%s.%s", songname, | |
1689 cfg.eqpreset_extension); | |
1690 g_free(songname); | |
1691 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
1692 eqname); | |
1693 g_free(eqname); | |
1694 } | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1695 |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1696 gtk_widget_destroy(dialog); |
2313 | 1697 } |
1698 | |
1699 void | |
1700 action_equ_save_preset_eqf(void) | |
1701 { | |
1702 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1703 gchar *filename; |
2313 | 1704 |
1705 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1706 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1707 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1708 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1709 save_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1710 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1711 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1712 gtk_widget_destroy(dialog); |
2313 | 1713 } |
1714 | |
1715 void | |
1716 action_equ_delete_preset(void) | |
1717 { | |
1718 if (equalizerwin_delete_window) { | |
1719 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window)); | |
1720 return; | |
1721 } | |
1722 | |
1723 equalizerwin_create_list_window(equalizer_presets, | |
1724 Q_("Delete preset"), | |
1725 &equalizerwin_delete_window, | |
1726 GTK_SELECTION_EXTENDED, NULL, | |
1727 GTK_STOCK_DELETE, | |
1728 G_CALLBACK(equalizerwin_delete_delete), | |
1729 NULL); | |
1730 } | |
1731 | |
1732 void | |
1733 action_equ_delete_auto_preset(void) | |
1734 { | |
1735 if (equalizerwin_delete_auto_window) { | |
1736 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window)); | |
1737 return; | |
1738 } | |
1739 | |
1740 equalizerwin_create_list_window(equalizer_auto_presets, | |
1741 Q_("Delete auto-preset"), | |
1742 &equalizerwin_delete_auto_window, | |
1743 GTK_SELECTION_EXTENDED, NULL, | |
1744 GTK_STOCK_DELETE, | |
1745 G_CALLBACK(equalizerwin_delete_auto_delete), | |
1746 NULL); | |
1747 } |