annotate audacious/equalizer.c @ 298:4f42c8bcf186 trunk

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