[gnac/devel] Code refactoring



commit c12cf9d776e0e6c0299301b50bf992ed075cc87d
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date:   Wed Dec 28 17:22:34 2011 +0100

    Code refactoring

 configure.ac                                 |    4 +-
 libgnac/libgnac-converter.c                  |   16 +--
 libgnac/libgnac-metadata.c                   |   12 ++-
 src/profiles/formats/gnac-profiles-aac.c     |   81 ++++++++------
 src/profiles/formats/gnac-profiles-flac.c    |   60 ++++++-----
 src/profiles/formats/gnac-profiles-lame.c    |  147 ++++++++++++++------------
 src/profiles/formats/gnac-profiles-speex.c   |  145 ++++++++++++++------------
 src/profiles/formats/gnac-profiles-unknown.c |   65 +++++++-----
 src/profiles/formats/gnac-profiles-vorbis.c  |   99 ++++++++++--------
 src/profiles/formats/gnac-profiles-wav.c     |   37 ++++---
 src/profiles/formats/gnac-profiles-wavpack.c |  123 ++++++++++++----------
 src/profiles/gnac-profiles-default.c         |   86 +++++++--------
 src/profiles/gnac-profiles-default.h         |   48 +++-----
 src/profiles/gnac-profiles-properties.c      |   14 +--
 src/profiles/gnac-profiles-properties.h      |    3 +
 src/profiles/gnac-profiles-utils.c           |  119 ++++++++++++---------
 src/profiles/gnac-profiles-utils.h           |   12 +-
 17 files changed, 568 insertions(+), 503 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f8ae313..ffea50d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,11 +119,11 @@ AC_SUBST(GSTREAMER_CFLAGS)
 AC_SUBST(GSTREAMER_LIBS)
 
 dnl Find the GStreamer elements we use, and warn if they are not present
+AM_GST_ELEMENT_CHECK(faac, , AC_MSG_WARN([The 'faac' element was not found. This will cause encoding to AAC to fail.]))
 AM_GST_ELEMENT_CHECK(flacenc, , AC_MSG_WARN([The 'flacenc' element was not found. This will cause encoding to FLAC to fail.]))
+AM_GST_ELEMENT_CHECK(lame, , AC_MSG_WARN([The 'lame' element was not found. This will cause encoding to MP3 to fail.]))
 AM_GST_ELEMENT_CHECK(wavenc, , AC_MSG_WARN([The 'wavenc' element was not found. This will cause encoding to WAV to fail.]))
 AM_GST_ELEMENT_CHECK(wavpackenc, , AC_MSG_WARN([The 'wavpackenc' element was not found. This will cause encoding to WAVPACK to fail.]))
-AM_GST_ELEMENT_CHECK(faac, , AC_MSG_WARN([The 'faac' element was not found. This will cause encoding to AAC to fail.]))
-AM_GST_ELEMENT_CHECK(lame, , AC_MSG_WARN([The 'lame' element was not found. This will cause encoding to MP3 to fail.]))
 
 dnl Optionnaly enable G* deprecations
 AC_MSG_CHECKING([Wether to enable deprecation warnings])
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index 101e3af..2b9e6bd 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -468,13 +468,10 @@ libgnac_converter_start_next(LibgnacConverter *self)
   GError *error = NULL;
 
   do {
-    LibgnacMediaItem *item = NULL;
-
     gchar *key = g_queue_pop_head(priv->queue_copy);
-    if (key) {
-      item = g_hash_table_lookup(priv->file_table, key);
-    }
+    if (!key) return FALSE;
 
+    LibgnacMediaItem *item = g_hash_table_lookup(priv->file_table, key);
     if (!item) return FALSE;
 
     priv->n_converted++;
@@ -805,12 +802,12 @@ libgnac_converter_error_sink(LibgnacMediaItem *item,
   /* Get parent folder name */
   GError *err = NULL;
   GFile *folder = g_file_get_parent(item->destination);
-  gboolean folder_creation = g_file_make_directory_with_parents(folder,
+  gboolean folder_created = g_file_make_directory_with_parents(folder,
       NULL, &err);
   g_object_unref(folder);
 
   /* New folder create relaunch pipeline */
-  if (folder_creation && !err) {
+  if (folder_created && !err) {
     libgnac_debug("Folder successfully created");
     return TRUE;
   }
@@ -982,12 +979,9 @@ libgnac_converter_percentage_cb(LibgnacConverter *converter)
 
   GstState state;
   GstState pending_state;
-
   gst_element_get_state(item->pipeline, &state, &pending_state, 0);
 
-  if (state == GST_STATE_PAUSED) {
-    return TRUE;
-  }
+  if (state == GST_STATE_PAUSED) return TRUE;
 
   if (state != GST_STATE_PLAYING && pending_state != GST_STATE_PLAYING) {
     item->timeout_id = 0;
diff --git a/libgnac/libgnac-metadata.c b/libgnac/libgnac-metadata.c
index e559378..1d1fb58 100644
--- a/libgnac/libgnac-metadata.c
+++ b/libgnac/libgnac-metadata.c
@@ -180,7 +180,7 @@ libgnac_metadata_process_tag_image(const GstTagList *taglist,
     GstBuffer *buffer = gst_value_get_buffer(val);
     g_return_if_fail(buffer);
       
-    gint image_type;
+    gint image_type = GST_TAG_IMAGE_TYPE_NONE;
 
     /* GST_TAG_PREVIEW_IMAGE does not have an "image-type" field */
     if (g_str_equal(tag_name, GST_TAG_IMAGE)) {
@@ -373,8 +373,10 @@ libgnac_metadata_on_message_error(GstBus          *bus,
   GError *error = NULL;
   gchar  *debug;
   gst_message_parse_error(message, &error, &debug);
-  libgnac_debug("Error on metadata reading: %s", error->message);
+  libgnac_debug("Error on metadata reading: %s (%s)", error->message, debug);
   md->priv->eos = TRUE; 
+  g_free(debug);
+  g_clear_error(&error);
 }
 
 
@@ -679,9 +681,9 @@ libgnac_metadata_extract(LibgnacMetadata  *md,
 void
 libgnac_metadata_tags_free(LibgnacTags *tags)
 {
-  if (tags) {
-    g_hash_table_destroy((GHashTable *) tags);
-  }
+  if (!tags) return;
+
+  g_hash_table_destroy((GHashTable *) tags);
 }
 
 
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index 76d9791..ae57d0b 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-aac.h"
 
 
@@ -54,17 +55,13 @@ BasicFormatInfo aac_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static const gchar *
-gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
+gnac_profiles_aac_init(void)
 {
   GtkWidget *widget;
   GtkWidget *widget2;
 
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&aac_bfi);
 
   // Bitrate
@@ -98,15 +95,13 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
 void
 gnac_profiles_aac_generate_pipeline(void)
 {
-  gchar *pipeline;
-
-  pipeline = gnac_profiles_default_generate_pipeline(&aac_bfi);
+  gchar *pipeline = gnac_profiles_default_generate_pipeline(&aac_bfi);
   pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &aac_bfi, 
       "combo-bitrate", "combo-outputformat", "combo-profile", NULL);
   pipeline = gnac_profiles_utils_add_properties_check(pipeline, &aac_bfi,
       "checkbutton-tns", NULL);
   
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(aac_bfi.pipeline);
 
@@ -115,24 +110,33 @@ gnac_profiles_aac_generate_pipeline(void)
 
 
 static void
-gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile)
+gnac_profiles_aac_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_default_fullfill_fields(NULL, &aac_bfi);
-    gnac_profiles_utils_reinit_values_combo(&aac_bfi,
-        "combo-bitrate", "combo-outputformat", "combo-profile", NULL);
-    gnac_profiles_utils_reinit_values_check(&aac_bfi,
-        "checkbutton-tns", NULL);
-  } else {
-    gnac_profiles_utils_set_values_combo(&aac_bfi,
-        "combo-bitrate", profile->bitrate,
-        "combo-outputformat", profile->outputformat,
-        "combo-profile", profile->profile,
-        NULL);
-    gnac_profiles_utils_set_values_check(&aac_bfi,
-        "checkbutton-tns", profile->tns,
-        NULL);
+  gnac_profiles_default_reset_ui(&aac_bfi);
+  gnac_profiles_utils_reset_values_combo(&aac_bfi,
+      "combo-bitrate", "combo-outputformat", "combo-profile", NULL);
+  gnac_profiles_utils_reset_values_check(&aac_bfi,
+      "checkbutton-tns", NULL);
+}
+
+
+static void
+gnac_profiles_aac_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_aac_reset_ui();
+    return;
   }
+
+  AudioProfileAAC *profile = (AudioProfileAAC *) data;
+  gnac_profiles_utils_set_values_combo(&aac_bfi,
+      "combo-bitrate", profile->bitrate,
+      "combo-outputformat", profile->outputformat,
+      "combo-profile", profile->profile,
+      NULL);
+  gnac_profiles_utils_set_values_check(&aac_bfi,
+      "checkbutton-tns", profile->tns,
+      NULL);
 }
 
 
@@ -144,9 +148,11 @@ gnac_profiles_aac_get_combo_format_name(void)
 
 
 static void
-gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
+gnac_profiles_aac_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
+
+  AudioProfileAAC *profile = (AudioProfileAAC *) data;
 
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
 
@@ -158,7 +164,7 @@ gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
 }
 
 
-static AudioProfileAAC *
+static gpointer
 gnac_profiles_aac_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -190,8 +196,11 @@ gnac_profiles_aac_get_widget(void)
 
 
 static void
-gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
+gnac_profiles_aac_save_profile(gpointer data)
 {
+  if (!data) return;
+
+  AudioProfileAAC *profile = (AudioProfileAAC *) data;
   XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &aac_bfi);
   gnac_profiles_utils_save_specific_properties_in_file(doc, 
       "bitrate", profile->bitrate,
@@ -205,7 +214,7 @@ gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
 }
 
 
-static AudioProfileAAC *
+static gpointer
 gnac_profiles_aac_load_specific_properties(XMLDoc              *doc,
                                            AudioProfileGeneric *generic)
 {
@@ -258,12 +267,12 @@ gnac_profiles_aac_get_funcs(void)
     gnac_profiles_aac_init,
     gnac_profiles_aac_get_description,
     gnac_profiles_aac_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_aac_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_aac_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_aac_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_aac_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_aac_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_aac_load_specific_properties,
+    gnac_profiles_aac_generate_audio_profile,
+    gnac_profiles_aac_free_audio_profile,
+    gnac_profiles_aac_fullfill_fields,
+    gnac_profiles_aac_get_widget,
+    gnac_profiles_aac_save_profile,
+    gnac_profiles_aac_load_specific_properties,
     gnac_profiles_aac_clean_up,
     NULL,
     gnac_profiles_aac_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index b7fae1e..23cf2b7 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-flac.h"
 
 
@@ -51,14 +52,10 @@ BasicFormatInfo flac_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static const gchar *
-gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
+gnac_profiles_flac_init(void)
 {
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&flac_bfi);
 
   gnac_profiles_utils_init_widget(&flac_bfi, "slider-compression",
@@ -77,7 +74,7 @@ gnac_profiles_flac_generate_pipeline(void)
   gchar *pipeline = gnac_profiles_default_generate_pipeline(&flac_bfi);
   pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &flac_bfi,
       "%.0f", "slider-compression", NULL);
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(flac_bfi.pipeline);
 
@@ -86,16 +83,25 @@ gnac_profiles_flac_generate_pipeline(void)
 
 
 static void
-gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile)
+gnac_profiles_flac_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_default_fullfill_fields(NULL, &flac_bfi);
-    gnac_profiles_utils_reinit_values_slider(&flac_bfi,
-        "slider-compression", NULL);
-  } else {
-    gnac_profiles_utils_set_values_slider(&flac_bfi,
-        "slider-compression", profile->quality, NULL);
+  gnac_profiles_default_reset_ui(&flac_bfi);
+  gnac_profiles_utils_reset_values_slider(&flac_bfi,
+      "slider-compression", NULL);
+}
+
+
+static void
+gnac_profiles_flac_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_flac_reset_ui();
+    return;
   }
+
+  AudioProfileFlac *profile = (AudioProfileFlac *) data;
+  gnac_profiles_utils_set_values_slider(&flac_bfi,
+      "slider-compression", profile->quality, NULL);
 }
 
 
