annotate audacious/equalizer.c @ 1546:693531793a75 trunk

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