annotate audacious/equalizer.c @ 43:23c9ae8118c9 trunk

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