changeset 4724:8817a9fd9b5e

branch merge
author Tomasz Mon <desowin@gmail.com>
date Sun, 13 Jul 2008 12:51:17 +0200
parents 07b4e2a5eedb (current diff) 1d13609b1c52 (diff)
children 4e38324b5e9f
files
diffstat 4 files changed, 57 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/dbus.c	Sun Jul 13 12:50:31 2008 +0200
+++ b/src/audacious/dbus.c	Sun Jul 13 12:51:17 2008 +0200
@@ -979,7 +979,7 @@
 
 gboolean audacious_rc_equalizer_activate(RemoteObject *obj, gboolean active, GError **error)
 {
-    equalizer_activate(active);
+    equalizer_set_active(active);
     return TRUE;
 }
 
--- a/src/audacious/equalizer.c	Sun Jul 13 12:50:31 2008 +0200
+++ b/src/audacious/equalizer.c	Sun Jul 13 12:51:17 2008 +0200
@@ -19,26 +19,19 @@
 
 #include "equalizer.h"
 
+#include "audconfig.h"
 #include "legacy/ui_equalizer.h"
 
+gfloat
+equalizer_get_preamp(void)
+{
+    return equalizerwin_get_preamp();
+}
+
 void
 equalizer_set_preamp(gfloat preamp)
 {
     equalizerwin_set_preamp(preamp);
-    equalizerwin_eq_changed();
-}
-
-void
-equalizer_set_band(gint band, gfloat value)
-{
-    equalizerwin_set_band(band, value);
-    equalizerwin_eq_changed();
-}
-
-gfloat
-equalizer_get_preamp(void)
-{
-    return equalizerwin_get_preamp();
 }
 
 gfloat
@@ -48,7 +41,18 @@
 }
 
 void
-equalizer_activate(gboolean active)
+equalizer_set_band(gint band, gfloat value)
+{
+    equalizerwin_set_band(band, value);
+}
+
+gboolean equalizer_get_active(gboolean active)
+{
+    return cfg.equalizer_active;
+}
+
+void
+equalizer_set_active(gboolean active)
 {
     equalizerwin_activate(active);
 }
--- a/src/audacious/equalizer.h	Sun Jul 13 12:50:31 2008 +0200
+++ b/src/audacious/equalizer.h	Sun Jul 13 12:51:17 2008 +0200
@@ -22,11 +22,12 @@
 
 #include <glib.h>
 
+gfloat equalizer_get_preamp(void);
 void equalizer_set_preamp(gfloat preamp);
+gfloat equalizer_get_band(gint band);
 void equalizer_set_band(gint band, gfloat value);
-gfloat equalizer_get_preamp(void);
-gfloat equalizer_get_band(gint band);
 
-void equalizer_activate(gboolean active);
+gboolean equalizer_get_active();
+void equalizer_set_active(gboolean active);
 
 #endif
--- a/src/audacious/legacy/ui_equalizer.c	Sun Jul 13 12:50:31 2008 +0200
+++ b/src/audacious/legacy/ui_equalizer.c	Sun Jul 13 12:51:17 2008 +0200
@@ -162,9 +162,9 @@
 {
     gint i;
 
-    cfg.equalizer_preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
+    cfg.equalizer_preamp = equalizerwin_get_preamp();
     for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
-        cfg.equalizer_bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
+        cfg.equalizer_bands[i] = equalizerwin_get_band(i);
 
     output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
                   cfg.equalizer_bands);
@@ -180,18 +180,15 @@
 
     gint i;
 
-    ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp);
-    for (i = 0; i < 10; i++) {
-        ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]);
-    }
-    equalizerwin_eq_changed();
+    equalizerwin_set_preamp(preset->preamp);
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+        equalizerwin_set_band(i, preset->bands[i]);
 }
 
 static void
 equalizerwin_on_pushed(void)
 {
-    cfg.equalizer_active = UI_SKINNED_BUTTON(equalizerwin_on)->inside;
-    equalizerwin_eq_changed();
+    equalizerwin_activate(!cfg.equalizer_active);
 }
 
 static void
@@ -374,7 +371,7 @@
     ui_skinned_toggle_button_setup(equalizerwin_on, SKINNED_WINDOW(equalizerwin)->fixed,
                                    14, 18, 25, 12, 10, 119, 128, 119, 69, 119, 187, 119, SKIN_EQMAIN);
     g_signal_connect(equalizerwin_on, "clicked", equalizerwin_on_pushed, NULL);