@@ -107,16 +113,17 @@ gnac_profiles_flac_get_combo_format_name(void)
 
 
 static void
-gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile)
+gnac_profiles_flac_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileFlac *profile = (AudioProfileFlac *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
   g_free(profile);
 }
 
 
-static AudioProfileFlac *
+static gpointer
 gnac_profiles_flac_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -141,8 +148,11 @@ gnac_profiles_flac_get_widget(void)
 
 
 static void
-gnac_profiles_flac_save_profile(AudioProfileFlac *profile)
+gnac_profiles_flac_save_profile(gpointer data)
 {
+  if (!data) return;
+
+  AudioProfileFlac *profile = (AudioProfileFlac *) data;
   gchar *quality = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
   XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &flac_bfi);
   gnac_profiles_utils_save_specific_properties_in_file(doc, 
@@ -153,7 +163,7 @@ gnac_profiles_flac_save_profile(AudioProfileFlac *profile)
 }
 
 
-static AudioProfileFlac*
+static gpointer
 gnac_profiles_flac_load_specific_properties(XMLDoc              *doc,
                                             AudioProfileGeneric *generic)
 {
@@ -205,12 +215,12 @@ gnac_profiles_flac_get_funcs(void)
     gnac_profiles_flac_init,
     gnac_profiles_flac_get_description,
     gnac_profiles_flac_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_flac_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_flac_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_flac_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_flac_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_flac_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_flac_load_specific_properties,
+    gnac_profiles_flac_generate_audio_profile,
+    gnac_profiles_flac_free_audio_profile,
+    gnac_profiles_flac_fullfill_fields,
+    gnac_profiles_flac_get_widget,
+    gnac_profiles_flac_save_profile,
+    gnac_profiles_flac_load_specific_properties,
     gnac_profiles_flac_clean_up,
     NULL,
     gnac_profiles_flac_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index 17abe44..c1b226b 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-lame.h"
 
 
@@ -68,8 +69,6 @@ BasicFormatInfo lame_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static void
 gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget);
@@ -88,15 +87,13 @@ gnac_profiles_lame_on_encoding_mode_changed(GtkComboBox *widget,
 
 
 static const gchar *
-gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
+gnac_profiles_lame_init(void)
 { 
   GtkWidget *widget;
   GtkWidget *widget2;
 
   gnac_profiles_default_init(&lame_bfi);
 
-  update_text_buffer_call_back = call_back;
-  
   // Bitrate
   gnac_profiles_utils_init_widget(&lame_bfi, "combo-bitrate",
       "//variable[ id='bitrate']");
@@ -316,7 +313,7 @@ gnac_profiles_lame_generate_pipeline(void)
 
   pipeline = gnac_profiles_utils_add_pipe(pipeline,
       lame_bfi.pipeline_multiplexers);
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(lame_bfi.pipeline);
 
@@ -334,59 +331,68 @@ gnac_profiles_lame_advanced_bitrate_on_toggle(GtkWidget       *widget,
 
 
 static void
-gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
+gnac_profiles_lame_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_utils_reinit_values_combo(&lame_bfi,
-        "combo-mode", "combo-bitrate", "combo-min-vbr", "combo-max-vbr",
-        "combo-preset", "combo-encoding-mode", NULL);
-    gnac_profiles_utils_reinit_values_slider(&lame_bfi,
-        "slider-vbr-quality", "slider-compression-ratio",
-        "slider-mean-vbr", "slider-mean-abr", NULL);
-    gnac_profiles_utils_set_active_toggle_button(&lame_bfi, FALSE,
-        "checkbutton-mean-bitrate", "checkbutton-min-bitrate",
-        "checkbutton-max-bitrate", NULL);
-  } else {
-    gnac_profiles_utils_set_values_combo(&lame_bfi,
-        "combo-encoding-mode", profile->encoding_mode,
-        "combo-mode", profile->mode, NULL);
+  gnac_profiles_utils_reset_values_combo(&lame_bfi,
+      "combo-mode", "combo-bitrate", "combo-min-vbr", "combo-max-vbr",
+      "combo-preset", "combo-encoding-mode", NULL);
+  gnac_profiles_utils_reset_values_slider(&lame_bfi,
+      "slider-vbr-quality", "slider-compression-ratio",
+      "slider-mean-vbr", "slider-mean-abr", NULL);
+  gnac_profiles_utils_set_active_toggle_button(&lame_bfi, FALSE,
+      "checkbutton-mean-bitrate", "checkbutton-min-bitrate",
+      "checkbutton-max-bitrate", NULL);
+}
 
-    if (profile->bitrate)
-    {
-      gnac_profiles_utils_set_values_combo(&lame_bfi,
-          "combo-bitrate", profile->bitrate, NULL);
-    }
-    else if (profile->preset)
-    {
-      gnac_profiles_utils_set_values_combo(&lame_bfi,
-          "combo-preset", profile->preset, NULL);
-    }
-    else if (profile->mean_abr != -1)
-    {
-      gnac_profiles_utils_set_values_slider(&lame_bfi,
-          "slider-mean-abr", profile->mean_abr, NULL);
-      gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
-          "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
-          "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
-          NULL );
-    }
-    else if (profile->quality != -1)
-    {
-      gnac_profiles_utils_set_values_slider(&lame_bfi,
-          "slider-vbr-quality", profile->quality, NULL);
-      gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
-          "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
-          "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
-          NULL );
-      gnac_profiles_utils_set_values_checked_slider(&lame_bfi,
-          "slider-mean-vbr", "checkbutton-mean-bitrate", profile->mean_bitrate,
-          NULL);
-    }
-    else if (profile->compression_ratio != -1)
-    {
-      gnac_profiles_utils_set_values_slider(&lame_bfi,
-          "slider-compression-ratio", profile->compression_ratio, NULL);
-    }
+
+static void
+gnac_profiles_lame_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_lame_reset_ui();
+    return;
+  }
+
+  AudioProfileLame *profile = (AudioProfileLame *) data;
+  gnac_profiles_utils_set_values_combo(&lame_bfi,
+      "combo-encoding-mode", profile->encoding_mode,
+      "combo-mode", profile->mode, NULL);
+
+  if (profile->bitrate)
+  {
+    gnac_profiles_utils_set_values_combo(&lame_bfi,
+        "combo-bitrate", profile->bitrate, NULL);
+  }
+  else if (profile->preset)
+  {
+    gnac_profiles_utils_set_values_combo(&lame_bfi,
+        "combo-preset", profile->preset, NULL);
+  }
+  else if (profile->mean_abr != -1)
+  {
+    gnac_profiles_utils_set_values_slider(&lame_bfi,
+        "slider-mean-abr", profile->mean_abr, NULL);
+    gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
+        "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
+        "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
+        NULL );
+  }
+  else if (profile->quality != -1)
+  {
+    gnac_profiles_utils_set_values_slider(&lame_bfi,
+        "slider-vbr-quality", profile->quality, NULL);
+    gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
+        "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
+        "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
+        NULL );
+    gnac_profiles_utils_set_values_checked_slider(&lame_bfi,
+        "slider-mean-vbr", "checkbutton-mean-bitrate", profile->mean_bitrate,
+        NULL);
+  }
+  else if (profile->compression_ratio != -1)
+  {
+    gnac_profiles_utils_set_values_slider(&lame_bfi,
+        "slider-compression-ratio", profile->compression_ratio, NULL);
   }
 }
 
