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