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