Mercurial > audlegacy
annotate src/audacious/ui_equalizer.c @ 4520:917112233875
remove some redundant code
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Mon, 28 Apr 2008 00:14:46 +0200 |
parents | 6e412073cf28 |
children | d4c5719d30d1 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3102
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3102
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
26 /*#define AUD_DEBUG*/ |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
27 |
2313 | 28 #ifdef HAVE_CONFIG_H |
29 # include "config.h" | |
30 #endif | |
31 | |
32 #include "ui_equalizer.h" | |
33 | |
34 #include <glib.h> | |
35 #include <glib/gi18n.h> | |
36 #include <gtk/gtk.h> | |
37 #include <stdio.h> | |
38 #include <math.h> | |
39 #include <string.h> | |
40 | |
41 #include "platform/smartinclude.h" | |
4508
246244ead30e
renamed skin.* to ui_skin.* and moved ui_skinned_widget_draw() to it
mf0102 <0102@gmx.at>
parents:
4504
diff
changeset
|
42 #include "ui_skin.h" |
2313 | 43 #include "dock.h" |
44 #include "input.h" | |
45 #include "main.h" | |
46 #include "ui_manager.h" | |
47 #include "actions-equalizer.h" | |
48 #include "playlist.h" | |
49 #include "ui_playlist.h" | |
50 #include "util.h" | |
51 #include "output.h" | |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
52 #include "equalizer_flow.h" |
2313 | 53 |
2537 | 54 #include "rcfile.h" |
2313 | 55 #include "vfs.h" |
56 | |
57 #include "images/audacious_eq.xpm" | |
58 | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
59 #include "ui_skinned_window.h" |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
60 #include "ui_skinned_button.h" |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
61 #include "ui_skinned_horizontal_slider.h" |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
62 #include "ui_skinned_equalizer_slider.h" |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
3098
diff
changeset
|
63 #include "ui_skinned_equalizer_graph.h" |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
64 |
2313 | 65 enum PresetViewCols { |
66 PRESET_VIEW_COL_NAME, | |
67 PRESET_VIEW_N_COLS | |
68 }; | |
69 | |
70 struct _EqualizerPreset { | |
71 gchar *name; | |
72 gfloat preamp, bands[10]; | |
73 }; | |
74 | |
75 typedef struct _EqualizerPreset EqualizerPreset; | |
76 | |
77 | |
78 GtkWidget *equalizerwin; | |
3918
a318d4b479d2
hide equalizer graph in special skins (needed for a certain skin)
mf0102 <0102@gmx.at>
parents:
3917
diff
changeset
|
79 GtkWidget *equalizerwin_graph; |
2313 | 80 |
81 static GtkWidget *equalizerwin_load_window = NULL; | |
82 static GtkWidget *equalizerwin_load_auto_window = NULL; | |
83 static GtkWidget *equalizerwin_save_window = NULL; | |
84 static GtkWidget *equalizerwin_save_entry = NULL; | |
85 static GtkWidget *equalizerwin_save_auto_window = NULL; | |
86 static GtkWidget *equalizerwin_save_auto_entry = NULL; | |
87 static GtkWidget *equalizerwin_delete_window = NULL; | |
88 static GtkWidget *equalizerwin_delete_auto_window = NULL; | |
89 | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
90 static GtkWidget *equalizerwin_on, *equalizerwin_auto; |
2313 | 91 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
92 static GtkWidget *equalizerwin_close, *equalizerwin_presets, *equalizerwin_shade; |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
93 static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10]; |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
94 static GtkWidget *equalizerwin_volume, *equalizerwin_balance; |
2313 | 95 |
96 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL; | |
97 | |
98 EqualizerPreset * | |
99 equalizer_preset_new(const gchar * name) | |
100 { | |
101 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); | |
102 preset->name = g_strdup(name); | |
103 return preset; | |
104 } | |
105 | |
106 void | |
107 equalizer_preset_free(EqualizerPreset * preset) | |
108 { | |
109 if (!preset) | |
110 return; | |
111 | |
112 g_free(preset->name); | |
113 g_free(preset); | |
114 } | |
115 | |
116 void | |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
117 equalizerwin_set_scaled(gboolean ds) |
2313 | 118 { |
119 gint height; | |
120 | |
121 if (cfg.equalizer_shaded) | |
122 height = 14; | |
123 else | |
124 height = 116; | |
125 | |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
126 if (cfg.scaled) { |
4219
8a848179e244
fixed the eqalizer window
Cristi Magherusan <majeru@atheme.org>
parents:
4216
diff
changeset
|
127 dock_window_resize(GTK_WINDOW(equalizerwin), 275 * cfg.scale_factor, |
8a848179e244
fixed the eqalizer window
Cristi Magherusan <majeru@atheme.org>
parents:
4216
diff
changeset
|
128 height * cfg.scale_factor, 275 * cfg.scale_factor, height * cfg.scale_factor); |
3243 | 129 } else { |
2313 | 130 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height, 275, height); |
131 } | |
132 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
133 GList *iter; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
134 for (iter = GTK_FIXED (SKINNED_WINDOW(equalizerwin)->fixed)->children; iter; iter = g_list_next (iter)) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
135 GtkFixedChild *child_data = (GtkFixedChild *) iter->data; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
136 GtkWidget *child = child_data->widget; |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
137 g_signal_emit_by_name(child, "toggle-scaled"); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
138 } |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
139 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + cfg.equalizer_shaded), 0, 0); |
2313 | 140 } |
141 | |
142 void | |
143 equalizerwin_set_shade_menu_cb(gboolean shaded) | |
144 { | |
145 cfg.equalizer_shaded = shaded; | |
146 | |
147 if (shaded) { | |
4517 | 148 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin), |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
149 14 * EQUALIZER_SCALE_FACTOR); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
150 ui_skinned_set_push_button_data(equalizerwin_shade, -1, 3, -1, 47); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
151 ui_skinned_button_set_skin_index1(equalizerwin_shade, SKIN_EQ_EX); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
152 ui_skinned_set_push_button_data(equalizerwin_close, 11, 38, 11, 47); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
153 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQ_EX); |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
154 gtk_widget_show(equalizerwin_volume); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
155 gtk_widget_show(equalizerwin_balance); |
2313 | 156 } |
157 else { | |
4517 | 158 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin), |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
159 116 * EQUALIZER_SCALE_FACTOR); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
160 ui_skinned_set_push_button_data(equalizerwin_shade, -1, 137, -1, 38); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
161 ui_skinned_button_set_skin_index1(equalizerwin_shade, SKIN_EQMAIN); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
162 ui_skinned_set_push_button_data(equalizerwin_close, 0, 116, 0, 125); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
163 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQMAIN); |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
164 gtk_widget_hide(equalizerwin_volume); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
165 gtk_widget_hide(equalizerwin_balance); |
2313 | 166 } |
4131 | 167 |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
168 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + cfg.equalizer_shaded), 0, 0); |
2313 | 169 } |
170 | |
171 static void | |
172 equalizerwin_set_shade(gboolean shaded) | |
173 { | |
174 GtkAction *action = gtk_action_group_get_action( | |
175 toggleaction_group_others , "roll up equalizer" ); | |
176 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
177 } | |
178 | |
179 static void | |
180 equalizerwin_shade_toggle(void) | |
181 { | |
182 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
183 } | |
184 | |
185 void | |
186 equalizerwin_eq_changed(void) | |
187 { | |
188 gint i; | |
189 | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
190 cfg.equalizer_preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); |
2313 | 191 for (i = 0; i < 10; i++) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
192 cfg.equalizer_bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]); |
2313 | 193 /* um .. i think we need both of these for xmms compatibility .. |
194 not sure. -larne */ | |
195 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
196 cfg.equalizer_bands); | |
197 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
198 cfg.equalizer_bands); | |
199 | |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
3098
diff
changeset
|
200 gtk_widget_queue_draw(equalizerwin_graph); |
2313 | 201 } |
202 | |
203 static void | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
204 equalizerwin_on_pushed(void) |
2313 | 205 { |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
206 cfg.equalizer_active = UI_SKINNED_BUTTON(equalizerwin_on)->inside; |
2313 | 207 equalizerwin_eq_changed(); |
208 } | |
209 | |
210 static void | |
211 equalizerwin_presets_pushed(void) | |
212 { | |
213 GdkModifierType modmask; | |
214 gint x, y; | |
215 | |
216 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
217 ui_manager_popup_menu_show(GTK_MENU(equalizerwin_presets_menu), x, y, 1, GDK_CURRENT_TIME); | |
218 } | |
219 | |
220 static void | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
221 equalizerwin_auto_pushed(void) |
2313 | 222 { |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
223 cfg.equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside; |
2313 | 224 } |
225 | |
226 gboolean | |
227 equalizerwin_press(GtkWidget * widget, GdkEventButton * event, | |
228 gpointer callback_data) | |
229 { | |
230 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
3218
018b37cf0730
hasta la vista old widgetcore
Tomasz Mon <desowin@gmail.com>
parents:
3123
diff
changeset
|
231 (cfg.easy_move || cfg.equalizer_shaded || event->y < 14)) { |
4517 | 232 dock_move_press(get_dock_window_list(), GTK_WINDOW(equalizerwin), event, |
2497
204d1bab71f9
[svn] - if (0 && hint_move_resize_available()) -- i'm not sure how this linked as we do not have a hint_move_resize_available().
nenolod
parents:
2495
diff
changeset
|
233 FALSE); |
2313 | 234 } |
235 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS | |
236 && event->y < 14) { | |
237 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
238 if (dock_is_moving(GTK_WINDOW(equalizerwin))) | |
239 dock_move_release(GTK_WINDOW(equalizerwin)); | |
240 } | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
241 else if (event->button == 3) { |
2313 | 242 /* |
243 * Pop up the main menu a few pixels down to avoid | |
244 * anything to be selected initially. | |
245 */ | |
246 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
247 event->y_root + 2, 3, event->time); | |
248 } | |
3102 | 249 |
2313 | 250 return FALSE; |
251 } | |
252 | |
253 static gboolean | |
254 equalizerwin_release(GtkWidget * widget, | |
255 GdkEventButton * event, gpointer callback_data) | |
256 { | |
257 if (dock_is_moving(GTK_WINDOW(equalizerwin))) { | |
258 dock_move_release(GTK_WINDOW(equalizerwin)); | |
259 } | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
260 |
2313 | 261 return FALSE; |
262 } | |
263 | |
264 static gboolean | |
265 equalizerwin_keypress(GtkWidget * widget, | |
266 GdkEventKey * event, | |
267 gpointer data) | |
268 { | |
3350
1292e4ca0f08
press ctrl+tab to switch between windows
Tomasz Mon <desowin@gmail.com>
parents:
3311
diff
changeset
|
269 if (event->keyval == GDK_Tab && event->state & GDK_CONTROL_MASK) { |
4117
a5779105e6d2
on ctrl-tab switch only between visible windows (Bugzilla #14)
Tomasz Mon <desowin@gmail.com>
parents:
4103
diff
changeset
|
270 if (cfg.playlist_visible) |
a5779105e6d2
on ctrl-tab switch only between visible windows (Bugzilla #14)
Tomasz Mon <desowin@gmail.com>
parents:
4103
diff
changeset
|
271 gtk_window_present(GTK_WINDOW(playlistwin)); |
a5779105e6d2
on ctrl-tab switch only between visible windows (Bugzilla #14)
Tomasz Mon <desowin@gmail.com>
parents:
4103
diff
changeset
|
272 else if (cfg.player_visible) |
a5779105e6d2
on ctrl-tab switch only between visible windows (Bugzilla #14)
Tomasz Mon <desowin@gmail.com>
parents:
4103
diff
changeset
|
273 gtk_window_present(GTK_WINDOW(mainwin)); |
3350
1292e4ca0f08
press ctrl+tab to switch between windows
Tomasz Mon <desowin@gmail.com>
parents:
3311
diff
changeset
|
274 return TRUE; |
1292e4ca0f08
press ctrl+tab to switch between windows
Tomasz Mon <desowin@gmail.com>
parents:
3311
diff
changeset
|
275 } |
1292e4ca0f08
press ctrl+tab to switch between windows
Tomasz Mon <desowin@gmail.com>
parents:
3311
diff
changeset
|
276 |
2313 | 277 if (!cfg.equalizer_shaded) { |
278 gtk_widget_event(mainwin, (GdkEvent *) event); | |
279 return TRUE; | |
280 } | |
281 | |
282 switch (event->keyval) { | |
283 case GDK_Left: | |
284 case GDK_KP_Left: | |
285 mainwin_set_balance_diff(-4); | |
286 break; | |
287 case GDK_Right: | |
288 case GDK_KP_Right: | |
289 mainwin_set_balance_diff(4); | |
290 break; | |
291 default: | |
292 gtk_widget_event(mainwin, (GdkEvent *) event); | |
293 break; | |
294 } | |
295 | |
296 return FALSE; | |
297 } | |
298 | |
299 static void | |
300 equalizerwin_close_cb(void) | |
301 { | |
302 equalizerwin_show(FALSE); | |
303 } | |
304 | |
305 static gboolean | |
306 equalizerwin_delete(GtkWidget * widget, | |
307 gpointer data) | |
308 { | |
309 equalizerwin_show(FALSE); | |
310 return TRUE; | |
311 } | |
312 | |
313 static GList * | |
314 equalizerwin_read_presets(const gchar * basename) | |
315 { | |
316 gchar *filename, *name; | |
317 RcFile *rcfile; | |
318 GList *list = NULL; | |
319 gint i, p = 0; | |
320 EqualizerPreset *preset; | |
321 | |
3238
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
322 /* START mod: add check for the default presets locate in system path ({prefix}/share/audacious) |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
323 by Massimo Cavalleri (submax) */ |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
324 |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
325 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL); |
2313 | 326 |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
327 if ((rcfile = aud_rcfile_open(filename)) == NULL) { |
2313 | 328 g_free(filename); |
3238
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
329 // DATA_DIR = "{prefix}/share/audacious" ; example is "/usr/share/audacious" |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
330 filename = g_build_filename(DATA_DIR, basename, NULL); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
331 if ((rcfile = aud_rcfile_open(filename)) == NULL) { |
3238
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
332 g_free(filename); |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
333 return NULL; |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
334 } |
2313 | 335 } |
336 | |
3238
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
337 // END mod |
ceaaadccfa00
Add a system path for default presets.
William Pitcock <nenolod@atheme-project.org>
parents:
3221
diff
changeset
|
338 |
2313 | 339 g_free(filename); |
340 | |
341 for (;;) { | |
342 gchar section[21]; | |
343 | |
344 g_snprintf(section, sizeof(section), "Preset%d", p++); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
345 if (aud_rcfile_read_string(rcfile, "Presets", section, &name)) { |
2313 | 346 preset = g_new0(EqualizerPreset, 1); |
347 preset->name = name; | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
348 aud_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); |
2313 | 349 for (i = 0; i < 10; i++) { |
350 gchar band[7]; | |
351 g_snprintf(band, sizeof(band), "Band%d", i); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
352 aud_rcfile_read_float(rcfile, name, band, &preset->bands[i]); |
2313 | 353 } |
354 list = g_list_prepend(list, preset); | |
355 } | |
356 else | |
357 break; | |
358 } | |
359 list = g_list_reverse(list); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
360 aud_rcfile_free(rcfile); |
2313 | 361 return list; |
362 } | |
363 | |
364 gint | |
365 equalizerwin_volume_frame_cb(gint pos) | |
366 { | |
367 if (equalizerwin_volume) { | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
368 gint x; |
2313 | 369 if (pos < 32) |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
370 x = 1; |
2313 | 371 else if (pos < 63) |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
372 x = 4; |
2313 | 373 else |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
374 x = 7; |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
375 |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
376 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_nx = x; |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
377 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_px = x; |
2313 | 378 } |
379 return 1; | |
380 } | |
381 | |
382 static void | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
383 equalizerwin_volume_motion_cb(GtkWidget *widget, gint pos) |
2313 | 384 { |
385 gint v = (gint) rint(pos * 100 / 94.0); | |
386 mainwin_adjust_volume_motion(v); | |
387 mainwin_set_volume_slider(v); | |
388 } | |
389 | |
390 static void | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
391 equalizerwin_volume_release_cb(GtkWidget *widget, gint pos) |
2313 | 392 { |
393 mainwin_adjust_volume_release(); | |
394 } | |
395 | |
396 static gint | |
397 equalizerwin_balance_frame_cb(gint pos) | |
398 { | |
399 if (equalizerwin_balance) { | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
400 gint x; |
2313 | 401 if (pos < 13) |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
402 x = 11; |
2313 | 403 else if (pos < 26) |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
404 x = 14; |
2313 | 405 else |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
406 x = 17; |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
407 |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
408 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_nx = x; |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
409 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_px = x; |
2313 | 410 } |
411 | |
412 return 1; | |
413 } | |
414 | |
415 static void | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
416 equalizerwin_balance_motion_cb(GtkWidget *widget, gint pos) |
2313 | 417 { |
418 gint b; | |
419 pos = MIN(pos, 38); /* The skin uses a even number of pixels | |
420 for the balance-slider *sigh* */ | |
421 b = (gint) rint((pos - 19) * 100 / 19.0); | |
422 mainwin_adjust_balance_motion(b); | |
423 mainwin_set_balance_slider(b); | |
424 } | |
425 | |
426 static void | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
427 equalizerwin_balance_release_cb(GtkWidget *widget, gint pos) |
2313 | 428 { |
429 mainwin_adjust_balance_release(); | |
430 } | |
431 | |
432 void | |
433 equalizerwin_set_balance_slider(gint percent) | |
434 { | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
435 ui_skinned_horizontal_slider_set_position(equalizerwin_balance, |
2313 | 436 (gint) rint((percent * 19 / 100.0) + 19)); |
437 } | |
438 | |
439 void | |
440 equalizerwin_set_volume_slider(gint percent) | |
441 { | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
442 ui_skinned_horizontal_slider_set_position(equalizerwin_volume, |
2313 | 443 (gint) rint(percent * 94 / 100.0)); |
444 } | |
445 | |
446 static void | |
447 equalizerwin_create_widgets(void) | |
448 { | |
449 gint i; | |
450 | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
451 equalizerwin_on = ui_skinned_button_new(); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
452 ui_skinned_toggle_button_setup(equalizerwin_on, SKINNED_WINDOW(equalizerwin)->fixed, |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
453 14, 18, 25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN); |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
454 g_signal_connect(equalizerwin_on, "clicked", equalizerwin_on_pushed, NULL); |
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
455 UI_SKINNED_BUTTON(equalizerwin_on)->inside = cfg.equalizer_active; |
2524 | 456 |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
457 equalizerwin_auto = ui_skinned_button_new(); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
458 ui_skinned_toggle_button_setup(equalizerwin_auto, SKINNED_WINDOW(equalizerwin)->fixed, |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
459 39, 18, 33, 12, 35, 119, 153, 119, 94, 119, 212, 119, SKIN_EQMAIN); |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
460 g_signal_connect(equalizerwin_auto, "clicked", equalizerwin_auto_pushed, NULL); |
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
461 UI_SKINNED_BUTTON(equalizerwin_auto)->inside = cfg.equalizer_autoload; |
2524 | 462 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
463 equalizerwin_presets = ui_skinned_button_new(); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
464 ui_skinned_push_button_setup(equalizerwin_presets, SKINNED_WINDOW(equalizerwin)->fixed, |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
465 217, 18, 44, 12, 224, 164, 224, 176, SKIN_EQMAIN); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
466 g_signal_connect(equalizerwin_presets, "clicked", equalizerwin_presets_pushed, NULL ); |
2524 | 467 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
468 equalizerwin_close = ui_skinned_button_new(); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
469 ui_skinned_push_button_setup(equalizerwin_close, SKINNED_WINDOW(equalizerwin)->fixed, |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
470 264, 3, 9, 9, 0, 116, 0, 125, SKIN_EQMAIN); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
471 g_signal_connect(equalizerwin_close, "clicked", equalizerwin_close_cb, NULL ); |
2313 | 472 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
473 equalizerwin_shade = ui_skinned_button_new(); |
3005
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
474 ui_skinned_push_button_setup(equalizerwin_shade, SKINNED_WINDOW(equalizerwin)->fixed, |
3db40ad79fd9
request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents:
3000
diff
changeset
|
475 254, 3, 9, 9, 254, 137, 1, 38, SKIN_EQMAIN); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
476 ui_skinned_button_set_skin_index2(equalizerwin_shade, SKIN_EQ_EX); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
477 g_signal_connect(equalizerwin_shade, "clicked", equalizerwin_shade_toggle, NULL ); |
2313 | 478 |
3101
b25db04ee2a1
replace EqGraph with UiSkinnedEqualizerGraph
Tomasz Mon <desowin@gmail.com>
parents:
3098
diff
changeset
|
479 equalizerwin_graph = ui_skinned_equalizer_graph_new(SKINNED_WINDOW(equalizerwin)->fixed, 86, 17); |
2524 | 480 |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
481 equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 21, 38); |
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
482 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, cfg.equalizer_preamp); |
2524 | 483 |
2313 | 484 for (i = 0; i < 10; i++) { |
485 equalizerwin_bands[i] = | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
486 ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 78 + (i * 18), 38); |
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
487 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]); |
2313 | 488 } |
489 | |
490 equalizerwin_volume = | |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
491 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
492 61, 4, 97, 8, 1, 30, 1, 30, 3, 7, 4, 61, 0, 94, |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
493 equalizerwin_volume_frame_cb, SKIN_EQ_EX); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
494 g_signal_connect(equalizerwin_volume, "motion", G_CALLBACK(equalizerwin_volume_motion_cb), NULL); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
495 g_signal_connect(equalizerwin_volume, "release", G_CALLBACK(equalizerwin_volume_release_cb), NULL); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
496 |
2524 | 497 |
2313 | 498 equalizerwin_balance = |
3049
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
499 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
500 164, 4, 42, 8, 11, 30, 11, 30, 3, 7, 4, 164, 0, 39, |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
501 equalizerwin_balance_frame_cb, SKIN_EQ_EX); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
502 g_signal_connect(equalizerwin_balance, "motion", G_CALLBACK(equalizerwin_balance_motion_cb), NULL); |
1a1116e50ad6
equalizerwin_volume and equalzerwin_balance are now UiSkinnedHorizontalSliders; hslider.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
3005
diff
changeset
|
503 g_signal_connect(equalizerwin_balance, "release", G_CALLBACK(equalizerwin_balance_release_cb), NULL); |
2313 | 504 } |
505 | |
506 | |
507 static void | |
508 equalizerwin_create_window(void) | |
509 { | |
510 GdkPixbuf *icon; | |
511 gint width, height; | |
512 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
513 width = 275; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
514 height = cfg.equalizer_shaded ? 14 : 116; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
515 |
3068
c5189bc4100b
Refactor skinned window code.
William Pitcock <nenolod@atheme-project.org>
parents:
3065
diff
changeset
|
516 equalizerwin = ui_skinned_window_new("equalizer"); |
2313 | 517 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer")); |
518 gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer"); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
519 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE); |
2313 | 520 |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
521 if (cfg.scaled && cfg.eq_scaled_linked) { |
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
522 width *= cfg.scale_factor; |
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
523 height *= cfg.scale_factor; |
2313 | 524 } |
525 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
526 gtk_widget_set_size_request(equalizerwin, width, height); |
2313 | 527 |
528 /* this will hide only mainwin. it's annoying! yaz */ | |
529 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin), | |
530 GTK_WINDOW(mainwin)); | |
531 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE); | |
532 | |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
533 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_eq_icon); |
2313 | 534 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon); |
535 g_object_unref(icon); | |
536 | |
537 gtk_widget_set_app_paintable(equalizerwin, TRUE); | |
538 | |
539 if (cfg.equalizer_x != -1 && cfg.save_window_position) | |
540 gtk_window_move(GTK_WINDOW(equalizerwin), | |
541 cfg.equalizer_x, cfg.equalizer_y); | |
542 | |
543 g_signal_connect(equalizerwin, "delete_event", | |
544 G_CALLBACK(equalizerwin_delete), NULL); | |
545 g_signal_connect(equalizerwin, "button_press_event", | |
546 G_CALLBACK(equalizerwin_press), NULL); | |
547 g_signal_connect(equalizerwin, "button_release_event", | |
548 G_CALLBACK(equalizerwin_release), NULL); | |
549 g_signal_connect(equalizerwin, "key_press_event", | |
550 G_CALLBACK(equalizerwin_keypress), NULL); | |
551 } | |
552 | |
553 void | |
554 equalizerwin_create(void) | |
555 { | |
556 equalizer_presets = equalizerwin_read_presets("eq.preset"); | |
557 equalizer_auto_presets = equalizerwin_read_presets("eq.auto_preset"); | |
558 | |
559 equalizerwin_create_window(); | |
560 | |
561 gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); | |
562 | |
563 equalizerwin_create_widgets(); | |
564 } | |
565 | |
566 | |
567 void | |
568 equalizerwin_show(gboolean show) | |
569 { | |
570 GtkAction *action = gtk_action_group_get_action( | |
571 toggleaction_group_others , "show equalizer" ); | |
572 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , show ); | |
573 | |
574 if (show) | |
575 equalizerwin_real_show(); | |
576 else | |
577 equalizerwin_real_hide(); | |
578 } | |
579 | |
580 void | |
581 equalizerwin_real_show(void) | |
582 { | |
2596
9903326fddf2
[svn] - reset the position of the equalizer window properly.
nenolod
parents:
2595
diff
changeset
|
583 gtk_window_move(GTK_WINDOW(equalizerwin), cfg.equalizer_x, cfg.equalizer_y); |
4216
75d99359357b
doublesize -> custom scale:
Cristi Magherusan <majeru@atheme.org>
parents:
4204
diff
changeset
|
584 if (cfg.scaled && cfg.eq_scaled_linked) |
4219
8a848179e244
fixed the eqalizer window
Cristi Magherusan <majeru@atheme.org>
parents:
4216
diff
changeset
|
585 gtk_widget_set_size_request(equalizerwin, 275 * cfg.scale_factor, |
8a848179e244
fixed the eqalizer window
Cristi Magherusan <majeru@atheme.org>
parents:
4216
diff
changeset
|
586 ((cfg.equalizer_shaded ? 14 : 116) * cfg.scale_factor)); |
2313 | 587 else |
588 gtk_widget_set_size_request(equalizerwin, 275, | |
589 (cfg.equalizer_shaded ? 14 : 116)); | |
590 cfg.equalizer_visible = TRUE; | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
591 UI_SKINNED_BUTTON(mainwin_eq)->inside = TRUE; |
3050
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
592 gtk_widget_show_all(equalizerwin); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
593 |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
594 if (!cfg.equalizer_shaded) { |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
595 gtk_widget_hide(equalizerwin_volume); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
596 gtk_widget_hide(equalizerwin_balance); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
597 } |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
598 else { |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
599 ui_skinned_set_push_button_data(equalizerwin_shade, -1, 3, -1, 47); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
600 ui_skinned_button_set_skin_index1(equalizerwin_shade, SKIN_EQ_EX); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
601 ui_skinned_set_push_button_data(equalizerwin_close, 11, 38, 11, 47); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
602 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQ_EX); |
a4288aa638b8
correct showing equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
3049
diff
changeset
|
603 } |
2313 | 604 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
605 gtk_window_present(GTK_WINDOW(equalizerwin)); |
2313 | 606 } |
607 | |
608 void | |
609 equalizerwin_real_hide(void) | |
610 { | |
611 /* | |
612 * This function should only be called from the | |
613 * main menu signal handler | |
614 */ | |
615 gtk_widget_hide(equalizerwin); | |
616 cfg.equalizer_visible = FALSE; | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
617 UI_SKINNED_BUTTON(mainwin_eq)->inside = FALSE; |
2999
e6340ab753a1
replace calling redraw signals with gtk_widget_queue_draw()
Tomasz Mon <desowin@gmail.com>
parents:
2857
diff
changeset
|
618 gtk_widget_queue_draw(mainwin_eq); |
2313 | 619 } |
620 | |
621 static EqualizerPreset * | |
622 equalizerwin_find_preset(GList * list, const gchar * name) | |
623 { | |
624 GList *node = list; | |
625 EqualizerPreset *preset; | |
626 | |
627 while (node) { | |
628 preset = node->data; | |
629 if (!strcasecmp(preset->name, name)) | |
630 return preset; | |
631 node = g_list_next(node); | |
632 } | |
633 return NULL; | |
634 } | |
635 | |
636 static void | |
637 equalizerwin_write_preset_file(GList * list, const gchar * basename) | |
638 { | |
639 gchar *filename, *tmp; | |
640 gint i, p; | |
641 EqualizerPreset *preset; | |
642 RcFile *rcfile; | |
643 GList *node; | |
644 | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
645 rcfile = aud_rcfile_new(); |
2313 | 646 p = 0; |
647 for (node = list; node; node = g_list_next(node)) { | |
648 preset = node->data; | |
649 tmp = g_strdup_printf("Preset%d", p++); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
650 aud_rcfile_write_string(rcfile, "Presets", tmp, preset->name); |
2313 | 651 g_free(tmp); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
652 aud_rcfile_write_float(rcfile, preset->name, "Preamp", |
2313 | 653 preset->preamp); |
654 for (i = 0; i < 10; i++) { | |
655 tmp = g_strdup_printf("Band%d\n", i); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
656 aud_rcfile_write_float(rcfile, preset->name, tmp, |
2313 | 657 preset->bands[i]); |
658 g_free(tmp); | |
659 } | |
660 } | |
661 | |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
662 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
663 aud_rcfile_write(rcfile, filename); |
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
664 aud_rcfile_free(rcfile); |
2313 | 665 g_free(filename); |
666 } | |
667 | |
668 static gboolean | |
669 equalizerwin_load_preset(GList * list, const gchar * name) | |
670 { | |
671 EqualizerPreset *preset; | |
672 gint i; | |
673 | |
674 if ((preset = equalizerwin_find_preset(list, name)) != NULL) { | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
675 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp); |
2313 | 676 for (i = 0; i < 10; i++) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
677 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]); |
2313 | 678 equalizerwin_eq_changed(); |
679 return TRUE; | |
680 } | |
681 return FALSE; | |
682 } | |
683 | |
684 static GList * | |
685 equalizerwin_save_preset(GList * list, const gchar * name, | |
686 const gchar * filename) | |
687 { | |
688 gint i; | |
689 EqualizerPreset *preset; | |
690 | |
691 if (!(preset = equalizerwin_find_preset(list, name))) { | |
692 preset = g_new0(EqualizerPreset, 1); | |
693 preset->name = g_strdup(name); | |
694 list = g_list_append(list, preset); | |
695 } | |
696 | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
697 preset->preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); |
2313 | 698 for (i = 0; i < 10; i++) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
699 preset->bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]); |
2313 | 700 |
701 equalizerwin_write_preset_file(list, filename); | |
702 | |
703 return list; | |
704 } | |
705 | |
706 static GList * | |
707 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename) | |
708 { | |
709 EqualizerPreset *preset; | |
710 GList *node; | |
711 | |
712 if (!(preset = equalizerwin_find_preset(list, name))) | |
713 return list; | |
714 | |
715 if (!(node = g_list_find(list, preset))) | |
716 return list; | |
717 | |
718 list = g_list_remove_link(list, node); | |
719 equalizer_preset_free(preset); | |
720 g_list_free_1(node); | |
721 | |
722 equalizerwin_write_preset_file(list, filename); | |
723 | |
724 return list; | |
725 } | |
726 | |
727 static void | |
728 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename) | |
729 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
730 gchar *text; |
2313 | 731 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
732 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
733 GtkTreeModel *model = gtk_tree_view_get_model(view); |
2313 | 734 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
735 /* |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
736 * first we are making a list of the selected rows, then we convert this |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
737 * list into a list of GtkTreeRowReferences, so that when you delete an |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
738 * item you can still access the other items |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
739 * finally we iterate through all GtkTreeRowReferences, convert them to |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
740 * GtkTreeIters and delete those one after the other |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
741 */ |
2313 | 742 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
743 GList *list = gtk_tree_selection_get_selected_rows(selection, &model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
744 GList *rrefs = NULL; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
745 GList *litr; |
2313 | 746 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
747 for (litr = list; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
748 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
749 GtkTreePath *path = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
750 rrefs = g_list_append(rrefs, gtk_tree_row_reference_new(model, path)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
751 } |
2313 | 752 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
753 for (litr = rrefs; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
754 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
755 GtkTreeRowReference *ref = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
756 GtkTreePath *path = gtk_tree_row_reference_get_path(ref); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
757 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
758 gtk_tree_model_get_iter(model, &iter, path); |
2313 | 759 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
760 gtk_tree_model_get(model, &iter, 0, &text, -1); |
2313 | 761 |
2785 | 762 if (!strcmp(filename, "eq.preset")) |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
763 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename); |
2785 | 764 else if (!strcmp(filename, "eq.auto_preset")) |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
765 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename); |
2313 | 766 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
767 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
768 } |
2313 | 769 } |
770 | |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
771 static GList * |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
772 import_winamp_eqf(VFSFile * file) |
2313 | 773 { |
774 gchar header[31]; | |
775 gchar bands[11]; | |
776 gint i = 0; | |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
777 EqualizerPreset *preset = NULL; |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
778 GList *list = NULL; |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
779 GtkWidget *dialog; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
780 gchar *realfn; |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
781 gchar preset_name[0xb4]; |
2313 | 782 |
783 vfs_fread(header, 1, 31, file); | |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
784 if (strncmp(header, "Winamp EQ library file v1.1", 27)) goto error; |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
785 |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
786 AUDDBG("The EQF header is OK\n"); |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
787 |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
788 if (vfs_fseek(file, 0x1f, SEEK_SET) == -1) goto error; |
2313 | 789 |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
790 while (vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) { |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
791 AUDDBG("The preset name is '%s'\n", preset_name); |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
792 vfs_fseek(file, 0x4d, SEEK_CUR); /* unknown crap --asphyx */ |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
793 if (vfs_fread(bands, 1, 11, file) != 11) break; |
2313 | 794 |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
795 preset = equalizer_preset_new(preset_name); |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
796 /*this was divided by 63, but shouldn't it be 64? --majeru*/ |
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
797 preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
798 |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
799 for (i = 0; i < 10; i++) |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
800 preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0); |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
801 |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
802 list = g_list_prepend(list, preset); |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
803 } |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
804 |
4308 | 805 list = g_list_reverse(list); |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
806 if (list == NULL) goto error; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
807 |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
808 return list; |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
809 |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
810 error: |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
811 realfn = g_filename_from_uri(file->uri, NULL, NULL); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
812 dialog = gtk_message_dialog_new (GTK_WINDOW(mainwin), |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
813 GTK_DIALOG_DESTROY_WITH_PARENT, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
814 GTK_MESSAGE_ERROR, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
815 GTK_BUTTONS_CLOSE, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
816 _("Error importing Winamp EQF file '%s'"), |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
817 realfn); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
818 gtk_dialog_run (GTK_DIALOG (dialog)); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
819 gtk_widget_destroy (dialog); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
820 g_free(realfn); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
821 return NULL; |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
822 } |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
823 |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
824 static void |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
825 free_cb (gpointer data, gpointer user_data) |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
826 { |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
827 equalizer_preset_free((EqualizerPreset*)data); |
2313 | 828 } |
829 | |
830 static void | |
831 equalizerwin_read_winamp_eqf(VFSFile * file) | |
832 { | |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
833 GList *presets; |
2313 | 834 gint i; |
835 | |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
836 if ((presets = import_winamp_eqf(file)) == NULL) |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
837 return; |
2313 | 838 |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
839 /* just get the first preset --asphyx */ |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
840 EqualizerPreset *preset = (EqualizerPreset*)presets->data; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
841 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
842 preset->preamp); |
2313 | 843 |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
844 for (i = 0; i < 10; i++) |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
845 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
846 preset->bands[i]); |
2313 | 847 |
4307
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
848 g_list_foreach(presets, free_cb, NULL); |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
849 g_list_free(presets); |
cfaecedace4e
importing of winamp EQ presets library
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4306
diff
changeset
|
850 |
2313 | 851 equalizerwin_eq_changed(); |
852 } | |
853 | |
854 static void | |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
855 equalizerwin_read_aud_preset(RcFile * rcfile) |
2313 | 856 { |
857 gfloat val; | |
858 gint i; | |
859 | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
860 if (aud_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
861 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, val); |
2313 | 862 for (i = 0; i < 10; i++) { |
863 gchar tmp[7]; | |
864 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
865 if (aud_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
866 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], val); |
2313 | 867 } |
868 equalizerwin_eq_changed(); | |
869 } | |
870 | |
871 static void | |
872 equalizerwin_save_ok(GtkWidget * widget, gpointer data) | |
873 { | |
874 const gchar *text; | |
875 | |
876 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry)); | |
877 if (strlen(text) != 0) | |
878 equalizer_presets = | |
879 equalizerwin_save_preset(equalizer_presets, text, "eq.preset"); | |
880 gtk_widget_destroy(equalizerwin_save_window); | |
881 } | |
882 | |
883 static void | |
884 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
885 GtkTreeViewColumn *col, gpointer data) |
2313 | 886 { |
887 gchar *text; | |
888 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
889 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
890 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
891 GtkTreeIter iter; |
2313 | 892 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
893 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
894 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
895 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
896 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
897 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
898 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
899 equalizerwin_save_ok(NULL, NULL); |
2313 | 900 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
901 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
902 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
903 } |
2313 | 904 } |
905 | |
906 static void | |
907 equalizerwin_load_ok(GtkWidget *widget, gpointer data) | |
908 { | |
909 gchar *text; | |
910 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
911 GtkTreeView* view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
912 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
913 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
914 GtkTreeIter iter; |
2313 | 915 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
916 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
917 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
918 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
919 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
920 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
921 equalizerwin_load_preset(equalizer_presets, text); |
2313 | 922 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
923 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
924 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
925 } |
2313 | 926 gtk_widget_destroy(equalizerwin_load_window); |
927 } | |
928 | |
929 static void | |
930 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
931 GtkTreeViewColumn *col, gpointer data) |
2313 | 932 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
933 equalizerwin_load_ok(NULL, treeview); |
2313 | 934 } |
935 | |
936 static void | |
937 equalizerwin_delete_delete(GtkWidget *widget, gpointer data) | |
938 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
939 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset"); |
2313 | 940 } |
941 | |
942 static void | |
943 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data) | |
944 { | |
945 const gchar *text; | |
946 | |
947 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry)); | |
948 if (strlen(text) != 0) | |
949 equalizer_auto_presets = | |
950 equalizerwin_save_preset(equalizer_auto_presets, text, | |
951 "eq.auto_preset"); | |
952 gtk_widget_destroy(equalizerwin_save_auto_window); | |
953 } | |
954 | |
955 static void | |
956 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
957 GtkTreeViewColumn *col, gpointer data) |
2313 | 958 { |
959 gchar *text; | |
960 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
961 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
962 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
963 GtkTreeIter iter; |
2313 | 964 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
965 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
966 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
967 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
968 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
969 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
970 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
971 equalizerwin_save_auto_ok(NULL, NULL); |
2313 | 972 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
973 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
974 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
975 } |
2313 | 976 } |
977 | |
978 static void | |
979 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data) | |
980 { | |
981 gchar *text; | |
982 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
983 GtkTreeView *view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
984 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
985 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
986 GtkTreeIter iter; |
2313 | 987 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
988 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
989 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
990 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
991 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
992 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
993 equalizerwin_load_preset(equalizer_auto_presets, text); |
2313 | 994 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
995 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
996 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
997 } |
2313 | 998 gtk_widget_destroy(equalizerwin_load_auto_window); |
999 } | |
1000 | |
1001 static void | |
1002 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1003 GtkTreeViewColumn *col, gpointer data) |
2313 | 1004 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1005 equalizerwin_load_auto_ok(NULL, treeview); |
2313 | 1006 } |
1007 | |
1008 static void | |
1009 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data) | |
1010 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1011 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset"); |
2313 | 1012 } |
1013 | |
1014 | |
1015 static void | |
1016 load_preset_file(const gchar *filename) | |
1017 { | |
1018 RcFile *rcfile; | |
1019 | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1020 if ((rcfile = aud_rcfile_open(filename)) != NULL) { |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
1021 equalizerwin_read_aud_preset(rcfile); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1022 aud_rcfile_free(rcfile); |
2313 | 1023 } |
1024 } | |
1025 | |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1026 static VFSFile * |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1027 open_vfs_file(const gchar *filename, const gchar *mode) |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1028 { |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1029 VFSFile *file; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1030 GtkWidget *dialog; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1031 |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1032 if (!(file = vfs_fopen(filename, mode))) { |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1033 dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1034 GTK_DIALOG_DESTROY_WITH_PARENT, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1035 GTK_MESSAGE_ERROR, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1036 GTK_BUTTONS_CLOSE, |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1037 "Error loading file '%s'", |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1038 filename); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1039 gtk_dialog_run (GTK_DIALOG (dialog)); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1040 gtk_widget_destroy (dialog); |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1041 } |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1042 |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1043 return file; |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1044 } |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1045 |
2313 | 1046 static void |
1047 load_winamp_file(const gchar * filename) | |
1048 { | |
1049 VFSFile *file; | |
1050 | |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1051 if (!(file = open_vfs_file(filename, "rb"))) |
2313 | 1052 return; |
1053 | |
1054 equalizerwin_read_winamp_eqf(file); | |
1055 vfs_fclose(file); | |
1056 } | |
1057 | |
1058 static void | |
1059 import_winamp_file(const gchar * filename) | |
1060 { | |
1061 VFSFile *file; | |
4309 | 1062 GList *list; |
2313 | 1063 |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1064 if (!(file = open_vfs_file(filename, "rb")) || |
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1065 !(list = import_winamp_eqf(file))) |
2313 | 1066 return; |
1067 | |
4309 | 1068 equalizer_presets = g_list_concat(equalizer_presets, list); |
2313 | 1069 equalizerwin_write_preset_file(equalizer_presets, "eq.preset"); |
1070 | |
1071 vfs_fclose(file); | |
1072 } | |
1073 | |
1074 static void | |
1075 save_preset_file(const gchar * filename) | |
1076 { | |
1077 RcFile *rcfile; | |
1078 gint i; | |
1079 | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1080 rcfile = aud_rcfile_new(); |
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1081 aud_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1082 ui_skinned_equalizer_slider_get_position(equalizerwin_preamp)); |
2313 | 1083 |
1084 for (i = 0; i < 10; i++) { | |
1085 gchar tmp[7]; | |
1086 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1087 aud_rcfile_write_float(rcfile, "Equalizer preset", tmp, |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1088 ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i])); |
2313 | 1089 } |
1090 | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1091 aud_rcfile_write(rcfile, filename); |
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1092 aud_rcfile_free(rcfile); |
2313 | 1093 } |
1094 | |
1095 static void | |
1096 save_winamp_file(const gchar * filename) | |
1097 { | |
1098 VFSFile *file; | |
1099 | |
1100 gchar name[257]; | |
1101 gint i; | |
1102 guchar bands[11]; | |
1103 | |
4325
309e8f970517
removed report_error() and reimplemented some error routines
mf0102 <0102@gmx.at>
parents:
4309
diff
changeset
|
1104 if (!(file = open_vfs_file(filename, "wb"))) |
2313 | 1105 return; |
1106 | |
1107 vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file); | |
1108 | |
1109 memset(name, 0, 257); | |
4103
7b9d5718a6dc
strncpy() -> g_strlcpy()
Jonathan Schleifer <js-audacious@webkeks.org>
parents:
4102
diff
changeset
|
1110 g_strlcpy(name, "Entry1", 257); |
2313 | 1111 vfs_fwrite(name, 1, 257, file); |
1112 | |
1113 for (i = 0; i < 10; i++) | |
4306
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
1114 bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); |
172d49b1200b
- equalizer sliders range changed to -12..12 dB
Eugene Zagidullin <e.asphyx@gmail.com>
parents:
4219
diff
changeset
|
1115 bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); |
2313 | 1116 vfs_fwrite(bands, 1, 11, file); |
1117 | |
1118 vfs_fclose(file); | |
1119 } | |
1120 | |
1121 static GtkWidget * | |
1122 equalizerwin_create_list_window(GList *preset_list, | |
1123 const gchar *title, | |
1124 GtkWidget **window, | |
1125 GtkSelectionMode sel_mode, | |
1126 GtkWidget **entry, | |
1127 const gchar *action_name, | |
1128 GCallback action_func, | |
1129 GCallback select_row_func) | |
1130 { | |
1131 GtkWidget *vbox, *scrolled_window, *bbox, *view; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1132 GtkWidget *button_cancel, *button_action; |
2313 | 1133 GList *node; |
1134 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1135 GtkListStore *store; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1136 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1137 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1138 GtkCellRenderer *renderer; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1139 GtkTreeSelection *selection; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1140 GtkTreeSortable *sortable; |
2313 | 1141 |
1142 | |
1143 | |
1144 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1145 gtk_window_set_title(GTK_WINDOW(*window), title); | |
1146 gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
1147 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300); | |
1148 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER); | |
1149 gtk_container_set_border_width(GTK_CONTAINER(*window), 10); | |
1150 gtk_window_set_transient_for(GTK_WINDOW(*window), | |
1151 GTK_WINDOW(equalizerwin)); | |
1152 g_signal_connect(*window, "destroy", | |
1153 G_CALLBACK(gtk_widget_destroyed), window); | |
1154 | |
1155 vbox = gtk_vbox_new(FALSE, 10); | |
1156 gtk_container_add(GTK_CONTAINER(*window), vbox); | |
1157 | |
1158 scrolled_window = gtk_scrolled_window_new(NULL, NULL); | |
1159 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), | |
1160 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1161 | |
1162 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1163 /* fill the store with the names of all available presets */ |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1164 store = gtk_list_store_new(1, G_TYPE_STRING); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1165 for (node = preset_list; node; node = g_list_next(node)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1166 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1167 gtk_list_store_append(store, &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1168 gtk_list_store_set(store, &iter, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1169 0, ((EqualizerPreset*)node->data)->name, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1170 -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1171 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1172 model = GTK_TREE_MODEL(store); |
2313 | 1173 |
1174 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1175 sortable = GTK_TREE_SORTABLE(store); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1176 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING); |
2313 | 1177 |
1178 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1179 view = gtk_tree_view_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1180 renderer = gtk_cell_renderer_text_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1181 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1182 _("Presets"), renderer, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1183 "text", 0, NULL); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1184 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1185 g_object_unref(model); |
2313 | 1186 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1187 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1188 gtk_tree_selection_set_mode(selection, sel_mode); |
2313 | 1189 |
1190 | |
1191 | |
1192 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1193 gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
2313 | 1194 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); |
1195 | |
1196 if (entry) { | |
1197 *entry = gtk_entry_new(); | |
1198 g_signal_connect(*entry, "activate", action_func, NULL); | |
1199 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0); | |
1200 } | |
1201 | |
1202 bbox = gtk_hbutton_box_new(); | |
1203 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1204 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1205 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1206 | |
1207 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1208 g_signal_connect_swapped(button_cancel, "clicked", | |
1209 G_CALLBACK(gtk_widget_destroy), | |
1210 GTK_OBJECT(*window)); | |
1211 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0); | |
1212 | |
1213 button_action = gtk_button_new_from_stock(action_name); | |
1214 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view); | |
1215 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT); | |
1216 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1217 if (select_row_func) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1218 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL); |
2313 | 1219 |
1220 | |
1221 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0); | |
1222 | |
1223 gtk_widget_grab_default(button_action); | |
1224 | |
1225 | |
1226 gtk_widget_show_all(*window); | |
1227 | |
1228 return *window; | |
1229 } | |
1230 | |
1231 void | |
1232 equalizerwin_load_auto_preset(const gchar * filename) | |
1233 { | |
1234 gchar *presetfilename, *directory; | |
1235 RcFile *rcfile; | |
1236 | |
1237 g_return_if_fail(filename != NULL); | |
1238 | |
1239 if (!cfg.equalizer_autoload) | |
1240 return; | |
1241 | |
1242 presetfilename = g_strconcat(filename, ".", cfg.eqpreset_extension, NULL); | |
1243 | |
1244 /* First try to find a per file preset file */ | |
1245 if (strlen(cfg.eqpreset_extension) > 0 && | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1246 (rcfile = aud_rcfile_open(presetfilename)) != NULL) { |
2313 | 1247 g_free(presetfilename); |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
1248 equalizerwin_read_aud_preset(rcfile); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1249 aud_rcfile_free(rcfile); |
2313 | 1250 return; |
1251 } | |
1252 | |
1253 g_free(presetfilename); | |
1254 | |
1255 directory = g_path_get_dirname(filename); | |
1256 presetfilename = g_build_filename(directory, cfg.eqpreset_default_file, | |
1257 NULL); | |
1258 g_free(directory); | |
1259 | |
1260 /* Try to find a per directory preset file */ | |
1261 if (strlen(cfg.eqpreset_default_file) > 0 && | |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1262 (rcfile = aud_rcfile_open(presetfilename)) != NULL) { |
4413
de33c83aa06f
Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents:
4405
diff
changeset
|
1263 equalizerwin_read_aud_preset(rcfile); |
4405
15c491f342eb
Rename bmp_rcfile* -> aud_rcfile*
Matti Hamalainen <ccr@tnsp.org>
parents:
4325
diff
changeset
|
1264 aud_rcfile_free(rcfile); |
2313 | 1265 } |
1266 else if (!equalizerwin_load_preset | |
1267 (equalizer_auto_presets, g_basename(filename))) { | |
1268 /* Fall back to the oldstyle auto presets */ | |
1269 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1270 } | |
1271 | |
1272 g_free(presetfilename); | |
1273 } | |
1274 | |
1275 void | |
1276 equalizerwin_set_preamp(gfloat preamp) | |
1277 { | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1278 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preamp); |
2313 | 1279 equalizerwin_eq_changed(); |
1280 } | |
1281 | |
1282 void | |
1283 equalizerwin_set_band(gint band, gfloat value) | |
1284 { | |
1285 g_return_if_fail(band >= 0 && band < 10); | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1286 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value); |
2313 | 1287 } |
1288 | |
1289 gfloat | |
1290 equalizerwin_get_preamp(void) | |
1291 { | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1292 return ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); |
2313 | 1293 } |
1294 | |
1295 gfloat | |
1296 equalizerwin_get_band(gint band) | |
1297 { | |
3915
86c9abc83fbd
audacious remote functions:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3534
diff
changeset
|
1298 g_return_val_if_fail(band >= 0 && band < 10, 0.0); |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1299 return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]); |
2313 | 1300 } |
1301 | |
1302 void | |
1303 action_equ_load_preset(void) | |
1304 { | |
1305 if (equalizerwin_load_window) { | |
1306 gtk_window_present(GTK_WINDOW(equalizerwin_load_window)); | |
1307 return; | |
1308 } | |
1309 | |
1310 equalizerwin_create_list_window(equalizer_presets, | |
1311 Q_("Load preset"), | |
1312 &equalizerwin_load_window, | |
1313 GTK_SELECTION_SINGLE, NULL, | |
1314 GTK_STOCK_OK, | |
1315 G_CALLBACK(equalizerwin_load_ok), | |
1316 G_CALLBACK(equalizerwin_load_select)); | |
1317 } | |
1318 | |
1319 void | |
1320 action_equ_load_auto_preset(void) | |
1321 { | |
1322 if (equalizerwin_load_auto_window) { | |
1323 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window)); | |
1324 return; | |
1325 } | |
1326 | |
1327 equalizerwin_create_list_window(equalizer_auto_presets, | |
1328 Q_("Load auto-preset"), | |
1329 &equalizerwin_load_auto_window, | |
1330 GTK_SELECTION_SINGLE, NULL, | |
1331 GTK_STOCK_OK, | |
1332 G_CALLBACK(equalizerwin_load_auto_ok), | |
1333 G_CALLBACK(equalizerwin_load_auto_select)); | |
1334 } | |
1335 | |
1336 void | |
1337 action_equ_load_default_preset(void) | |
1338 { | |
1339 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1340 } | |
1341 | |
1342 void | |
1343 action_equ_zero_preset(void) | |
1344 { | |
1345 gint i; | |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1346 |
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1347 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, 0); |
2313 | 1348 for (i = 0; i < 10; i++) |
3098
821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
Tomasz Mon <desowin@gmail.com>
parents:
3077
diff
changeset
|
1349 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], 0); |
2313 | 1350 |
1351 equalizerwin_eq_changed(); | |
1352 } | |
1353 | |
1354 void | |
1355 action_equ_load_preset_file(void) | |
1356 { | |
1357 GtkWidget *dialog; | |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1358 gchar *file_uri; |
2313 | 1359 |
1360 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1361 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1362 { |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1363 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1364 load_preset_file(file_uri); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1365 g_free(file_uri); |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1366 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1367 gtk_widget_destroy(dialog); |
2313 | 1368 } |
1369 | |
1370 void | |
1371 action_equ_load_preset_eqf(void) | |
1372 { | |
1373 GtkWidget *dialog; | |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1374 gchar *file_uri; |
2313 | 1375 |
1376 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1377 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1378 { |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1379 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1380 load_winamp_file(file_uri); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1381 g_free(file_uri); |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1382 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1383 gtk_widget_destroy(dialog); |
2313 | 1384 } |
1385 | |
1386 void | |
1387 action_equ_import_winamp_presets(void) | |
1388 { | |
1389 GtkWidget *dialog; | |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1390 gchar *file_uri; |
2313 | 1391 |
1392 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1393 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1394 { |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1395 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1396 import_winamp_file(file_uri); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1397 g_free(file_uri); |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1398 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1399 gtk_widget_destroy(dialog); |
2313 | 1400 } |
1401 | |
1402 void | |
1403 action_equ_save_preset(void) | |
1404 { | |
1405 if (equalizerwin_save_window) { | |
1406 gtk_window_present(GTK_WINDOW(equalizerwin_save_window)); | |
1407 return; | |
1408 } | |
1409 | |
1410 equalizerwin_create_list_window(equalizer_presets, | |
1411 Q_("Save preset"), | |
1412 &equalizerwin_save_window, | |
1413 GTK_SELECTION_SINGLE, | |
1414 &equalizerwin_save_entry, | |
1415 GTK_STOCK_OK, | |
1416 G_CALLBACK(equalizerwin_save_ok), | |
1417 G_CALLBACK(equalizerwin_save_select)); | |
1418 } | |
1419 | |
1420 void | |
1421 action_equ_save_auto_preset(void) | |
1422 { | |
1423 gchar *name; | |
1424 Playlist *playlist = playlist_get_active(); | |
1425 | |
1426 if (equalizerwin_save_auto_window) | |
1427 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window)); | |
1428 else | |
1429 equalizerwin_create_list_window(equalizer_auto_presets, | |
1430 Q_("Save auto-preset"), | |
1431 &equalizerwin_save_auto_window, | |
1432 GTK_SELECTION_SINGLE, | |
1433 &equalizerwin_save_auto_entry, | |
1434 GTK_STOCK_OK, | |
1435 G_CALLBACK(equalizerwin_save_auto_ok), | |
1436 G_CALLBACK(equalizerwin_save_auto_select)); | |
1437 | |
1438 name = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1439 if (name) { | |
1440 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), | |
1441 g_basename(name)); | |
1442 g_free(name); | |
1443 } | |
1444 } | |
1445 | |
1446 void | |
1447 action_equ_save_default_preset(void) | |
1448 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1449 equalizer_presets = |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1450 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset"); |
2313 | 1451 } |
1452 | |
1453 void | |
1454 action_equ_save_preset_file(void) | |
1455 { | |
1456 GtkWidget *dialog; | |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1457 gchar *file_uri; |
2313 | 1458 gchar *songname; |
1459 Playlist *playlist = playlist_get_active(); | |
1460 | |
1461 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1462 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1463 { |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1464 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1465 save_preset_file(file_uri); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1466 g_free(file_uri); |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1467 } |
2313 | 1468 |
1469 songname = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1470 if (songname) { | |
1471 gchar *eqname = g_strdup_printf("%s.%s", songname, | |
1472 cfg.eqpreset_extension); | |
1473 g_free(songname); | |
1474 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
1475 eqname); | |
1476 g_free(eqname); | |
1477 } | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1478 |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1479 gtk_widget_destroy(dialog); |
2313 | 1480 } |
1481 | |
1482 void | |
1483 action_equ_save_preset_eqf(void) | |
1484 { | |
1485 GtkWidget *dialog; | |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1486 gchar *file_uri; |
2313 | 1487 |
1488 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1489 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1490 { |
4203
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1491 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1492 save_winamp_file(file_uri); |
d9db67e2fef6
fixed WinAMP EQF file handling, did some more URI-fications
Cristi Magherusan <majeru@atheme.org>
parents:
4198
diff
changeset
|
1493 g_free(file_uri); |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1494 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1495 gtk_widget_destroy(dialog); |
2313 | 1496 } |
1497 | |
1498 void | |
1499 action_equ_delete_preset(void) | |
1500 { | |
1501 if (equalizerwin_delete_window) { | |
1502 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window)); | |
1503 return; | |
1504 } | |
1505 | |
1506 equalizerwin_create_list_window(equalizer_presets, | |
1507 Q_("Delete preset"), | |
1508 &equalizerwin_delete_window, | |
1509 GTK_SELECTION_EXTENDED, NULL, | |
1510 GTK_STOCK_DELETE, | |
1511 G_CALLBACK(equalizerwin_delete_delete), | |
1512 NULL); | |
1513 } | |
1514 | |
1515 void | |
1516 action_equ_delete_auto_preset(void) | |
1517 { | |
1518 if (equalizerwin_delete_auto_window) { | |
1519 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window)); | |
1520 return; | |
1521 } | |
1522 | |
1523 equalizerwin_create_list_window(equalizer_auto_presets, | |
1524 Q_("Delete auto-preset"), | |
1525 &equalizerwin_delete_auto_window, | |
1526 GTK_SELECTION_EXTENDED, NULL, | |
1527 GTK_STOCK_DELETE, | |
1528 G_CALLBACK(equalizerwin_delete_auto_delete), | |
1529 NULL); | |
1530 } | |
3917 | 1531 |
1532 void | |
1533 equalizer_activate(gboolean active) | |
1534 { | |
1535 cfg.equalizer_active = active; | |
1536 UI_SKINNED_BUTTON(equalizerwin_on)->inside = active; | |
1537 gtk_widget_queue_draw(equalizerwin_on); | |
1538 | |
1539 equalizerwin_eq_changed(); | |
1540 } |