@@ -420,12 +426,12 @@ gnac_profiles_lame_audio_profile_new(void)
 
 
 static void
-gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile)
+gnac_profiles_lame_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileLame *profile = (AudioProfileLame *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
-  
   g_free(profile->encoding_mode);
   g_free(profile->mode);
   g_free(profile->bitrate);
@@ -436,7 +442,7 @@ gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile)
 }
 
 
-static AudioProfileLame *
+static gpointer
 gnac_profiles_lame_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -506,12 +512,15 @@ gnac_profiles_lame_get_widget(void)
 
 
 static void
-gnac_profiles_lame_save_profile(AudioProfileLame *profile)
+gnac_profiles_lame_save_profile(gpointer data)
 {
+  if (!data) return;
+
   gchar *quality = NULL;
   gchar *mean_bitrate = NULL;
   gchar *mean_abr = NULL;
   gchar *compression_ratio = NULL;
+  AudioProfileLame *profile = (AudioProfileLame *) data;
   
   if (profile->quality != -1)
   {
@@ -554,7 +563,7 @@ gnac_profiles_lame_save_profile(AudioProfileLame *profile)
 }
 
 
-static AudioProfileLame *
+static gpointer
 gnac_profiles_lame_load_specific_properties(XMLDoc              *doc,
                                             AudioProfileGeneric *generic)
 {
@@ -636,12 +645,12 @@ gnac_profiles_lame_get_funcs(void)
     gnac_profiles_lame_init,
     gnac_profiles_lame_get_description,
     gnac_profiles_lame_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_lame_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_lame_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_lame_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_lame_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_lame_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_lame_load_specific_properties,
+    gnac_profiles_lame_generate_audio_profile,
+    gnac_profiles_lame_free_audio_profile,
+    gnac_profiles_lame_fullfill_fields,
+    gnac_profiles_lame_get_widget,
+    gnac_profiles_lame_save_profile,
+    gnac_profiles_lame_load_specific_properties,
     gnac_profiles_lame_clean_up,
     NULL,
     gnac_profiles_lame_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index 79ae3a6..f15c7e3 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-speex.h"
 
 
@@ -64,8 +65,6 @@ BasicFormatInfo speex_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static void
 gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget);
@@ -87,13 +86,11 @@ gnac_profiles_speex_on_bitrate_mode_changed(GtkComboBox *widget,
 
 
 static const gchar *
-gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
+gnac_profiles_speex_init(void)
 {
   GtkWidget *widget;
   GtkWidget *widget2;
 
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&speex_bfi);
 
   gnac_profiles_utils_init_widget(&speex_bfi, "slider-bitrate-cbr",
@@ -289,7 +286,7 @@ gnac_profiles_speex_generate_pipeline(void)
   pipeline = gnac_profiles_utils_add_pipe(pipeline,
       speex_bfi.pipeline_multiplexers);
 
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(speex_bfi.pipeline);
 
@@ -323,60 +320,69 @@ gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
 
 
 static void
-gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
+gnac_profiles_speex_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_default_fullfill_fields(NULL, &speex_bfi);
-    gnac_profiles_utils_reinit_values_combo(&speex_bfi,
-        "combo-bitrate-mode", "combo-mode", NULL);
-    gnac_profiles_utils_reinit_values_slider(&speex_bfi,
-        "slider-quality-cbr", "slider-quality-vbr", "slider-bitrate-cbr",
-        "slider-bitrate-abr", "slider-complexity", NULL);
-    gnac_profiles_utils_reinit_values_check(&speex_bfi,
-        "checkbutton-vad", "checkbutton-dtx", NULL);
-    gnac_profiles_utils_set_active_toggle_button(&speex_bfi, FALSE,
-        "checkbutton-complexity", "checkbutton-bitrate-cbr", NULL);
-  } else {
-    gnac_profiles_default_fullfill_fields(profile->generic, &speex_bfi);
-    gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
-        "slider-complexity", "checkbutton-complexity",
-        profile->complexity, NULL);
-    gnac_profiles_utils_set_values_combo(&speex_bfi,
-        "combo-mode", profile->mode, NULL);
-    gnac_profiles_utils_set_values_check(&speex_bfi,
-        "checkbutton-vad", profile->vad,
-        "checkbutton-dtx", profile->dtx, NULL);
-
-    GtkWidget *widget = gnac_profiles_utils_get_widget(&speex_bfi,
-        "combo-bitrate-mode");
-
-    if (profile->quality_cbr != -1)
-    {
-      gnac_profiles_utils_set_values_slider(&speex_bfi, "slider-bitrate-cbr",
-          profile->bitrate_cbr, NULL);
+  gnac_profiles_default_reset_ui(&speex_bfi);
+  gnac_profiles_utils_reset_values_combo(&speex_bfi,
+      "combo-bitrate-mode", "combo-mode", NULL);
+  gnac_profiles_utils_reset_values_slider(&speex_bfi,
+      "slider-quality-cbr", "slider-quality-vbr", "slider-bitrate-cbr",
+      "slider-bitrate-abr", "slider-complexity", NULL);
+  gnac_profiles_utils_reset_values_check(&speex_bfi,
+      "checkbutton-vad", "checkbutton-dtx", NULL);
+  gnac_profiles_utils_set_active_toggle_button(&speex_bfi, FALSE,
+      "checkbutton-complexity", "checkbutton-bitrate-cbr", NULL);
+}
 
-      if (profile->bitrate_cbr != 1) {
-        gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
-            "slider-bitrate-cbr", "checkbutton-bitrate-cbr",
-            profile->bitrate_cbr, NULL);
-      }
 
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
-    }
-    else if (profile->quality_vbr != -1)
-    {
-      gnac_profiles_utils_set_active_toggle_button(&speex_bfi, TRUE,
-          "checkbutton-vbr", NULL);
-      gnac_profiles_utils_set_values_slider(&speex_bfi,
-          "slider-quality-vbr", profile->quality_vbr, NULL);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
-    }
-    else
-    {
-      gnac_profiles_utils_set_values_slider(&speex_bfi,
-          "slider-bitrate-abr", profile->bitrate_abr, NULL);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
+static void
+gnac_profiles_speex_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_speex_reset_ui();
+    return;
+  }
+
+  AudioProfileSpeex *profile = (AudioProfileSpeex *) data;
+  gnac_profiles_default_init_fields(profile->generic, &speex_bfi);
+  gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
+      "slider-complexity", "checkbutton-complexity",
+      profile->complexity, NULL);
+  gnac_profiles_utils_set_values_combo(&speex_bfi,
+      "combo-mode", profile->mode, NULL);
+  gnac_profiles_utils_set_values_check(&speex_bfi,
+      "checkbutton-vad", profile->vad,
+      "checkbutton-dtx", profile->dtx, NULL);
+
+  GtkWidget *widget = gnac_profiles_utils_get_widget(&speex_bfi,
+      "combo-bitrate-mode");
+
+  if (profile->quality_cbr != -1)
+  {
+    gnac_profiles_utils_set_values_slider(&speex_bfi, "slider-bitrate-cbr",
+        profile->bitrate_cbr, NULL);
+
+    if (profile->bitrate_cbr != 1) {
+      gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
+          "slider-bitrate-cbr", "checkbutton-bitrate-cbr",
+          profile->bitrate_cbr, NULL);
     }
+
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
+  }
+  else if (profile->quality_vbr != -1)
+  {
+    gnac_profiles_utils_set_active_toggle_button(&speex_bfi, TRUE,
+        "checkbutton-vbr", NULL);
+    gnac_profiles_utils_set_values_slider(&speex_bfi,
+        "slider-quality-vbr", profile->quality_vbr, NULL);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
+  }
+  else
+  {
+    gnac_profiles_utils_set_values_slider(&speex_bfi,
+        "slider-bitrate-abr", profile->bitrate_abr, NULL);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
   }
 }
 
