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