annotate src/skins/ui_equalizer.c @ 3182:631d217913e0

alsa-ng: Fix arithmetic overflow on 32-bit systems.
author John Lindgren <john.lindgren@tds.net>
date Fri, 12 Jun 2009 09:17:09 -0400
parents 1ffcad5f406c
children
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"
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2792
diff changeset
48 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2792
diff changeset
49 #include <audlegacy/equalizer_preset.h>
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 #include "images/audacious_eq.xpm"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 #include "ui_dock.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 #include "ui_skinned_window.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 #include "ui_skinned_button.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 #include "ui_skinned_horizontal_slider.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 #include "ui_skinned_equalizer_slider.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 #include "ui_skinned_equalizer_graph.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 #include "skins_cfg.h"
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 enum PresetViewCols {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 PRESET_VIEW_COL_NAME,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 PRESET_VIEW_N_COLS
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 GtkWidget *equalizerwin;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 GtkWidget *equalizerwin_graph;
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 static GtkWidget *equalizerwin_load_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 static GtkWidget *equalizerwin_load_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 static GtkWidget *equalizerwin_save_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 static GtkWidget *equalizerwin_save_entry = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 static GtkWidget *equalizerwin_save_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 static GtkWidget *equalizerwin_save_auto_entry = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 static GtkWidget *equalizerwin_delete_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 static GtkWidget *equalizerwin_delete_auto_window = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 static GtkWidget *equalizerwin_on, *equalizerwin_auto;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
80 static GtkWidget *equalizerwin_close, *equalizerwin_shade;
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
81 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
82 static GtkWidget *equalizerwin_presets;
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 static GtkWidget *equalizerwin_volume, *equalizerwin_balance;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 EqualizerPreset *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 equalizer_preset_new(const gchar * name)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 EqualizerPreset *preset = g_new0(EqualizerPreset, 1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 preset->name = g_strdup(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 return preset;
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 equalizer_preset_free(EqualizerPreset * preset)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 if (!preset)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 return;
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 g_free(preset->name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 g_free(preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 equalizerwin_set_scaled(gboolean ds)
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 gint height;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 if (config.equalizer_shaded)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 height = 14;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 height = 116;
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 if (config.scaled) {
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
117 dock_window_resize(GTK_WINDOW(equalizerwin), 275 * config.scale_factor,
3158
8b97f9560dc3 More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem).
John Lindgren <john.lindgren@tds.net>
parents: 3017
diff changeset
118 height * config.scale_factor);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 } else {
3158
8b97f9560dc3 More clean-up of roll-up code (should fix bug #37; if not, it's a WM problem).
John Lindgren <john.lindgren@tds.net>
parents: 3017
diff changeset
120 dock_window_resize(GTK_WINDOW(equalizerwin), 275, height);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 }
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 GList *iter;
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
124 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
125 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 GtkWidget *child = child_data->widget;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 g_signal_emit_by_name(child, "toggle-scaled");
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 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
130 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 equalizerwin_set_shade_menu_cb(gboolean shaded)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 config.equalizer_shaded = shaded;
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
136 ui_skinned_window_set_shade(equalizerwin, shaded);
2606
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 if (shaded) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 14 * EQUALIZER_SCALE_FACTOR);
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
141 } else {
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 dock_shade(get_dock_window_list(), GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 116 * EQUALIZER_SCALE_FACTOR);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 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
147 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 equalizerwin_set_shade(gboolean shaded)
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 GtkAction *action = gtk_action_group_get_action(
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 toggleaction_group_others , "roll up equalizer" );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(action) , shaded );
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 equalizerwin_shade_toggle(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 equalizerwin_set_shade(!config.equalizer_shaded);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 equalizerwin_eq_changed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
168 aud_cfg->equalizer_preamp = equalizerwin_get_preamp();
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
169 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
170 aud_cfg->equalizer_bands[i] = equalizerwin_get_band(i);
2641
ba91ea50f214 use equalzier changed hook
Tomasz Mon <desowin@gmail.com>
parents: 2606
diff changeset
171
ba91ea50f214 use equalzier changed hook
Tomasz Mon <desowin@gmail.com>
parents: 2606
diff changeset
172 aud_hook_call("equalizer changed", NULL);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 gtk_widget_queue_draw(equalizerwin_graph);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 static void
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
177 equalizerwin_apply_preset(EqualizerPreset *preset)
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
178 {
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
179 if (preset == NULL)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
180 return;
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
181
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
182 gint i;
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
183
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
184 equalizerwin_set_preamp(preset->preamp);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
185 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
186 equalizerwin_set_band(i, preset->bands[i]);
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
187 }
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
188
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
189 static void
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 equalizerwin_on_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 {
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
192 equalizerwin_activate(!aud_cfg->equalizer_active);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 equalizerwin_presets_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 GdkModifierType modmask;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 gint x, y;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 gdk_window_get_pointer(NULL, &x, &y, &modmask);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 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
203 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 equalizerwin_auto_pushed(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208 aud_cfg->equalizer_autoload = UI_SKINNED_BUTTON(equalizerwin_auto)->inside;
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 equalizerwin_press(GtkWidget * widget, GdkEventButton * event,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 gpointer callback_data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 && event->y < 14) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 equalizerwin_set_shade(!config.equalizer_shaded);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 if (dock_is_moving(GTK_WINDOW(equalizerwin)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 dock_move_release(GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 return TRUE;
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 if (event->button == 3) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 /*
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 * Pop up the main menu a few pixels down to avoid
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225 * anything to be selected initially.
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 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
228 event->y_root + 2, 3, event->time);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 }
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 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 equalizerwin_keypress(GtkWidget * widget,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 GdkEventKey * event,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240 if (event->keyval == GDK_Tab && event->state & GDK_CONTROL_MASK) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 if (config.playlist_visible)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 gtk_window_present(GTK_WINDOW(playlistwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243 else if (config.player_visible)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244 gtk_window_present(GTK_WINDOW(mainwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
245 return TRUE;
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 if (!config.equalizer_shaded) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 gtk_widget_event(mainwin, (GdkEvent *) event);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 switch (event->keyval) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 case GDK_Left:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 case GDK_KP_Left:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 mainwin_set_balance_diff(-4);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 case GDK_Right:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 case GDK_KP_Right:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 mainwin_set_balance_diff(4);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
261 default:
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 gtk_widget_event(mainwin, (GdkEvent *) event);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 break;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 equalizerwin_close_cb(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 equalizerwin_show(FALSE);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 equalizerwin_delete(GtkWidget * widget,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 equalizerwin_show(FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 gint
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 equalizerwin_volume_frame_cb(gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 if (equalizerwin_volume) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 gint x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 if (pos < 32)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 x = 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 else if (pos < 63)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 x = 4;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 x = 7;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_nx = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
296 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_volume)->knob_px = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 return 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 equalizerwin_volume_motion_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304 gint v = (gint) rint(pos * 100 / 94.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 mainwin_adjust_volume_motion(v);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 mainwin_set_volume_slider(v);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 equalizerwin_volume_release_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 mainwin_adjust_volume_release();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 static gint
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316 equalizerwin_balance_frame_cb(gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318 if (equalizerwin_balance) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 gint x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 if (pos < 13)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 x = 11;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 else if (pos < 26)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 x = 14;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 x = 17;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_nx = x;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 UI_SKINNED_HORIZONTAL_SLIDER(equalizerwin_balance)->knob_px = x;
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 return 1;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 equalizerwin_balance_motion_cb(GtkWidget *widget, gint pos)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 gint b;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 pos = MIN(pos, 38); /* The skin uses a even number of pixels
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 for the balance-slider *sigh* */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 b = (gint) rint((pos - 19) * 100 / 19.0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 mainwin_adjust_balance_motion(b);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 mainwin_set_balance_slider(b);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346 equalizerwin_balance_release_cb(GtkWidget *widget, gint pos)
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 mainwin_adjust_balance_release();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 equalizerwin_set_balance_slider(gint percent)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 ui_skinned_horizontal_slider_set_position(equalizerwin_balance,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 (gint) rint((percent * 19 / 100.0) + 19));
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 equalizerwin_set_volume_slider(gint percent)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 ui_skinned_horizontal_slider_set_position(equalizerwin_volume,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362 (gint) rint(percent * 94 / 100.0));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 equalizerwin_create_widgets(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 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
371 ui_skinned_toggle_button_setup(equalizerwin_on, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 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
373 g_signal_connect(equalizerwin_on, "clicked", equalizerwin_on_pushed, NULL);
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
374 ui_skinned_button_set_inside (equalizerwin_on, aud_cfg->equalizer_active);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376 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
377 ui_skinned_toggle_button_setup(equalizerwin_auto, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 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
379 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
380 ui_skinned_button_set_inside(equalizerwin_auto, aud_cfg->equalizer_autoload);
2606
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 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
383 ui_skinned_push_button_setup(equalizerwin_presets, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384 217, 18, 44, 12, 224, 164, 224, 176, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 g_signal_connect(equalizerwin_presets, "clicked", equalizerwin_presets_pushed, NULL );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 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
388 ui_skinned_push_button_setup(equalizerwin_close, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389 264, 3, 9, 9, 0, 116, 0, 125, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 g_signal_connect(equalizerwin_close, "clicked", equalizerwin_close_cb, NULL );
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 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
393 ui_skinned_push_button_setup(equalizerwin_shade, SKINNED_WINDOW(equalizerwin)->normal,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 254, 3, 9, 9, 254, 137, 1, 38, SKIN_EQMAIN);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 ui_skinned_button_set_skin_index2(equalizerwin_shade, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 g_signal_connect(equalizerwin_shade, "clicked", equalizerwin_shade_toggle, NULL );
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
398 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
399 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
400 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
401 g_signal_connect(equalizerwin_shaded_close, "clicked", equalizerwin_close_cb, NULL );
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
402
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
403 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
404 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
405 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
406 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
407
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
408 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
409
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
410 equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 21, 38);
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
411 ui_skinned_equalizer_slider_set_position (equalizerwin_preamp,
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
412 aud_cfg->equalizer_preamp);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
413
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
414 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
415 equalizerwin_bands[i] =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
416 ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->normal, 78 + (i * 18), 38);
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
417 ui_skinned_equalizer_slider_set_position (equalizerwin_bands [i],
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
418 aud_cfg->equalizer_bands [i]);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
419 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
420
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
421 equalizerwin_volume =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
422 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
423 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
424 equalizerwin_volume_frame_cb, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
425 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
426 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
427
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
428
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
429 equalizerwin_balance =
2719
51fc44b99b58 use two GtkFixed in SkinnedWindow - normal and shaded
Tomasz Mon <desowin@gmail.com>
parents: 2678
diff changeset
430 ui_skinned_horizontal_slider_new(SKINNED_WINDOW(equalizerwin)->shaded,
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
431 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
432 equalizerwin_balance_frame_cb, SKIN_EQ_EX);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
433 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
434 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
435 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
436
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
437
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
438 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
439 equalizerwin_create_window(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
440 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
441 GdkPixbuf *icon;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
442 gint width, height;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
443
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
444 width = 275;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
445 height = config.equalizer_shaded ? 14 : 116;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
446
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
447 equalizerwin = ui_skinned_window_new("equalizer");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
448 gtk_window_set_title(GTK_WINDOW(equalizerwin), _("Audacious Equalizer"));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
449 gtk_window_set_role(GTK_WINDOW(equalizerwin), "equalizer");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
450 gtk_window_set_resizable(GTK_WINDOW(equalizerwin), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
451
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
452 if (config.scaled && config.eq_scaled_linked) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
453 width *= config.scale_factor;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
454 height *= config.scale_factor;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
455 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
456
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
457 gtk_widget_set_size_request(equalizerwin, width, height);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
458
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
459 /* this will hide only mainwin. it's annoying! yaz */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
460 gtk_window_set_transient_for(GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
461 GTK_WINDOW(mainwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
462 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(equalizerwin), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
463
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
464 icon = gdk_pixbuf_new_from_xpm_data((const gchar **) audacious_eq_icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
465 gtk_window_set_icon(GTK_WINDOW(equalizerwin), icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
466 g_object_unref(icon);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
467
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
468 gtk_widget_set_app_paintable(equalizerwin, TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
469
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
470 if (config.equalizer_x != -1 && config.save_window_position)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
471 gtk_window_move(GTK_WINDOW(equalizerwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
472 config.equalizer_x, config.equalizer_y);
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 g_signal_connect(equalizerwin, "delete_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
475 G_CALLBACK(equalizerwin_delete), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
476 g_signal_connect(equalizerwin, "button_press_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
477 G_CALLBACK(equalizerwin_press), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
478 g_signal_connect(equalizerwin, "key_press_event",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
479 G_CALLBACK(equalizerwin_keypress), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
480 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
483 equalizerwin_create(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
484 {
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
485 equalizer_presets = aud_equalizer_read_presets("eq.preset");
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
486 equalizer_auto_presets = aud_equalizer_read_presets("eq.auto_preset");
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
487
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
488 equalizerwin_create_window();
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 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
491
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
492 equalizerwin_create_widgets();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
493 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
494
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
495 static void equalizerwin_real_show (void)
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
496 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
497 gtk_window_move(GTK_WINDOW(equalizerwin), config.equalizer_x, config.equalizer_y);
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 gtk_widget_set_size_request(equalizerwin, 275 * config.scale_factor,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
500 ((config.equalizer_shaded ? 14 : 116) * config.scale_factor));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
501 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
502 gtk_widget_set_size_request(equalizerwin, 275,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
503 (config.equalizer_shaded ? 14 : 116));
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
504 ui_skinned_button_set_inside(mainwin_eq, TRUE);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
505 gtk_widget_show_all(equalizerwin);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
506
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
507 gtk_window_present(GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
508 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
509
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
510 static void equalizerwin_real_hide (void)
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
511 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
512 gtk_widget_hide(equalizerwin);
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
513 ui_skinned_button_set_inside(mainwin_eq, FALSE);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
514 gtk_widget_queue_draw(mainwin_eq);
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
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
517 void
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
518 equalizerwin_show(gboolean show)
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
519 {
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
520 GtkAction * a;
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
521
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
522 a = gtk_action_group_get_action (toggleaction_group_others, "show equalizer");
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
523
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
524 if (a && gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (a)) != show)
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
525 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (a), show);
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
526 else
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
527 {
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
528 config.equalizer_visible = show;
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
529 aud_cfg->equalizer_visible = show;
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
530
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
531 if (show)
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
532 equalizerwin_real_show ();
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
533 else
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
534 equalizerwin_real_hide ();
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
535 }
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
536 }
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
537
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
538 static EqualizerPreset *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
539 equalizerwin_find_preset(GList * list, const gchar * name)
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 GList *node = list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
542 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
543
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
544 while (node) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
545 preset = node->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
546 if (!strcasecmp(preset->name, name))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
547 return preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
548 node = g_list_next(node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
549 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
550 return NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
551 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
552
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
553 static gboolean
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
554 equalizerwin_load_preset(GList * list, const gchar * name)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
555 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
556 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
557 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
558
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
559 if ((preset = equalizerwin_find_preset(list, name)) != NULL) {
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
560 equalizerwin_set_preamp(preset->preamp);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
561 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
562 equalizerwin_set_band(i, preset->bands[i]);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
563
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
564 return TRUE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
565 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
566 return FALSE;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
567 }
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 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
570 equalizerwin_save_preset(GList * list, const gchar * name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
571 const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
572 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
573 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
574 EqualizerPreset *preset;
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 if (!(preset = equalizerwin_find_preset(list, name))) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
577 preset = g_new0(EqualizerPreset, 1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
578 preset->name = g_strdup(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
579 list = g_list_append(list, preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
580 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
581
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
582 preset->preamp = equalizerwin_get_preamp();
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
583 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
584 preset->bands[i] = equalizerwin_get_band(i);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
585
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
586 aud_equalizer_write_preset_file(list, filename);
2606
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 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
589 }
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 static GList *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
592 equalizerwin_delete_preset(GList * list, gchar * name, gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
593 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
594 EqualizerPreset *preset;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
595 GList *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 if (!(preset = equalizerwin_find_preset(list, name)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
598 return list;
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 if (!(node = g_list_find(list, preset)))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
601 return list;
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 list = g_list_remove_link(list, node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
604 equalizer_preset_free(preset);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
605 g_list_free_1(node);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
606
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
607 aud_equalizer_write_preset_file(list, filename);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
608
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
609 return list;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
610 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
611
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
612 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
613 equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
614 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
615 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
616
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
617 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
618 GtkTreeModel *model = gtk_tree_view_get_model(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
619
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
620 /*
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
621 * 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
622 * list into a list of GtkTreeRowReferences, so that when you delete an
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
623 * item you can still access the other items
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
624 * finally we iterate through all GtkTreeRowReferences, convert them to
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
625 * GtkTreeIters and delete those one after the other
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
628 GList *list = gtk_tree_selection_get_selected_rows(selection, &model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
629 GList *rrefs = NULL;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
630 GList *litr;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
631
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
632 for (litr = list; litr; litr = litr->next)
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 GtkTreePath *path = litr->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
635 rrefs = g_list_append(rrefs, gtk_tree_row_reference_new(model, path));
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
638 for (litr = rrefs; litr; litr = litr->next)
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 GtkTreeRowReference *ref = litr->data;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
641 GtkTreePath *path = gtk_tree_row_reference_get_path(ref);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
642 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
643 gtk_tree_model_get_iter(model, &iter, path);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
644
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
645 gtk_tree_model_get(model, &iter, 0, &text, -1);
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 if (!strcmp(filename, "eq.preset"))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
648 equalizer_presets = equalizerwin_delete_preset(equalizer_presets, text, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
649 else if (!strcmp(filename, "eq.auto_preset"))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
650 equalizer_auto_presets = equalizerwin_delete_preset(equalizer_auto_presets, text, filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
651
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
652 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
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 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
655
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
656 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
657 free_cb (gpointer data, gpointer user_data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
658 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
659 equalizer_preset_free((EqualizerPreset*)data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
660 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
663 equalizerwin_read_winamp_eqf(VFSFile * file)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
664 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
665 GList *presets;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
666 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
667
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
668 if ((presets = aud_import_winamp_eqf(file)) == NULL)
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
669 return;
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 /* just get the first preset --asphyx */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
672 EqualizerPreset *preset = (EqualizerPreset*)presets->data;
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
673 equalizerwin_set_preamp(preset->preamp);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
674
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
675 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
676 equalizerwin_set_band(i, preset->bands[i]);
2606
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 g_list_foreach(presets, free_cb, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
679 g_list_free(presets);
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 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
682 }
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
683
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
684 static void
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
685 equalizerwin_read_aud_preset(const gchar * file)
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
686 {
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
687 EqualizerPreset *preset = aud_equalizer_read_aud_preset(file);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
688 if (preset) {
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
689 equalizerwin_apply_preset(preset);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
690 equalizer_preset_free(preset);
2606
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
694 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
695 equalizerwin_save_ok(GtkWidget * widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
696 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
697 const gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
698
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
699 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_entry));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
700 if (strlen(text) != 0)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
701 equalizer_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
702 equalizerwin_save_preset(equalizer_presets, text, "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
703 gtk_widget_destroy(equalizerwin_save_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
704 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
705
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
706 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
707 equalizerwin_save_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
708 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
709 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
710 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
711
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
712 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
713 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
714 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
715
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
716 if (selection)
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 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
719 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
720 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
721 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_entry), text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
722 equalizerwin_save_ok(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
723
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
724 g_free(text);
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 }
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
729 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
730 equalizerwin_load_ok(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
731 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
732 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
733
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
734 GtkTreeView* view = GTK_TREE_VIEW(data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
735 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
736 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
737 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
738
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
739 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
740 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
741 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
742 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
743 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
744 equalizerwin_load_preset(equalizer_presets, text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
745
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
746 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
747 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
748 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
749 gtk_widget_destroy(equalizerwin_load_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
750 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
751
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
752 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
753 equalizerwin_load_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
754 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
755 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
756 equalizerwin_load_ok(NULL, treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
757 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
758
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
759 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
760 equalizerwin_delete_delete(GtkWidget *widget, gpointer data)
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 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
763 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
764
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
765 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
766 equalizerwin_save_auto_ok(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
767 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
768 const gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
769
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
770 text = gtk_entry_get_text(GTK_ENTRY(equalizerwin_save_auto_entry));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
771 if (strlen(text) != 0)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
772 equalizer_auto_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
773 equalizerwin_save_preset(equalizer_auto_presets, text,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
774 "eq.auto_preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
775 gtk_widget_destroy(equalizerwin_save_auto_window);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
778 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
779 equalizerwin_save_auto_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
780 GtkTreeViewColumn *col, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
781 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
782 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
783
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
784 GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
785 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
786 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
787
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
788 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
789 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
790 if (gtk_tree_selection_get_selected(selection, &model, &iter))
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 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
793 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry), text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
794 equalizerwin_save_auto_ok(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
795
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
796 g_free(text);
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 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
799 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
802 equalizerwin_load_auto_ok(GtkWidget *widget, gpointer data)
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 gchar *text;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
805
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
806 GtkTreeView *view = GTK_TREE_VIEW(data);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
807 GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
808 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
809 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
810
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
811 if (selection)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
812 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
813 if (gtk_tree_selection_get_selected(selection, &model, &iter))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
814 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
815 gtk_tree_model_get(model, &iter, 0, &text, -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
816 equalizerwin_load_preset(equalizer_auto_presets, text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
817
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
818 g_free(text);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
819 }
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 gtk_widget_destroy(equalizerwin_load_auto_window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
822 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
823
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
824 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
825 equalizerwin_load_auto_select(GtkTreeView *treeview, GtkTreePath *path,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
826 GtkTreeViewColumn *col, gpointer data)
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 equalizerwin_load_auto_ok(NULL, treeview);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
829 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
830
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
831 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
832 equalizerwin_delete_auto_delete(GtkWidget *widget, gpointer data)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
833 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
834 equalizerwin_delete_selected_presets(GTK_TREE_VIEW(data), "eq.auto_preset");
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
837 static VFSFile *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
838 open_vfs_file(const gchar *filename, const gchar *mode)
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 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
841 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
842
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
843 if (!(file = aud_vfs_fopen(filename, mode))) {
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
844 dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
845 GTK_DIALOG_DESTROY_WITH_PARENT,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
846 GTK_MESSAGE_ERROR,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
847 GTK_BUTTONS_CLOSE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
848 "Error loading file '%s'",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
849 filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
850 gtk_dialog_run (GTK_DIALOG (dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
851 gtk_widget_destroy (dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
852 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
853
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
854 return file;
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
857 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
858 load_winamp_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
859 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
860 VFSFile *file;
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 (!(file = open_vfs_file(filename, "rb")))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
863 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
864
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
865 equalizerwin_read_winamp_eqf(file);
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
866 aud_vfs_fclose(file);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
867 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
868
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
869 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
870 import_winamp_file(const gchar * filename)
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 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
873 GList *list;
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 if (!(file = open_vfs_file(filename, "rb")) ||
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
876 !(list = aud_import_winamp_eqf(file)))
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
877 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
878
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
879 equalizer_presets = g_list_concat(equalizer_presets, list);
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
880 aud_equalizer_write_preset_file(equalizer_presets, "eq.preset");
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
881
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
882 aud_vfs_fclose(file);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
883 }
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 static void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
886 save_winamp_file(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
887 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
888 VFSFile *file;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
889
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
890 gchar name[257];
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
891 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
892 guchar bands[11];
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 if (!(file = open_vfs_file(filename, "wb")))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
895 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
896
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
897 aud_vfs_fwrite("Winamp EQ library file v1.1\x1a!--", 1, 31, file);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
898
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
899 memset(name, 0, 257);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
900 g_strlcpy(name, "Entry1", 257);
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
901 aud_vfs_fwrite(name, 1, 257, file);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
902
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
903 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
904 bands[i] = 63 - (((equalizerwin_get_band(i) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
905
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
906 bands[AUD_EQUALIZER_NBANDS] = 63 - (((equalizerwin_get_preamp() + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
907
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
908 aud_vfs_fwrite(bands, 1, 11, file);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
909 aud_vfs_fclose(file);
2606
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
912 static GtkWidget *
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
913 equalizerwin_create_list_window(GList *preset_list,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
914 const gchar *title,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
915 GtkWidget **window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
916 GtkSelectionMode sel_mode,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
917 GtkWidget **entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
918 const gchar *action_name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
919 GCallback action_func,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
920 GCallback select_row_func)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
921 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
922 GtkWidget *vbox, *scrolled_window, *bbox, *view;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
923 GtkWidget *button_cancel, *button_action;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
924 GList *node;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
925
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
926 GtkListStore *store;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
927 GtkTreeIter iter;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
928 GtkTreeModel *model;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
929 GtkCellRenderer *renderer;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
930 GtkTreeSelection *selection;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
931 GtkTreeSortable *sortable;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
932
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
935 *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
936 gtk_window_set_title(GTK_WINDOW(*window), title);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
937 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
938 gtk_window_set_default_size(GTK_WINDOW(*window), 350, 300);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
939 gtk_window_set_position(GTK_WINDOW(*window), GTK_WIN_POS_CENTER);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
940 gtk_container_set_border_width(GTK_CONTAINER(*window), 10);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
941 gtk_window_set_transient_for(GTK_WINDOW(*window),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
942 GTK_WINDOW(equalizerwin));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
943 g_signal_connect(*window, "destroy",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
944 G_CALLBACK(gtk_widget_destroyed), window);
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 vbox = gtk_vbox_new(FALSE, 10);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
947 gtk_container_add(GTK_CONTAINER(*window), vbox);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
948
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
949 scrolled_window = gtk_scrolled_window_new(NULL, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
950 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
951 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
952
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
953
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
954 /* fill the store with the names of all available presets */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
955 store = gtk_list_store_new(1, G_TYPE_STRING);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
956 for (node = preset_list; node; node = g_list_next(node))
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
957 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
958 gtk_list_store_append(store, &iter);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
959 gtk_list_store_set(store, &iter,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
960 0, ((EqualizerPreset*)node->data)->name,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
961 -1);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
962 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
963 model = GTK_TREE_MODEL(store);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
964
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 sortable = GTK_TREE_SORTABLE(store);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
967 gtk_tree_sortable_set_sort_column_id(sortable, 0, GTK_SORT_ASCENDING);
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 view = gtk_tree_view_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
971 renderer = gtk_cell_renderer_text_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
972 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
973 _("Presets"), renderer,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
974 "text", 0, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
975 gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
976 g_object_unref(model);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
977
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
978 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
979 gtk_tree_selection_set_mode(selection, sel_mode);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
980
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 gtk_container_add(GTK_CONTAINER(scrolled_window), view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
985 gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
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 (entry) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
988 *entry = gtk_entry_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
989 g_signal_connect(*entry, "activate", action_func, NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
990 gtk_box_pack_start(GTK_BOX(vbox), *entry, FALSE, FALSE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
991 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
992
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
993 bbox = gtk_hbutton_box_new();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
994 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
3017
963796db51ea Don't use deprecated gtk macros and types
Tomasz Mon <desowin@gmail.com>
parents: 2971
diff changeset
995 gtk_box_set_spacing(GTK_BOX(bbox), 5);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
996 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
997
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
998 button_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
999 g_signal_connect_swapped(button_cancel, "clicked",
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1000 G_CALLBACK(gtk_widget_destroy),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1001 GTK_OBJECT(*window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1002 gtk_box_pack_start(GTK_BOX(bbox), button_cancel, TRUE, TRUE, 0);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1003
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1004 button_action = gtk_button_new_from_stock(action_name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1005 g_signal_connect(button_action, "clicked", G_CALLBACK(action_func), view);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1006 GTK_WIDGET_SET_FLAGS(button_action, GTK_CAN_DEFAULT);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1007
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1008 if (select_row_func)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1009 g_signal_connect(view, "row-activated", G_CALLBACK(select_row_func), NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1010
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
1011
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1012 gtk_box_pack_start(GTK_BOX(bbox), button_action, TRUE, TRUE, 0);
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 gtk_widget_grab_default(button_action);
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 gtk_widget_show_all(*window);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1018
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1019 return *window;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1020 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1021
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1022 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1023 equalizerwin_load_auto_preset(const gchar * filename)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1024 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1025 gchar *presetfilename, *directory;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1026
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1027 g_return_if_fail(filename != NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1028
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1029 if (!aud_cfg->equalizer_autoload)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1030 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1031
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1032 presetfilename = g_strconcat(filename, ".", aud_cfg->eqpreset_extension, NULL);
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 /* First try to find a per file preset file */
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1035 if (strlen(aud_cfg->eqpreset_extension) > 0) {
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1036 equalizerwin_read_aud_preset(presetfilename);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1037 g_free(presetfilename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1038 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1039 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1040
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1041 g_free(presetfilename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1042
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1043 directory = g_path_get_dirname(filename);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1044 presetfilename = g_build_filename(directory, aud_cfg->eqpreset_default_file,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1045 NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1046 g_free(directory);
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 /* Try to find a per directory preset file */
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1049 if (strlen(aud_cfg->eqpreset_default_file) > 0) {
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1050 equalizerwin_read_aud_preset(presetfilename);
2606
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 else if (!equalizerwin_load_preset
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1053 (equalizer_auto_presets, g_basename(filename))) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1054 /* Fall back to the oldstyle auto presets */
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1055 equalizerwin_load_preset(equalizer_presets, "Default");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1056 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1057
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1058 g_free(presetfilename);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1061 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1062 equalizerwin_set_preamp(gfloat preamp)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1063 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1064 ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1065 equalizerwin_eq_changed();
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1068 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1069 equalizerwin_set_band(gint band, gfloat value)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1070 {
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1071 g_return_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1072 ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value);
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
1073 equalizerwin_eq_changed();
2606
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1076 gfloat
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1077 equalizerwin_get_preamp(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1078 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1079 return ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1080 }
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 gfloat
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1083 equalizerwin_get_band(gint band)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1084 {
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1085 g_return_val_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS, 0.0);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1086 return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1087 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1088
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1089 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1090 action_equ_load_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1091 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1092 if (equalizerwin_load_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1093 gtk_window_present(GTK_WINDOW(equalizerwin_load_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1094 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1095 }
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1096
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1097 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1098 Q_("Load preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1099 &equalizerwin_load_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1100 GTK_SELECTION_SINGLE, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1101 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1102 G_CALLBACK(equalizerwin_load_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1103 G_CALLBACK(equalizerwin_load_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1104 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1105
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1106 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1107 action_equ_load_auto_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1108 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1109 if (equalizerwin_load_auto_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1110 gtk_window_present(GTK_WINDOW(equalizerwin_load_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1111 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1112 }
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 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1115 Q_("Load auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1116 &equalizerwin_load_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1117 GTK_SELECTION_SINGLE, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1118 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1119 G_CALLBACK(equalizerwin_load_auto_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1120 G_CALLBACK(equalizerwin_load_auto_select));
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1124 action_equ_load_default_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1125 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1126 equalizerwin_load_preset(equalizer_presets, "Default");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1127 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1128
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1129 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1130 action_equ_zero_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1131 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1132 gint i;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1133
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1134 equalizerwin_set_preamp(0);
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1135 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1136 equalizerwin_set_band(i, 0);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1137 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1138
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1139 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1140 action_equ_load_preset_file(void)
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 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1143 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1144
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1145 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1146 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1147 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1148 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1149 EqualizerPreset *preset = aud_load_preset_file(file_uri);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1150 equalizerwin_apply_preset(preset);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1151 equalizer_preset_free(preset);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1152 g_free(file_uri);
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 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1155 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1158 action_equ_load_preset_eqf(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1159 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1160 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1161 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1162
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1163 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1164 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
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 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1167 load_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1168 g_free(file_uri);
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 gtk_widget_destroy(dialog);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1173 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1174 action_equ_import_winamp_presets(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1175 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1176 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1177 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1178
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1179 dialog = make_filebrowser(Q_("Load equalizer preset"), FALSE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1180 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1181 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1182 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1183 import_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1184 g_free(file_uri);
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 gtk_widget_destroy(dialog);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1187 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1188
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1189 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1190 action_equ_save_preset(void)
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 if (equalizerwin_save_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1193 gtk_window_present(GTK_WINDOW(equalizerwin_save_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1194 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1195 }
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
1196
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1197 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1198 Q_("Save preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1199 &equalizerwin_save_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1200 GTK_SELECTION_SINGLE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1201 &equalizerwin_save_entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1202 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1203 G_CALLBACK(equalizerwin_save_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1204 G_CALLBACK(equalizerwin_save_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1205 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1208 action_equ_save_auto_preset(void)
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 gchar *name;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1211 Playlist *playlist = aud_playlist_get_active();
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 (equalizerwin_save_auto_window)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1214 gtk_window_present(GTK_WINDOW(equalizerwin_save_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1215 else
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1216 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1217 Q_("Save auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1218 &equalizerwin_save_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1219 GTK_SELECTION_SINGLE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1220 &equalizerwin_save_auto_entry,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1221 GTK_STOCK_OK,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1222 G_CALLBACK(equalizerwin_save_auto_ok),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1223 G_CALLBACK(equalizerwin_save_auto_select));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1224
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1225 name = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1226 if (name) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1227 gtk_entry_set_text(GTK_ENTRY(equalizerwin_save_auto_entry),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1228 g_basename(name));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1229 g_free(name);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1230 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1234 action_equ_save_default_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1235 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1236 equalizer_presets =
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1237 equalizerwin_save_preset(equalizer_presets, Q_("Default"), "eq.preset");
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1238 }
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1241 action_equ_save_preset_file(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1242 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1243 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1244 gchar *file_uri;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1245 gchar *songname;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1246 Playlist *playlist = aud_playlist_get_active();
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1247 gint i;
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1248
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1249 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1250 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
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 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1253 EqualizerPreset *preset = g_new0(EqualizerPreset, 1);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1254 preset->name = g_strdup(file_uri);
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1255 preset->preamp = equalizerwin_get_preamp();
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1256 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1257 preset->bands[i] = equalizerwin_get_band(i);
2786
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1258 aud_save_preset_file(preset, file_uri);
b7d8e6fd4644 make use of exported equalzier preset functions
Tomasz Mon <desowin@gmail.com>
parents: 2719
diff changeset
1259 equalizer_preset_free(preset);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1260 g_free(file_uri);
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 songname = aud_playlist_get_filename(playlist, aud_playlist_get_position(playlist));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1264 if (songname) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1265 gchar *eqname = g_strdup_printf("%s.%s", songname,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1266 aud_cfg->eqpreset_extension);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1267 g_free(songname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1268 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1269 eqname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1270 g_free(eqname);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1271 }
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 gtk_widget_destroy(dialog);
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 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1277 action_equ_save_preset_eqf(void)
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 GtkWidget *dialog;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1280 gchar *file_uri;
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 dialog = make_filebrowser(Q_("Save equalizer preset"), TRUE);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1283 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1284 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1285 file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1286 save_winamp_file(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1287 g_free(file_uri);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1288 }
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1289 gtk_widget_destroy(dialog);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1292 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1293 action_equ_delete_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1294 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1295 if (equalizerwin_delete_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1296 gtk_window_present(GTK_WINDOW(equalizerwin_delete_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1297 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1298 }
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
1299
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1300 equalizerwin_create_list_window(equalizer_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1301 Q_("Delete preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1302 &equalizerwin_delete_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1303 GTK_SELECTION_EXTENDED, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1304 GTK_STOCK_DELETE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1305 G_CALLBACK(equalizerwin_delete_delete),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1306 NULL);
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
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1309 void
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1310 action_equ_delete_auto_preset(void)
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1311 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1312 if (equalizerwin_delete_auto_window) {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1313 gtk_window_present(GTK_WINDOW(equalizerwin_delete_auto_window));
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1314 return;
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1315 }
3159
1ffcad5f406c import new skins plugin
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3158
diff changeset
1316
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1317 equalizerwin_create_list_window(equalizer_auto_presets,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1318 Q_("Delete auto-preset"),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1319 &equalizerwin_delete_auto_window,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1320 GTK_SELECTION_EXTENDED, NULL,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1321 GTK_STOCK_DELETE,
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1322 G_CALLBACK(equalizerwin_delete_auto_delete),
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1323 NULL);
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1324 }
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 void
2792
04c38b7a6079 sync ui_equalizer changes with skins plugin
mf0102 <0102@gmx.at>
parents: 2786
diff changeset
1327 equalizerwin_activate(gboolean active)
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1328 {
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1329 aud_cfg->equalizer_active = active;
2668
a1431a900f28 introduce ui_skinned_button_set_inside
Tomasz Mon <desowin@gmail.com>
parents: 2641
diff changeset
1330 ui_skinned_button_set_inside(equalizerwin_on, active);
2606
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1331 equalizerwin_eq_changed();
b53841a1b5d3 add ui_equalizer
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1332 }