@@ -408,12 +414,12 @@ gnac_profiles_speex_audio_profile_new(void)
 
 
 static void
-gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile)
+gnac_profiles_speex_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileSpeex *profile = (AudioProfileSpeex *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
-  
   g_free(profile->mode);
   g_free(profile->vad);
   g_free(profile->dtx);
@@ -421,7 +427,7 @@ gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile)
 }
 
 
-static AudioProfileSpeex *
+static gpointer
 gnac_profiles_speex_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -474,13 +480,16 @@ gnac_profiles_speex_get_widget(void)
 
 
 static void
-gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
+gnac_profiles_speex_save_profile(gpointer data)
 {
+  if (!data) return;
+
   gchar *quality_cbr = NULL;
   gchar *bitrate_cbr = NULL;
   gchar *bitrate_abr = NULL;
   gchar *quality_vbr = NULL;
   gchar *complexity = NULL;
+  AudioProfileSpeex *profile = (AudioProfileSpeex *) data;
   
   if (profile->quality_cbr != -1)
   {
@@ -526,7 +535,7 @@ gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
 }
 
 
-static AudioProfileSpeex *
+static gpointer
 gnac_profiles_speex_load_specific_properties(XMLDoc              *doc,
                                              AudioProfileGeneric *generic)
 {
@@ -617,12 +626,12 @@ gnac_profiles_speex_get_funcs(void)
     gnac_profiles_speex_init,
     gnac_profiles_speex_get_description,
     gnac_profiles_speex_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_speex_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_speex_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_speex_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_speex_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_speex_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_speex_load_specific_properties,
+    gnac_profiles_speex_generate_audio_profile,
+    gnac_profiles_speex_free_audio_profile,
+    gnac_profiles_speex_fullfill_fields,
+    gnac_profiles_speex_get_widget,
+    gnac_profiles_speex_save_profile,
+    gnac_profiles_speex_load_specific_properties,
     gnac_profiles_speex_clean_up,
     NULL,
     gnac_profiles_speex_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index ffcaee6..9416833 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -29,6 +29,7 @@
 #include "gnac-main.h"
 #include "gnac-ui-utils.h"
 #include "gnac-utils.h"
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-unknown.h"
 
 
@@ -62,7 +63,7 @@ gnac_profiles_unknown_text_view_handler(GtkWidget *widget,
 
 
 static const gchar *
-gnac_profiles_unknown_init(UpdateTextBufferFunc call_back)
+gnac_profiles_unknown_init(void)
 {
   unknown_bfi.builder = gnac_ui_utils_create_gtk_builder(
       unknown_bfi.gtkbuilder_xml_file);
@@ -88,25 +89,35 @@ gnac_profiles_unknown_generate_pipeline(void)
 
 
 static void
-gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile)
+gnac_profiles_unknown_reset_ui(void)
 {
   GtkWidget *widget = gnac_profiles_utils_get_widget(&unknown_bfi,
       "entry-extension");
+  gtk_entry_set_text(GTK_ENTRY(widget), "");
+  if (unknown_bfi.pipeline) {
+    g_free(unknown_bfi.pipeline);
+    unknown_bfi.pipeline = NULL;
+  }
+}
 
-  if (!profile) {
-    gtk_entry_set_text(GTK_ENTRY(widget), "");
-    if (unknown_bfi.pipeline) {
-      g_free(unknown_bfi.pipeline);
-      unknown_bfi.pipeline = NULL;
-    }
-  } else {
-    gtk_entry_set_text(GTK_ENTRY(widget), profile->extension);
-    GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
-        GTK_TEXT_VIEW(pipeline_text_view));
-    gtk_text_buffer_set_text(text_buffer, profile->pipeline,
-        g_utf8_strlen(profile->pipeline, -1));
-    unknown_bfi.pipeline = g_strdup(profile->pipeline);
+
+static void
+gnac_profiles_unknown_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_unknown_reset_ui();
+    return;
   }
+
+  AudioProfileGeneric *profile = (AudioProfileGeneric *) data;
+  GtkWidget *widget = gnac_profiles_utils_get_widget(&unknown_bfi,
+      "entry-extension");
+  gtk_entry_set_text(GTK_ENTRY(widget), profile->extension);
+  GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
+      GTK_TEXT_VIEW(pipeline_text_view));
+  gtk_text_buffer_set_text(text_buffer, profile->pipeline,
+      g_utf8_strlen(profile->pipeline, -1));
+  unknown_bfi.pipeline = g_strdup(profile->pipeline);
 }
 
 
@@ -118,13 +129,14 @@ gnac_profiles_unknown_get_combo_format_name(void)
 
 
 static void
-gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile)
+gnac_profiles_unknown_free_audio_profile(gpointer data)
 {
+  AudioProfileGeneric *profile = (AudioProfileGeneric *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile); 
 }
 
 
-static AudioProfileGeneric *
+static gpointer
 gnac_profiles_unknown_generate_audio_profile(GError **error)
 {
   GtkWidget *widget = gnac_profiles_utils_get_widget(&unknown_bfi,
@@ -182,15 +194,18 @@ gnac_profiles_unknown_get_widget(void)
 
 
 static void
-gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile)
+gnac_profiles_unknown_save_profile(gpointer data)
 {
+  if (!data) return;
+
+  AudioProfileGeneric *profile = (AudioProfileGeneric *) data;
   XMLDoc *doc = gnac_profiles_default_save_profile(profile, &unknown_bfi);
   gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
   gnac_profiles_xml_engine_free_doc_xpath(doc);
 }
 
 
-static AudioProfileGeneric *
+static gpointer
 gnac_profiles_unknown_load_specific_properties(
     XMLDoc              *doc G_GNUC_UNUSED,
     AudioProfileGeneric *generic)
@@ -257,12 +272,12 @@ gnac_profiles_unknown_get_funcs(void)
     gnac_profiles_unknown_init,
     gnac_profiles_unknown_get_description,
     gnac_profiles_unknown_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_unknown_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_unknown_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_unknown_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_unknown_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_unknown_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_unknown_load_specific_properties,
+    gnac_profiles_unknown_generate_audio_profile,
+    gnac_profiles_unknown_free_audio_profile,
+    gnac_profiles_unknown_fullfill_fields,
+    gnac_profiles_unknown_get_widget,
+    gnac_profiles_unknown_save_profile,
+    gnac_profiles_unknown_load_specific_properties,
     gnac_profiles_unknown_clean_up,
     gnac_profiles_unknown_set_pipeline_text_view,
     gnac_profiles_unknown_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index 9e5dcba..bffaad1 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-vorbis.h"
 
 
@@ -59,8 +60,6 @@ BasicFormatInfo vorbis_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static void
 gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget);
@@ -115,12 +114,10 @@ gnac_profiles_vorbis_show_vbr_widgets(gboolean show)
 
 
 static const gchar *
-gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
+gnac_profiles_vorbis_init(void)
 {
   GtkWidget *widget;
 
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&vorbis_bfi);
 
   // Bitrate
@@ -185,7 +182,7 @@ gnac_profiles_vorbis_generate_pipeline(void)
 
   pipeline = gnac_profiles_utils_add_pipe(pipeline,
       vorbis_bfi.pipeline_multiplexers);
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(vorbis_bfi.pipeline);
 
@@ -203,35 +200,44 @@ gnac_profiles_vorbis_advanced_bitrate_on_toggle(GtkWidget       *widget,
 
 
 static void
-gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
+gnac_profiles_vorbis_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_default_fullfill_fields(NULL, &vorbis_bfi);
-    gnac_profiles_utils_reinit_values_combo(&vorbis_bfi,
-        "combo-encoding-mode", "combo-bitrate",
-        "combo-min-vbr", "combo-max-vbr", NULL);
-    gnac_profiles_utils_reinit_values_slider(&vorbis_bfi,
-        "slider-quality", NULL);
-    gnac_profiles_utils_set_active_toggle_button(&vorbis_bfi, FALSE,
-        "checkbutton-min-bitrate", "checkbutton-max-bitrate", NULL);
+  gnac_profiles_default_reset_ui(&vorbis_bfi);
+  gnac_profiles_utils_reset_values_combo(&vorbis_bfi,
+      "combo-encoding-mode", "combo-bitrate",
+      "combo-min-vbr", "combo-max-vbr", NULL);
+  gnac_profiles_utils_reset_values_slider(&vorbis_bfi,
+      "slider-quality", NULL);
+  gnac_profiles_utils_set_active_toggle_button(&vorbis_bfi, FALSE,
+      "checkbutton-min-bitrate", "checkbutton-max-bitrate", NULL);
+}
+
+
+static void
+gnac_profiles_vorbis_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_vorbis_reset_ui();
+    return;
+  }
+
+  AudioProfileVorbis *profile = (AudioProfileVorbis *) data;
+  GtkWidget *widget = gnac_profiles_utils_get_widget(&vorbis_bfi,
+      "combo-encoding-mode");
+  gnac_profiles_default_init_fields(profile->generic, &vorbis_bfi);
+
+  if (profile->quality == -1) {
+    gnac_profiles_utils_set_values_combo(&vorbis_bfi,
+        "combo-bitrate", profile->bitrate, NULL);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
   } else {
-    GtkWidget *widget = gnac_profiles_utils_get_widget(&vorbis_bfi,
-        "combo-encoding-mode");
-    gnac_profiles_default_fullfill_fields(profile->generic, &vorbis_bfi);
-
-    if (profile->quality == -1) {
-      gnac_profiles_utils_set_values_combo(&vorbis_bfi,
-          "combo-bitrate", profile->bitrate, NULL);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
-    } else {
-      gnac_profiles_utils_set_values_slider(&vorbis_bfi,
-          "slider-quality", profile->quality, NULL);
-      gnac_profiles_utils_set_values_checked_combo(&vorbis_bfi, 
-          "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
-          "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
-          NULL);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
-    }
+    gnac_profiles_utils_set_values_slider(&vorbis_bfi,
+        "slider-quality", profile->quality, NULL);
+    gnac_profiles_utils_set_values_checked_combo(&vorbis_bfi,
+        "combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
+        "combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
+        NULL);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
   }
 }
 
