Mercurial > audlegacy
annotate src/audacious/ui_equalizer.c @ 3043:59452118044d
MacOS (and others): Relocate libintl to a location where audacious can link to it automatically.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Thu, 12 Jul 2007 06:01:51 -0500 |
parents | 3db40ad79fd9 |
children | 1a1116e50ad6 |
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 | |
12 * the Free Software Foundation; under version 2 of the License. | |
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 | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #include "ui_equalizer.h" | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <gtk/gtk.h> | |
33 #include <stdio.h> | |
34 #include <math.h> | |
35 #include <string.h> | |
36 | |
37 #include "platform/smartinclude.h" | |
38 #include "widgets/widgetcore.h" | |
39 #include "dock.h" | |
40 #include "hints.h" | |
41 #include "input.h" | |
42 #include "main.h" | |
43 #include "ui_manager.h" | |
44 #include "actions-equalizer.h" | |
45 #include "playlist.h" | |
46 #include "ui_playlist.h" | |
47 #include "util.h" | |
48 #include "output.h" | |
49 | |
2537 | 50 #include "rcfile.h" |
2313 | 51 #include "vfs.h" |
52 | |
53 #include "images/audacious_eq.xpm" | |
54 | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
55 #include "ui_skinned_window.h" |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
56 #include "ui_skinned_button.h" |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
57 |
2313 | 58 enum PresetViewCols { |
59 PRESET_VIEW_COL_NAME, | |
60 PRESET_VIEW_N_COLS | |
61 }; | |
62 | |
63 struct _EqualizerPreset { | |
64 gchar *name; | |
65 gfloat preamp, bands[10]; | |
66 }; | |
67 | |
68 typedef struct _EqualizerPreset EqualizerPreset; | |
69 | |
70 | |
71 GtkWidget *equalizerwin; | |
72 | |
73 static GtkWidget *equalizerwin_load_window = NULL; | |
74 static GtkWidget *equalizerwin_load_auto_window = NULL; | |
75 static GtkWidget *equalizerwin_save_window = NULL; | |
76 static GtkWidget *equalizerwin_save_entry = NULL; | |
77 static GtkWidget *equalizerwin_save_auto_window = NULL; | |
78 static GtkWidget *equalizerwin_save_auto_entry = NULL; | |
79 static GtkWidget *equalizerwin_delete_window = NULL; | |
80 static GtkWidget *equalizerwin_delete_auto_window = NULL; | |
81 | |
82 static GdkPixmap *equalizerwin_bg, *equalizerwin_bg_x2; | |
83 | |
84 static GList *equalizerwin_wlist = NULL; | |
85 | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
86 static GtkWidget *equalizerwin_on, *equalizerwin_auto; |
2313 | 87 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
88 static GtkWidget *equalizerwin_close, *equalizerwin_presets, *equalizerwin_shade; |
2313 | 89 static EqGraph *equalizerwin_graph; |
90 static EqSlider *equalizerwin_preamp, *equalizerwin_bands[10]; | |
91 static HSlider *equalizerwin_volume, *equalizerwin_balance; | |
92 | |
93 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL; | |
94 | |
95 EqualizerPreset * | |
96 equalizer_preset_new(const gchar * name) | |
97 { | |
98 EqualizerPreset *preset = g_new0(EqualizerPreset, 1); | |
99 preset->name = g_strdup(name); | |
100 return preset; | |
101 } | |
102 | |
103 void | |
104 equalizer_preset_free(EqualizerPreset * preset) | |
105 { | |
106 if (!preset) | |
107 return; | |
108 | |
109 g_free(preset->name); | |
110 g_free(preset); | |
111 } | |
112 | |
113 | |
114 static void | |
115 equalizerwin_set_shape_mask(void) | |
116 { | |
117 if (cfg.show_wm_decorations) | |
118 return; | |
119 | |
120 if (cfg.doublesize == FALSE) | |
121 gtk_widget_shape_combine_mask(equalizerwin, | |
122 skin_get_mask(bmp_active_skin, | |
123 SKIN_MASK_EQ), 0, 0); | |
124 else | |
125 gtk_widget_shape_combine_mask(equalizerwin, NULL, 0, 0); | |
126 } | |
127 | |
128 void | |
129 equalizerwin_set_doublesize(gboolean ds) | |
130 { | |
131 gint height; | |
132 | |
133 if (cfg.equalizer_shaded) | |
134 height = 14; | |
135 else | |
136 height = 116; | |
137 | |
138 equalizerwin_set_shape_mask(); | |
139 | |
140 if (ds) { | |
141 dock_window_resize(GTK_WINDOW(equalizerwin), 550, height * 2, 550, height * 2); | |
142 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg_x2, | |
143 0); | |
144 } | |
145 else { | |
146 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height, 275, height); | |
147 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg, 0); | |
148 } | |
149 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
150 GList *iter; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
151 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
|
152 GtkFixedChild *child_data = (GtkFixedChild *) iter->data; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
153 GtkWidget *child = child_data->widget; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
154 g_signal_emit_by_name(child, "toggle-double-size"); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
155 } |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
156 |
2313 | 157 draw_equalizer_window(TRUE); |
158 } | |
159 | |
160 void | |
161 equalizerwin_set_shade_menu_cb(gboolean shaded) | |
162 { | |
163 cfg.equalizer_shaded = shaded; | |
164 | |
165 equalizerwin_set_shape_mask(); | |
166 | |
167 if (shaded) { | |
168 dock_shade(dock_window_list, GTK_WINDOW(equalizerwin), | |
169 14 * (EQUALIZER_DOUBLESIZE + 1)); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQ_EX); |
2313 | 174 widget_show(WIDGET(equalizerwin_volume)); |
175 widget_show(WIDGET(equalizerwin_balance)); | |
176 } | |
177 else { | |
178 dock_shade(dock_window_list, GTK_WINDOW(equalizerwin), | |
179 116 * (EQUALIZER_DOUBLESIZE + 1)); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
180 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
|
181 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
|
182 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
|
183 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQMAIN); |
2313 | 184 widget_hide(WIDGET(equalizerwin_volume)); |
185 widget_hide(WIDGET(equalizerwin_balance)); | |
186 } | |
187 | |
188 draw_equalizer_window(TRUE); | |
189 } | |
190 | |
191 static void | |
192 equalizerwin_set_shade(gboolean shaded) | |
193 { | |
194 GtkAction *action = gtk_action_group_get_action( | |
195 toggleaction_group_others , "roll up equalizer" ); | |
196 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded ); | |
197 } | |
198 | |
199 static void | |
200 equalizerwin_shade_toggle(void) | |
201 { | |
202 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
203 } | |
204 | |
205 static void | |
206 equalizerwin_raise(void) | |
207 { | |
208 if (cfg.equalizer_visible) | |
209 gtk_window_present(GTK_WINDOW(equalizerwin)); | |
210 } | |
211 | |
212 void | |
213 equalizerwin_eq_changed(void) | |
214 { | |
215 gint i; | |
216 | |
217 cfg.equalizer_preamp = eqslider_get_position(equalizerwin_preamp); | |
218 for (i = 0; i < 10; i++) | |
219 cfg.equalizer_bands[i] = eqslider_get_position(equalizerwin_bands[i]); | |
220 /* um .. i think we need both of these for xmms compatibility .. | |
221 not sure. -larne */ | |
222 input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
223 cfg.equalizer_bands); | |
224 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, | |
225 cfg.equalizer_bands); | |
226 | |
227 widget_draw(WIDGET(equalizerwin_graph)); | |
228 } | |
229 | |
230 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
|
231 equalizerwin_on_pushed(void) |
2313 | 232 { |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
233 cfg.equalizer_active = UI_SKINNED_BUTTON(equalizerwin_on)->inside; |
2313 | 234 equalizerwin_eq_changed(); |
235 } | |
236 | |
237 static void | |
238 equalizerwin_presets_pushed(void) | |
239 { | |
240 GdkModifierType modmask; | |
241 gint x, y; | |
242 | |
243 gdk_window_get_pointer(NULL, &x, &y, &modmask); | |
244 ui_manager_popup_menu_show(GTK_MENU(equalizerwin_presets_menu), x, y, 1, GDK_CURRENT_TIME); | |
245 } | |
246 | |
247 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
|
248 equalizerwin_auto_pushed(void) |
2313 | 249 { |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
250 cfg.equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside; |
2313 | 251 } |
252 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
253 static void equalizerwin_draw_titlebar() { |
2313 | 254 if (gtk_window_has_toplevel_focus(GTK_WINDOW(equalizerwin)) || |
255 !cfg.dim_titlebar) { | |
256 if (!cfg.equalizer_shaded) | |
257 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 258 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 134, 0, |
2313 | 259 0, 275, 14); |
260 else | |
261 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 262 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 0, 0, 0, |
2313 | 263 275, 14); |
264 } | |
265 else { | |
266 if (!cfg.equalizer_shaded) | |
267 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 268 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQMAIN, 0, 149, 0, |
2313 | 269 0, 275, 14); |
270 else | |
271 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, | |
2526 | 272 SKINNED_WINDOW(equalizerwin)->gc, SKIN_EQ_EX, 0, 15, 0, 0, |
2313 | 273 275, 14); |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
274 } |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
275 } |
2313 | 276 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
277 void |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
278 draw_equalizer_window(gboolean force) |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
279 { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
280 GdkImage *img, *img2x; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
281 GList *wl; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
282 Widget *w; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
283 gboolean redraw; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
284 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
285 if (!cfg.equalizer_visible) |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
286 return; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
287 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
288 widget_list_lock(equalizerwin_wlist); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
289 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
290 if (force) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
291 if (!cfg.equalizer_shaded) |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
292 skin_draw_pixmap(bmp_active_skin, equalizerwin_bg, SKINNED_WINDOW(equalizerwin)->gc, |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
293 SKIN_EQMAIN, 0, 0, 0, 0, 275, 116); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
294 equalizerwin_draw_titlebar(); |
3000
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
295 |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
296 GList *iter; |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
297 for (iter = GTK_FIXED (SKINNED_WINDOW(equalizerwin)->fixed)->children; iter; iter = g_list_next (iter)) { |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
298 GtkFixedChild *child_data = (GtkFixedChild *) iter->data; |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
299 GtkWidget *child = child_data->widget; |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
300 gtk_widget_queue_draw(child); |
bbca1e0e054a
don't call gtk_widget_show/hide from func that's called every now and then
Tomasz Mon <desowin@gmail.com>
parents:
2999
diff
changeset
|
301 } |
2313 | 302 } |
303 | |
304 widget_list_draw(equalizerwin_wlist, &redraw, force); | |
305 | |
306 if (force || redraw) { | |
307 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
308 if (force) { | |
309 img = gdk_drawable_get_image(equalizerwin_bg, 0, 0, 275, 116); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
310 img2x = create_dblsize_image(img); |
2526 | 311 gdk_draw_image(equalizerwin_bg_x2, SKINNED_WINDOW(equalizerwin)->gc, |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
312 img2x, 0, 0, 0, 0, 550, 232); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
313 g_object_unref(img2x); |
2313 | 314 g_object_unref(img); |
315 } | |
316 else { | |
317 for (wl = equalizerwin_wlist; wl; wl = g_list_next(wl)) { | |
318 w = WIDGET(wl->data); | |
319 if (w->redraw && w->visible) { | |
320 img = gdk_drawable_get_image(equalizerwin_bg, | |
321 w->x, w->y, | |
322 w->width, w->height); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
323 img2x = create_dblsize_image(img); |
2313 | 324 gdk_draw_image(equalizerwin_bg_x2, |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
325 SKINNED_WINDOW(equalizerwin)->gc, img2x, 0, 0, |
2313 | 326 w->x << 1, w->y << 1, w->width << 1, |
327 w->height << 1); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
328 g_object_unref(img2x); |
2313 | 329 g_object_unref(img); |
330 w->redraw = FALSE; | |
331 } | |
332 } | |
333 } | |
334 } | |
335 else | |
336 widget_list_clear_redraw(equalizerwin_wlist); | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
337 |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
338 gdk_window_clear(equalizerwin->window); |
2313 | 339 gdk_flush(); |
340 } | |
341 | |
342 widget_list_unlock(equalizerwin_wlist); | |
343 } | |
344 | |
345 gboolean | |
346 equalizerwin_press(GtkWidget * widget, GdkEventButton * event, | |
347 gpointer callback_data) | |
348 { | |
349 gint mx, my; | |
350 gboolean grab = TRUE; | |
351 | |
352 mx = event->x; | |
353 my = event->y; | |
354 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
355 event->x /= 2; | |
356 event->y /= 2; | |
357 } | |
358 | |
359 if (event->button == 1 && event->type == GDK_BUTTON_PRESS && | |
360 ((cfg.easy_move || cfg.equalizer_shaded || event->y < 14) && | |
2524 | 361 !ui_skinned_window_widgetlist_contained(equalizerwin, event->x, event->y))) { |
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
|
362 equalizerwin_raise(); |
204d1bab71f9
[svn] - if (0 && hint_move_resize_available()) -- i'm not sure how this linked as we do not have a hint_move_resize_available().
nenolod
parents:
2495
diff
changeset
|
363 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
|
364 FALSE); |
2313 | 365 } |
366 else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS | |
367 && event->y < 14) { | |
368 equalizerwin_set_shade(!cfg.equalizer_shaded); | |
369 if (dock_is_moving(GTK_WINDOW(equalizerwin))) | |
370 dock_move_release(GTK_WINDOW(equalizerwin)); | |
371 } | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
372 else if (event->button == 3) { |
2313 | 373 /* |
374 * Pop up the main menu a few pixels down to avoid | |
375 * anything to be selected initially. | |
376 */ | |
377 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root, | |
378 event->y_root + 2, 3, event->time); | |
379 grab = FALSE; | |
380 } | |
381 else { | |
382 handle_press_cb(equalizerwin_wlist, widget, event); | |
383 draw_equalizer_window(FALSE); | |
384 } | |
385 if (grab) | |
386 gdk_pointer_grab(GDK_WINDOW(equalizerwin->window), FALSE, | |
387 GDK_BUTTON_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
388 NULL, NULL, GDK_CURRENT_TIME); | |
389 | |
390 return FALSE; | |
391 } | |
392 | |
393 static void | |
394 equalizerwin_scroll(GtkWidget * widget, GdkEventScroll * event, gpointer data) | |
395 { | |
396 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
397 event->x /= 2; | |
398 event->y /= 2; | |
399 } | |
400 | |
401 handle_scroll_cb(equalizerwin_wlist, widget, event); | |
402 draw_equalizer_window(FALSE); | |
403 } | |
404 | |
405 static gboolean | |
406 equalizerwin_motion(GtkWidget * widget, | |
407 GdkEventMotion * event, gpointer callback_data) | |
408 { | |
409 GdkEvent *gevent; | |
410 | |
411 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
412 event->x /= 2; | |
413 event->y /= 2; | |
414 } | |
2494
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
415 |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
416 handle_motion_cb(equalizerwin_wlist, widget, event); |
59661bd074b4
[svn] Try to put some skinned window code in a common place.
nenolod
parents:
2331
diff
changeset
|
417 draw_equalizer_window(FALSE); |
2313 | 418 |
419 gdk_flush(); | |
420 | |
2601 | 421 while ((gevent = gdk_event_get()) != NULL) gdk_event_free(gevent); |
2313 | 422 |
423 return FALSE; | |
424 } | |
425 | |
426 static gboolean | |
427 equalizerwin_release(GtkWidget * widget, | |
428 GdkEventButton * event, gpointer callback_data) | |
429 { | |
430 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
431 gdk_flush(); | |
432 | |
433 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
434 event->x /= 2; | |
435 event->y /= 2; | |
436 } | |
437 if (dock_is_moving(GTK_WINDOW(equalizerwin))) { | |
438 dock_move_release(GTK_WINDOW(equalizerwin)); | |
439 } | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
440 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
441 handle_release_cb(equalizerwin_wlist, widget, event); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
442 draw_equalizer_window(FALSE); |
2313 | 443 |
444 return FALSE; | |
445 } | |
446 | |
447 static gboolean | |
448 equalizerwin_focus_in(GtkWidget * widget, | |
449 GdkEvent * event, | |
450 gpointer data) | |
451 { | |
452 draw_equalizer_window(TRUE); | |
453 return TRUE; | |
454 } | |
455 | |
456 static gboolean | |
457 equalizerwin_focus_out(GtkWidget * widget, | |
458 GdkEventButton * event, | |
459 gpointer data) | |
460 { | |
461 draw_equalizer_window(TRUE); | |
462 return TRUE; | |
463 } | |
464 | |
465 static gboolean | |
466 equalizerwin_keypress(GtkWidget * widget, | |
467 GdkEventKey * event, | |
468 gpointer data) | |
469 { | |
470 if (!cfg.equalizer_shaded) { | |
471 gtk_widget_event(mainwin, (GdkEvent *) event); | |
472 return TRUE; | |
473 } | |
474 | |
475 switch (event->keyval) { | |
476 case GDK_Left: | |
477 case GDK_KP_Left: | |
478 mainwin_set_balance_diff(-4); | |
479 break; | |
480 case GDK_Right: | |
481 case GDK_KP_Right: | |
482 mainwin_set_balance_diff(4); | |
483 break; | |
484 default: | |
485 gtk_widget_event(mainwin, (GdkEvent *) event); | |
486 break; | |
487 } | |
488 | |
489 return FALSE; | |
490 } | |
491 | |
492 static gboolean | |
493 equalizerwin_configure(GtkWidget * window, | |
494 GdkEventConfigure * event, | |
495 gpointer data) | |
496 { | |
497 if (!GTK_WIDGET_VISIBLE(window)) | |
498 return FALSE; | |
499 | |
500 cfg.equalizer_x = event->x; | |
501 cfg.equalizer_y = event->y; | |
502 return FALSE; | |
503 } | |
504 | |
505 static void | |
506 equalizerwin_set_back_pixmap(void) | |
507 { | |
508 if (cfg.doublesize && cfg.eq_doublesize_linked) | |
509 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg_x2, | |
510 0); | |
511 else | |
512 gdk_window_set_back_pixmap(equalizerwin->window, equalizerwin_bg, 0); | |
513 gdk_window_clear(equalizerwin->window); | |
514 } | |
515 | |
516 static void | |
517 equalizerwin_close_cb(void) | |
518 { | |
519 equalizerwin_show(FALSE); | |
520 } | |
521 | |
522 static gboolean | |
523 equalizerwin_delete(GtkWidget * widget, | |
524 gpointer data) | |
525 { | |
526 equalizerwin_show(FALSE); | |
527 return TRUE; | |
528 } | |
529 | |
530 static GList * | |
531 equalizerwin_read_presets(const gchar * basename) | |
532 { | |
533 gchar *filename, *name; | |
534 RcFile *rcfile; | |
535 GList *list = NULL; | |
536 gint i, p = 0; | |
537 EqualizerPreset *preset; | |
538 | |
539 filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); | |
540 | |
541 if ((rcfile = bmp_rcfile_open(filename)) == NULL) { | |
542 g_free(filename); | |
543 return NULL; | |
544 } | |
545 | |
546 g_free(filename); | |
547 | |
548 for (;;) { | |
549 gchar section[21]; | |
550 | |
551 g_snprintf(section, sizeof(section), "Preset%d", p++); | |
552 if (bmp_rcfile_read_string(rcfile, "Presets", section, &name)) { | |
553 preset = g_new0(EqualizerPreset, 1); | |
554 preset->name = name; | |
555 bmp_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp); | |
556 for (i = 0; i < 10; i++) { | |
557 gchar band[7]; | |
558 g_snprintf(band, sizeof(band), "Band%d", i); | |
559 bmp_rcfile_read_float(rcfile, name, band, &preset->bands[i]); | |
560 } | |
561 list = g_list_prepend(list, preset); | |
562 } | |
563 else | |
564 break; | |
565 } | |
566 list = g_list_reverse(list); | |
567 bmp_rcfile_free(rcfile); | |
568 return list; | |
569 } | |
570 | |
571 gint | |
572 equalizerwin_volume_frame_cb(gint pos) | |
573 { | |
574 if (equalizerwin_volume) { | |
575 if (pos < 32) | |
576 equalizerwin_volume->hs_knob_nx = | |
577 equalizerwin_volume->hs_knob_px = 1; | |
578 else if (pos < 63) | |
579 equalizerwin_volume->hs_knob_nx = | |
580 equalizerwin_volume->hs_knob_px = 4; | |
581 else | |
582 equalizerwin_volume->hs_knob_nx = | |
583 equalizerwin_volume->hs_knob_px = 7; | |
584 } | |
585 return 1; | |
586 } | |
587 | |
588 static void | |
589 equalizerwin_volume_motion_cb(gint pos) | |
590 { | |
591 gint v = (gint) rint(pos * 100 / 94.0); | |
592 mainwin_adjust_volume_motion(v); | |
593 mainwin_set_volume_slider(v); | |
594 } | |
595 | |
596 static void | |
597 equalizerwin_volume_release_cb(gint pos) | |
598 { | |
599 mainwin_adjust_volume_release(); | |
600 } | |
601 | |
602 static gint | |
603 equalizerwin_balance_frame_cb(gint pos) | |
604 { | |
605 if (equalizerwin_balance) { | |
606 if (pos < 13) | |
607 equalizerwin_balance->hs_knob_nx = | |
608 equalizerwin_balance->hs_knob_px = 11; | |
609 else if (pos < 26) | |
610 equalizerwin_balance->hs_knob_nx = | |
611 equalizerwin_balance->hs_knob_px = 14; | |
612 else | |
613 equalizerwin_balance->hs_knob_nx = | |
614 equalizerwin_balance->hs_knob_px = 17; | |
615 } | |
616 | |
617 return 1; | |
618 } | |
619 | |
620 static void | |
621 equalizerwin_balance_motion_cb(gint pos) | |
622 { | |
623 gint b; | |
624 pos = MIN(pos, 38); /* The skin uses a even number of pixels | |
625 for the balance-slider *sigh* */ | |
626 b = (gint) rint((pos - 19) * 100 / 19.0); | |
627 mainwin_adjust_balance_motion(b); | |
628 mainwin_set_balance_slider(b); | |
629 } | |
630 | |
631 static void | |
632 equalizerwin_balance_release_cb(gint pos) | |
633 { | |
634 mainwin_adjust_balance_release(); | |
635 } | |
636 | |
637 void | |
638 equalizerwin_set_balance_slider(gint percent) | |
639 { | |
640 hslider_set_position(equalizerwin_balance, | |
641 (gint) rint((percent * 19 / 100.0) + 19)); | |
642 } | |
643 | |
644 void | |
645 equalizerwin_set_volume_slider(gint percent) | |
646 { | |
647 hslider_set_position(equalizerwin_volume, | |
648 (gint) rint(percent * 94 / 100.0)); | |
649 } | |
650 | |
651 static void | |
652 equalizerwin_create_widgets(void) | |
653 { | |
654 gint i; | |
655 | |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
656 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
|
657 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
|
658 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
|
659 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
|
660 UI_SKINNED_BUTTON(equalizerwin_on)->inside = cfg.equalizer_active; |
2524 | 661 |
2857
c35703c9dd9e
fix equalizerwin, replace TButtons with UiSkinnedButton, tbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2853
diff
changeset
|
662 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
|
663 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
|
664 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
|
665 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
|
666 UI_SKINNED_BUTTON(equalizerwin_auto)->inside = cfg.equalizer_autoload; |
2524 | 667 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 g_signal_connect(equalizerwin_presets, "clicked", equalizerwin_presets_pushed, NULL ); |
2524 | 672 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
673 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
|
674 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
|
675 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
|
676 g_signal_connect(equalizerwin_close, "clicked", equalizerwin_close_cb, NULL ); |
2313 | 677 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
678 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
|
679 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
|
680 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
|
681 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
|
682 g_signal_connect(equalizerwin_shade, "clicked", equalizerwin_shade_toggle, NULL ); |
2313 | 683 |
684 equalizerwin_graph = | |
685 create_eqgraph(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 686 SKINNED_WINDOW(equalizerwin)->gc, 86, 17); |
2524 | 687 ui_skinned_window_widgetlist_associate(equalizerwin, |
688 WIDGET(equalizerwin_graph)); | |
689 | |
2313 | 690 equalizerwin_preamp = |
691 create_eqslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 692 SKINNED_WINDOW(equalizerwin)->gc, 21, 38); |
2313 | 693 eqslider_set_position(equalizerwin_preamp, cfg.equalizer_preamp); |
2524 | 694 ui_skinned_window_widgetlist_associate(equalizerwin, |
695 WIDGET(equalizerwin_preamp)); | |
696 | |
2313 | 697 for (i = 0; i < 10; i++) { |
698 equalizerwin_bands[i] = | |
699 create_eqslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 700 SKINNED_WINDOW(equalizerwin)->gc, 78 + (i * 18), 38); |
2313 | 701 eqslider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]); |
2524 | 702 ui_skinned_window_widgetlist_associate(equalizerwin, |
703 WIDGET(equalizerwin_bands[i])); | |
2313 | 704 } |
705 | |
706 equalizerwin_volume = | |
707 create_hslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 708 SKINNED_WINDOW(equalizerwin)->gc, 61, 4, 97, 8, 1, 30, 1, 30, 3, 7, |
2313 | 709 4, 61, 0, 94, equalizerwin_volume_frame_cb, |
710 equalizerwin_volume_motion_cb, | |
711 equalizerwin_volume_release_cb, SKIN_EQ_EX); | |
2524 | 712 ui_skinned_window_widgetlist_associate(equalizerwin, |
713 WIDGET(equalizerwin_volume)); | |
714 | |
2313 | 715 equalizerwin_balance = |
716 create_hslider(&equalizerwin_wlist, equalizerwin_bg, | |
2526 | 717 SKINNED_WINDOW(equalizerwin)->gc, 164, 4, 42, 8, 11, 30, 11, 30, 3, |
2313 | 718 7, 4, 164, 0, 39, equalizerwin_balance_frame_cb, |
719 equalizerwin_balance_motion_cb, | |
720 equalizerwin_balance_release_cb, SKIN_EQ_EX); | |
2524 | 721 ui_skinned_window_widgetlist_associate(equalizerwin, |
722 WIDGET(equalizerwin_balance)); | |
2313 | 723 |
724 if (!cfg.equalizer_shaded) { | |
725 widget_hide(WIDGET(equalizerwin_volume)); | |
726 widget_hide(WIDGET(equalizerwin_balance)); | |
727 } | |
728 else { | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
729 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
|
730 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
|
731 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
|
732 ui_skinned_button_set_skin_index(equalizerwin_close, SKIN_EQ_EX); |
2313 | 733 } |
734 } | |
735 | |
736 | |
737 static void | |
738 equalizerwin_create_window(void) | |
739 { | |
740 GdkPixbuf *icon; | |
741 gint width, height; | |
742 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
743 width = 275; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
744 height = cfg.equalizer_shaded ? 14 : 116; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
745 |
2515
319b10203d7c
[svn] gtk_window_set_wmclass() has to be called before gtk_widget_realize(). Patched by Christian "Joker" Birchinger from Gentoo.
chainsaw
parents:
2514
diff
changeset
|
746 equalizerwin = ui_skinned_window_new(GTK_WINDOW_TOPLEVEL, "equalizer"); |
2313 | 747 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer")); |
748 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
|
749 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE); |
2313 | 750 |
751 if (cfg.doublesize && cfg.eq_doublesize_linked) { | |
752 width *= 2; | |
753 height *= 2; | |
754 } | |
755 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
756 gtk_widget_set_size_request(equalizerwin, width, height); |
2313 | 757 |
758 /* this will hide only mainwin. it's annoying! yaz */ | |
759 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin), | |
760 GTK_WINDOW(mainwin)); | |
761 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE); | |
762 | |
763 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) bmp_eq_icon); | |
764 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon); | |
765 g_object_unref(icon); | |
766 | |
767 gtk_widget_set_app_paintable(equalizerwin, TRUE); | |
768 | |
769 if (cfg.equalizer_x != -1 && cfg.save_window_position) | |
770 gtk_window_move(GTK_WINDOW(equalizerwin), | |
771 cfg.equalizer_x, cfg.equalizer_y); | |
772 | |
773 g_signal_connect(equalizerwin, "delete_event", | |
774 G_CALLBACK(equalizerwin_delete), NULL); | |
775 g_signal_connect(equalizerwin, "button_press_event", | |
776 G_CALLBACK(equalizerwin_press), NULL); | |
777 g_signal_connect(equalizerwin, "button_release_event", | |
778 G_CALLBACK(equalizerwin_release), NULL); | |
779 g_signal_connect(equalizerwin, "motion_notify_event", | |
780 G_CALLBACK(equalizerwin_motion), NULL); | |
781 g_signal_connect_after(equalizerwin, "focus_in_event", | |
782 G_CALLBACK(equalizerwin_focus_in), NULL); | |
783 g_signal_connect_after(equalizerwin, "focus_out_event", | |
784 G_CALLBACK(equalizerwin_focus_out), NULL); | |
785 g_signal_connect(equalizerwin, "configure_event", | |
786 G_CALLBACK(equalizerwin_configure), NULL); | |
787 g_signal_connect(equalizerwin, "style_set", | |
788 G_CALLBACK(equalizerwin_set_back_pixmap), NULL); | |
789 g_signal_connect(equalizerwin, "key_press_event", | |
790 G_CALLBACK(equalizerwin_keypress), NULL); | |
791 g_signal_connect(equalizerwin, "scroll_event", | |
792 G_CALLBACK(equalizerwin_scroll), NULL); | |
793 } | |
794 | |
795 void | |
796 equalizerwin_create(void) | |
797 { | |
798 equalizer_presets = equalizerwin_read_presets("eq.preset"); | |
799 equalizer_auto_presets = equalizerwin_read_presets("eq.auto_preset"); | |
800 | |
801 equalizerwin_create_window(); | |
802 | |
803 gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); | |
804 | |
805 equalizerwin_bg = gdk_pixmap_new(equalizerwin->window, 275, 116, -1); | |
806 equalizerwin_bg_x2 = gdk_pixmap_new(equalizerwin->window, 550, 232, -1); | |
807 | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
808 equalizerwin_set_back_pixmap(); |
2313 | 809 equalizerwin_create_widgets(); |
810 } | |
811 | |
812 | |
813 void | |
814 equalizerwin_show(gboolean show) | |
815 { | |
816 GtkAction *action = gtk_action_group_get_action( | |
817 toggleaction_group_others , "show equalizer" ); | |
818 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , show ); | |
819 | |
820 if (show) | |
821 equalizerwin_real_show(); | |
822 else | |
823 equalizerwin_real_hide(); | |
824 } | |
825 | |
826 void | |
827 equalizerwin_real_show(void) | |
828 { | |
2596
9903326fddf2
[svn] - reset the position of the equalizer window properly.
nenolod
parents:
2595
diff
changeset
|
829 gtk_window_move(GTK_WINDOW(equalizerwin), cfg.equalizer_x, cfg.equalizer_y); |
2313 | 830 if (cfg.doublesize && cfg.eq_doublesize_linked) |
831 gtk_widget_set_size_request(equalizerwin, 550, | |
832 (cfg.equalizer_shaded ? 28 : 232)); | |
833 else | |
834 gtk_widget_set_size_request(equalizerwin, 275, | |
835 (cfg.equalizer_shaded ? 14 : 116)); | |
836 gdk_flush(); | |
837 draw_equalizer_window(TRUE); | |
838 cfg.equalizer_visible = TRUE; | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
839 UI_SKINNED_BUTTON(mainwin_eq)->inside = TRUE; |
2999
e6340ab753a1
replace calling redraw signals with gtk_widget_queue_draw()
Tomasz Mon <desowin@gmail.com>
parents:
2857
diff
changeset
|
840 gtk_widget_queue_draw(mainwin_eq); |
2313 | 841 |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
842 gtk_widget_show_all(equalizerwin); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
843 gtk_window_present(GTK_WINDOW(equalizerwin)); |
2313 | 844 } |
845 | |
846 void | |
847 equalizerwin_real_hide(void) | |
848 { | |
849 /* | |
850 * This function should only be called from the | |
851 * main menu signal handler | |
852 */ | |
853 gtk_widget_hide(equalizerwin); | |
854 cfg.equalizer_visible = FALSE; | |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
855 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
|
856 gtk_widget_queue_draw(mainwin_eq); |
2313 | 857 } |
858 | |
859 static EqualizerPreset * | |
860 equalizerwin_find_preset(GList * list, const gchar * name) | |
861 { | |
862 GList *node = list; | |
863 EqualizerPreset *preset; | |
864 | |
865 while (node) { | |
866 preset = node->data; | |
867 if (!strcasecmp(preset->name, name)) | |
868 return preset; | |
869 node = g_list_next(node); | |
870 } | |
871 return NULL; | |
872 } | |
873 | |
874 static void | |
875 equalizerwin_write_preset_file(GList * list, const gchar * basename) | |
876 { | |
877 gchar *filename, *tmp; | |
878 gint i, p; | |
879 EqualizerPreset *preset; | |
880 RcFile *rcfile; | |
881 GList *node; | |
882 | |
883 rcfile = bmp_rcfile_new(); | |
884 p = 0; | |
885 for (node = list; node; node = g_list_next(node)) { | |
886 preset = node->data; | |
887 tmp = g_strdup_printf("Preset%d", p++); | |
888 bmp_rcfile_write_string(rcfile, "Presets", tmp, preset->name); | |
889 g_free(tmp); | |
890 bmp_rcfile_write_float(rcfile, preset->name, "Preamp", | |
891 preset->preamp); | |
892 for (i = 0; i < 10; i++) { | |
893 tmp = g_strdup_printf("Band%d\n", i); | |
894 bmp_rcfile_write_float(rcfile, preset->name, tmp, | |
895 preset->bands[i]); | |
896 g_free(tmp); | |
897 } | |
898 } | |
899 | |
900 filename = g_build_filename(bmp_paths[BMP_PATH_USER_DIR], basename, NULL); | |
901 bmp_rcfile_write(rcfile, filename); | |
902 bmp_rcfile_free(rcfile); | |
903 g_free(filename); | |
904 } | |
905 | |
906 static gboolean | |
907 equalizerwin_load_preset(GList * list, const gchar * name) | |
908 { | |
909 EqualizerPreset *preset; | |
910 gint i; | |
911 | |
912 if ((preset = equalizerwin_find_preset(list, name)) != NULL) { | |
913 eqslider_set_position(equalizerwin_preamp, preset->preamp); | |
914 for (i = 0; i < 10; i++) | |
915 eqslider_set_position(equalizerwin_bands[i], preset->bands[i]); | |
916 equalizerwin_eq_changed(); | |
917 return TRUE; | |
918 } | |
919 return FALSE; | |
920 } | |
921 | |
922 static GList * | |
923 equalizerwin_save_preset(GList * list, const gchar * name, | |
924 const gchar * filename) | |
925 { | |
926 gint i; | |
927 EqualizerPreset *preset; | |
928 | |
929 if (!(preset = equalizerwin_find_preset(list, name))) { | |
930 preset = g_new0(EqualizerPreset, 1); | |
931 preset->name = g_strdup(name); | |
932 list = g_list_append(list, preset); | |
933 } | |
934 | |
935 preset->preamp = eqslider_get_position(equalizerwin_preamp); | |
936 for (i = 0; i < 10; i++) | |
937 preset->bands[i] = eqslider_get_position(equalizerwin_bands[i]); | |
938 | |
939 equalizerwin_write_preset_file(list, filename); | |
940 | |
941 return list; | |
942 } | |
943 | |
944 static GList * | |
945 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename) | |
946 { | |
947 EqualizerPreset *preset; | |
948 GList *node; | |
949 | |
950 if (!(preset = equalizerwin_find_preset(list, name))) | |
951 return list; | |
952 | |
953 if (!(node = g_list_find(list, preset))) | |
954 return list; | |
955 | |
956 list = g_list_remove_link(list, node); | |
957 equalizer_preset_free(preset); | |
958 g_list_free_1(node); | |
959 | |
960 equalizerwin_write_preset_file(list, filename); | |
961 | |
962 return list; | |
963 } | |
964 | |
965 static void | |
966 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename) | |
967 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
968 gchar *text; |
2313 | 969 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
970 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
971 GtkTreeModel *model = gtk_tree_view_get_model(view); |
2313 | 972 |
2514
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 * 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
|
975 * 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
|
976 * item you can still access the other items |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
977 * finally we iterate through all GtkTreeRowReferences, convert them to |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
978 * GtkTreeIters and delete those one after the other |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
979 */ |
2313 | 980 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
981 GList *list = gtk_tree_selection_get_selected_rows(selection, &model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
982 GList *rrefs = NULL; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
983 GList *litr; |
2313 | 984 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
985 for (litr = list; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
986 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
987 GtkTreePath *path = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
988 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
|
989 } |
2313 | 990 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
991 for (litr = rrefs; litr; litr = litr->next) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
992 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
993 GtkTreeRowReference *ref = litr->data; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
994 GtkTreePath *path = gtk_tree_row_reference_get_path(ref); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
995 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
996 gtk_tree_model_get_iter(model, &iter, path); |
2313 | 997 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
998 gtk_tree_model_get(model, &iter, 0, &text, -1); |
2313 | 999 |
2785 | 1000 if (!strcmp(filename, "eq.preset")) |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1001 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename); |
2785 | 1002 else if (!strcmp(filename, "eq.auto_preset")) |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1003 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename); |
2313 | 1004 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1005 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1006 } |
2313 | 1007 } |
1008 | |
1009 | |
1010 static GList * | |
1011 import_winamp_eqf(VFSFile * file) | |
1012 { | |
1013 gchar header[31]; | |
1014 gchar name[257]; | |
1015 gchar bands[11]; | |
1016 gint i = 0; | |
1017 GList *list = NULL; | |
1018 EqualizerPreset *preset; | |
1019 | |
1020 vfs_fread(header, 1, 31, file); | |
1021 if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { | |
1022 while (vfs_fread(name, 1, 257, file)) { | |
1023 preset = equalizer_preset_new(name); | |
1024 preset->preamp = 20.0 - ((bands[10] * 40.0) / 64); | |
1025 | |
1026 vfs_fread(bands, 1, 11, file); | |
1027 | |
1028 for (i = 0; i < 10; i++) | |
1029 preset->bands[i] = 20.0 - ((bands[i] * 40.0) / 64); | |
1030 | |
1031 list = g_list_prepend(list, preset); | |
1032 } | |
1033 } | |
1034 | |
1035 list = g_list_reverse(list); | |
1036 return list; | |
1037 } | |
1038 | |
1039 static void | |
1040 equalizerwin_read_winamp_eqf(VFSFile * file) | |
1041 { | |
1042 gchar header[31]; | |
1043 guchar bands[11]; | |
1044 gint i; | |
1045 | |
1046 vfs_fread(header, 1, 31, file); | |
1047 | |
1048 if (!strncmp(header, "Winamp EQ library file v1.1", 27)) { | |
1049 /* Skip name */ | |
1050 if (vfs_fseek(file, 257, SEEK_CUR) == -1) | |
1051 return; | |
1052 | |
1053 if (vfs_fread(bands, 1, 11, file) != 11) | |
1054 return; | |
1055 | |
1056 eqslider_set_position(equalizerwin_preamp, | |
1057 20.0 - ((bands[10] * 40.0) / 63.0)); | |
1058 | |
1059 for (i = 0; i < 10; i++) | |
1060 eqslider_set_position(equalizerwin_bands[i], | |
1061 20.0 - ((bands[i] * 40.0) / 64.0)); | |
1062 } | |
1063 | |
1064 equalizerwin_eq_changed(); | |
1065 } | |
1066 | |
1067 static void | |
1068 equalizerwin_read_bmp_preset(RcFile * rcfile) | |
1069 { | |
1070 gfloat val; | |
1071 gint i; | |
1072 | |
1073 if (bmp_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) | |
1074 eqslider_set_position(equalizerwin_preamp, val); | |
1075 for (i = 0; i < 10; i++) { | |
1076 gchar tmp[7]; | |
1077 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
1078 if (bmp_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) | |
1079 eqslider_set_position(equalizerwin_bands[i], val); | |
1080 } | |
1081 equalizerwin_eq_changed(); | |
1082 } | |
1083 | |
1084 static void | |
1085 equalizerwin_save_ok(GtkWidget * widget, gpointer data) | |
1086 { | |
1087 const gchar *text; | |
1088 | |
1089 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry)); | |
1090 if (strlen(text) != 0) | |
1091 equalizer_presets = | |
1092 equalizerwin_save_preset(equalizer_presets, text, "eq.preset"); | |
1093 gtk_widget_destroy(equalizerwin_save_window); | |
1094 } | |
1095 | |
1096 static void | |
1097 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1098 GtkTreeViewColumn *col, gpointer data) |
2313 | 1099 { |
1100 gchar *text; | |
1101 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1102 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1103 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1104 GtkTreeIter iter; |
2313 | 1105 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1106 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1107 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1108 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1109 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1110 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1111 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1112 equalizerwin_save_ok(NULL, NULL); |
2313 | 1113 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1114 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1115 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1116 } |
2313 | 1117 } |
1118 | |
1119 static void | |
1120 equalizerwin_load_ok(GtkWidget *widget, gpointer data) | |
1121 { | |
1122 gchar *text; | |
1123 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1124 GtkTreeView* view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1125 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1126 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1127 GtkTreeIter iter; |
2313 | 1128 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1129 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1130 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1131 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1132 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1133 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1134 equalizerwin_load_preset(equalizer_presets, text); |
2313 | 1135 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1136 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1137 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1138 } |
2313 | 1139 gtk_widget_destroy(equalizerwin_load_window); |
1140 } | |
1141 | |
1142 static void | |
1143 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1144 GtkTreeViewColumn *col, gpointer data) |
2313 | 1145 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1146 equalizerwin_load_ok(NULL, treeview); |
2313 | 1147 } |
1148 | |
1149 static void | |
1150 equalizerwin_delete_delete(GtkWidget *widget, gpointer data) | |
1151 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1152 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset"); |
2313 | 1153 } |
1154 | |
1155 static void | |
1156 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data) | |
1157 { | |
1158 const gchar *text; | |
1159 | |
1160 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry)); | |
1161 if (strlen(text) != 0) | |
1162 equalizer_auto_presets = | |
1163 equalizerwin_save_preset(equalizer_auto_presets, text, | |
1164 "eq.auto_preset"); | |
1165 gtk_widget_destroy(equalizerwin_save_auto_window); | |
1166 } | |
1167 | |
1168 static void | |
1169 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1170 GtkTreeViewColumn *col, gpointer data) |
2313 | 1171 { |
1172 gchar *text; | |
1173 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1174 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1175 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1176 GtkTreeIter iter; |
2313 | 1177 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1178 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1179 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1180 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1181 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1182 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1183 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1184 equalizerwin_save_auto_ok(NULL, NULL); |
2313 | 1185 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1186 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1187 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1188 } |
2313 | 1189 } |
1190 | |
1191 static void | |
1192 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data) | |
1193 { | |
1194 gchar *text; | |
1195 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1196 GtkTreeView *view = GTK_TREE_VIEW(data); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1197 GtkTreeSelection *selection = gtk_tree_view_get_selection(view); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1198 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1199 GtkTreeIter iter; |
2313 | 1200 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1201 if (selection) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1202 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1203 if (gtk_tree_selection_get_selected(selection, &model, &iter)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1204 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1205 gtk_tree_model_get(model, &iter, 0, &text, -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1206 equalizerwin_load_preset(equalizer_auto_presets, text); |
2313 | 1207 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1208 g_free(text); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1209 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1210 } |
2313 | 1211 gtk_widget_destroy(equalizerwin_load_auto_window); |
1212 } | |
1213 | |
1214 static void | |
1215 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path, | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1216 GtkTreeViewColumn *col, gpointer data) |
2313 | 1217 { |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1218 equalizerwin_load_auto_ok(NULL, treeview); |
2313 | 1219 } |
1220 | |
1221 static void | |
1222 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data) | |
1223 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1224 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset"); |
2313 | 1225 } |
1226 | |
1227 | |
1228 static void | |
1229 load_preset_file(const gchar *filename) | |
1230 { | |
1231 RcFile *rcfile; | |
1232 | |
1233 if ((rcfile = bmp_rcfile_open(filename)) != NULL) { | |
1234 equalizerwin_read_bmp_preset(rcfile); | |
1235 bmp_rcfile_free(rcfile); | |
1236 } | |
1237 } | |
1238 | |
1239 static void | |
1240 load_winamp_file(const gchar * filename) | |
1241 { | |
1242 VFSFile *file; | |
1243 gchar *tmp; | |
1244 | |
1245 if (!(file = vfs_fopen(filename, "rb"))) { | |
1246 tmp = g_strconcat("Failed to load WinAmp file: ",filename,"\n",NULL); | |
1247 report_error(tmp); | |
1248 g_free(tmp); | |
1249 return; | |
1250 } | |
1251 | |
1252 equalizerwin_read_winamp_eqf(file); | |
1253 vfs_fclose(file); | |
1254 } | |
1255 | |
1256 static void | |
1257 import_winamp_file(const gchar * filename) | |
1258 { | |
1259 VFSFile *file; | |
1260 gchar *tmp; | |
1261 | |
1262 if (!(file = vfs_fopen(filename, "rb"))) { | |
1263 tmp = g_strconcat("Failed to import WinAmp file: ",filename,"\n",NULL); | |
1264 report_error(tmp); | |
1265 g_free(tmp); | |
1266 return; | |
1267 } | |
1268 | |
1269 equalizer_presets = g_list_concat(equalizer_presets, | |
1270 import_winamp_eqf(file)); | |
1271 equalizerwin_write_preset_file(equalizer_presets, "eq.preset"); | |
1272 | |
1273 vfs_fclose(file); | |
1274 } | |
1275 | |
1276 static void | |
1277 save_preset_file(const gchar * filename) | |
1278 { | |
1279 RcFile *rcfile; | |
1280 gint i; | |
1281 | |
1282 rcfile = bmp_rcfile_new(); | |
1283 bmp_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", | |
1284 eqslider_get_position(equalizerwin_preamp)); | |
1285 | |
1286 for (i = 0; i < 10; i++) { | |
1287 gchar tmp[7]; | |
1288 g_snprintf(tmp, sizeof(tmp), "Band%d", i); | |
1289 bmp_rcfile_write_float(rcfile, "Equalizer preset", tmp, | |
1290 eqslider_get_position(equalizerwin_bands[i])); | |
1291 } | |
1292 | |
1293 bmp_rcfile_write(rcfile, filename); | |
1294 bmp_rcfile_free(rcfile); | |
1295 } | |
1296 | |
1297 static void | |
1298 save_winamp_file(const gchar * filename) | |
1299 { | |
1300 VFSFile *file; | |
1301 | |
1302 gchar name[257]; | |
1303 gint i; | |
1304 guchar bands[11]; | |
1305 gchar *tmp; | |
1306 | |
1307 if (!(file = vfs_fopen(filename, "wb"))) { | |
1308 tmp = g_strconcat("Failed to save WinAmp file: ",filename,"\n",NULL); | |
1309 report_error(tmp); | |
1310 g_free(tmp); | |
1311 return; | |
1312 } | |
1313 | |
1314 vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file); | |
1315 | |
1316 memset(name, 0, 257); | |
1317 strcpy(name, "Entry1"); | |
1318 vfs_fwrite(name, 1, 257, file); | |
1319 | |
1320 for (i = 0; i < 10; i++) | |
1321 bands[i] = 63 - (((eqslider_get_position(equalizerwin_bands[i]) + 20) * 63) / 40); | |
1322 bands[10] = 63 - (((eqslider_get_position(equalizerwin_preamp) + 20) * 63) / 40); | |
1323 vfs_fwrite(bands, 1, 11, file); | |
1324 | |
1325 vfs_fclose(file); | |
1326 } | |
1327 | |
1328 static GtkWidget * | |
1329 equalizerwin_create_list_window(GList *preset_list, | |
1330 const gchar *title, | |
1331 GtkWidget **window, | |
1332 GtkSelectionMode sel_mode, | |
1333 GtkWidget **entry, | |
1334 const gchar *action_name, | |
1335 GCallback action_func, | |
1336 GCallback select_row_func) | |
1337 { | |
1338 GtkWidget *vbox, *scrolled_window, *bbox, *view; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1339 GtkWidget *button_cancel, *button_action; |
2313 | 1340 GList *node; |
1341 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1342 GtkListStore *store; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1343 GtkTreeIter iter; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1344 GtkTreeModel *model; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1345 GtkCellRenderer *renderer; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1346 GtkTreeSelection *selection; |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1347 GtkTreeSortable *sortable; |
2313 | 1348 |
1349 | |
1350 | |
1351 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1352 gtk_window_set_title(GTK_WINDOW(*window), title); | |
1353 gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
1354 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300); | |
1355 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER); | |
1356 gtk_container_set_border_width(GTK_CONTAINER(*window), 10); | |
1357 gtk_window_set_transient_for(GTK_WINDOW(*window), | |
1358 GTK_WINDOW(equalizerwin)); | |
1359 g_signal_connect(*window, "destroy", | |
1360 G_CALLBACK(gtk_widget_destroyed), window); | |
1361 | |
1362 vbox = gtk_vbox_new(FALSE, 10); | |
1363 gtk_container_add(GTK_CONTAINER(*window), vbox); | |
1364 | |
1365 scrolled_window = gtk_scrolled_window_new(NULL, NULL); | |
1366 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), | |
1367 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
1368 | |
1369 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1370 /* fill the store with the names of all available presets */ |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1371 store = gtk_list_store_new(1, G_TYPE_STRING); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1372 for (node = preset_list; node; node = g_list_next(node)) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1373 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1374 gtk_list_store_append(store, &iter); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1375 gtk_list_store_set(store, &iter, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1376 0, ((EqualizerPreset*)node->data)->name, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1377 -1); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1378 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1379 model = GTK_TREE_MODEL(store); |
2313 | 1380 |
1381 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1382 sortable = GTK_TREE_SORTABLE(store); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1383 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING); |
2313 | 1384 |
1385 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1386 view = gtk_tree_view_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1387 renderer = gtk_cell_renderer_text_new(); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1388 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
|
1389 _("Presets"), renderer, |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1390 "text", 0, NULL); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1391 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1392 g_object_unref(model); |
2313 | 1393 |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1394 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1395 gtk_tree_selection_set_mode(selection, sel_mode); |
2313 | 1396 |
1397 | |
1398 | |
1399 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1400 gtk_container_add(GTK_CONTAINER(scrolled_window), view); |
2313 | 1401 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); |
1402 | |
1403 if (entry) { | |
1404 *entry = gtk_entry_new(); | |
1405 g_signal_connect(*entry, "activate", action_func, NULL); | |
1406 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0); | |
1407 } | |
1408 | |
1409 bbox = gtk_hbutton_box_new(); | |
1410 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
1411 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
1412 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
1413 | |
1414 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
1415 g_signal_connect_swapped(button_cancel, "clicked", | |
1416 G_CALLBACK(gtk_widget_destroy), | |
1417 GTK_OBJECT(*window)); | |
1418 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0); | |
1419 | |
1420 button_action = gtk_button_new_from_stock(action_name); | |
1421 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view); | |
1422 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT); | |
1423 | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1424 if (select_row_func) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1425 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL); |
2313 | 1426 |
1427 | |
1428 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0); | |
1429 | |
1430 gtk_widget_grab_default(button_action); | |
1431 | |
1432 | |
1433 gtk_widget_show_all(*window); | |
1434 | |
1435 return *window; | |
1436 } | |
1437 | |
1438 void | |
1439 equalizerwin_load_auto_preset(const gchar * filename) | |
1440 { | |
1441 gchar *presetfilename, *directory; | |
1442 RcFile *rcfile; | |
1443 | |
1444 g_return_if_fail(filename != NULL); | |
1445 | |
1446 if (!cfg.equalizer_autoload) | |
1447 return; | |
1448 | |
1449 presetfilename = g_strconcat(filename, ".", cfg.eqpreset_extension, NULL); | |
1450 | |
1451 /* First try to find a per file preset file */ | |
1452 if (strlen(cfg.eqpreset_extension) > 0 && | |
1453 (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { | |
1454 g_free(presetfilename); | |
1455 equalizerwin_read_bmp_preset(rcfile); | |
1456 bmp_rcfile_free(rcfile); | |
1457 return; | |
1458 } | |
1459 | |
1460 g_free(presetfilename); | |
1461 | |
1462 directory = g_path_get_dirname(filename); | |
1463 presetfilename = g_build_filename(directory, cfg.eqpreset_default_file, | |
1464 NULL); | |
1465 g_free(directory); | |
1466 | |
1467 /* Try to find a per directory preset file */ | |
1468 if (strlen(cfg.eqpreset_default_file) > 0 && | |
1469 (rcfile = bmp_rcfile_open(presetfilename)) != NULL) { | |
1470 equalizerwin_read_bmp_preset(rcfile); | |
1471 bmp_rcfile_free(rcfile); | |
1472 } | |
1473 else if (!equalizerwin_load_preset | |
1474 (equalizer_auto_presets, g_basename(filename))) { | |
1475 /* Fall back to the oldstyle auto presets */ | |
1476 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1477 } | |
1478 | |
1479 g_free(presetfilename); | |
1480 } | |
1481 | |
1482 void | |
1483 equalizerwin_set_preamp(gfloat preamp) | |
1484 { | |
1485 eqslider_set_position(equalizerwin_preamp, preamp); | |
1486 equalizerwin_eq_changed(); | |
1487 } | |
1488 | |
1489 void | |
1490 equalizerwin_set_band(gint band, gfloat value) | |
1491 { | |
1492 g_return_if_fail(band >= 0 && band < 10); | |
1493 eqslider_set_position(equalizerwin_bands[band], value); | |
1494 } | |
1495 | |
1496 gfloat | |
1497 equalizerwin_get_preamp(void) | |
1498 { | |
1499 return eqslider_get_position(equalizerwin_preamp); | |
1500 } | |
1501 | |
1502 gfloat | |
1503 equalizerwin_get_band(gint band) | |
1504 { | |
1505 g_return_val_if_fail(band >= 0 && band < 10, 0); | |
1506 return eqslider_get_position(equalizerwin_bands[band]); | |
1507 } | |
1508 | |
1509 void | |
1510 action_equ_load_preset(void) | |
1511 { | |
1512 if (equalizerwin_load_window) { | |
1513 gtk_window_present(GTK_WINDOW(equalizerwin_load_window)); | |
1514 return; | |
1515 } | |
1516 | |
1517 equalizerwin_create_list_window(equalizer_presets, | |
1518 Q_("Load preset"), | |
1519 &equalizerwin_load_window, | |
1520 GTK_SELECTION_SINGLE, NULL, | |
1521 GTK_STOCK_OK, | |
1522 G_CALLBACK(equalizerwin_load_ok), | |
1523 G_CALLBACK(equalizerwin_load_select)); | |
1524 } | |
1525 | |
1526 void | |
1527 action_equ_load_auto_preset(void) | |
1528 { | |
1529 if (equalizerwin_load_auto_window) { | |
1530 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window)); | |
1531 return; | |
1532 } | |
1533 | |
1534 equalizerwin_create_list_window(equalizer_auto_presets, | |
1535 Q_("Load auto-preset"), | |
1536 &equalizerwin_load_auto_window, | |
1537 GTK_SELECTION_SINGLE, NULL, | |
1538 GTK_STOCK_OK, | |
1539 G_CALLBACK(equalizerwin_load_auto_ok), | |
1540 G_CALLBACK(equalizerwin_load_auto_select)); | |
1541 } | |
1542 | |
1543 void | |
1544 action_equ_load_default_preset(void) | |
1545 { | |
1546 equalizerwin_load_preset(equalizer_presets, "Default"); | |
1547 } | |
1548 | |
1549 void | |
1550 action_equ_zero_preset(void) | |
1551 { | |
1552 gint i; | |
1553 | |
1554 eqslider_set_position(equalizerwin_preamp, 0); | |
1555 for (i = 0; i < 10; i++) | |
1556 eqslider_set_position(equalizerwin_bands[i], 0); | |
1557 | |
1558 equalizerwin_eq_changed(); | |
1559 } | |
1560 | |
1561 void | |
1562 action_equ_load_preset_file(void) | |
1563 { | |
1564 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1565 gchar *filename; |
2313 | 1566 |
1567 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1568 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1569 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1570 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1571 load_preset_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1572 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1573 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1574 gtk_widget_destroy(dialog); |
2313 | 1575 } |
1576 | |
1577 void | |
1578 action_equ_load_preset_eqf(void) | |
1579 { | |
1580 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1581 gchar *filename; |
2313 | 1582 |
1583 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1584 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1585 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1586 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1587 load_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1588 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1589 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1590 gtk_widget_destroy(dialog); |
2313 | 1591 } |
1592 | |
1593 void | |
1594 action_equ_import_winamp_presets(void) | |
1595 { | |
1596 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1597 gchar *filename; |
2313 | 1598 |
1599 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1600 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1601 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1602 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1603 import_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1604 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1605 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1606 gtk_widget_destroy(dialog); |
2313 | 1607 } |
1608 | |
1609 void | |
1610 action_equ_save_preset(void) | |
1611 { | |
1612 if (equalizerwin_save_window) { | |
1613 gtk_window_present(GTK_WINDOW(equalizerwin_save_window)); | |
1614 return; | |
1615 } | |
1616 | |
1617 equalizerwin_create_list_window(equalizer_presets, | |
1618 Q_("Save preset"), | |
1619 &equalizerwin_save_window, | |
1620 GTK_SELECTION_SINGLE, | |
1621 &equalizerwin_save_entry, | |
1622 GTK_STOCK_OK, | |
1623 G_CALLBACK(equalizerwin_save_ok), | |
1624 G_CALLBACK(equalizerwin_save_select)); | |
1625 } | |
1626 | |
1627 void | |
1628 action_equ_save_auto_preset(void) | |
1629 { | |
1630 gchar *name; | |
1631 Playlist *playlist = playlist_get_active(); | |
1632 | |
1633 if (equalizerwin_save_auto_window) | |
1634 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window)); | |
1635 else | |
1636 equalizerwin_create_list_window(equalizer_auto_presets, | |
1637 Q_("Save auto-preset"), | |
1638 &equalizerwin_save_auto_window, | |
1639 GTK_SELECTION_SINGLE, | |
1640 &equalizerwin_save_auto_entry, | |
1641 GTK_STOCK_OK, | |
1642 G_CALLBACK(equalizerwin_save_auto_ok), | |
1643 G_CALLBACK(equalizerwin_save_auto_select)); | |
1644 | |
1645 name = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1646 if (name) { | |
1647 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), | |
1648 g_basename(name)); | |
1649 g_free(name); | |
1650 } | |
1651 } | |
1652 | |
1653 void | |
1654 action_equ_save_default_preset(void) | |
1655 { | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1656 equalizer_presets = |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1657 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset"); |
2313 | 1658 } |
1659 | |
1660 void | |
1661 action_equ_save_preset_file(void) | |
1662 { | |
1663 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1664 gchar *filename; |
2313 | 1665 gchar *songname; |
1666 Playlist *playlist = playlist_get_active(); | |
1667 | |
1668 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1669 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1670 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1671 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1672 save_preset_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1673 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1674 } |
2313 | 1675 |
1676 songname = playlist_get_filename(playlist, playlist_get_position(playlist)); | |
1677 if (songname) { | |
1678 gchar *eqname = g_strdup_printf("%s.%s", songname, | |
1679 cfg.eqpreset_extension); | |
1680 g_free(songname); | |
1681 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), | |
1682 eqname); | |
1683 g_free(eqname); | |
1684 } | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1685 |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1686 gtk_widget_destroy(dialog); |
2313 | 1687 } |
1688 | |
1689 void | |
1690 action_equ_save_preset_eqf(void) | |
1691 { | |
1692 GtkWidget *dialog; | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1693 gchar *filename; |
2313 | 1694 |
1695 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE); | |
2514
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1696 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1697 { |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1698 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1699 save_winamp_file(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1700 g_free(filename); |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1701 } |
7934ac463591
[svn] - removed unused function bmp_menu_translate()
mf0102
parents:
2497
diff
changeset
|
1702 gtk_widget_destroy(dialog); |
2313 | 1703 } |
1704 | |
1705 void | |
1706 action_equ_delete_preset(void) | |
1707 { | |
1708 if (equalizerwin_delete_window) { | |
1709 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window)); | |
1710 return; | |
1711 } | |
1712 | |
1713 equalizerwin_create_list_window(equalizer_presets, | |
1714 Q_("Delete preset"), | |
1715 &equalizerwin_delete_window, | |
1716 GTK_SELECTION_EXTENDED, NULL, | |
1717 GTK_STOCK_DELETE, | |
1718 G_CALLBACK(equalizerwin_delete_delete), | |
1719 NULL); | |
1720 } | |
1721 | |
1722 void | |
1723 action_equ_delete_auto_preset(void) | |
1724 { | |
1725 if (equalizerwin_delete_auto_window) { | |
1726 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window)); | |
1727 return; | |
1728 } | |
1729 | |
1730 equalizerwin_create_list_window(equalizer_auto_presets, | |
1731 Q_("Delete auto-preset"), | |
1732 &equalizerwin_delete_auto_window, | |
1733 GTK_SELECTION_EXTENDED, NULL, | |
1734 GTK_STOCK_DELETE, | |
1735 G_CALLBACK(equalizerwin_delete_auto_delete), | |
1736 NULL); | |
1737 } |