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