@@ -259,12 +265,12 @@ gnac_profiles_vorbis_audio_profile_new(void)
 
 
 static void
-gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile)
+gnac_profiles_vorbis_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileVorbis *profile = (AudioProfileVorbis *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
-  
   g_free(profile->bitrate);
   g_free(profile->min_bitrate);
   g_free(profile->max_bitrate);
@@ -272,7 +278,7 @@ gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile)
 }
 
 
-static AudioProfileVorbis *
+static gpointer
 gnac_profiles_vorbis_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -307,8 +313,11 @@ gnac_profiles_vorbis_get_widget(void)
 
 
 static void
-gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
+gnac_profiles_vorbis_save_profile(gpointer data)
 {
+  if (!data) return;
+
+  AudioProfileVorbis *profile = (AudioProfileVorbis *) data;
   gchar *quality = gnac_profiles_utils_gdouble_to_gchararray_format(
       profile->quality, "%.1f");
   XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &vorbis_bfi);
@@ -323,7 +332,7 @@ gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
 }
 
 
-static AudioProfileVorbis *
+static gpointer
 gnac_profiles_vorbis_load_specific_properties(XMLDoc              *doc,
                                               AudioProfileGeneric *generic)
 {
@@ -381,12 +390,12 @@ gnac_profiles_vorbis_get_funcs(void)
     gnac_profiles_vorbis_init,
     gnac_profiles_vorbis_get_description,
     gnac_profiles_vorbis_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_vorbis_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_vorbis_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_vorbis_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_vorbis_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_vorbis_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_vorbis_load_specific_properties,
+    gnac_profiles_vorbis_generate_audio_profile,
+    gnac_profiles_vorbis_free_audio_profile,
+    gnac_profiles_vorbis_fullfill_fields,
+    gnac_profiles_vorbis_get_widget,
+    gnac_profiles_vorbis_save_profile,
+    gnac_profiles_vorbis_load_specific_properties,
     gnac_profiles_vorbis_clean_up,
     NULL,
     gnac_profiles_vorbis_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index 8b551e3..be64dcc 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-wav.h"
 
 
@@ -43,14 +44,10 @@ BasicFormatInfo wav_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static const gchar *
-gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
+gnac_profiles_wav_init(void)
 {
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&wav_bfi);
   
   gnac_profiles_xml_engine_free_doc_xpath(wav_bfi.doc);
@@ -64,7 +61,7 @@ static void
 gnac_profiles_wav_generate_pipeline(void)
 {
   gchar *pipeline = gnac_profiles_default_generate_pipeline(&wav_bfi);
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(wav_bfi.pipeline);
 
@@ -73,7 +70,7 @@ gnac_profiles_wav_generate_pipeline(void)
 
 
 static void
-gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile G_GNUC_UNUSED)
+gnac_profiles_wav_fullfill_fields(gpointer data G_GNUC_UNUSED)
 {
 }
 
@@ -86,15 +83,16 @@ gnac_profiles_wav_get_combo_format_name(void)
 
 
 static void
-gnac_profiles_wav_free_audio_profile(AudioProfileGeneric *profile)
+gnac_profiles_wav_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileGeneric *profile = (AudioProfileGeneric *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
 }
 
 
-static AudioProfileGeneric *
+static gpointer
 gnac_profiles_wav_generate_audio_profile(GError **error)
 {
   return gnac_profiles_default_generate_audio_profile(&wav_bfi);
@@ -109,15 +107,18 @@ gnac_profiles_wav_get_widget(void)
 
 
 static void
-gnac_profiles_wav_save_profile(AudioProfileGeneric *profile)
+gnac_profiles_wav_save_profile(gpointer data)
 {
+  if (!data) return;
+
+  AudioProfileGeneric *profile = (AudioProfileGeneric *) data;
   XMLDoc *doc = gnac_profiles_default_save_profile(profile, &wav_bfi);
   gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
   gnac_profiles_xml_engine_free_doc_xpath(doc);
 }
 
 
-static AudioProfileGeneric *
+static gpointer
 gnac_profiles_wav_load_specific_properties(XMLDoc              *doc,
                                            AudioProfileGeneric *generic)
 {
@@ -154,12 +155,12 @@ gnac_profiles_wav_get_funcs(void)
     gnac_profiles_wav_init,
     gnac_profiles_wav_get_description,
     gnac_profiles_wav_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wav_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_wav_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_wav_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_wav_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_wav_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wav_load_specific_properties,
+    gnac_profiles_wav_generate_audio_profile,
+    gnac_profiles_wav_free_audio_profile,
+    gnac_profiles_wav_fullfill_fields,
+    gnac_profiles_wav_get_widget,
+    gnac_profiles_wav_save_profile,
+    gnac_profiles_wav_load_specific_properties,
     gnac_profiles_wav_clean_up,
     NULL,
     gnac_profiles_wav_get_combo_format_name,
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index ca6381d..9d52ea1 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -25,6 +25,7 @@
 
 #include <glib/gstdio.h>
 
+#include "../gnac-profiles-properties.h"
 #include "gnac-profiles-wavpack.h"
 
 
@@ -61,8 +62,6 @@ BasicFormatInfo wavpack_bfi = {
   NULL
 };
 
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
 
 static void
 gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget);
@@ -81,13 +80,11 @@ gnac_profiles_wavpack_on_bitrate_control_changed(GtkComboBox *widget,
 
 
 static const gchar *
-gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
+gnac_profiles_wavpack_init(void)
 {
   GtkWidget *widget;
   GtkWidget *widget2;
 
-  update_text_buffer_call_back = call_back;
-
   gnac_profiles_default_init(&wavpack_bfi);
 
   // Encoding mode
@@ -218,7 +215,7 @@ gnac_profiles_wavpack_generate_pipeline(void)
     }
   }
 
-  update_text_buffer_call_back(pipeline);
+  gnac_profiles_properties_update_textbuffer(pipeline);
 
   g_free(wavpack_bfi.pipeline);
 
@@ -258,46 +255,55 @@ gnac_profiles_wavpack_joint_stereo_mode_on_toggle(GtkWidget       *widget,
 
 
 static void
-gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
+gnac_profiles_wavpack_reset_ui(void)
 {
-  if (!profile) {
-    gnac_profiles_default_fullfill_fields(NULL, &wavpack_bfi);
-    gnac_profiles_utils_reinit_values_combo(&wavpack_bfi,
-        "combo-mode", "combo-bitrate-control", "combo-joint-stereo-mode", NULL);
-    gnac_profiles_utils_reinit_values_check(&wavpack_bfi,
-        "checkbutton-md5", NULL);
-    gnac_profiles_utils_reinit_values_slider(&wavpack_bfi,
-        "slider-bitrate", "slider-bits-per-sample",
-        "slider-extra-processing", NULL);
-    gnac_profiles_utils_set_active_toggle_button(&wavpack_bfi, FALSE,
-        "checkbutton-bitrate-control", NULL);
-  } else {
-    gnac_profiles_utils_set_values_combo(&wavpack_bfi,
-        "combo-mode", profile->mode, NULL);
-    gnac_profiles_utils_set_values_checked_combo(&wavpack_bfi,
-        "combo-joint-stereo-mode", "checkbutton-joint-stereo-mode",
-        profile->joint_stereo_mode, NULL);
+  gnac_profiles_default_reset_ui(&wavpack_bfi);
+  gnac_profiles_utils_reset_values_combo(&wavpack_bfi,
+      "combo-mode", "combo-bitrate-control", "combo-joint-stereo-mode", NULL);
+  gnac_profiles_utils_reset_values_check(&wavpack_bfi,
+      "checkbutton-md5", NULL);
+  gnac_profiles_utils_reset_values_slider(&wavpack_bfi,
+      "slider-bitrate", "slider-bits-per-sample",
+      "slider-extra-processing", NULL);
+  gnac_profiles_utils_set_active_toggle_button(&wavpack_bfi, FALSE,
+      "checkbutton-bitrate-control", NULL);
+}
+
+
+static void
+gnac_profiles_wavpack_fullfill_fields(gpointer data)
+{
+  if (!data) {
+    gnac_profiles_wavpack_reset_ui();
+    return;
+  }
+
+  AudioProfileWavpack *profile = (AudioProfileWavpack *) data;
+  gnac_profiles_utils_set_values_combo(&wavpack_bfi,
+      "combo-mode", profile->mode, NULL);
+  gnac_profiles_utils_set_values_checked_combo(&wavpack_bfi,
+      "combo-joint-stereo-mode", "checkbutton-joint-stereo-mode",
+      profile->joint_stereo_mode, NULL);
+  gnac_profiles_utils_set_values_slider(&wavpack_bfi,
+      "slider-extra-processing", profile->extra_processing, NULL);
+  gnac_profiles_utils_set_values_check(&wavpack_bfi,
+      "checkbutton-md5", profile->md5, NULL);
+
+  GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
+      "combo-bitrate-control");
+  GtkWidget *check = gnac_profiles_utils_get_widget(&wavpack_bfi,
+      "checkbutton-bitrate-control");
+
+  if (profile->bitrate != -1.0) {
     gnac_profiles_utils_set_values_slider(&wavpack_bfi,
-        "slider-extra-processing", profile->extra_processing, NULL);
-    gnac_profiles_utils_set_values_check(&wavpack_bfi,
-        "checkbutton-md5", profile->md5, NULL);
-
-    GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
-        "combo-bitrate-control");
-    GtkWidget *check = gnac_profiles_utils_get_widget(&wavpack_bfi,
-        "checkbutton-bitrate-control");
-
-    if (profile->bitrate != -1.0) {
-      gnac_profiles_utils_set_values_slider(&wavpack_bfi,
-          "slider-bitrate", profile->bitrate, NULL);
-      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
-    } else if (profile->bits_per_sample != -1) {
-      gnac_profiles_utils_set_values_slider(&wavpack_bfi,
-          "slider-bits-per-sample", profile->bits_per_sample, NULL);
-      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
-      gtk_combo_box_set_active(GTK_COMBO_BOX(widget), BITS_PER_SAMPLE);
-    }
+        "slider-bitrate", profile->bitrate, NULL);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
+  } else if (profile->bits_per_sample != -1) {
+    gnac_profiles_utils_set_values_slider(&wavpack_bfi,
+        "slider-bits-per-sample", profile->bits_per_sample, NULL);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(widget), BITS_PER_SAMPLE);
   }
 }
 
