[gnac/devel] Code refactoring
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code refactoring
- Date: Fri, 30 Dec 2011 09:31:16 +0000 (UTC)
commit 73284e84f77e5545d708b388c46acbf347518997
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Fri Dec 30 00:00:16 2011 +0100
Code refactoring
src/profiles/formats/gnac-profiles-aac.c | 7 +--
src/profiles/formats/gnac-profiles-flac.c | 4 +-
src/profiles/formats/gnac-profiles-lame.c | 14 +++---
src/profiles/formats/gnac-profiles-speex.c | 20 ++++-----
src/profiles/formats/gnac-profiles-vorbis.c | 6 +-
src/profiles/formats/gnac-profiles-wav.c | 2 +-
src/profiles/formats/gnac-profiles-wavpack.c | 16 +++----
src/profiles/gnac-profiles-utils.c | 61 ++++++++------------------
src/profiles/gnac-profiles-utils.h | 10 +---
9 files changed, 51 insertions(+), 89 deletions(-)
---
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index eeb82f1..119566f 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -171,13 +171,10 @@ gnac_profiles_aac_generate_audio_profile(GError **error)
profile->generic = generic;
- gnac_profiles_utils_get_values_combo_and_set(&aac_bfi,
+ gnac_profiles_utils_get_values_and_set(&aac_bfi,
"combo-bitrate", &profile->bitrate,
"combo-outputformat", &profile->outputformat,
"combo-profile", &profile->profile,
- NULL);
-
- gnac_profiles_utils_get_values_check_and_set(&aac_bfi,
"checkbutton-tns", &profile->tns,
NULL);
@@ -238,7 +235,7 @@ gnac_profiles_aac_clean_up(void)
gnac_profiles_utils_free_values(&aac_bfi,
"combo-bitrate", "combo-outputformat",
"combo-profile", "checkbutton-tns", NULL);
- gnac_profiles_utils_free_basic_format_info_content(&aac_bfi);
+ gnac_profiles_utils_free_basic_format_info(&aac_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index 019c64a..1a56e96 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -133,7 +133,7 @@ gnac_profiles_flac_generate_audio_profile(GError **error)
profile->generic = generic;
- gnac_profiles_utils_get_values_slider_and_set(&flac_bfi,
+ gnac_profiles_utils_get_values_and_set(&flac_bfi,
"slider-compression", &profile->quality, NULL);
return profile;
@@ -190,7 +190,7 @@ gnac_profiles_flac_clean_up(void)
{
gnac_profiles_default_clean_up(&flac_bfi);
gnac_profiles_utils_free_values(&flac_bfi, "slider-compression", NULL);
- gnac_profiles_utils_free_basic_format_info_content(&flac_bfi);
+ gnac_profiles_utils_free_basic_format_info(&flac_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index 108c8e9..a461aea 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -447,7 +447,7 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
AudioProfileLame *profile = gnac_profiles_lame_audio_profile_new();
profile->generic = generic;
- gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"combo-encoding-mode", &profile->encoding_mode,
"combo-mode", &profile->mode,
NULL);
@@ -458,12 +458,12 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)))
{
case CONSTANT_BITRATE:
- gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"combo-bitrate", &profile->bitrate, NULL);
break;
case AVERAGE_BITRATE:
- gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"slider-mean-abr", &profile->mean_abr, NULL);
gnac_profiles_utils_get_values_checked_combo_and_set(&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", &profile->min_bitrate,
@@ -472,7 +472,7 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
break;
case VARIABLE_BITRATE:
- gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"slider-vbr-quality", &profile->quality, NULL);
gnac_profiles_utils_get_values_checked_slider_and_set(&lame_bfi,
"slider-mean-vbr", "checkbutton-mean-bitrate", &profile->mean_bitrate,
@@ -484,12 +484,12 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
break;
case PRESETS:
- gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"combo-preset", &profile->preset, NULL);
break;
case COMPRESSION_RATIO:
- gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
+ gnac_profiles_utils_get_values_and_set(&lame_bfi,
"slider-compression-ratio", &profile->compression_ratio, NULL);
break;
@@ -616,7 +616,7 @@ gnac_profiles_lame_clean_up(void)
"combo-preset", "combo-encoding-mode", "slider-vbr-quality",
"slider-compression-ratio", "slider-mean-vbr", "slider-mean-abr",
NULL);
- gnac_profiles_utils_free_basic_format_info_content(&lame_bfi);
+ gnac_profiles_utils_free_basic_format_info(&lame_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index a580f73..10bd2b0 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -434,32 +434,30 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
"combo-bitrate-mode");
BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- gnac_profiles_utils_get_values_combo_and_set(&speex_bfi,
- "combo-mode", &profile->mode, NULL);
+ gnac_profiles_utils_get_values_and_set(&speex_bfi,
+ "combo-mode", &profile->mode,
+ "checkbutton-dtx", &profile->dtx, NULL);
gnac_profiles_utils_get_values_checked_slider_and_set(&speex_bfi,
"slider-complexity", "checkbutton-complexity", &profile->complexity, NULL);
- gnac_profiles_utils_get_values_check_and_set(&speex_bfi,
- "checkbutton-dtx", &profile->dtx, NULL);
switch (bitrate_mode)
{
case CONSTANT_BITRATE:
- gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
- "slider-quality-cbr", &profile->quality_cbr, NULL);
+ gnac_profiles_utils_get_values_and_set(&speex_bfi,
+ "slider-quality-cbr", &profile->quality_cbr,
+ "checkbutton-vad", &profile->vad, NULL);
gnac_profiles_utils_get_values_checked_slider_and_set(&speex_bfi,
"slider-bitrate-cbr", "checkbutton-bitrate-cbr",
&profile->bitrate_cbr, NULL);
- gnac_profiles_utils_get_values_check_and_set(&speex_bfi,
- "checkbutton-vad", &profile->vad, NULL);
break;
case AVERAGE_BITRATE:
- gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
+ gnac_profiles_utils_get_values_and_set(&speex_bfi,
"slider-bitrate-abr", &profile->bitrate_abr, NULL);
break;
case VARIABLE_BITRATE:
- gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
+ gnac_profiles_utils_get_values_and_set(&speex_bfi,
"slider-quality-vbr", &profile->quality_vbr, NULL);
break;
}
@@ -595,7 +593,7 @@ gnac_profiles_speex_clean_up(void)
"slider-quality-vbr", "slider-bitrate-cbr", "slider-bitrate-abr",
"slider-complexity", "checkbutton-vad", "checkbutton-dtx",
"checkbutton-vbr", NULL);
- gnac_profiles_utils_free_basic_format_info_content(&speex_bfi);
+ gnac_profiles_utils_free_basic_format_info(&speex_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index 63ed324..f52b501 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -288,10 +288,10 @@ gnac_profiles_vorbis_generate_audio_profile(GError **error)
EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (encoding_mode == CONSTANT_BITRATE) {
- gnac_profiles_utils_get_values_combo_and_set(&vorbis_bfi,
+ gnac_profiles_utils_get_values_and_set(&vorbis_bfi,
"combo-bitrate", &profile->bitrate, NULL);
} else {
- gnac_profiles_utils_get_values_slider_and_set(&vorbis_bfi,
+ gnac_profiles_utils_get_values_and_set(&vorbis_bfi,
"slider-quality", &profile->quality, NULL);
gnac_profiles_utils_get_values_checked_combo_and_set(&vorbis_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", &profile->min_bitrate,
@@ -362,7 +362,7 @@ gnac_profiles_vorbis_clean_up(void)
gnac_profiles_utils_free_values(&vorbis_bfi,
"combo-bitrate", "combo-min-vbr", "combo-max-vbr",
"combo-encoding-mode", "slider-quality", NULL);
- gnac_profiles_utils_free_basic_format_info_content(&vorbis_bfi);
+ gnac_profiles_utils_free_basic_format_info(&vorbis_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index 01f527b..c80ad9c 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -131,7 +131,7 @@ static void
gnac_profiles_wav_clean_up(void)
{
gnac_profiles_default_clean_up(&wav_bfi);
- gnac_profiles_utils_free_basic_format_info_content(&wav_bfi);
+ gnac_profiles_utils_free_basic_format_info(&wav_bfi);
}
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index 738b9bf..01d91c2 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -349,15 +349,13 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
AudioProfileWavpack *profile = gnac_profiles_wavpack_audio_profile_new();
profile->generic = generic;
- gnac_profiles_utils_get_values_combo_and_set(&wavpack_bfi,
- "combo-mode", &profile->mode, NULL);
+ gnac_profiles_utils_get_values_and_set(&wavpack_bfi,
+ "combo-mode", &profile->mode,
+ "slider-extra-processing", &profile->extra_processing,
+ "checkbutton-md5", &profile->md5, NULL);
gnac_profiles_utils_get_values_checked_combo_and_set(&wavpack_bfi,
"combo-joint-stereo-mode", "checkbutton-joint-stereo-mode",
&profile->joint_stereo_mode, NULL);
- gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
- "slider-extra-processing", &profile->extra_processing, NULL);
- gnac_profiles_utils_get_values_check_and_set(&wavpack_bfi,
- "checkbutton-md5", &profile->md5, NULL);
GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
"combo-bitrate-control");
@@ -368,10 +366,10 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
ControlMethod control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (control_method == AVERAGE_BITRATE) {
- gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
+ gnac_profiles_utils_get_values_and_set(&wavpack_bfi,
"slider-bitrate", &profile->bitrate, NULL);
} else {
- gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
+ gnac_profiles_utils_get_values_and_set(&wavpack_bfi,
"slider-bits-per-sample", &profile->bits_per_sample, NULL);
}
}
@@ -470,7 +468,7 @@ gnac_profiles_wavpack_clean_up(void)
"combo-bitrate-control", "combo-mode", "combo-joint-stereo-mode",
"checkbutton-md5", "slider-bitrate", "slider-bits-per-sample",
"slider-extra-processing", NULL);
- gnac_profiles_utils_free_basic_format_info_content(&wavpack_bfi);
+ gnac_profiles_utils_free_basic_format_info(&wavpack_bfi);
}
diff --git a/src/profiles/gnac-profiles-utils.c b/src/profiles/gnac-profiles-utils.c
index e0a4695..e14126e 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -332,7 +332,7 @@ gnac_profiles_utils_get_value_combo(GtkWidget *combo)
void
-gnac_profiles_utils_get_values_combo_and_set(BasicFormatInfo *bfi, ...)
+gnac_profiles_utils_get_values_and_set(BasicFormatInfo *bfi, ...)
{
va_list ap;
va_start(ap, bfi);
@@ -341,8 +341,22 @@ gnac_profiles_utils_get_values_combo_and_set(BasicFormatInfo *bfi, ...)
while (name) {
GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, name);
- gchar **value = va_arg(ap, gchar **);
- *value = gnac_profiles_utils_get_value_combo(widget);
+
+ if (GTK_IS_COMBO_BOX(widget)) {
+ const gchar **value = va_arg(ap, const gchar **);
+ *value = gnac_profiles_utils_get_value_combo(widget);
+ } else if (GTK_IS_CHECK_BUTTON(widget)) {
+ const gchar **value = va_arg(ap, const gchar **);
+ *value = g_strdup(gtk_toggle_button_get_active(
+ GTK_TOGGLE_BUTTON(widget)) ? "true" : "false");
+ } else if (GTK_IS_RANGE(widget)) {
+ gdouble *value = va_arg(ap, gdouble *);
+ *value = gtk_range_get_value(GTK_RANGE(widget));
+ } else {
+ libgnac_debug("Unhandled widget type: %s",
+ g_type_name(G_OBJECT_TYPE(widget)));
+ }
+
name = va_arg(ap, const gchar *);
}
@@ -376,25 +390,6 @@ gnac_profiles_utils_get_values_checked_combo_and_set(BasicFormatInfo *bfi, ...)
void
-gnac_profiles_utils_get_values_slider_and_set(BasicFormatInfo *bfi, ...)
-{
- va_list ap;
- va_start(ap, bfi);
-
- const gchar *name = va_arg(ap, const gchar *);
-
- while (name) {
- gdouble *value = va_arg(ap, gdouble *);
- GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, name);
- *value = gtk_range_get_value(GTK_RANGE(widget));
- name = va_arg(ap, const gchar *);
- }
-
- va_end(ap);
-}
-
-
-void
gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...)
{
va_list ap;
@@ -420,26 +415,6 @@ gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...)
void
-gnac_profiles_utils_get_values_check_and_set(BasicFormatInfo *bfi, ...)
-{
- va_list ap;
- va_start(ap, bfi);
-
- const gchar *name = va_arg(ap, const gchar *);
-
- while (name) {
- GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, name);
- const gchar **value = va_arg(ap, const gchar **);
- *value = g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ?
- "true" : "false");
- name = va_arg(ap, const gchar *);
- }
-
- va_end(ap);
-}
-
-
-void
gnac_profiles_utils_add_description_tooltip(BasicFormatInfo *bfi,
const gchar *xpath_query,
...)
@@ -811,7 +786,7 @@ gnac_profiles_utils_free_audio_profile_generic(AudioProfileGeneric *profile)
void
-gnac_profiles_utils_free_basic_format_info_content(BasicFormatInfo *bfi)
+gnac_profiles_utils_free_basic_format_info(BasicFormatInfo *bfi)
{
if (!bfi) return;
diff --git a/src/profiles/gnac-profiles-utils.h b/src/profiles/gnac-profiles-utils.h
index d391a1f..2ed8ec3 100755
--- a/src/profiles/gnac-profiles-utils.h
+++ b/src/profiles/gnac-profiles-utils.h
@@ -100,21 +100,15 @@ gchar *
gnac_profiles_utils_get_value_combo(GtkWidget *combo);
void
-gnac_profiles_utils_get_values_combo_and_set(BasicFormatInfo *bfi, ...);
+gnac_profiles_utils_get_values_and_set(BasicFormatInfo *bfi, ...);
void
gnac_profiles_utils_get_values_checked_combo_and_set(BasicFormatInfo *bfi, ...);
void
-gnac_profiles_utils_get_values_slider_and_set(BasicFormatInfo *bfi, ...);
-
-void
gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...);
void
-gnac_profiles_utils_get_values_check_and_set(BasicFormatInfo *bfi, ...);
-
-void
gnac_profiles_utils_add_description_tooltip(BasicFormatInfo *bfi,
const gchar *xpath_query,
...);
@@ -190,7 +184,7 @@ void
gnac_profiles_utils_free_audio_profile_generic(AudioProfileGeneric *profile);
void
-gnac_profiles_utils_free_basic_format_info_content(BasicFormatInfo *bfi);
+gnac_profiles_utils_free_basic_format_info(BasicFormatInfo *bfi);
void
gnac_profiles_utils_free_values(BasicFormatInfo *bfi, ...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]