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