annotate audacious/equalizer.c @ 1294:447c70bfa3db trunk

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