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