diff options
author | Alessio Treglia <alessio@debian.org> | 2012-06-02 13:29:23 +0200 |
---|---|---|
committer | Alessio Treglia <alessio@debian.org> | 2012-06-02 13:29:23 +0200 |
commit | e6e39e3e85728d2a0fe9567fec4c256fdfc16ce9 (patch) | |
tree | 913cb2f16e143c5cb9332275db46d992fa9bff69 /src/skins/ui_equalizer.c | |
parent | 09e552d4002c35efd1c4c6b2e43c196ba20b79b8 (diff) |
Imported Upstream version 3.2.3
Diffstat (limited to 'src/skins/ui_equalizer.c')
-rw-r--r-- | src/skins/ui_equalizer.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/src/skins/ui_equalizer.c b/src/skins/ui_equalizer.c index f52f88a..f7fbab3 100644 --- a/src/skins/ui_equalizer.c +++ b/src/skins/ui_equalizer.c @@ -58,6 +58,8 @@ static gfloat equalizerwin_get_band (gint band); static void equalizerwin_set_preamp (gfloat preamp); static void equalizerwin_set_band (gint band, gfloat value); +static void position_cb (void * data, void * user_data); + GtkWidget *equalizerwin; static GtkWidget *equalizerwin_graph; @@ -90,6 +92,14 @@ equalizer_preset_free(EqualizerPreset * preset) g_free(preset); } +static void free_presets (Index * presets) +{ + for (int p = 0; p < index_count (presets); p ++) + equalizer_preset_free (index_get (presets, p)); + + index_free (presets); +} + void equalizerwin_set_shape (void) { gint id = config.equalizer_shaded ? SKIN_MASK_EQ_SHADE : SKIN_MASK_EQ; @@ -402,6 +412,13 @@ static void equalizerwin_destroyed (void) hook_dissociate ("set equalizer_active", (HookFunction) update_from_config); hook_dissociate ("set equalizer_bands", (HookFunction) update_from_config); hook_dissociate ("set equalizer_preamp", (HookFunction) update_from_config); + + hook_dissociate ("playlist position", position_cb); + + free_presets (equalizer_presets); + free_presets (equalizer_auto_presets); + equalizer_presets = NULL; + equalizer_auto_presets = NULL; } void @@ -410,6 +427,11 @@ equalizerwin_create(void) equalizer_presets = aud_equalizer_read_presets("eq.preset"); equalizer_auto_presets = aud_equalizer_read_presets("eq.auto_preset"); + if (! equalizer_presets) + equalizer_presets = index_new (); + if (! equalizer_auto_presets) + equalizer_auto_presets = index_new (); + equalizerwin_create_window(); gtk_window_add_accel_group( GTK_WINDOW(equalizerwin) , ui_manager_get_accel_group() ); @@ -422,6 +444,16 @@ equalizerwin_create(void) hook_associate ("set equalizer_active", (HookFunction) update_from_config, NULL); hook_associate ("set equalizer_bands", (HookFunction) update_from_config, NULL); hook_associate ("set equalizer_preamp", (HookFunction) update_from_config, NULL); + + int playlist = aud_playlist_get_playing (); + + /* Load preset for the first song. FIXME: Doing this at interface load is + really too late as the song may already be started. Really, this stuff + shouldn't be in the interface plugin at all but in core. -jlindgren */ + if (playlist != -1) + position_cb (GINT_TO_POINTER (playlist), NULL); + + hook_associate ("playlist position", position_cb, NULL); } static void equalizerwin_real_show (gboolean show) @@ -551,14 +583,6 @@ equalizerwin_delete_selected_presets(GtkTreeView *view, gchar *filename) } } -static void free_presets (Index * presets) -{ - for (int p = 0; p < index_count (presets); p ++) - equalizer_preset_free (index_get (presets, p)); - - index_free (presets); -} - static void equalizerwin_read_winamp_eqf(VFSFile * file) { @@ -1250,32 +1274,6 @@ static void position_cb (void * data, void * user_data) str_unref (filename); } -void eq_init_hooks (void) -{ - equalizer_presets = index_new (); - equalizer_auto_presets = index_new (); - - gint playlist = aud_playlist_get_playing (); - - /* Load preset for the first song. FIXME: Doing this at interface load is - really too late as the song may already be started. Really, this stuff - shouldn't be in the interface plugin at all but in core. -jlindgren */ - if (playlist != -1) - position_cb (GINT_TO_POINTER (playlist), NULL); - - hook_associate ("playlist position", position_cb, NULL); -} - -void eq_end_hooks (void) -{ - hook_dissociate ("playlist position", position_cb); - - free_presets (equalizer_presets); - free_presets (equalizer_auto_presets); - equalizer_presets = NULL; - equalizer_auto_presets = NULL; -} - void action_show_equalizer (GtkToggleAction * action) { equalizerwin_show (gtk_toggle_action_get_active (action)); |