@@ -327,12 +333,12 @@ gnac_profiles_wavpack_audio_profile_new(void)
 
 
 static void
-gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile)
+gnac_profiles_wavpack_free_audio_profile(gpointer data)
 {
-  if (!profile) return;
+  if (!data) return;
 
+  AudioProfileWavpack *profile = (AudioProfileWavpack *) data;
   gnac_profiles_utils_free_audio_profile_generic(profile->generic); 
-  
   g_free(profile->mode);
   g_free(profile->joint_stereo_mode);
   g_free(profile->md5);
@@ -340,7 +346,7 @@ gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile)
 }
 
 
-static AudioProfileWavpack *
+static gpointer
 gnac_profiles_wavpack_generate_audio_profile(GError **error)
 {
   AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
@@ -387,11 +393,14 @@ gnac_profiles_wavpack_get_widget(void)
 
 
 static void
-gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
+gnac_profiles_wavpack_save_profile(gpointer data)
 {
+  if (!data) return;
+
   gchar *bitrate = NULL;
   gchar *bits_per_sample = NULL;
-  
+  AudioProfileWavpack *profile = (AudioProfileWavpack *) data;
+
   if (profile->bitrate != -1) {
     bitrate = gnac_profiles_utils_gdouble_to_gchararray(profile->bitrate);
   } else if (profile->bits_per_sample != -1) {
@@ -421,7 +430,7 @@ gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
 }
 
 
-static AudioProfileWavpack *
+static gpointer
 gnac_profiles_wavpack_load_specific_properties(XMLDoc              *doc,
                                                AudioProfileGeneric *generic)
 {
@@ -493,12 +502,12 @@ gnac_profiles_wavpack_get_funcs(void)
     gnac_profiles_wavpack_init,
     gnac_profiles_wavpack_get_description,
     gnac_profiles_wavpack_generate_pipeline,
-    (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wavpack_generate_audio_profile,
-    (FormatModuleFreeAudioProfileFunc) gnac_profiles_wavpack_free_audio_profile,
-    (FormatModuleFullfillFieldsFunc) gnac_profiles_wavpack_fullfill_fields,
-    (FormatModuleGetWidgetFunc) gnac_profiles_wavpack_get_widget,
-    (FormatModuleSaveInFileFunc) gnac_profiles_wavpack_save_profile,
-    (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wavpack_load_specific_properties,
+    gnac_profiles_wavpack_generate_audio_profile,
+    gnac_profiles_wavpack_free_audio_profile,
+    gnac_profiles_wavpack_fullfill_fields,
+    gnac_profiles_wavpack_get_widget,
+    gnac_profiles_wavpack_save_profile,
+    gnac_profiles_wavpack_load_specific_properties,
     gnac_profiles_wavpack_clean_up,
     NULL,
     gnac_profiles_wavpack_get_combo_format_name,
diff --git a/src/profiles/gnac-profiles-default.c b/src/profiles/gnac-profiles-default.c
index d0ab7fc..1737cf3 100755
--- a/src/profiles/gnac-profiles-default.c
+++ b/src/profiles/gnac-profiles-default.c
@@ -32,7 +32,8 @@
 
 
 static void
-gnac_profiles_default_init_ui(BasicFormatInfo *bfi)
+gnac_profiles_default_init_ui(BasicFormatInfo *bfi,
+                              XMLDoc          *base_values_doc)
 {
   GError *error = NULL;
 
@@ -51,16 +52,35 @@ gnac_profiles_default_init_ui(BasicFormatInfo *bfi)
       "properties-table-advanced");
   gtk_table_attach_defaults(GTK_TABLE(widget),
       profile_advanced_base_widget, 0, 2, 0, 1);
+
+  gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
+      "combo-channels", "//variable[ id='channels']");
+  gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
+      "combo-sample-rate", "//variable[ id='sample-rate']");
+}
+
+
+static void
+gnac_profiles_default_init_muxers_list(BasicFormatInfo *bfi)
+{
+  bfi->pipeline_multiplexers = g_strconcat("", NULL);
+  GList *multiplexers_list = gnac_profiles_xml_engine_get_list_values(bfi->doc,
+      "//process[ id='multiplexer']/value");
+  if (multiplexers_list) {
+    bfi->pipeline_multiplexers = gnac_profiles_utils_add_pipes(
+        bfi->pipeline_multiplexers, multiplexers_list);
+    g_list_free(multiplexers_list);
+  }
 }
 
 
 void
 gnac_profiles_default_init(BasicFormatInfo *bfi)
 {
-  gnac_profiles_default_init_ui(bfi);
-
   XMLDoc *base_values_doc = gnac_profiles_xml_engine_load_doc_xpath(
       PKGDATADIR "/profiles/base.xml");
+
+  gnac_profiles_utils_init_raw_audioconvert(base_values_doc);
   
   bfi->doc = gnac_profiles_xml_engine_load_doc_xpath(bfi->data_xml_file);
   bfi->format_id = gnac_profiles_xml_engine_get_format_id(bfi->doc);
@@ -72,28 +92,12 @@ gnac_profiles_default_init(BasicFormatInfo *bfi)
       bfi->format_id);
   bfi->format_plugin_name = gnac_profiles_xml_engine_get_text_node(bfi->doc,
       "//gst-plugin-name");
-
-  // Advanced
-
-  gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
-      "combo-channels", "//variable[ id='channels']");
-  gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
-      "combo-sample-rate", "//variable[ id='sample-rate']");
-
-  gnac_profiles_utils_init_raw_audioconvert(base_values_doc);
-  
-  // pipeline
-
   bfi->pipeline_encoder = gnac_profiles_xml_engine_get_text_node(bfi->doc,
       "//process[ id='gstreamer-audio']");
-  bfi->pipeline_multiplexers = g_strconcat("", NULL);
-  GList *multiplexers_list = gnac_profiles_xml_engine_get_list_values(bfi->doc,
-      "//process[ id='multiplexer']/value");
-  if (multiplexers_list) {
-    bfi->pipeline_multiplexers = gnac_profiles_utils_add_pipes(
-        bfi->pipeline_multiplexers, multiplexers_list);
-    g_list_free(multiplexers_list);
-  }
+
+  gnac_profiles_default_init_muxers_list(bfi);
+
+  gnac_profiles_default_init_ui(bfi, base_values_doc);
 
   gnac_profiles_xml_engine_free_doc_xpath(base_values_doc);
 }
@@ -137,22 +141,21 @@ gnac_profiles_default_get_combo_format_name(BasicFormatInfo *bfi)
 
 
 void
