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