-    UI_SKINNED_BUTTON(equalizerwin_on)->inside = cfg.equalizer_active;
+    equalizerwin_activate(cfg.equalizer_active);
 
     equalizerwin_auto = ui_skinned_button_new();
     ui_skinned_toggle_button_setup(equalizerwin_auto, SKINNED_WINDOW(equalizerwin)->fixed,
@@ -401,12 +398,12 @@
     equalizerwin_graph = ui_skinned_equalizer_graph_new(SKINNED_WINDOW(equalizerwin)->fixed, 86, 17);
 
     equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 21, 38);
-    ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, cfg.equalizer_preamp);
+    equalizerwin_set_preamp(cfg.equalizer_preamp);
 
     for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) {
         equalizerwin_bands[i] =
             ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 78 + (i * 18), 38);
-        ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]);
+        equalizerwin_set_band(i, cfg.equalizer_bands[i]);
     }
 
     equalizerwin_volume =
@@ -560,10 +557,10 @@
     gint i;
 
     if ((preset = equalizerwin_find_preset(list, name)) != NULL) {
-        ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp);
-        for (i = 0; i < 10; i++)
-            ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]);
-        equalizerwin_eq_changed();
+        equalizerwin_set_preamp(preset->preamp);
+        for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+            equalizerwin_set_band(i, preset->bands[i]);
+
         return TRUE;
     }
     return FALSE;
@@ -582,9 +579,9 @@
         list = g_list_append(list, preset);
     }
 
-    preset->preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
-    for (i = 0; i < 10; i++)
-        preset->bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
+    preset->preamp = equalizerwin_get_preamp();
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+        preset->bands[i] = equalizerwin_get_band(i);
 
     equalizer_write_preset_file(list, filename);
 
@@ -673,12 +670,10 @@
 
     /* just get the first preset --asphyx */
     EqualizerPreset *preset = (EqualizerPreset*)presets->data;
-    ui_skinned_equalizer_slider_set_position(equalizerwin_preamp,
-                                             preset->preamp);
+    equalizerwin_set_preamp(preset->preamp);
 
-    for (i = 0; i < 10; i++)
-        ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i],
-                                                 preset->bands[i]);
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+        equalizerwin_set_band(i, preset->bands[i]);
 
     g_list_foreach(presets, free_cb, NULL);
     g_list_free(presets);
@@ -905,11 +900,12 @@
     g_strlcpy(name, "Entry1", 257);
     vfs_fwrite(name, 1, 257, file);
 
-    for (i = 0; i < 10; i++)
-        bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
-    bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+        bands[i] = 63 - (((equalizerwin_get_band(i) + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
+
+    bands[AUD_EQUALIZER_NBANDS] = 63 - (((equalizerwin_get_preamp() + EQUALIZER_MAX_GAIN) * 63) / EQUALIZER_MAX_GAIN / 2);
+
     vfs_fwrite(bands, 1, 11, file);
-
     vfs_fclose(file);
 }
 
@@ -1072,8 +1068,9 @@
 void
 equalizerwin_set_band(gint band, gfloat value)
 {
-    g_return_if_fail(band >= 0 && band < 10);
+    g_return_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS);
     ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value);
+    equalizerwin_eq_changed();
 }
 
 gfloat
@@ -1085,7 +1082,7 @@
 gfloat
 equalizerwin_get_band(gint band)
 {
-    g_return_val_if_fail(band >= 0 && band < 10, 0.0);
+    g_return_val_if_fail(band >= 0 && band < AUD_EQUALIZER_NBANDS, 0.0);
     return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]);
 }
 
@@ -1134,11 +1131,9 @@
 {
     gint i;
 
-    ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, 0);
-    for (i = 0; i < 10; i++)
-        ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], 0);
-
-    equalizerwin_eq_changed();
+    equalizerwin_set_preamp(0);
+    for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+        equalizerwin_set_band(i, 0);
 }
 
 void
@@ -1257,9 +1252,9 @@
         file_uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
         EqualizerPreset *preset = g_new0(EqualizerPreset, 1);
         preset->name = g_strdup(file_uri);
-        preset->preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp);
-        for (i = 0; i < 10; i++)
-            preset->bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]);
+        preset->preamp = equalizerwin_get_preamp();
+        for (i = 0; i < AUD_EQUALIZER_NBANDS; i++)
+            preset->bands[i] = equalizerwin_get_band(i);
         save_preset_file(preset, file_uri);
         equalizer_preset_free(preset);
         g_free(file_uri);
@@ -1334,6 +1329,5 @@
     cfg.equalizer_active = active;
     UI_SKINNED_BUTTON(equalizerwin_on)->inside = active;
     gtk_widget_queue_draw(equalizerwin_on);
-
     equalizerwin_eq_changed();
 }