-gnac_profiles_default_fullfill_fields(AudioProfileGeneric *profile,
-                                      BasicFormatInfo     *bfi)
+gnac_profiles_default_reset_ui(BasicFormatInfo *bfi)
 {
-  if (!profile) {
-    gnac_profiles_utils_reinit_values_combo(bfi,
-        "combo-channels", "combo-sample-rate", NULL);
-    return;
-  }
+  gnac_profiles_utils_reset_values_combo(bfi,
+      "combo-channels", "combo-sample-rate", NULL);
+}
 
-  GtkWidget *widget;
 
-  widget = gnac_profiles_utils_get_widget(bfi, "combo-channels");
-  gnac_profiles_utils_set_value_combo(widget, profile->channels);
+void
+gnac_profiles_default_init_fields(AudioProfileGeneric *profile,
+                                  BasicFormatInfo     *bfi)
+{
+  g_return_if_fail(profile);
 
-  widget = gnac_profiles_utils_get_widget(bfi, "combo-sample-rate");
-  gnac_profiles_utils_set_value_combo(widget, profile->rate);
+  gnac_profiles_utils_set_value_combo(bfi, "combo-channels", profile->channels);
+  gnac_profiles_utils_set_value_combo(bfi, "combo-sample-rate", profile->rate);
 }
 
 
@@ -182,16 +185,9 @@ gnac_profiles_default_save_profile(AudioProfileGeneric *profile,
   XMLDoc *doc = gnac_profiles_xml_engine_load_doc_xpath(
       PKGDATADIR "/profiles/profile-base-save.xml");
   gnac_profiles_xml_engine_modify_values(doc, "/audio-profile/base/*",
-      generic->pipeline,
-      generic->rate,
-      generic->channels,
-      generic->description,
-      generic->name,
-      generic->extension,
-      generic->format_name,
-      generic->format_id,
-      NULL);
-  
+      generic->pipeline, generic->rate, generic->channels,
+      generic->description, generic->name, generic->extension,
+      generic->format_name, generic->format_id, NULL);
   return doc;
 }
 
diff --git a/src/profiles/gnac-profiles-default.h b/src/profiles/gnac-profiles-default.h
index d190e13..6ec85e1 100755
--- a/src/profiles/gnac-profiles-default.h
+++ b/src/profiles/gnac-profiles-default.h
@@ -30,35 +30,20 @@
 
 G_BEGIN_DECLS
 
-typedef const gchar *(*FormatModuleInitFunc)(UpdateTextBufferFunc update_pipeline_text_buffer);
-typedef void (*FormatModuleGeneratePipelineFunc) (void);
-typedef gpointer (*FormatModuleGenerateAudioProfileFunc) (GError**);
-typedef void (*FormatModuleFreeAudioProfileFunc) (gpointer);
-typedef void (*FormatModuleFullfillFieldsFunc) (gpointer);
-typedef gchar *(*FormatModuleGetComboFormatNameFunc) (void);
-typedef GtkWidget *(*FormatModuleGetWidgetFunc) (void);
-typedef void (*FormatModuleSaveInFileFunc) (gpointer);
-typedef gpointer (*FormatModuleLoadSpecificPropertiesFunc) (XMLDoc *doc, AudioProfileGeneric *generic);
-typedef const gchar *(*FormatModuleGetPluginName) (void);
-typedef const gchar *(*FormatModuleGetDescription) (void);
-typedef void (*FormatModuleCleanUp) (void);
-
-typedef void (*FormatModuleSetPipelineTextViewFunc) (GtkTextView*, GtkWidget*);
-
 typedef struct {
-  FormatModuleInitFunc                   init;
-  FormatModuleGetDescription             get_description;
-  FormatModuleGeneratePipelineFunc       generate_pipeline;
-  FormatModuleGenerateAudioProfileFunc   generate_audio_profile;
-  FormatModuleFreeAudioProfileFunc       free_audio_profile;
-  FormatModuleFullfillFieldsFunc         fullfill_fields;
-  FormatModuleGetWidgetFunc              get_widget;
-  FormatModuleSaveInFileFunc             save_profile_in_file;
-  FormatModuleLoadSpecificPropertiesFunc load_specific_properties;
-  FormatModuleCleanUp                    clean_up;
-  FormatModuleSetPipelineTextViewFunc    set_pipeline_func;
-  FormatModuleGetComboFormatNameFunc     get_combo_format_name;
-  FormatModuleGetPluginName              get_plugin_name;
+  const gchar *(*init)                    (void);
+  const gchar *(*get_description)         (void);
+  void         (*generate_pipeline)       (void);
+  gpointer     (*generate_audio_profile)  (GError **);
+  void         (*free_audio_profile)      (gpointer);
+  void         (*fullfill_fields)         (gpointer);
+  GtkWidget   *(*get_widget)              (void);
+  void         (*save_profile_in_file)    (gpointer);
+  gpointer     (*load_specific_properties)(XMLDoc *, AudioProfileGeneric *);
+  void         (*clean_up)                (void);
+  void         (*set_pipeline_func)       (GtkTextView *, GtkWidget *);
+  gchar       *(*get_combo_format_name)   (void);
+  const gchar *(*get_plugin_name)         (void);
 } FormatModuleFuncs;
 
 typedef FormatModuleFuncs (*FormatModuleGetFuncs) (void);
@@ -76,8 +61,11 @@ gchar *
 gnac_profiles_default_generate_pipeline(BasicFormatInfo *bfi);
 
 void
-gnac_profiles_default_fullfill_fields(AudioProfileGeneric *profile,
-                                      BasicFormatInfo     *bfi);
+gnac_profiles_default_reset_ui(BasicFormatInfo *bfi);
+
+void
+gnac_profiles_default_init_fields(AudioProfileGeneric *profile,
+                                  BasicFormatInfo     *bfi);
 
 AudioProfileGeneric *
 gnac_profiles_default_generate_audio_profile(BasicFormatInfo *bfi);
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index d638172..8b690b6 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -92,9 +92,6 @@ static void
 gnac_profiles_properties_description_set_text(const gchar *description);
 
 static void
-gnac_profiles_properties_update_textbuffer(const gchar *pipeline);
-
-static void
 gnac_profiles_properties_display_status_message(const gchar *error);
 
 static gboolean
@@ -115,7 +112,7 @@ gnac_profiles_properties_name_description_set_text(const gchar *name,
                                                    const gchar *description);
 
 static void
-gnac_profiles_properties_reinit(void);
+gnac_profiles_properties_reset(void);
 
 
 static GObject *
