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