Mercurial > audlegacy-plugins
annotate src/skins/ui_equalizer.c @ 3182:631d217913e0
alsa-ng: Fix arithmetic overflow on 32-bit systems.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Fri, 12 Jun 2009 09:17:09 -0400 |
parents | 1ffcad5f406c |
children |
rev | line source |
---|---|
2606 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team. | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 3 of the License. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
21 * | |
22 * The Audacious team does not consider modular code linking to | |
23 * Audacious or using our public API to be a derived work. | |
24 */ | |
25 | |
26 /*#define AUD_DEBUG*/ | |
27 | |
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" | |
42 #include "ui_skin.h" | |
43 #include "ui_manager.h" | |
44 #include "actions-equalizer.h" | |
45 #include "util.h" | |
46 #include "ui_main.h" | |
2678 | 47 #include "ui_playlist.h" |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2792
diff
changeset
|
48 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2792
diff
changeset
|
49 #include <audlegacy/equalizer_preset.h> |
2606 | 50 |
51 #include "images/audacious_eq.xpm" | |
52 | |
53 #include "ui_dock.h" | |
54 #include "ui_skinned_window.h" | |
55 #include "ui_skinned_button.h" | |
56 #include "ui_skinned_horizontal_slider.h" | |
57 #include "ui_skinned_equalizer_slider.h" | |
58 #include "ui_skinned_equalizer_graph.h" | |
59 #include "skins_cfg.h" | |
60 | |
61 enum PresetViewCols { | |
62 PRESET_VIEW_COL_NAME, | |
63 PRESET_VIEW_N_COLS | |
64 }; | |
65 | |
66 GtkWidget *equalizerwin; | |
67 GtkWidget *equalizerwin_graph; | |
68 | |
69 static GtkWidget *equalizerwin_load_window = NULL; | |
70 static GtkWidget *equalizerwin_load_auto_window = NULL; | |
71 static GtkWidget *equalizerwin_save_window = NULL; | |
72 static GtkWidget *equalizerwin_save_entry = NULL; | |
73 static GtkWidget *equalizerwin_save_auto_window = NULL; | |
74 static GtkWidget *equalizerwin_save_auto_entry = NULL; | |
75 static GtkWidget *equalizerwin_delete_window = NULL; | |
76 static GtkWidget *equalizerwin_delete_auto_window = NULL; | |
77 | |
78 static GtkWidget *equalizerwin_on, *equalizerwin_auto; | |
79 | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
80 static GtkWidget *equalizerwin_close, *equalizerwin_shade; |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
81 static GtkWidget *equalizerwin_shaded_close, *equalizerwin_shaded_shade; |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
82 static GtkWidget *equalizerwin_presets; |
2606 | 83 static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10]; |
84 static GtkWidget *equalizerwin_volume, *equalizerwin_balance; | |
85 | |
86 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL; | |
87 | |
88 EqualizerPreset * | |
89 equalizer_preset_new(const gchar * name) | |
90 { | |
91 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); | |
92 preset->name = g_strdup(name); | |
93 return preset; | |
94 } | |
95 | |
96 void | |
97 equalizer_preset_free(EqualizerPreset * preset) | |
98 { | |
99 if (!preset) | |
100 return; | |
101 | |
102 g_free(preset->name); | |
103 g_free(preset); | |
104 } | |
105 | |
106 void | |
107 equalizerwin_set_scaled(gboolean ds) | |
108 { | |
109 gint height; | |
110 | |
111 if (config.equalizer_shaded) | |
112 height = 14; | |
113 else | |
114 height = 116; | |
115 | |
116 if (config.scaled) { | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
117 dock_window_resize(GTK_WINDOW(equalizerwin), 275 * config.scale_factor, |
3158
8b97f9560dc3
More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem).
John Lindgren <john.lindgren@tds.net>
parents:
3017
diff
changeset
|
118 height * config.scale_factor); |
2606 | 119 } else { |
3158
8b97f9560dc3
More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem).
John Lindgren <john.lindgren@tds.net>
parents:
3017
diff
changeset
|
120 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height); |
2606 | 121 } |
122 | |
123 GList *iter; | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
124 for (iter = GTK_FIXED (SKINNED_WINDOW(equalizerwin)->normal)->children; iter; iter = g_list_next (iter)) { |
2606 | 125 GtkFixedChild *child_data = (GtkFixedChild *) iter->data; |
126 GtkWidget *child = child_data->widget; | |
127 g_signal_emit_by_name(child, "toggle-scaled"); | |
128 } | |
129 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + config.equalizer_shaded), 0, 0); | |
130 } | |
131 | |
132 void | |
133 equalizerwin_set_shade_menu_cb(gboolean shaded) | |
134 { | |
135 config.equalizer_shaded = shaded; | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
136 ui_skinned_window_set_shade(equalizerwin, shaded); |
2606 | 137 |
138 if (shaded) { | |
139 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin), | |
140 14 * EQUALIZER_SCALE_FACTOR); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
141 } else { |
2606 | 142 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin), |
143 116 * EQUALIZER_SCALE_FACTOR); | |
144 } | |
145 | |
146 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + config.equalizer_shaded), 0, 0); | |
147 } | |
148 | |
149 static void | |
150 equalizerwin_set_shade(gboolean shaded) | |
151 { | |
152 GtkAction *action = gtk_action_group_get_action( | |
153 toggleaction_group_others , "roll up equalizer" ); | |
154 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
155 } | |
156 | |
157 static void | |
158 equalizerwin_shade_toggle(void) | |
159 { | |
160 equalizerwin_set_shade(!config.equalizer_shaded); | |
161 } | |
162 | |
163 void | |
164 equalizerwin_eq_changed(void) | |
165 { | |
166 gint i; | |
167 | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
168 aud_cfg->equalizer_preamp = equalizerwin_get_preamp(); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
169 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
170 aud_cfg->equalizer_bands[i] = equalizerwin_get_band(i); |
2641 | 171 |
172 aud_hook_call("equalizer changed", NULL); | |
2606 | 173 gtk_widget_queue_draw(equalizerwin_graph); |
174 } | |
175 | |
176 static void | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
177 equalizerwin_apply_preset(EqualizerPreset *preset) |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
178 { |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
179 if (preset == NULL) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
180 return; |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
181 |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
182 gint i; |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
183 |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
184 equalizerwin_set_preamp(preset->preamp); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
185 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
186 equalizerwin_set_band(i, preset->bands[i]); |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
187 } |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
188 |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
189 static void |
2606 | 190 equalizerwin_on_pushed(void) |
191 { | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
192 equalizerwin_activate(!aud_cfg->equalizer_active); |
2606 | 193 } |
194 | |
195 static void | |
196 equalizerwin_presets_pushed(void) | |
197 { | |
198 GdkModifierType modmask; | |
199 gint x, y; | |
200 | |
201 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
202 ui_manager_popup_menu_show(GTK_MENU(equalizerwin_presets_menu), x, y, 1, GDK_CURRENT_TIME); | |
203 } | |
204 | |
205 static void | |
206 equalizerwin_auto_pushed(void) | |
207 { | |
208 aud_cfg->equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside; | |
209 } | |
210 | |
211 gboolean | |
212 equalizerwin_press(GtkWidget * widget, GdkEventButton * event, | |
213 gpointer callback_data) | |
214 { | |
215 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS | |
216 && event->y < 14) { | |
217 equalizerwin_set_shade(!config.equalizer_shaded); | |
218 if (dock_is_moving(GTK_WINDOW(equalizerwin))) | |
219 dock_move_release(GTK_WINDOW(equalizerwin)); | |
220 return TRUE; | |
221 } | |
222 if (event->button == 3) { | |
223 /* | |
224 * Pop up the main menu a few pixels down to avoid | |
225 * anything to be selected initially. | |
226 */ | |
227 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
228 event->y_root + 2, 3, event->time); | |
229 return TRUE; | |
230 } | |
231 | |
232 return FALSE; | |
233 } | |
234 | |
235 static gboolean | |
236 equalizerwin_keypress(GtkWidget * widget, | |
237 GdkEventKey * event, | |
238 gpointer data) | |
239 { | |
240 if (event->keyval == GDK_Tab && event->state & GDK_CONTROL_MASK) { | |
241 if (config.playlist_visible) | |
242 gtk_window_present(GTK_WINDOW(playlistwin)); | |
243 else if (config.player_visible) | |
244 gtk_window_present(GTK_WINDOW(mainwin)); | |
245 return TRUE; | |
246 } | |
247 if (!config.equalizer_shaded) { | |
248 gtk_widget_event(mainwin, (GdkEvent *) event); | |
249 return TRUE; | |
250 } | |
251 | |
252 switch (event->keyval) { | |
253 case GDK_Left: | |
254 case GDK_KP_Left: | |
255 mainwin_set_balance_diff(-4); | |
256 break; | |
257 case GDK_Right: | |
258 case GDK_KP_Right: | |
259 mainwin_set_balance_diff(4); | |
260 break; | |
261 default: | |
262 gtk_widget_event(mainwin, (GdkEvent *) event); | |
263 break; | |
264 } | |
265 | |
266 return FALSE; | |
267 } | |
268 | |
269 static void | |
270 equalizerwin_close_cb(void) | |
271 { | |
272 equalizerwin_show(FALSE); | |
273 } | |
274 | |
275 static gboolean | |
276 equalizerwin_delete(GtkWidget * widget, | |
277 gpointer data) | |
278 { | |
279 equalizerwin_show(FALSE); | |
280 return TRUE; | |
281 } | |
282 | |
283 gint | |
284 equalizerwin_volume_frame_cb(gint pos) | |
285 { | |
286 if (equalizerwin_volume) { | |
287 gint x; | |
288 if (pos < 32) | |
289 x = 1; | |
290 else if (pos < 63) | |
291 x = 4; | |
292 else | |
293 x = 7; | |
294 | |
295 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_nx = x; | |
296 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_px = x; | |
297 } | |
298 return 1; | |
299 } | |
300 | |
301 static void | |
302 equalizerwin_volume_motion_cb(GtkWidget *widget, gint pos) | |
303 { | |
304 gint v = (gint) rint(pos * 100 / 94.0); | |
305 mainwin_adjust_volume_motion(v); | |
306 mainwin_set_volume_slider(v); | |
307 } | |
308 | |
309 static void | |
310 equalizerwin_volume_release_cb(GtkWidget *widget, gint pos) | |
311 { | |
312 mainwin_adjust_volume_release(); | |
313 } | |
314 | |
315 static gint | |
316 equalizerwin_balance_frame_cb(gint pos) | |
317 { | |
318 if (equalizerwin_balance) { | |
319 gint x; | |
320 if (pos < 13) | |
321 x = 11; | |
322 else if (pos < 26) | |
323 x = 14; | |
324 else | |
325 x = 17; | |
326 | |
327 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_nx = x; | |
328 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_px = x; | |
329 } | |
330 | |
331 return 1; | |
332 } | |
333 | |
334 static void | |
335 equalizerwin_balance_motion_cb(GtkWidget *widget, gint pos) | |
336 { | |
337 gint b; | |
338 pos = MIN(pos, 38); /* The skin uses a even number of pixels | |
339 for the balance-slider *sigh* */ | |
340 b = (gint) rint((pos - 19) * 100 / 19.0); | |
341 mainwin_adjust_balance_motion(b); | |
342 mainwin_set_balance_slider(b); | |
343 } | |
344 | |
345 static void | |
346 equalizerwin_balance_release_cb(GtkWidget *widget, gint pos) | |
347 { | |
348 mainwin_adjust_balance_release(); | |
349 } | |
350 | |
351 void | |
352 equalizerwin_set_balance_slider(gint percent) | |
353 { | |
354 ui_skinned_horizontal_slider_set_position(equalizerwin_balance, | |
355 (gint) rint((percent * 19 / 100.0) + 19)); | |
356 } | |
357 | |
358 void | |
359 equalizerwin_set_volume_slider(gint percent) | |
360 { | |
361 ui_skinned_horizontal_slider_set_position(equalizerwin_volume, | |
362 (gint) rint(percent * 94 / 100.0)); | |
363 } | |
364 | |
365 static void | |
366 equalizerwin_create_widgets(void) | |
367 { | |
368 gint i; | |
369 | |
370 equalizerwin_on = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
371 ui_skinned_toggle_button_setup(equalizerwin_on, SKINNED_WINDOW(equalizerwin)->normal, |
2606 | 372 14, 18, 25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN); |
373 g_signal_connect(equalizerwin_on, "clicked", equalizerwin_on_pushed, NULL); | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
374 ui_skinned_button_set_inside (equalizerwin_on, aud_cfg->equalizer_active); |
2606 | 375 |
376 equalizerwin_auto = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
377 ui_skinned_toggle_button_setup(equalizerwin_auto, SKINNED_WINDOW(equalizerwin)->normal, |
2606 | 378 39, 18, 33, 12, 35, 119, 153, 119, 94, 119, 212, 119, SKIN_EQMAIN); |
379 g_signal_connect(equalizerwin_auto, "clicked", equalizerwin_auto_pushed, NULL); | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2641
diff
changeset
|
380 ui_skinned_button_set_inside(equalizerwin_auto, aud_cfg->equalizer_autoload); |
2606 | 381 |
382 equalizerwin_presets = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
383 ui_skinned_push_button_setup(equalizerwin_presets, SKINNED_WINDOW(equalizerwin)->normal, |
2606 | 384 217, 18, 44, 12, 224, 164, 224, 176, SKIN_EQMAIN); |
385 g_signal_connect(equalizerwin_presets, "clicked", equalizerwin_presets_pushed, NULL ); | |
386 | |
387 equalizerwin_close = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
388 ui_skinned_push_button_setup(equalizerwin_close, SKINNED_WINDOW(equalizerwin)->normal, |
2606 | 389 264, 3, 9, 9, 0, 116, 0, 125, SKIN_EQMAIN); |
390 g_signal_connect(equalizerwin_close, "clicked", equalizerwin_close_cb, NULL ); | |
391 | |
392 equalizerwin_shade = ui_skinned_button_new(); | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
393 ui_skinned_push_button_setup(equalizerwin_shade, SKINNED_WINDOW(equalizerwin)->normal, |
2606 | 394 254, 3, 9, 9, 254, 137, 1, 38, SKIN_EQMAIN); |
395 ui_skinned_button_set_skin_index2(equalizerwin_shade, SKIN_EQ_EX); | |
396 g_signal_connect(equalizerwin_shade, "clicked", equalizerwin_shade_toggle, NULL ); | |
397 | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
398 equalizerwin_shaded_close = ui_skinned_button_new(); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
399 ui_skinned_push_button_setup(equalizerwin_shaded_close, SKINNED_WINDOW(equalizerwin)->shaded, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
400 264, 3, 9, 9, 11, 38, 11, 47, SKIN_EQ_EX); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
401 g_signal_connect(equalizerwin_shaded_close, "clicked", equalizerwin_close_cb, NULL ); |
2606 | 402 |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
403 equalizerwin_shaded_shade = ui_skinned_button_new(); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
404 ui_skinned_push_button_setup(equalizerwin_shaded_shade, SKINNED_WINDOW(equalizerwin)->shaded, |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
405 254, 3, 9, 9, 254, 3, 1, 47, SKIN_EQ_EX); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
406 g_signal_connect(equalizerwin_shaded_shade, "clicked", equalizerwin_shade_toggle, NULL ); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
407 |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
408 equalizerwin_graph = ui_skinned_equalizer_graph_new(SKINNED_WINDOW(equalizerwin)->normal, 86, 17); |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
409 |
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
410 equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 21, 38); |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
411 ui_skinned_equalizer_slider_set_position (equalizerwin_preamp, |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
412 aud_cfg->equalizer_preamp); |
2606 | 413 |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
414 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) { |
2606 | 415 equalizerwin_bands[i] = |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
416 ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 78 + (i * 18), 38); |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
417 ui_skinned_equalizer_slider_set_position (equalizerwin_bands [i], |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
418 aud_cfg->equalizer_bands [i]); |
2606 | 419 } |
420 | |
421 equalizerwin_volume = | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
422 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded, |
2606 | 423 61, 4, 97, 8, 1, 30, 1, 30, 3, 7, 4, 61, 0, 94, |
424 equalizerwin_volume_frame_cb, SKIN_EQ_EX); | |
425 g_signal_connect(equalizerwin_volume, "motion", G_CALLBACK(equalizerwin_volume_motion_cb), NULL); | |
426 g_signal_connect(equalizerwin_volume, "release", G_CALLBACK(equalizerwin_volume_release_cb), NULL); | |
427 | |
428 | |
429 equalizerwin_balance = | |
2719
51fc44b99b58
use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents:
2678
diff
changeset
|
430 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded, |
2606 | 431 164, 4, 42, 8, 11, 30, 11, 30, 3, 7, 4, 164, 0, 39, |
432 equalizerwin_balance_frame_cb, SKIN_EQ_EX); | |
433 g_signal_connect(equalizerwin_balance, "motion", G_CALLBACK(equalizerwin_balance_motion_cb), NULL); | |
434 g_signal_connect(equalizerwin_balance, "release", G_CALLBACK(equalizerwin_balance_release_cb), NULL); | |
435 } | |
436 | |
437 | |
438 static void | |
439 equalizerwin_create_window(void) | |
440 { | |
441 GdkPixbuf *icon; | |
442 gint width, height; | |
443 | |
444 width = 275; | |
445 height = config.equalizer_shaded ? 14 : 116; | |
446 | |
447 equalizerwin = ui_skinned_window_new("equalizer"); | |
448 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer")); | |
449 gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer"); | |
450 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE); | |
451 | |
452 if (config.scaled && config.eq_scaled_linked) { | |
453 width *= config.scale_factor; | |
454 height *= config.scale_factor; | |
455 } | |
456 | |
457 gtk_widget_set_size_request(equalizerwin, width, height); | |
458 | |
459 /* this will hide only mainwin. it's annoying! yaz */ | |
460 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin), | |
461 GTK_WINDOW(mainwin)); | |
462 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE); | |
463 | |
464 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_eq_icon); | |
465 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon); | |
466 g_object_unref(icon); | |
467 | |
468 gtk_widget_set_app_paintable(equalizerwin, TRUE); | |
469 | |
470 if (config.equalizer_x != -1 && config.save_window_position) | |
471 gtk_window_move(GTK_WINDOW(equalizerwin), | |
472 config.equalizer_x, config.equalizer_y); | |
473 | |
474 g_signal_connect(equalizerwin, "delete_event", | |
475 G_CALLBACK(equalizerwin_delete), NULL); | |
476 g_signal_connect(equalizerwin, "button_press_event", | |
477 G_CALLBACK(equalizerwin_press), NULL); | |
478 g_signal_connect(equalizerwin, "key_press_event", | |
479 G_CALLBACK(equalizerwin_keypress), NULL); | |
480 } | |
481 | |
482 void | |
483 equalizerwin_create(void) | |
484 { | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
485 equalizer_presets = aud_equalizer_read_presets("eq.preset"); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
486 equalizer_auto_presets = aud_equalizer_read_presets("eq.auto_preset"); |
2606 | 487 |
488 equalizerwin_create_window(); | |
489 | |
490 gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); | |
491 | |
492 equalizerwin_create_widgets(); | |
493 } | |
494 | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
495 static void equalizerwin_real_show (void) |
2606 | 496 { |
497 gtk_window_move(GTK_WINDOW(equalizerwin), config.equalizer_x, config.equalizer_y); | |
498 if (config.scaled && config.eq_scaled_linked) | |
499 gtk_widget_set_size_request(equalizerwin, 275 * config.scale_factor, | |
500 ((config.equalizer_shaded ? 14 : 116) * config.scale_factor)); | |
501 else | |
502 gtk_widget_set_size_request(equalizerwin, 275, | |
503 (config.equalizer_shaded ? 14 : 116)); | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2641
diff
changeset
|
504 ui_skinned_button_set_inside(mainwin_eq, TRUE); |
2606 | 505 gtk_widget_show_all(equalizerwin); |
506 | |
507 gtk_window_present(GTK_WINDOW(equalizerwin)); | |
508 } | |
509 | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
510 static void equalizerwin_real_hide (void) |
2606 | 511 { |
512 gtk_widget_hide(equalizerwin); | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2641
diff
changeset
|
513 ui_skinned_button_set_inside(mainwin_eq, FALSE); |
2606 | 514 gtk_widget_queue_draw(mainwin_eq); |
515 } | |
516 | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
517 void |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
518 equalizerwin_show(gboolean show) |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
519 { |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
520 GtkAction * a; |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
521 |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
522 a = gtk_action_group_get_action (toggleaction_group_others, "show equalizer"); |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
523 |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
524 if (a && gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (a)) != show) |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
525 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), show); |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
526 else |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
527 { |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
528 config.equalizer_visible = show; |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
529 aud_cfg->equalizer_visible = show; |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
530 |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
531 if (show) |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
532 equalizerwin_real_show (); |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
533 else |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
534 equalizerwin_real_hide (); |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
535 } |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
536 } |
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
537 |
2606 | 538 static EqualizerPreset * |
539 equalizerwin_find_preset(GList * list, const gchar * name) | |
540 { | |
541 GList *node = list; | |
542 EqualizerPreset *preset; | |
543 | |
544 while (node) { | |
545 preset = node->data; | |
546 if (!strcasecmp(preset->name, name)) | |
547 return preset; | |
548 node = g_list_next(node); | |
549 } | |
550 return NULL; | |
551 } | |
552 | |
553 static gboolean | |
554 equalizerwin_load_preset(GList * list, const gchar * name) | |
555 { | |
556 EqualizerPreset *preset; | |
557 gint i; | |
558 | |
559 if ((preset = equalizerwin_find_preset(list, name)) != NULL) { | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
560 equalizerwin_set_preamp(preset->preamp); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
561 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
562 equalizerwin_set_band(i, preset->bands[i]); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
563 |
2606 | 564 return TRUE; |
565 } | |
566 return FALSE; | |
567 } | |
568 | |
569 static GList * | |
570 equalizerwin_save_preset(GList * list, const gchar * name, | |
571 const gchar * filename) | |
572 { | |
573 gint i; | |
574 EqualizerPreset *preset; | |
575 | |
576 if (!(preset = equalizerwin_find_preset(list, name))) { | |
577 preset = g_new0(EqualizerPreset, 1); | |
578 preset->name = g_strdup(name); | |
579 list = g_list_append(list, preset); | |
580 } | |
581 | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
582 preset->preamp = equalizerwin_get_preamp(); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
583 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
584 preset->bands[i] = equalizerwin_get_band(i); |
2606 | 585 |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
586 aud_equalizer_write_preset_file(list, filename); |
2606 | 587 |
588 return list; | |
589 } | |
590 | |
591 static GList * | |
592 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename) | |
593 { | |
594 EqualizerPreset *preset; | |
595 GList *node; | |
596 | |
597 if (!(preset = equalizerwin_find_preset(list, name))) | |
598 return list; | |
599 | |
600 if (!(node = g_list_find(list, preset))) | |
601 return list; | |
602 | |
603 list = g_list_remove_link(list, node); | |
604 equalizer_preset_free(preset); | |
605 g_list_free_1(node); | |
606 | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
607 aud_equalizer_write_preset_file(list, filename); |
2606 | 608 |
609 return list; | |
610 } | |
611 | |
612 static void | |
613 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename) | |
614 { | |
615 gchar *text; | |
616 | |
617 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); | |
618 GtkTreeModel *model = gtk_tree_view_get_model(view); | |
619 | |
620 /* | |
621 * first we are making a list of the selected rows, then we convert this | |
622 * list into a list of GtkTreeRowReferences, so that when you delete an | |
623 * item you can still access the other items | |
624 * finally we iterate through all GtkTreeRowReferences, convert them to | |
625 * GtkTreeIters and delete those one after the other | |
626 */ | |
627 | |
628 GList *list = gtk_tree_selection_get_selected_rows(selection, &model); | |
629 GList *rrefs = NULL; | |
630 GList *litr; | |
631 | |
632 for (litr = list; litr; litr = litr->next) | |
633 { | |
634 GtkTreePath *path = litr->data; | |
635 rrefs = g_list_append(rrefs, gtk_tree_row_reference_new(model, path)); | |
636 } | |
637 | |
638 for (litr = rrefs; litr; litr = litr->next) | |
639 { | |
640 GtkTreeRowReference *ref = litr->data; | |
641 GtkTreePath *path = gtk_tree_row_reference_get_path(ref); | |
642 GtkTreeIter iter; | |
643 gtk_tree_model_get_iter(model, &iter, path); | |
644 | |
645 gtk_tree_model_get(model, &iter, 0, &text, -1); | |
646 | |
647 if (!strcmp(filename, "eq.preset")) | |
648 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename); | |
649 else if (!strcmp(filename, "eq.auto_preset")) | |
650 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename); | |
651 | |
652 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
653 } | |
654 } | |
655 | |
656 static void | |
657 free_cb (gpointer data, gpointer user_data) | |
658 { | |
659 equalizer_preset_free((EqualizerPreset*)data); | |
660 } | |
661 | |
662 static void | |
663 equalizerwin_read_winamp_eqf(VFSFile * file) | |
664 { | |
665 GList *presets; | |
666 gint i; | |
667 | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
668 if ((presets = aud_import_winamp_eqf(file)) == NULL) |
2606 | 669 return; |
670 | |
671 /* just get the first preset --asphyx */ | |
672 EqualizerPreset *preset = (EqualizerPreset*)presets->data; | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
673 equalizerwin_set_preamp(preset->preamp); |
2606 | 674 |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
675 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
676 equalizerwin_set_band(i, preset->bands[i]); |
2606 | 677 |
678 g_list_foreach(presets, free_cb, NULL); | |
679 g_list_free(presets); | |
680 | |
681 equalizerwin_eq_changed(); | |
682 } | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
683 |
2606 | 684 static void |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
685 equalizerwin_read_aud_preset(const gchar * file) |
2606 | 686 { |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
687 EqualizerPreset *preset = aud_equalizer_read_aud_preset(file); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
688 if (preset) { |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
689 equalizerwin_apply_preset(preset); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
690 equalizer_preset_free(preset); |
2606 | 691 } |
692 } | |
693 | |
694 static void | |
695 equalizerwin_save_ok(GtkWidget * widget, gpointer data) | |
696 { | |
697 const gchar *text; | |
698 | |
699 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry)); | |
700 if (strlen(text) != 0) | |
701 equalizer_presets = | |
702 equalizerwin_save_preset(equalizer_presets, text, "eq.preset"); | |
703 gtk_widget_destroy(equalizerwin_save_window); | |
704 } | |
705 | |
706 static void | |
707 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path, | |
708 GtkTreeViewColumn *col, gpointer data) | |
709 { | |
710 gchar *text; | |
711 | |
712 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); | |
713 GtkTreeModel *model; | |
714 GtkTreeIter iter; | |
715 | |
716 if (selection) | |
717 { | |
718 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
719 { | |
720 gtk_tree_model_get(model, &iter, 0, &text, -1); | |
721 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text); | |
722 equalizerwin_save_ok(NULL, NULL); | |
723 | |
724 g_free(text); | |
725 } | |
726 } | |
727 } | |
728 | |
729 static void | |
730 equalizerwin_load_ok(GtkWidget *widget, gpointer data) | |
731 { | |
732 gchar *text; | |
733 | |
734 GtkTreeView* view = GTK_TREE_VIEW(data); | |
735 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); | |
736 GtkTreeModel *model; | |
737 GtkTreeIter iter; | |
738 | |
739 if (selection) | |
740 { | |
741 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
742 { | |
743 gtk_tree_model_get(model, &iter, 0, &text, -1); | |
744 equalizerwin_load_preset(equalizer_presets, text); | |
745 | |
746 g_free(text); | |
747 } | |
748 } | |
749 gtk_widget_destroy(equalizerwin_load_window); | |
750 } | |
751 | |
752 static void | |
753 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path, | |
754 GtkTreeViewColumn *col, gpointer data) | |
755 { | |
756 equalizerwin_load_ok(NULL, treeview); | |
757 } | |
758 | |
759 static void | |
760 equalizerwin_delete_delete(GtkWidget *widget, gpointer data) | |
761 { | |
762 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset"); | |
763 } | |
764 | |
765 static void | |
766 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data) | |
767 { | |
768 const gchar *text; | |
769 | |
770 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry)); | |
771 if (strlen(text) != 0) | |
772 equalizer_auto_presets = | |
773 equalizerwin_save_preset(equalizer_auto_presets, text, | |
774 "eq.auto_preset"); | |
775 gtk_widget_destroy(equalizerwin_save_auto_window); | |
776 } | |
777 | |
778 static void | |
779 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
780 GtkTreeViewColumn *col, gpointer data) | |
781 { | |
782 gchar *text; | |
783 | |
784 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); | |
785 GtkTreeModel *model; | |
786 GtkTreeIter iter; | |
787 | |
788 if (selection) | |
789 { | |
790 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
791 { | |
792 gtk_tree_model_get(model, &iter, 0, &text, -1); | |
793 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text); | |
794 equalizerwin_save_auto_ok(NULL, NULL); | |
795 | |
796 g_free(text); | |
797 } | |
798 } | |
799 } | |
800 | |
801 static void | |
802 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data) | |
803 { | |
804 gchar *text; | |
805 | |
806 GtkTreeView *view = GTK_TREE_VIEW(data); | |
807 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); | |
808 GtkTreeModel *model; | |
809 GtkTreeIter iter; | |
810 | |
811 if (selection) | |
812 { | |
813 if (gtk_tree_selection_get_selected(selection, &model, &iter)) | |
814 { | |
815 gtk_tree_model_get(model, &iter, 0, &text, -1); | |
816 equalizerwin_load_preset(equalizer_auto_presets, text); | |
817 | |
818 g_free(text); | |
819 } | |
820 } | |
821 gtk_widget_destroy(equalizerwin_load_auto_window); | |
822 } | |
823 | |
824 static void | |
825 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
826 GtkTreeViewColumn *col, gpointer data) | |
827 { | |
828 equalizerwin_load_auto_ok(NULL, treeview); | |
829 } | |
830 | |
831 static void | |
832 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data) | |
833 { | |
834 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset"); | |
835 } | |
836 | |
837 static VFSFile * | |
838 open_vfs_file(const gchar *filename, const gchar *mode) | |
839 { | |
840 VFSFile *file; | |
841 GtkWidget *dialog; | |
842 | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
843 if (!(file = aud_vfs_fopen(filename, mode))) { |
2606 | 844 dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), |
845 GTK_DIALOG_DESTROY_WITH_PARENT, | |
846 GTK_MESSAGE_ERROR, | |
847 GTK_BUTTONS_CLOSE, | |
848 "Error loading file '%s'", | |
849 filename); | |
850 gtk_dialog_run (GTK_DIALOG (dialog)); | |
851 gtk_widget_destroy (dialog); | |
852 } | |
853 | |
854 return file; | |
855 } | |
856 | |
857 static void | |
858 load_winamp_file(const gchar * filename) | |
859 { | |
860 VFSFile *file; | |
861 | |
862 if (!(file = open_vfs_file(filename, "rb"))) | |
863 return; | |
864 | |
865 equalizerwin_read_winamp_eqf(file); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
866 aud_vfs_fclose(file); |
2606 | 867 } |
868 | |
869 static void | |
870 import_winamp_file(const gchar * filename) | |
871 { | |
872 VFSFile *file; | |
873 GList *list; | |
874 | |
875 if (!(file = open_vfs_file(filename, "rb")) || | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
876 !(list = aud_import_winamp_eqf(file))) |
2606 | 877 return; |
878 | |
879 equalizer_presets = g_list_concat(equalizer_presets, list); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
880 aud_equalizer_write_preset_file(equalizer_presets, "eq.preset"); |
2606 | 881 |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
882 aud_vfs_fclose(file); |
2606 | 883 } |
884 | |
885 static void | |
886 save_winamp_file(const gchar * filename) | |
887 { | |
888 VFSFile *file; | |
889 | |
890 gchar name[257]; | |
891 gint i; | |
892 guchar bands[11]; | |
893 | |
894 if (!(file = open_vfs_file(filename, "wb"))) | |
895 return; | |
896 | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
897 aud_vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file); |
2606 | 898 |
899 memset(name, 0, 257); | |
900 g_strlcpy(name, "Entry1", 257); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
901 aud_vfs_fwrite(name, 1, 257, file); |
2606 | 902 |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
903 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
904 bands[i] = 63 - (((equalizerwin_get_band(i) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
905 |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
906 bands[AUD_EQUALIZER_NBANDS] = 63 - (((equalizerwin_get_preamp() + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
907 |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
908 aud_vfs_fwrite(bands, 1, 11, file); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
909 aud_vfs_fclose(file); |
2606 | 910 } |
911 | |
912 static GtkWidget * | |
913 equalizerwin_create_list_window(GList *preset_list, | |
914 const gchar *title, | |
915 GtkWidget **window, | |
916 GtkSelectionMode sel_mode, | |
917 GtkWidget **entry, | |
918 const gchar *action_name, | |
919 GCallback action_func, | |
920 GCallback select_row_func) | |
921 { | |
922 GtkWidget *vbox, *scrolled_window, *bbox, *view; | |
923 GtkWidget *button_cancel, *button_action; | |
924 GList *node; | |
925 | |
926 GtkListStore *store; | |
927 GtkTreeIter iter; | |
928 GtkTreeModel *model; | |
929 GtkCellRenderer *renderer; | |
930 GtkTreeSelection *selection; | |
931 GtkTreeSortable *sortable; | |
932 | |
933 | |
934 | |
935 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
936 gtk_window_set_title(GTK_WINDOW(*window), title); | |
937 gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
938 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300); | |
939 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER); | |
940 gtk_container_set_border_width(GTK_CONTAINER(*window), 10); | |
941 gtk_window_set_transient_for(GTK_WINDOW(*window), | |
942 GTK_WINDOW(equalizerwin)); | |
943 g_signal_connect(*window, "destroy", | |
944 G_CALLBACK(gtk_widget_destroyed), window); | |
945 | |
946 vbox = gtk_vbox_new(FALSE, 10); | |
947 gtk_container_add(GTK_CONTAINER(*window), vbox); | |
948 | |
949 scrolled_window = gtk_scrolled_window_new(NULL, NULL); | |
950 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), | |
951 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
952 | |
953 | |
954 /* fill the store with the names of all available presets */ | |
955 store = gtk_list_store_new(1, G_TYPE_STRING); | |
956 for (node = preset_list; node; node = g_list_next(node)) | |
957 { | |
958 gtk_list_store_append(store, &iter); | |
959 gtk_list_store_set(store, &iter, | |
960 0, ((EqualizerPreset*)node->data)->name, | |
961 -1); | |
962 } | |
963 model = GTK_TREE_MODEL(store); | |
964 | |
965 | |
966 sortable = GTK_TREE_SORTABLE(store); | |
967 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING); | |
968 | |
969 | |
970 view = gtk_tree_view_new(); | |
971 renderer = gtk_cell_renderer_text_new(); | |
972 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, | |
973 _("Presets"), renderer, | |
974 "text", 0, NULL); | |
975 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); | |
976 g_object_unref(model); | |
977 | |
978 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); | |
979 gtk_tree_selection_set_mode(selection, sel_mode); | |
980 | |
981 | |
982 | |
983 | |
984 gtk_container_add(GTK_CONTAINER(scrolled_window), view); | |
985 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); | |
986 | |
987 if (entry) { | |
988 *entry = gtk_entry_new(); | |
989 g_signal_connect(*entry, "activate", action_func, NULL); | |
990 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0); | |
991 } | |
992 | |
993 bbox = gtk_hbutton_box_new(); | |
994 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
3017
963796db51ea
Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents:
2971
diff
changeset
|
995 gtk_box_set_spacing(GTK_BOX(bbox), 5); |
2606 | 996 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); |
997 | |
998 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
999 g_signal_connect_swapped(button_cancel, "clicked", | |
1000 G_CALLBACK(gtk_widget_destroy), | |
1001 GTK_OBJECT(*window)); | |
1002 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0); | |
1003 | |
1004 button_action = gtk_button_new_from_stock(action_name); | |
1005 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view); | |
1006 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT); | |
1007 | |
1008 if (select_row_func) | |
1009 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL); | |
1010 | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
1011 |
2606 | 1012 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0); |
1013 | |
1014 gtk_widget_grab_default(button_action); | |
1015 | |
1016 | |
1017 gtk_widget_show_all(*window); | |
1018 | |
1019 return *window; | |
1020 } | |
1021 | |
1022 void | |
1023 equalizerwin_load_auto_preset(const gchar * filename) | |
1024 { | |
1025 gchar *presetfilename, *directory; | |
1026 | |
1027 g_return_if_fail(filename != NULL); | |
1028 | |
1029 if (!aud_cfg->equalizer_autoload) | |
1030 return; | |
1031 | |
1032 presetfilename = g_strconcat(filename, ".", aud_cfg->eqpreset_extension, NULL); | |
1033 | |
1034 /* First try to find a per file preset file */ | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1035 if (strlen(aud_cfg->eqpreset_extension) > 0) { |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1036 equalizerwin_read_aud_preset(presetfilename); |
2606 | 1037 g_free(presetfilename); |
1038 return; | |
1039 } | |
1040 | |
1041 g_free(presetfilename); | |
1042 | |
1043 directory = g_path_get_dirname(filename); | |
1044 presetfilename = g_build_filename(directory, aud_cfg->eqpreset_default_file, | |
1045 NULL); | |
1046 g_free(directory); | |
1047 | |
1048 /* Try to find a per directory preset file */ | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1049 if (strlen(aud_cfg->eqpreset_default_file) > 0) { |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1050 equalizerwin_read_aud_preset(presetfilename); |
2606 | 1051 } |
1052 else if (!equalizerwin_load_preset | |
1053 (equalizer_auto_presets, g_basename(filename))) { | |
1054 /* Fall back to the oldstyle auto presets */ | |
1055 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1056 } | |
1057 | |
1058 g_free(presetfilename); | |
1059 } | |
1060 | |
1061 void | |
1062 equalizerwin_set_preamp(gfloat preamp) | |
1063 { | |
1064 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preamp); | |
1065 equalizerwin_eq_changed(); | |
1066 } | |
1067 | |
1068 void | |
1069 equalizerwin_set_band(gint band, gfloat value) | |
1070 { | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1071 g_return_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS); |
2606 | 1072 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value); |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
1073 equalizerwin_eq_changed(); |
2606 | 1074 } |
1075 | |
1076 gfloat | |
1077 equalizerwin_get_preamp(void) | |
1078 { | |
1079 return ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); | |
1080 } | |
1081 | |
1082 gfloat | |
1083 equalizerwin_get_band(gint band) | |
1084 { | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1085 g_return_val_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS, 0.0); |
2606 | 1086 return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]); |
1087 } | |
1088 | |
1089 void | |
1090 action_equ_load_preset(void) | |
1091 { | |
1092 if (equalizerwin_load_window) { | |
1093 gtk_window_present(GTK_WINDOW(equalizerwin_load_window)); | |
1094 return; | |
1095 } | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1096 |
2606 | 1097 equalizerwin_create_list_window(equalizer_presets, |
1098 Q_("Load preset"), | |
1099 &equalizerwin_load_window, | |
1100 GTK_SELECTION_SINGLE, NULL, | |
1101 GTK_STOCK_OK, | |
1102 G_CALLBACK(equalizerwin_load_ok), | |
1103 G_CALLBACK(equalizerwin_load_select)); | |
1104 } | |
1105 | |
1106 void | |
1107 action_equ_load_auto_preset(void) | |
1108 { | |
1109 if (equalizerwin_load_auto_window) { | |
1110 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window)); | |
1111 return; | |
1112 } | |
1113 | |
1114 equalizerwin_create_list_window(equalizer_auto_presets, | |
1115 Q_("Load auto-preset"), | |
1116 &equalizerwin_load_auto_window, | |
1117 GTK_SELECTION_SINGLE, NULL, | |
1118 GTK_STOCK_OK, | |
1119 G_CALLBACK(equalizerwin_load_auto_ok), | |
1120 G_CALLBACK(equalizerwin_load_auto_select)); | |
1121 } | |
1122 | |
1123 void | |
1124 action_equ_load_default_preset(void) | |
1125 { | |
1126 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1127 } | |
1128 | |
1129 void | |
1130 action_equ_zero_preset(void) | |
1131 { | |
1132 gint i; | |
1133 | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1134 equalizerwin_set_preamp(0); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1135 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1136 equalizerwin_set_band(i, 0); |
2606 | 1137 } |
1138 | |
1139 void | |
1140 action_equ_load_preset_file(void) | |
1141 { | |
1142 GtkWidget *dialog; | |
1143 gchar *file_uri; | |
1144 | |
1145 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
1146 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1147 { | |
1148 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1149 EqualizerPreset *preset = aud_load_preset_file(file_uri); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1150 equalizerwin_apply_preset(preset); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1151 equalizer_preset_free(preset); |
2606 | 1152 g_free(file_uri); |
1153 } | |
1154 gtk_widget_destroy(dialog); | |
1155 } | |
1156 | |
1157 void | |
1158 action_equ_load_preset_eqf(void) | |
1159 { | |
1160 GtkWidget *dialog; | |
1161 gchar *file_uri; | |
1162 | |
1163 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
1164 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1165 { | |
1166 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); | |
1167 load_winamp_file(file_uri); | |
1168 g_free(file_uri); | |
1169 } | |
1170 gtk_widget_destroy(dialog); | |
1171 } | |
1172 | |
1173 void | |
1174 action_equ_import_winamp_presets(void) | |
1175 { | |
1176 GtkWidget *dialog; | |
1177 gchar *file_uri; | |
1178 | |
1179 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
1180 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1181 { | |
1182 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); | |
1183 import_winamp_file(file_uri); | |
1184 g_free(file_uri); | |
1185 } | |
1186 gtk_widget_destroy(dialog); | |
1187 } | |
1188 | |
1189 void | |
1190 action_equ_save_preset(void) | |
1191 { | |
1192 if (equalizerwin_save_window) { | |
1193 gtk_window_present(GTK_WINDOW(equalizerwin_save_window)); | |
1194 return; | |
1195 } | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
1196 |
2606 | 1197 equalizerwin_create_list_window(equalizer_presets, |
1198 Q_("Save preset"), | |
1199 &equalizerwin_save_window, | |
1200 GTK_SELECTION_SINGLE, | |
1201 &equalizerwin_save_entry, | |
1202 GTK_STOCK_OK, | |
1203 G_CALLBACK(equalizerwin_save_ok), | |
1204 G_CALLBACK(equalizerwin_save_select)); | |
1205 } | |
1206 | |
1207 void | |
1208 action_equ_save_auto_preset(void) | |
1209 { | |
1210 gchar *name; | |
1211 Playlist *playlist = aud_playlist_get_active(); | |
1212 | |
1213 if (equalizerwin_save_auto_window) | |
1214 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window)); | |
1215 else | |
1216 equalizerwin_create_list_window(equalizer_auto_presets, | |
1217 Q_("Save auto-preset"), | |
1218 &equalizerwin_save_auto_window, | |
1219 GTK_SELECTION_SINGLE, | |
1220 &equalizerwin_save_auto_entry, | |
1221 GTK_STOCK_OK, | |
1222 G_CALLBACK(equalizerwin_save_auto_ok), | |
1223 G_CALLBACK(equalizerwin_save_auto_select)); | |
1224 | |
1225 name = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist)); | |
1226 if (name) { | |
1227 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), | |
1228 g_basename(name)); | |
1229 g_free(name); | |
1230 } | |
1231 } | |
1232 | |
1233 void | |
1234 action_equ_save_default_preset(void) | |
1235 { | |
1236 equalizer_presets = | |
1237 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset"); | |
1238 } | |
1239 | |
1240 void | |
1241 action_equ_save_preset_file(void) | |
1242 { | |
1243 GtkWidget *dialog; | |
1244 gchar *file_uri; | |
1245 gchar *songname; | |
1246 Playlist *playlist = aud_playlist_get_active(); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1247 gint i; |
2606 | 1248 |
1249 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
1250 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1251 { | |
1252 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); | |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1253 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1254 preset->name = g_strdup(file_uri); |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1255 preset->preamp = equalizerwin_get_preamp(); |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1256 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) |
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1257 preset->bands[i] = equalizerwin_get_band(i); |
2786
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1258 aud_save_preset_file(preset, file_uri); |
b7d8e6fd4644
make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents:
2719
diff
changeset
|
1259 equalizer_preset_free(preset); |
2606 | 1260 g_free(file_uri); |
1261 } | |
1262 | |
1263 songname = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist)); | |
1264 if (songname) { | |
1265 gchar *eqname = g_strdup_printf("%s.%s", songname, | |
1266 aud_cfg->eqpreset_extension); | |
1267 g_free(songname); | |
1268 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
1269 eqname); | |
1270 g_free(eqname); | |
1271 } | |
1272 | |
1273 gtk_widget_destroy(dialog); | |
1274 } | |
1275 | |
1276 void | |
1277 action_equ_save_preset_eqf(void) | |
1278 { | |
1279 GtkWidget *dialog; | |
1280 gchar *file_uri; | |
1281 | |
1282 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
1283 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) | |
1284 { | |
1285 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog)); | |
1286 save_winamp_file(file_uri); | |
1287 g_free(file_uri); | |
1288 } | |
1289 gtk_widget_destroy(dialog); | |
1290 } | |
1291 | |
1292 void | |
1293 action_equ_delete_preset(void) | |
1294 { | |
1295 if (equalizerwin_delete_window) { | |
1296 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window)); | |
1297 return; | |
1298 } | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
1299 |
2606 | 1300 equalizerwin_create_list_window(equalizer_presets, |
1301 Q_("Delete preset"), | |
1302 &equalizerwin_delete_window, | |
1303 GTK_SELECTION_EXTENDED, NULL, | |
1304 GTK_STOCK_DELETE, | |
1305 G_CALLBACK(equalizerwin_delete_delete), | |
1306 NULL); | |
1307 } | |
1308 | |
1309 void | |
1310 action_equ_delete_auto_preset(void) | |
1311 { | |
1312 if (equalizerwin_delete_auto_window) { | |
1313 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window)); | |
1314 return; | |
1315 } | |
3159
1ffcad5f406c
import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
3158
diff
changeset
|
1316 |
2606 | 1317 equalizerwin_create_list_window(equalizer_auto_presets, |
1318 Q_("Delete auto-preset"), | |
1319 &equalizerwin_delete_auto_window, | |
1320 GTK_SELECTION_EXTENDED, NULL, | |
1321 GTK_STOCK_DELETE, | |
1322 G_CALLBACK(equalizerwin_delete_auto_delete), | |
1323 NULL); | |
1324 } | |
1325 | |
1326 void | |
2792
04c38b7a6079
sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents:
2786
diff
changeset
|
1327 equalizerwin_activate(gboolean active) |
2606 | 1328 { |
1329 aud_cfg->equalizer_active = active; | |
2668
a1431a900f28
introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents:
2641
diff
changeset
|
1330 ui_skinned_button_set_inside(equalizerwin_on, active); |
2606 | 1331 equalizerwin_eq_changed(); |
1332 } |