@@ -169,8 +166,7 @@ gnac_profiles_properties_init_format(void)
   for (i = 0; i < G_N_ELEMENTS(formats_get_funcs); i++) {
     FormatModule *format_module = g_malloc(sizeof(FormatModule));
     format_module->funcs = formats_get_funcs[i]();
-    const gchar *format_id = format_module->funcs.init(
-        gnac_profiles_properties_update_textbuffer);
+    const gchar *format_id = format_module->funcs.init();
     gchar *format_name = format_module->funcs.get_combo_format_name();
 
     g_hash_table_insert(formats, (gpointer) format_id, format_module);
@@ -219,7 +215,7 @@ gnac_profiles_properties_show(gpointer     profile,
 {
   GtkWidget *widget;
   
-  gnac_profiles_properties_reinit();
+  gnac_profiles_properties_reset();
 
   widget = gnac_profiles_properties_get_widget("save-button");
 
@@ -348,7 +344,7 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
 }
 
 
-static void
+void
 gnac_profiles_properties_update_textbuffer(const gchar *pipeline)
 {
   GtkWidget *text_view =
@@ -379,7 +375,7 @@ gnac_profiles_properties_display_status_message(const gchar *error_message)
 
 
 static void
-gnac_profiles_properties_reinit(void)
+gnac_profiles_properties_reset(void)
 {
   gnac_profiles_properties_display_status_message(NULL);
   gnac_profiles_properties_update_textbuffer("");
diff --git a/src/profiles/gnac-profiles-properties.h b/src/profiles/gnac-profiles-properties.h
index e4e2b59..da2d2f3 100644
--- a/src/profiles/gnac-profiles-properties.h
+++ b/src/profiles/gnac-profiles-properties.h
@@ -83,6 +83,9 @@ void
 gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
                                                  gpointer     user_data);
 
+void
+gnac_profiles_properties_update_textbuffer(const gchar *pipeline);
+
 G_END_DECLS
 
 #endif /* GNAC_PROFILES_PROPERTIES_H */
diff --git a/src/profiles/gnac-profiles-utils.c b/src/profiles/gnac-profiles-utils.c
index 3a677f8..30f3b68 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -159,23 +159,26 @@ gnac_profiles_utils_init_widget(BasicFormatInfo *bfi,
 }
 
 
+static void
+gnac_profiles_utils_reset_value_combo(BasicFormatInfo *bfi,
+                                       const gchar     *combo_name)
+{
+  GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, combo_name);
+  ComboValues *values = g_object_get_data(G_OBJECT(widget), "combo-values");
+  gnac_profiles_utils_set_value_combo(bfi, combo_name, values->default_value);
+}
+
+
 void
-gnac_profiles_utils_reinit_values_combo(BasicFormatInfo *bfi, ...)
+gnac_profiles_utils_reset_values_combo(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget   *widget;
-  ComboValues *values;
-  va_list      ap;
-  const gchar *combo_name;
+  va_list ap;
 
   va_start(ap, bfi);
-  combo_name = va_arg(ap, const gchar *);
+  const gchar *combo_name = va_arg(ap, const gchar *);
 
   while (combo_name) {
-    widget = gnac_profiles_utils_get_widget(bfi, combo_name);
-    values = g_object_get_data(G_OBJECT(widget), "combo-values");
-    
-    gnac_profiles_utils_set_value_combo(widget, values->default_value);
-
+    gnac_profiles_utils_reset_value_combo(bfi, combo_name);
     combo_name = va_arg(ap, const gchar *);
   }
 
@@ -184,9 +187,11 @@ gnac_profiles_utils_reinit_values_combo(BasicFormatInfo *bfi, ...)
 
 
 void
-gnac_profiles_utils_set_value_combo(GtkWidget   *combo,
-                                    const gchar *value)
+gnac_profiles_utils_set_value_combo(BasicFormatInfo *bfi,
+                                    const gchar     *combo_name,
+                                    const gchar     *value)
 {
+  GtkWidget *combo = gnac_profiles_utils_get_widget(bfi, combo_name);
   ComboValues *combo_values = g_object_get_data(G_OBJECT(combo), "combo-values");
   GList *values = combo_values->values;
 
@@ -207,7 +212,6 @@ gnac_profiles_utils_set_value_combo(GtkWidget   *combo,
 void
 gnac_profiles_utils_set_values_combo(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget   *widget;
   va_list      ap;
   const gchar *name;
   const gchar *value;
@@ -217,8 +221,7 @@ gnac_profiles_utils_set_values_combo(BasicFormatInfo *bfi, ...)
 
   while (name) {
     value = va_arg(ap, const gchar *);
-    widget = gnac_profiles_utils_get_widget(bfi, name);
-    gnac_profiles_utils_set_value_combo(widget, value);
+    gnac_profiles_utils_set_value_combo(bfi, name, value);
     name = va_arg(ap, const gchar *);
   }
 
@@ -229,7 +232,6 @@ gnac_profiles_utils_set_values_combo(BasicFormatInfo *bfi, ...)
 void
 gnac_profiles_utils_set_values_checked_combo(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget   *widget;
   va_list      ap;
   const gchar *name_combo;
   const gchar *name_checkbox;
@@ -243,11 +245,10 @@ gnac_profiles_utils_set_values_checked_combo(BasicFormatInfo *bfi, ...)
     value = va_arg(ap, const gchar *);
     
     if (value) {
-      widget = gnac_profiles_utils_get_widget(bfi, name_combo);
-      gnac_profiles_utils_set_value_combo(widget, value);
+      gnac_profiles_utils_set_value_combo(bfi, name_combo, value);
     }
     
-    widget = gnac_profiles_utils_get_widget(bfi, name_checkbox);
+    GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, name_checkbox);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), value != NULL);
 
     name_combo = va_arg(ap, const gchar *);
@@ -317,21 +318,26 @@ gnac_profiles_utils_get_values_checked_combo_and_set(BasicFormatInfo *bfi, ...)
 }
 
 
+static void
+gnac_profiles_utils_reset_value_slider(BasicFormatInfo *bfi,
+                                        const gchar     *slider_name)
+{
+  GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, slider_name);
+  SliderValues *values = g_object_get_data(G_OBJECT(widget), "slider-values");
+  gtk_range_set_value(GTK_RANGE(widget), values->default_value);
+}
+
+
 void
-gnac_profiles_utils_reinit_values_slider(BasicFormatInfo *bfi, ...)
+gnac_profiles_utils_reset_values_slider(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget    *widget;
-  SliderValues *values;
-  va_list       ap;
-  const gchar  *slider_name;
+  va_list ap;
 
   va_start(ap, bfi);
-  slider_name = va_arg(ap, const gchar *);
+  const gchar *slider_name = va_arg(ap, const gchar *);
 
   while (slider_name) {
-    widget = gnac_profiles_utils_get_widget(bfi, slider_name);
-    values = g_object_get_data(G_OBJECT(widget), "slider-values");
-    gtk_range_set_value(GTK_RANGE(widget), values->default_value);
+    gnac_profiles_utils_reset_value_slider(bfi, slider_name);
     slider_name = va_arg(ap, const gchar *);
   }
 
@@ -443,22 +449,26 @@ gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...)
 }
 
 
+static void
+gnac_profiles_utils_reset_value_check(BasicFormatInfo *bfi,
+                                       const gchar     *check_name)
+{
+  GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, check_name);
+  CheckValues *values = g_object_get_data(G_OBJECT(widget), "check-values");
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), values->default_value);
+}
+
+
 void
-gnac_profiles_utils_reinit_values_check(BasicFormatInfo *bfi, ...)
+gnac_profiles_utils_reset_values_check(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget   *widget;
-  CheckValues *values;
-  va_list      ap;
-  const gchar *check_name;
+  va_list ap;
 
   va_start(ap, bfi);
-  check_name = va_arg(ap, const gchar *);
+  const gchar *check_name = va_arg(ap, const gchar *);
 
   while (check_name) {
-    widget = gnac_profiles_utils_get_widget(bfi, check_name);
-    values = g_object_get_data(G_OBJECT(widget), "check-values");
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
-        values->default_value);
+    gnac_profiles_utils_reset_value_check(bfi, check_name);
     check_name = va_arg(ap, gpointer);
   }
 
@@ -466,22 +476,28 @@ gnac_profiles_utils_reinit_values_check(BasicFormatInfo *bfi, ...)
 }
 
 
+static void
+gnac_profiles_utils_set_value_check(BasicFormatInfo *bfi,
+                                    const gchar     *name,
+                                    const gchar     *value)
+{
+  GtkWidget *widget = gnac_profiles_utils_get_widget(bfi, name);
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
+      gnac_utils_str_equal(value, "true"));
+}
+
+
 void
 gnac_profiles_utils_set_values_check(BasicFormatInfo *bfi, ...)
 {
-  GtkWidget   *widget;
-  va_list      ap;
-  const gchar *name;
-  const gchar *value;
+  va_list ap;
 
   va_start(ap, bfi);
-  name = va_arg(ap, const gchar *);
+  const gchar *name = va_arg(ap, const gchar *);
 
   while (name) {
-    value = va_arg(ap, const gchar *);
-    widget = gnac_profiles_utils_get_widget(bfi, name);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
-        gnac_utils_str_equal(value, "true"));
+    const gchar *value = va_arg(ap, const gchar *);
+    gnac_profiles_utils_set_value_check(bfi, name, value);
     name = va_arg(ap, const gchar *);
   }
 
@@ -805,12 +821,11 @@ gnac_profiles_utils_set_active_toggle_button(BasicFormatInfo *bfi,
                                              gboolean         active,
                                              ...)
 {
-  GtkWidget   *widget;
-  va_list      ap;
-  const gchar *name;
+  GtkWidget *widget;
+  va_list    ap;
 
   va_start(ap, active);
-  name = va_arg(ap, const gchar *);
+  const gchar *name = va_arg(ap, const gchar *);
 
   while (name) {
     widget = gnac_profiles_utils_get_widget(bfi, name);
diff --git a/src/profiles/gnac-profiles-utils.h b/src/profiles/gnac-profiles-utils.h
index 7b14722..72106b3 100755
--- a/src/profiles/gnac-profiles-utils.h
+++ b/src/profiles/gnac-profiles-utils.h
@@ -70,7 +70,6 @@ typedef struct
 }
 BasicFormatInfo;
 
-typedef void (*UpdateTextBufferFunc) (const gchar*);
 typedef void (*StandardCallBack) (GtkWidget *widget, gpointer data);
 
 gchar *
@@ -89,11 +88,12 @@ gnac_profiles_utils_init_widget(BasicFormatInfo *bfi,
                                 const gchar     *xpath_query);
 
 void
-gnac_profiles_utils_reinit_values_combo(BasicFormatInfo *bfi, ...);
+gnac_profiles_utils_reset_values_combo(BasicFormatInfo *bfi, ...);
 
 void
-gnac_profiles_utils_set_value_combo(GtkWidget   *combo,
-                                    const gchar *value);
+gnac_profiles_utils_set_value_combo(BasicFormatInfo *bfi,
+                                    const gchar     *combo_name,
+                                    const gchar     *value);
 
 void
 gnac_profiles_utils_set_values_combo(BasicFormatInfo *bfi, ...);
@@ -111,7 +111,7 @@ void
 gnac_profiles_utils_get_values_checked_combo_and_set(BasicFormatInfo *bfi, ...);
 
 void
-gnac_profiles_utils_reinit_values_slider(BasicFormatInfo *bfi, ...);
+gnac_profiles_utils_reset_values_slider(BasicFormatInfo *bfi, ...);
 
 void
 gnac_profiles_utils_set_values_slider(BasicFormatInfo *bfi, ...);
@@ -126,7 +126,7 @@ void
 gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...);
 
 void
-gnac_profiles_utils_reinit_values_check(BasicFormatInfo *bfi, ...);
+gnac_profiles_utils_reset_values_check(BasicFormatInfo *bfi, ...);
 
 void
 gnac_profiles_utils_set_values_check(BasicFormatInfo *bfi, ...);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]