annotate audacious/equalizer.c @ 1048:b10e09537428 trunk

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