annotate src/skins/ui_equalizer.c @ 2719:51fc44b99b58

use two GtkFixed in SkinnedWindow - normal and shaded
author Tomasz Mon <desowin@gmail.com>
date Fri, 20 Jun 2008 21:26:12 +0200
parents 59af999361d8
children b7d8e6fd4644
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 * Based on BMP:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Based on XMMS:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; under version 3 of the License.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * GNU General Public License for more details.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 * The Audacious team does not consider modular code linking to
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 * Audacious or using our public API to be a derived work.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24 */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26 /*#define AUD_DEBUG*/
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #ifdef HAVE_CONFIG_H
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 # include "config.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include "ui_equalizer.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 #include <glib.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #include <glib/gi18n.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 #include <gtk/gtk.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 #include <stdio.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 #include <math.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 #include <string.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 #include "platform/smartinclude.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 #include "ui_skin.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 #include "ui_manager.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 #include "actions-equalizer.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 #include "util.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 #include "ui_main.h"
2678
Tomasz Mon <desowin@gmail.com>
parents: 2677
diff changeset
47 #include "ui_playlist.h"
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 #include <audacious/plugin.h>
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 #include "images/audacious_eq.xpm"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 #include "ui_dock.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 #include "ui_skinned_window.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 #include "ui_skinned_button.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 #include "ui_skinned_horizontal_slider.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 #include "ui_skinned_equalizer_slider.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 #include "ui_skinned_equalizer_graph.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 #include "skins_cfg.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 enum PresetViewCols {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 PRESET_VIEW_COL_NAME,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 PRESET_VIEW_N_COLS
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 };
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 struct _EqualizerPreset {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 gchar *name;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 gfloat preamp, bands[10];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 };
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 typedef struct _EqualizerPreset EqualizerPreset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 GtkWidget *equalizerwin;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 GtkWidget *equalizerwin_graph;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 static GtkWidget *equalizerwin_load_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 static GtkWidget *equalizerwin_load_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 static GtkWidget *equalizerwin_save_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 static GtkWidget *equalizerwin_save_entry = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 static GtkWidget *equalizerwin_save_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 static GtkWidget *equalizerwin_save_auto_entry = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 static GtkWidget *equalizerwin_delete_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 static GtkWidget *equalizerwin_delete_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 static GtkWidget *equalizerwin_on, *equalizerwin_auto;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
87 static GtkWidget *equalizerwin_close, *equalizerwin_shade;
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
88 static GtkWidget *equalizerwin_shaded_close, *equalizerwin_shaded_shade;
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
89 static GtkWidget *equalizerwin_presets;
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 static GtkWidget *equalizerwin_volume, *equalizerwin_balance;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 EqualizerPreset *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 equalizer_preset_new(const gchar * name)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 EqualizerPreset *preset = g_new0(EqualizerPreset, 1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 preset->name = g_strdup(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 return preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 equalizer_preset_free(EqualizerPreset * preset)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 if (!preset)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 g_free(preset->name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 g_free(preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 equalizerwin_set_scaled(gboolean ds)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 gint height;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 if (config.equalizer_shaded)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 height = 14;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 height = 116;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 if (config.scaled) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 dock_window_resize(GTK_WINDOW(equalizerwin), 275 * config.scale_factor,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 height * config.scale_factor, 275 * config.scale_factor, height * config.scale_factor);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 } else {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height, 275, height);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 GList *iter;
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
131 for (iter = GTK_FIXED (SKINNED_WINDOW(equalizerwin)->normal)->children; iter; iter = g_list_next (iter)) {
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 GtkWidget *child = child_data->widget;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 g_signal_emit_by_name(child, "toggle-scaled");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + config.equalizer_shaded), 0, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 equalizerwin_set_shade_menu_cb(gboolean shaded)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 config.equalizer_shaded = shaded;
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
143 ui_skinned_window_set_shade(equalizerwin, shaded);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 if (shaded) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 14 * EQUALIZER_SCALE_FACTOR);
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
148 } else {
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 116 * EQUALIZER_SCALE_FACTOR);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 gtk_widget_shape_combine_mask(equalizerwin, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + config.equalizer_shaded), 0, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 equalizerwin_set_shade(gboolean shaded)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 GtkAction *action = gtk_action_group_get_action(
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 toggleaction_group_others , "roll up equalizer" );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 equalizerwin_shade_toggle(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 equalizerwin_set_shade(!config.equalizer_shaded);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 equalizerwin_eq_changed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175 aud_cfg->equalizer_preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 aud_cfg->equalizer_bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
2641
ba91ea50f214 use equalzier changed hook
Tomasz Mon <desowin@gmail.com>
parents: 2606
diff changeset
178
ba91ea50f214 use equalzier changed hook
Tomasz Mon <desowin@gmail.com>
parents: 2606
diff changeset
179 aud_hook_call("equalizer changed", NULL);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 gtk_widget_queue_draw(equalizerwin_graph);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 equalizerwin_on_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 aud_cfg->equalizer_active = UI_SKINNED_BUTTON(equalizerwin_on)->inside;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 equalizerwin_presets_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 GdkModifierType modmask;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 gint x, y;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 gdk_window_get_pointer(NULL, &x, &y, &modmask);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 ui_manager_popup_menu_show(GTK_MENU(equalizerwin_presets_menu), x, y, 1, GDK_CURRENT_TIME);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 equalizerwin_auto_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 aud_cfg->equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 equalizerwin_press(GtkWidget * widget, GdkEventButton * event,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 gpointer callback_data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 && event->y < 14) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 equalizerwin_set_shade(!config.equalizer_shaded);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 if (dock_is_moving(GTK_WINDOW(equalizerwin)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 dock_move_release(GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 if (event->button == 3) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 /*
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 * Pop up the main menu a few pixels down to avoid
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 * anything to be selected initially.
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 ui_manager_popup_menu_show(GTK_MENU(mainwin_general_menu), event->x_root,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 event->y_root + 2, 3, event->time);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 equalizerwin_keypress(GtkWidget * widget,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 GdkEventKey * event,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 if (event->keyval == GDK_Tab && event->state & GDK_CONTROL_MASK) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 if (config.playlist_visible)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 gtk_window_present(GTK_WINDOW(playlistwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 else if (config.player_visible)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239 gtk_window_present(GTK_WINDOW(mainwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 if (!config.equalizer_shaded) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 gtk_widget_event(mainwin, (GdkEvent *) event);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
246
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 switch (event->keyval) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 case GDK_Left:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 case GDK_KP_Left:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 mainwin_set_balance_diff(-4);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 case GDK_Right:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 case GDK_KP_Right:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 mainwin_set_balance_diff(4);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 default:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 gtk_widget_event(mainwin, (GdkEvent *) event);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 equalizerwin_close_cb(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 equalizerwin_show(FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 equalizerwin_delete(GtkWidget * widget,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 equalizerwin_show(FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 equalizerwin_read_presets(const gchar * basename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282 gchar *filename, *name;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 RcFile *rcfile;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 GList *list = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 gint i, p = 0;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 /* START mod: add check for the default presets locate in system path ({prefix}/share/audacious)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 by Massimo Cavalleri (submax) */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 if ((rcfile = aud_rcfile_open(filename)) == NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294 g_free(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 // DATA_DIR = "{prefix}/share/audacious" ; example is "/usr/share/audacious"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 filename = g_build_filename(DATA_DIR, basename, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 if ((rcfile = aud_rcfile_open(filename)) == NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 g_free(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 return NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 // END mod
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 g_free(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 for (;;) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 gchar section[21];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 g_snprintf(section, sizeof(section), "Preset%d", p++);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311 if (aud_rcfile_read_string(rcfile, "Presets", section, &name)) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 preset = g_new0(EqualizerPreset, 1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 preset->name = name;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314 aud_rcfile_read_float(rcfile, name, "Preamp", &preset->preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 for (i = 0; i < 10; i++) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 gchar band[7];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 g_snprintf(band, sizeof(band), "Band%d", i);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 aud_rcfile_read_float(rcfile, name, band, &preset->bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 list = g_list_prepend(list, preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 list = g_list_reverse(list);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 gint
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 equalizerwin_volume_frame_cb(gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 if (equalizerwin_volume) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 gint x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 if (pos < 32)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 x = 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 else if (pos < 63)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 x = 4;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 x = 7;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_nx = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_px = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 return 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 equalizerwin_volume_motion_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 gint v = (gint) rint(pos * 100 / 94.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 mainwin_adjust_volume_motion(v);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 mainwin_set_volume_slider(v);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 equalizerwin_volume_release_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 mainwin_adjust_volume_release();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 static gint
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 equalizerwin_balance_frame_cb(gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 if (equalizerwin_balance) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 gint x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 if (pos < 13)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369 x = 11;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 else if (pos < 26)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 x = 14;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 x = 17;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_nx = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_px = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379 return 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 equalizerwin_balance_motion_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 gint b;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386 pos = MIN(pos, 38); /* The skin uses a even number of pixels
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 for the balance-slider *sigh* */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 b = (gint) rint((pos - 19) * 100 / 19.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389 mainwin_adjust_balance_motion(b);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 mainwin_set_balance_slider(b);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 equalizerwin_balance_release_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 mainwin_adjust_balance_release();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
398
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
399 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
400 equalizerwin_set_balance_slider(gint percent)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
401 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402 ui_skinned_horizontal_slider_set_position(equalizerwin_balance,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
403 (gint) rint((percent * 19 / 100.0) + 19));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
404 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
405
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
406 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
407 equalizerwin_set_volume_slider(gint percent)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
408 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
409 ui_skinned_horizontal_slider_set_position(equalizerwin_volume,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
410 (gint) rint(percent * 94 / 100.0));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
411 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
412
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
414 equalizerwin_create_widgets(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
416 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
417
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
418 equalizerwin_on = ui_skinned_button_new();
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
419 ui_skinned_toggle_button_setup(equalizerwin_on, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420 14, 18, 25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 g_signal_connect(equalizerwin_on, "clicked", equalizerwin_on_pushed, NULL);
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
422 ui_skinned_button_set_inside(equalizerwin_on, aud_cfg->equalizer_active);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
424 equalizerwin_auto = ui_skinned_button_new();
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
425 ui_skinned_toggle_button_setup(equalizerwin_auto, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
426 39, 18, 33, 12, 35, 119, 153, 119, 94, 119, 212, 119, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
427 g_signal_connect(equalizerwin_auto, "clicked", equalizerwin_auto_pushed, NULL);
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
428 ui_skinned_button_set_inside(equalizerwin_auto, aud_cfg->equalizer_autoload);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
430 equalizerwin_presets = ui_skinned_button_new();
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
431 ui_skinned_push_button_setup(equalizerwin_presets, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
432 217, 18, 44, 12, 224, 164, 224, 176, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433 g_signal_connect(equalizerwin_presets, "clicked", equalizerwin_presets_pushed, NULL );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
434
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
435 equalizerwin_close = ui_skinned_button_new();
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
436 ui_skinned_push_button_setup(equalizerwin_close, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437 264, 3, 9, 9, 0, 116, 0, 125, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438 g_signal_connect(equalizerwin_close, "clicked", equalizerwin_close_cb, NULL );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 equalizerwin_shade = ui_skinned_button_new();
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
441 ui_skinned_push_button_setup(equalizerwin_shade, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 254, 3, 9, 9, 254, 137, 1, 38, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443 ui_skinned_button_set_skin_index2(equalizerwin_shade, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 g_signal_connect(equalizerwin_shade, "clicked", equalizerwin_shade_toggle, NULL );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
446 equalizerwin_shaded_close = ui_skinned_button_new();
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
447 ui_skinned_push_button_setup(equalizerwin_shaded_close, SKINNED_WINDOW(equalizerwin)->shaded,
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
448 264, 3, 9, 9, 11, 38, 11, 47, SKIN_EQ_EX);
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
449 g_signal_connect(equalizerwin_shaded_close, "clicked", equalizerwin_close_cb, NULL );
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
451 equalizerwin_shaded_shade = ui_skinned_button_new();
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
452 ui_skinned_push_button_setup(equalizerwin_shaded_shade, SKINNED_WINDOW(equalizerwin)->shaded,
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
453 254, 3, 9, 9, 254, 3, 1, 47, SKIN_EQ_EX);
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
454 g_signal_connect(equalizerwin_shaded_shade, "clicked", equalizerwin_shade_toggle, NULL );
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
455
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
456 equalizerwin_graph = ui_skinned_equalizer_graph_new(SKINNED_WINDOW(equalizerwin)->normal, 86, 17);
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
457
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
458 equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 21, 38);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
459 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, aud_cfg->equalizer_preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 for (i = 0; i < 10; i++) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 equalizerwin_bands[i] =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
463 ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 78 + (i * 18), 38);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], aud_cfg->equalizer_bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467 equalizerwin_volume =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
468 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469 61, 4, 97, 8, 1, 30, 1, 30, 3, 7, 4, 61, 0, 94,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 equalizerwin_volume_frame_cb, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 g_signal_connect(equalizerwin_volume, "motion", G_CALLBACK(equalizerwin_volume_motion_cb), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 g_signal_connect(equalizerwin_volume, "release", G_CALLBACK(equalizerwin_volume_release_cb), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
473
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
474
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 equalizerwin_balance =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
476 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 164, 4, 42, 8, 11, 30, 11, 30, 3, 7, 4, 164, 0, 39,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 equalizerwin_balance_frame_cb, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479 g_signal_connect(equalizerwin_balance, "motion", G_CALLBACK(equalizerwin_balance_motion_cb), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 g_signal_connect(equalizerwin_balance, "release", G_CALLBACK(equalizerwin_balance_release_cb), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
481 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
482
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
485 equalizerwin_create_window(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
486 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487 GdkPixbuf *icon;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 gint width, height;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
489
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
490 width = 275;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
491 height = config.equalizer_shaded ? 14 : 116;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 equalizerwin = ui_skinned_window_new("equalizer");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer"));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
495 gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
497
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
498 if (config.scaled && config.eq_scaled_linked) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
499 width *= config.scale_factor;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 height *= config.scale_factor;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
501 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
502
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 gtk_widget_set_size_request(equalizerwin, width, height);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
504
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 /* this will hide only mainwin. it's annoying! yaz */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 GTK_WINDOW(mainwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
510 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_eq_icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
512 g_object_unref(icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
513
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 gtk_widget_set_app_paintable(equalizerwin, TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
515
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
516 if (config.equalizer_x != -1 && config.save_window_position)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
517 gtk_window_move(GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
518 config.equalizer_x, config.equalizer_y);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
519
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
520 g_signal_connect(equalizerwin, "delete_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
521 G_CALLBACK(equalizerwin_delete), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
522 g_signal_connect(equalizerwin, "button_press_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
523 G_CALLBACK(equalizerwin_press), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
524 g_signal_connect(equalizerwin, "key_press_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
525 G_CALLBACK(equalizerwin_keypress), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
526 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
527
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
528 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
529 equalizerwin_create(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
530 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
531 equalizer_presets = equalizerwin_read_presets("eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
532 equalizer_auto_presets = equalizerwin_read_presets("eq.auto_preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
533
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
534 equalizerwin_create_window();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
535
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
536 gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
537
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 equalizerwin_create_widgets();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
540
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
541
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543 equalizerwin_show(gboolean show)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 GtkAction *action = gtk_action_group_get_action(
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546 toggleaction_group_others , "show equalizer" );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , show );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
548
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
549 if (show)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
550 equalizerwin_real_show();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552 equalizerwin_real_hide();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
553 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 equalizerwin_real_show(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558 gtk_window_move(GTK_WINDOW(equalizerwin), config.equalizer_x, config.equalizer_y);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
559 if (config.scaled && config.eq_scaled_linked)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
560 gtk_widget_set_size_request(equalizerwin, 275 * config.scale_factor,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
561 ((config.equalizer_shaded ? 14 : 116) * config.scale_factor));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
562 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
563 gtk_widget_set_size_request(equalizerwin, 275,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564 (config.equalizer_shaded ? 14 : 116));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565 config.equalizer_visible = TRUE;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
566 ui_skinned_button_set_inside(mainwin_eq, TRUE);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 gtk_widget_show_all(equalizerwin);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
568
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
569 gtk_window_present(GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
570 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
571
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
572 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
573 equalizerwin_real_hide(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
574 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
575 /*
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
576 * This function should only be called from the
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
577 * main menu signal handler
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
578 */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579 gtk_widget_hide(equalizerwin);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
580 config.equalizer_visible = FALSE;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
581 ui_skinned_button_set_inside(mainwin_eq, FALSE);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
582 gtk_widget_queue_draw(mainwin_eq);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
583 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
584
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
585 static EqualizerPreset *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
586 equalizerwin_find_preset(GList * list, const gchar * name)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
587 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
588 GList *node = list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
589 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
590
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
591 while (node) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
592 preset = node->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
593 if (!strcasecmp(preset->name, name))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
594 return preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
595 node = g_list_next(node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
596 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
597 return NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
599
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
600 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 equalizerwin_write_preset_file(GList * list, const gchar * basename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
602 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
603 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
604 gchar *filename, *tmp;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
605 gint i, p;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
607 RcFile *rcfile;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608 GList *node;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
609
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
610 rcfile = aud_rcfile_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
611 p = 0;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 for (node = list; node; node = g_list_next(node)) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613 preset = node->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614 tmp = g_strdup_printf("Preset%d", p++);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 aud_rcfile_write_string(rcfile, "Presets", tmp, preset->name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616 g_free(tmp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 aud_rcfile_write_float(rcfile, preset->name, "Preamp",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 preset->preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
619 for (i = 0; i < 10; i++) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
620 tmp = g_strdup_printf("Band%d\n", i);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621 aud_rcfile_write_float(rcfile, preset->name, tmp,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
622 preset->bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623 g_free(tmp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
624 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
625 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
626
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
627 filename = g_build_filename(aud_paths[BMP_PATH_USER_DIR], basename, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628 aud_rcfile_write(rcfile, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630 g_free(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
631 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
632 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
633
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
634 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 equalizerwin_load_preset(GList * list, const gchar * name)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
636 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
637 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
639
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
640 if ((preset = equalizerwin_find_preset(list, name)) != NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
641 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
642 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
643 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
644 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
645 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
646 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
647 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
648 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
649
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
650 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
651 equalizerwin_save_preset(GList * list, const gchar * name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
652 const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
653 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
654 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
655 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
656
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657 if (!(preset = equalizerwin_find_preset(list, name))) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
658 preset = g_new0(EqualizerPreset, 1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
659 preset->name = g_strdup(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
660 list = g_list_append(list, preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
661 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
662
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 preset->preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
665 preset->bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
666
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
667 equalizerwin_write_preset_file(list, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
668
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
669 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
670 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
671
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
672 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
673 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
675 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
676 GList *node;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
677
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
678 if (!(preset = equalizerwin_find_preset(list, name)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
679 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
680
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
681 if (!(node = g_list_find(list, preset)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
682 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
683
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
684 list = g_list_remove_link(list, node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
685 equalizer_preset_free(preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
686 g_list_free_1(node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
687
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
688 equalizerwin_write_preset_file(list, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
689
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
690 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
691 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
692
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
693 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
694 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
695 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
696 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
697
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
698 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
699 GtkTreeModel *model = gtk_tree_view_get_model(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
700
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
701 /*
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
702 * first we are making a list of the selected rows, then we convert this
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
703 * list into a list of GtkTreeRowReferences, so that when you delete an
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
704 * item you can still access the other items
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
705 * finally we iterate through all GtkTreeRowReferences, convert them to
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
706 * GtkTreeIters and delete those one after the other
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
707 */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
708
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
709 GList *list = gtk_tree_selection_get_selected_rows(selection, &model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
710 GList *rrefs = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
711 GList *litr;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
712
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
713 for (litr = list; litr; litr = litr->next)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
714 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
715 GtkTreePath *path = litr->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
716 rrefs = g_list_append(rrefs, gtk_tree_row_reference_new(model, path));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
717 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
718
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
719 for (litr = rrefs; litr; litr = litr->next)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
720 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
721 GtkTreeRowReference *ref = litr->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
722 GtkTreePath *path = gtk_tree_row_reference_get_path(ref);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
723 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
724 gtk_tree_model_get_iter(model, &iter, path);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
725
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
726 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
727
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
728 if (!strcmp(filename, "eq.preset"))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
729 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
730 else if (!strcmp(filename, "eq.auto_preset"))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
731 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
732
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
733 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
734 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
735 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
736
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
737 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
738 import_winamp_eqf(VFSFile * file)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
739 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
740 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
741 gchar header[31];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
742 gchar bands[11];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
743 gint i = 0;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
744 EqualizerPreset *preset = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
745 GList *list = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
746 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
747 gchar *realfn;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
748 gchar preset_name[0xb4];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
749
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
750 vfs_fread(header, 1, 31, file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
751 if (strncmp(header, "Winamp EQ library file v1.1", 27)) goto error;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
752
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
753 AUDDBG("The EQF header is OK\n");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
754
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
755 if (vfs_fseek(file, 0x1f, SEEK_SET) == -1) goto error;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
756
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
757 while (vfs_fread(preset_name, 1, 0xb4, file) == 0xb4) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
758 AUDDBG("The preset name is '%s'\n", preset_name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
759 vfs_fseek(file, 0x4d, SEEK_CUR); /* unknown crap --asphyx */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
760 if (vfs_fread(bands, 1, 11, file) != 11) break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
761
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
762 preset = equalizer_preset_new(preset_name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
763 /*this was divided by 63, but shouldn't it be 64? --majeru*/
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
764 preset->preamp = EQUALIZER_MAX_GAIN - ((bands[10] * EQUALIZER_MAX_GAIN * 2) / 64.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
765
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
766 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
767 preset->bands[i] = EQUALIZER_MAX_GAIN - ((bands[i] * EQUALIZER_MAX_GAIN * 2) / 64.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
768
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
769 list = g_list_prepend(list, preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
770 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
771
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
772 list = g_list_reverse(list);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
773 if (list == NULL) goto error;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
774
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
775 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
776
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
777 error:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
778 realfn = g_filename_from_uri(file->uri, NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
779 dialog = gtk_message_dialog_new (GTK_WINDOW(mainwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
780 GTK_DIALOG_DESTROY_WITH_PARENT,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
781 GTK_MESSAGE_ERROR,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
782 GTK_BUTTONS_CLOSE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
783 _("Error importing Winamp EQF file '%s'"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
784 realfn);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
785 gtk_dialog_run (GTK_DIALOG (dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
786 gtk_widget_destroy (dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
787 g_free(realfn);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
788 return NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
789 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
790 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
791
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
792 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
793 free_cb (gpointer data, gpointer user_data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
794 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
795 equalizer_preset_free((EqualizerPreset*)data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
796 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
797
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
798 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
799 equalizerwin_read_winamp_eqf(VFSFile * file)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
800 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
801 GList *presets;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
802 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
803
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
804 if ((presets = import_winamp_eqf(file)) == NULL)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
805 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
806
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
807 /* just get the first preset --asphyx */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
808 EqualizerPreset *preset = (EqualizerPreset*)presets->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
809 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
810 preset->preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
811
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
812 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
813 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i],
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
814 preset->bands[i]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
815
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
816 g_list_foreach(presets, free_cb, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
817 g_list_free(presets);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
818
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
819 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
820 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
821 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
822 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
823 equalizerwin_read_aud_preset(RcFile * rcfile)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
824 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
825 gfloat val;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
826 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
827
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
828 if (aud_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
829 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, val);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
830 for (i = 0; i < 10; i++) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
831 gchar tmp[7];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
832 g_snprintf(tmp, sizeof(tmp), "Band%d", i);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
833 if (aud_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
834 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], val);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
835 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
836 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
837 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
838 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
839
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
840 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
841 equalizerwin_save_ok(GtkWidget * widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
842 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
843 const gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
844
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
845 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
846 if (strlen(text) != 0)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
847 equalizer_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
848 equalizerwin_save_preset(equalizer_presets, text, "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
849 gtk_widget_destroy(equalizerwin_save_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
850 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
851
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
852 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
853 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
854 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
855 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
856 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
857
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
858 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
859 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
860 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
861
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
862 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
863 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
864 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
865 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
866 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
867 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
868 equalizerwin_save_ok(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
869
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
870 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
871 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
872 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
873 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
874
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
875 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
876 equalizerwin_load_ok(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
877 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
878 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
879
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
880 GtkTreeView* view = GTK_TREE_VIEW(data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
881 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
882 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
883 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
884
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
885 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
886 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
887 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
888 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
889 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
890 equalizerwin_load_preset(equalizer_presets, text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
891
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
892 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
893 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
894 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
895 gtk_widget_destroy(equalizerwin_load_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
896 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
897
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
898 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
899 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
900 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
901 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
902 equalizerwin_load_ok(NULL, treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
903 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
904
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
905 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
906 equalizerwin_delete_delete(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
907 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
908 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
909 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
910
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
911 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
912 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
913 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
914 const gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
915
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
916 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
917 if (strlen(text) != 0)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
918 equalizer_auto_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
919 equalizerwin_save_preset(equalizer_auto_presets, text,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
920 "eq.auto_preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
921 gtk_widget_destroy(equalizerwin_save_auto_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
922 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
923
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
924 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
925 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
926 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
927 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
928 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
929
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
930 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
931 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
932 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
933
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
934 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
935 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
936 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
937 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
938 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
939 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
940 equalizerwin_save_auto_ok(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
941
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
942 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
943 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
944 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
945 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
946
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
947 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
948 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
949 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
950 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
951
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
952 GtkTreeView *view = GTK_TREE_VIEW(data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
953 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
954 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
955 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
956
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
957 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
958 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
959 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
960 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
961 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
962 equalizerwin_load_preset(equalizer_auto_presets, text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
963
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
964 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
965 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
966 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
967 gtk_widget_destroy(equalizerwin_load_auto_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
968 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
969
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
970 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
971 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
972 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
973 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
974 equalizerwin_load_auto_ok(NULL, treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
975 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
976
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
977 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
978 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
979 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
980 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
981 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
982
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
983
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
984 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
985 load_preset_file(const gchar *filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
986 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
987 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
988 RcFile *rcfile;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
989
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
990 if ((rcfile = aud_rcfile_open(filename)) != NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
991 equalizerwin_read_aud_preset(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
992 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
993 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
994 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
995 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
996
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
997 static VFSFile *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
998 open_vfs_file(const gchar *filename, const gchar *mode)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
999 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1000 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1001 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1002
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1003 if (!(file = vfs_fopen(filename, mode))) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1004 dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1005 GTK_DIALOG_DESTROY_WITH_PARENT,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1006 GTK_MESSAGE_ERROR,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1007 GTK_BUTTONS_CLOSE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1008 "Error loading file '%s'",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1009 filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1010 gtk_dialog_run (GTK_DIALOG (dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1011 gtk_widget_destroy (dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1012 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1013
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1014 return file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1015 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1016
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1017 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1018 load_winamp_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1019 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1020 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1021 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1022
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1023 if (!(file = open_vfs_file(filename, "rb")))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1024 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1025
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1026 equalizerwin_read_winamp_eqf(file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1027 vfs_fclose(file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1028 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1029 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1030
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1031 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1032 import_winamp_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1033 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1034 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1035 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1036 GList *list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1037
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1038 if (!(file = open_vfs_file(filename, "rb")) ||
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1039 !(list = import_winamp_eqf(file)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1040 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1041
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1042 equalizer_presets = g_list_concat(equalizer_presets, list);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1043 equalizerwin_write_preset_file(equalizer_presets, "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1044
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1045 vfs_fclose(file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1046 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1047 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1048
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1049 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1050 save_preset_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1051 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1052 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1053 RcFile *rcfile;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1054 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1055
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1056 rcfile = aud_rcfile_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1057 aud_rcfile_write_float(rcfile, "Equalizer preset", "Preamp",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1058 ui_skinned_equalizer_slider_get_position(equalizerwin_preamp));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1059
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1060 for (i = 0; i < 10; i++) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1061 gchar tmp[7];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1062 g_snprintf(tmp, sizeof(tmp), "Band%d", i);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1063 aud_rcfile_write_float(rcfile, "Equalizer preset", tmp,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1064 ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1065 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1066
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1067 aud_rcfile_write(rcfile, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1068 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1069 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1070 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1071
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1072 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1073 save_winamp_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1074 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1075 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1076 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1077
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1078 gchar name[257];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1079 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1080 guchar bands[11];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1081
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1082 if (!(file = open_vfs_file(filename, "wb")))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1083 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1084
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1085 vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1086
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1087 memset(name, 0, 257);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1088 g_strlcpy(name, "Entry1", 257);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1089 vfs_fwrite(name, 1, 257, file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1090
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1091 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1092 bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1093 bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1094 vfs_fwrite(bands, 1, 11, file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1095
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1096 vfs_fclose(file);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1097 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1098 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1099
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1100 static GtkWidget *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1101 equalizerwin_create_list_window(GList *preset_list,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1102 const gchar *title,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1103 GtkWidget **window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1104 GtkSelectionMode sel_mode,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1105 GtkWidget **entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1106 const gchar *action_name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1107 GCallback action_func,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1108 GCallback select_row_func)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1109 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1110 GtkWidget *vbox, *scrolled_window, *bbox, *view;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1111 GtkWidget *button_cancel, *button_action;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1112 GList *node;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1113
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1114 GtkListStore *store;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1115 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1116 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1117 GtkCellRenderer *renderer;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1118 GtkTreeSelection *selection;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1119 GtkTreeSortable *sortable;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1120
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1121
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1122
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1123 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1124 gtk_window_set_title(GTK_WINDOW(*window), title);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1125 gtk_window_set_type_hint(GTK_WINDOW(*window), GDK_WINDOW_TYPE_HINT_DIALOG);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1126 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1127 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1128 gtk_container_set_border_width(GTK_CONTAINER(*window), 10);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1129 gtk_window_set_transient_for(GTK_WINDOW(*window),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1130 GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1131 g_signal_connect(*window, "destroy",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1132 G_CALLBACK(gtk_widget_destroyed), window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1133
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1134 vbox = gtk_vbox_new(FALSE, 10);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1135 gtk_container_add(GTK_CONTAINER(*window), vbox);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1136
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1137 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1138 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1139 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1140
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1141
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1142 /* fill the store with the names of all available presets */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1143 store = gtk_list_store_new(1, G_TYPE_STRING);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1144 for (node = preset_list; node; node = g_list_next(node))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1145 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1146 gtk_list_store_append(store, &iter);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1147 gtk_list_store_set(store, &iter,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1148 0, ((EqualizerPreset*)node->data)->name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1149 -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1150 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1151 model = GTK_TREE_MODEL(store);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1152
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1153
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1154 sortable = GTK_TREE_SORTABLE(store);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1155 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1156
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1157
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1158 view = gtk_tree_view_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1159 renderer = gtk_cell_renderer_text_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1160 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1161 _("Presets"), renderer,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1162 "text", 0, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1163 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1164 g_object_unref(model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1165
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1166 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1167 gtk_tree_selection_set_mode(selection, sel_mode);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1168
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1169
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1170
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1171
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1172 gtk_container_add(GTK_CONTAINER(scrolled_window), view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1173 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1174
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1175 if (entry) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1176 *entry = gtk_entry_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1177 g_signal_connect(*entry, "activate", action_func, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1178 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1179 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1180
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1181 bbox = gtk_hbutton_box_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1182 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1183 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1184 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1185
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1186 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1187 g_signal_connect_swapped(button_cancel, "clicked",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1188 G_CALLBACK(gtk_widget_destroy),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1189 GTK_OBJECT(*window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1190 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1191
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1192 button_action = gtk_button_new_from_stock(action_name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1193 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1194 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1195
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1196 if (select_row_func)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1197 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1198
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1199
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1200 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1201
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1202 gtk_widget_grab_default(button_action);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1203
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1204
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1205 gtk_widget_show_all(*window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1206
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1207 return *window;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1208 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1209
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1210 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1211 equalizerwin_load_auto_preset(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1212 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1213 #if 0
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1214 gchar *presetfilename, *directory;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1215 RcFile *rcfile;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1216
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1217 g_return_if_fail(filename != NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1218
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1219 if (!aud_cfg->equalizer_autoload)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1220 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1221
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1222 presetfilename = g_strconcat(filename, ".", aud_cfg->eqpreset_extension, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1223
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1224 /* First try to find a per file preset file */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1225 if (strlen(aud_cfg->eqpreset_extension) > 0 &&
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1226 (rcfile = aud_rcfile_open(presetfilename)) != NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1227 g_free(presetfilename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1228 equalizerwin_read_aud_preset(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1229 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1230 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1231 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1232
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1233 g_free(presetfilename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1234
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1235 directory = g_path_get_dirname(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1236 presetfilename = g_build_filename(directory, aud_cfg->eqpreset_default_file,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1237 NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1238 g_free(directory);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1239
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1240 /* Try to find a per directory preset file */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1241 if (strlen(aud_cfg->eqpreset_default_file) > 0 &&
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1242 (rcfile = aud_rcfile_open(presetfilename)) != NULL) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1243 equalizerwin_read_aud_preset(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1244 aud_rcfile_free(rcfile);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1245 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1246 else if (!equalizerwin_load_preset
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1247 (equalizer_auto_presets, g_basename(filename))) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1248 /* Fall back to the oldstyle auto presets */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1249 equalizerwin_load_preset(equalizer_presets, "Default");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1250 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1251
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1252 g_free(presetfilename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1253 #endif
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1254 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1255
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1256 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1257 equalizerwin_set_preamp(gfloat preamp)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1258 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1259 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1260 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1261 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1262
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1263 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1264 equalizerwin_set_band(gint band, gfloat value)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1265 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1266 g_return_if_fail(band >= 0 && band < 10);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1267 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1268 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1269
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1270 gfloat
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1271 equalizerwin_get_preamp(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1272 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1273 return ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1274 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1275
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1276 gfloat
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1277 equalizerwin_get_band(gint band)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1278 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1279 g_return_val_if_fail(band >= 0 && band < 10, 0.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1280 return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1281 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1282
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1283 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1284 action_equ_load_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1285 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1286 if (equalizerwin_load_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1287 gtk_window_present(GTK_WINDOW(equalizerwin_load_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1288 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1289 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1290
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1291 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1292 Q_("Load preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1293 &equalizerwin_load_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1294 GTK_SELECTION_SINGLE, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1295 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1296 G_CALLBACK(equalizerwin_load_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1297 G_CALLBACK(equalizerwin_load_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1298 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1299
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1300 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1301 action_equ_load_auto_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1302 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1303 if (equalizerwin_load_auto_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1304 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1305 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1306 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1307
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1308 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1309 Q_("Load auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1310 &equalizerwin_load_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1311 GTK_SELECTION_SINGLE, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1312 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1313 G_CALLBACK(equalizerwin_load_auto_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1314 G_CALLBACK(equalizerwin_load_auto_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1315 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1316
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1317 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1318 action_equ_load_default_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1319 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1320 equalizerwin_load_preset(equalizer_presets, "Default");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1321 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1322
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1323 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1324 action_equ_zero_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1325 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1326 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1327
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1328 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1329 for (i = 0; i < 10; i++)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1330 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1331
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1332 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1333 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1334
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1335 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1336 action_equ_load_preset_file(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1337 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1338 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1339 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1340
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1341 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1342 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1343 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1344 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1345 load_preset_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1346 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1347 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1348 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1349 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1350
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1351 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1352 action_equ_load_preset_eqf(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1353 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1354 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1355 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1356
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1357 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1358 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1359 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1360 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1361 load_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1362 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1363 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1364 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1365 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1366
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1367 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1368 action_equ_import_winamp_presets(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1369 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1370 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1371 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1372
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1373 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1374 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1375 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1376 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1377 import_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1378 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1379 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1380 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1381 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1382
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1383 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1384 action_equ_save_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1385 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1386 if (equalizerwin_save_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1387 gtk_window_present(GTK_WINDOW(equalizerwin_save_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1388 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1389 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1390
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1391 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1392 Q_("Save preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1393 &equalizerwin_save_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1394 GTK_SELECTION_SINGLE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1395 &equalizerwin_save_entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1396 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1397 G_CALLBACK(equalizerwin_save_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1398 G_CALLBACK(equalizerwin_save_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1399 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1400
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1401 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1402 action_equ_save_auto_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1403 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1404 gchar *name;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1405 Playlist *playlist = aud_playlist_get_active();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1406
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1407 if (equalizerwin_save_auto_window)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1408 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1409 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1410 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1411 Q_("Save auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1412 &equalizerwin_save_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1413 GTK_SELECTION_SINGLE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1414 &equalizerwin_save_auto_entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1415 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1416 G_CALLBACK(equalizerwin_save_auto_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1417 G_CALLBACK(equalizerwin_save_auto_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1418
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1419 name = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1420 if (name) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1421 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1422 g_basename(name));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1423 g_free(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1424 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1425 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1426
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1427 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1428 action_equ_save_default_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1429 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1430 equalizer_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1431 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1432 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1433
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1434 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1435 action_equ_save_preset_file(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1436 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1437 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1438 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1439 gchar *songname;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1440 Playlist *playlist = aud_playlist_get_active();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1441
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1442 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1443 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1444 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1445 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1446 save_preset_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1447 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1448 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1449
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1450 songname = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1451 if (songname) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1452 gchar *eqname = g_strdup_printf("%s.%s", songname,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1453 aud_cfg->eqpreset_extension);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1454 g_free(songname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1455 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1456 eqname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1457 g_free(eqname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1458 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1459
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1460 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1461 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1462
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1463 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1464 action_equ_save_preset_eqf(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1465 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1466 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1467 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1468
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1469 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1470 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1471 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1472 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1473 save_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1474 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1475 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1476 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1477 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1478
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1479 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1480 action_equ_delete_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1481 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1482 if (equalizerwin_delete_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1483 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1484 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1485 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1486
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1487 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1488 Q_("Delete preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1489 &equalizerwin_delete_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1490 GTK_SELECTION_EXTENDED, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1491 GTK_STOCK_DELETE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1492 G_CALLBACK(equalizerwin_delete_delete),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1493 NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1494 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1495
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1496 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1497 action_equ_delete_auto_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1498 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1499 if (equalizerwin_delete_auto_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1500 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1501 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1502 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1503
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1504 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1505 Q_("Delete auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1506 &equalizerwin_delete_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1507 GTK_SELECTION_EXTENDED, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1508 GTK_STOCK_DELETE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1509 G_CALLBACK(equalizerwin_delete_auto_delete),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1510 NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1511 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1512
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1513 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1514 equalizer_activate(gboolean active)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1515 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1516 aud_cfg->equalizer_active = active;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
1517 ui_skinned_button_set_inside(equalizerwin_on, active);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1518
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1519 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1520 }