[gnac/devel] Code refactoring



commit 6009d028dc671cc0b54d0a8b80ffaf2adcabc5d2
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date:   Fri Nov 4 16:45:58 2011 +0000

    Code refactoring

 src/profiles/formats/gnac-profiles-aac.c     |    4 ++--
 src/profiles/formats/gnac-profiles-flac.c    |    4 ++--
 src/profiles/formats/gnac-profiles-lame.c    |   21 +++++++++++++--------
 src/profiles/formats/gnac-profiles-speex.c   |   21 +++++++++++++--------
 src/profiles/formats/gnac-profiles-unknown.c |    4 ++--
 src/profiles/formats/gnac-profiles-vorbis.c  |   21 +++++++++++++--------
 src/profiles/formats/gnac-profiles-wav.c     |    4 ++--
 src/profiles/formats/gnac-profiles-wavpack.c |   23 ++++++++++++++---------
 src/profiles/gnac-profiles-default.h         |    2 +-
 src/profiles/gnac-profiles-properties.c      |    4 ++--
 10 files changed, 64 insertions(+), 44 deletions(-)
---
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index a397dd8..4b68342 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -60,7 +60,7 @@ static const gchar *
 gnac_profiles_aac_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_aac_generate_pipeline(GtkWidget *widget);
+gnac_profiles_aac_generate_pipeline(void);
 
 static AudioProfileAAC *
 gnac_profiles_aac_generate_audio_profile(GError **error);
@@ -161,7 +161,7 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
 
 
 static void
-gnac_profiles_aac_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
+gnac_profiles_aac_generate_pipeline(void)
 {
   gchar *pipeline;
 
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index def99b9..11607a6 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -57,7 +57,7 @@ static const gchar *
 gnac_profiles_flac_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_flac_generate_pipeline(GtkWidget *widget);
+gnac_profiles_flac_generate_pipeline(void);
 
 static AudioProfileFlac *
 gnac_profiles_flac_generate_audio_profile(GError **error);
@@ -134,7 +134,7 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
 
 
 static void
-gnac_profiles_flac_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
+gnac_profiles_flac_generate_pipeline(void)
 {
   gchar *pipeline;
 
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index e80f0ba..a173e2a 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -74,7 +74,7 @@ static const gchar *
 gnac_profiles_lame_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_lame_generate_pipeline(GtkWidget *widget);
+gnac_profiles_lame_generate_pipeline(void);
 
 static AudioProfileLame *
 gnac_profiles_lame_generate_audio_profile(GError **error);
@@ -141,6 +141,15 @@ gnac_profiles_lame_get_funcs(void)
 }
 
 
+static void
+gnac_profiles_lame_on_encoding_mode_changed(GtkComboBox *widget,
+                                            gpointer     user_data)
+{
+  gnac_profiles_lame_vbr_on_changed(widget);
+  gnac_profiles_lame_generate_pipeline();
+}
+
+
 static const gchar *
 gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
 { 
@@ -215,7 +224,7 @@ gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
 
   // Encoding mode
   widget = gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
-      G_CALLBACK(gnac_profiles_lame_generate_pipeline),
+      G_CALLBACK(gnac_profiles_lame_on_encoding_mode_changed),
       "combo-encoding-mode", "//variable[ id='encoding-mode']/*");
  
   gnac_profiles_lame_vbr_on_changed(GTK_COMBO_BOX(widget));
@@ -332,7 +341,7 @@ gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget)
 
 
 static void
-gnac_profiles_lame_generate_pipeline(GtkWidget *w)
+gnac_profiles_lame_generate_pipeline(void)
 {
   EncodingMode  encoding_mode;
   gchar        *pipeline;
@@ -341,10 +350,6 @@ gnac_profiles_lame_generate_pipeline(GtkWidget *w)
   pipeline = gnac_profiles_default_generate_pipeline(&lame_bfi);
   widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
   
-  if (w == widget) {
-    gnac_profiles_lame_vbr_on_changed(GTK_COMBO_BOX(w));
-  }
-
   encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
 
   // Mode
@@ -413,7 +418,7 @@ gnac_profiles_lame_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
                                               gpointer         user_data)
 {
   gnac_profiles_utils_on_toggle_optionnal_property(togglebutton, user_data);
-  gnac_profiles_lame_generate_pipeline(GTK_WIDGET(togglebutton));
+  gnac_profiles_lame_generate_pipeline();
 }
 
 
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index 3892b81..2cd4592 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -71,7 +71,7 @@ static const gchar *
 gnac_profiles_speex_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_speex_generate_pipeline(GtkWidget *widget);
+gnac_profiles_speex_generate_pipeline(void);
 
 static AudioProfileSpeex *
 gnac_profiles_speex_generate_audio_profile(GError **error);
@@ -145,6 +145,15 @@ gnac_profiles_speex_get_funcs(void)
 }
 
 
+static void
+gnac_profiles_speex_on_bitrate_mode_changed(GtkComboBox *widget,
+                                            gpointer     user_data)
+{
+  gnac_profiles_speex_bitrate_on_changed(widget);
+  gnac_profiles_speex_generate_pipeline();
+}
+
+
 static const gchar *
 gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
 {
@@ -224,7 +233,7 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
  
   // Bitrate mode
   widget = gnac_profiles_utils_all_in_one_for_combo(&speex_bfi, 
-      G_CALLBACK(gnac_profiles_speex_generate_pipeline),
+      G_CALLBACK(gnac_profiles_speex_on_bitrate_mode_changed),
       "combo-bitrate-mode", "//variable[ id='bitrate-mode']/*");
   
   gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(widget));
@@ -322,7 +331,7 @@ gnac_profiles_speex_display_vad(BitrateMode bitrate_mode)
 
 
 static void
-gnac_profiles_speex_generate_pipeline(GtkWidget *w)
+gnac_profiles_speex_generate_pipeline(void)
 {
   gchar     *pipeline;
   GtkWidget *widget; 
@@ -330,10 +339,6 @@ gnac_profiles_speex_generate_pipeline(GtkWidget *w)
   pipeline = gnac_profiles_default_generate_pipeline(&speex_bfi);
   widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
 
-  if (w == widget) {
-    gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(w));
-  }
-
   BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
 
   switch (bitrate_mode)
@@ -399,7 +404,7 @@ gnac_profiles_speex_advanced_on_toggle(GtkToggleButton *togglebutton,
                                        gpointer         user_data)
 {
   gnac_profiles_utils_on_toggle_optionnal_property(togglebutton, user_data);
-  gnac_profiles_speex_generate_pipeline(GTK_WIDGET(togglebutton));
+  gnac_profiles_speex_generate_pipeline();
 }
 
 
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index a92d290..0e6a1cf 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -64,7 +64,7 @@ static void
 gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile);
 
 static void
-gnac_profiles_unknown_generate_pipeline(GtkWidget *widget);
+gnac_profiles_unknown_generate_pipeline(void);
 
 static void
 gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile);
@@ -143,7 +143,7 @@ gnac_profiles_unknown_set_pipeline_text_view(GtkTextView *text_view,
 
 
 static void
-gnac_profiles_unknown_generate_pipeline(GtkWidget *widget)
+gnac_profiles_unknown_generate_pipeline(void)
 {
 
 }
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index 718368c..4fe9982 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -65,7 +65,7 @@ static const gchar *
 gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_vorbis_generate_pipeline(GtkWidget *widget);
+gnac_profiles_vorbis_generate_pipeline(void);
 
 static AudioProfileVorbis *
 gnac_profiles_vorbis_generate_audio_profile(GError **error);
@@ -133,6 +133,15 @@ gnac_profiles_vorbis_get_funcs(void)
 
 
 static void
+gnac_profiles_vorbis_on_encoding_mode_changed(GtkComboBox *widget,
+                                              gpointer     user_data)
+{
+  gnac_profiles_vorbis_vbr_on_changed(widget);
+  gnac_profiles_vorbis_generate_pipeline();
+}
+
+
+static void
 gnac_profiles_vorbis_show_cbr_widgets(gboolean show)
 {
   GtkWidget *cbr_widgets[] = {
@@ -209,7 +218,7 @@ gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
 
   // Encoding mode
   widget = gnac_profiles_utils_all_in_one_for_combo(&vorbis_bfi, 
-      G_CALLBACK(gnac_profiles_vorbis_generate_pipeline),
+      G_CALLBACK(gnac_profiles_vorbis_on_encoding_mode_changed),
       "combo-encoding-mode", "//variable[ id='vbr']/*");
   
   gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(widget));
@@ -232,7 +241,7 @@ gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
 
 
 static void
-gnac_profiles_vorbis_generate_pipeline(GtkWidget *w)
+gnac_profiles_vorbis_generate_pipeline(void)
 {
   GtkWidget *widget; 
   gchar     *pipeline;
@@ -240,10 +249,6 @@ gnac_profiles_vorbis_generate_pipeline(GtkWidget *w)
   pipeline = gnac_profiles_default_generate_pipeline(&vorbis_bfi);
   widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
 
-  if (w == widget) {
-    gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(w));
-  }
-
   EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
 
   if (encoding_mode == CONSTANT_BITRATE) {
@@ -274,7 +279,7 @@ gnac_profiles_vorbis_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
                                                 gpointer         user_data)
 {
   gnac_profiles_utils_on_toggle_optionnal_property(togglebutton, user_data);
-  gnac_profiles_vorbis_generate_pipeline(GTK_WIDGET(togglebutton));
+  gnac_profiles_vorbis_generate_pipeline();
 }
 
 
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index dd953ca..952db4a 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -49,7 +49,7 @@ static const gchar *
 gnac_profiles_wav_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_wav_generate_pipeline(GtkWidget *widget);
+gnac_profiles_wav_generate_pipeline(void);
 
 static void
 gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile);
@@ -122,7 +122,7 @@ gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
 
 
 static void
-gnac_profiles_wav_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
+gnac_profiles_wav_generate_pipeline(void)
 {
   gchar *pipeline;
 
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index 3b291bb..bb5568e 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -67,7 +67,7 @@ static const gchar *
 gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back);
 
 static void
-gnac_profiles_wavpack_generate_pipeline(GtkWidget *widget);
+gnac_profiles_wavpack_generate_pipeline(void);
 
 static AudioProfileWavpack *
 gnac_profiles_wavpack_generate_audio_profile(GError **error);
@@ -138,6 +138,15 @@ gnac_profiles_wavpack_get_funcs(void)
 }
 
 
+static void
+gnac_profiles_wavpack_on_bitrate_control_changed(GtkComboBox *widget,
+                                                 gpointer     user_data)
+{
+  gnac_profiles_wavpack_bitrate_control_on_changed(widget);
+  gnac_profiles_wavpack_generate_pipeline();
+}
+
+
 static const gchar *
 gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
 {
@@ -191,7 +200,7 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
 
  // Bitrate control
   widget = gnac_profiles_utils_all_in_one_for_combo(&wavpack_bfi, 
-      G_CALLBACK(gnac_profiles_wavpack_generate_pipeline),
+      G_CALLBACK(gnac_profiles_wavpack_on_bitrate_control_changed),
       "combo-bitrate-control", "//variable[ id='bitrate-control']/*");
   widget2 = gnac_profiles_utils_add_toggle_signal(&wavpack_bfi,
       "checkbutton-bitrate-control",
@@ -257,7 +266,7 @@ gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
 
 
 static void
-gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
+gnac_profiles_wavpack_generate_pipeline(void)
 {
   GtkWidget *widget; 
   GtkWidget *check;
@@ -267,10 +276,6 @@ gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
   pipeline = gnac_profiles_default_generate_pipeline(&wavpack_bfi);
   widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
 
-  if (w == widget) {
-    gnac_profiles_wavpack_bitrate_control_on_changed(GTK_COMBO_BOX(w));
-  }
-
   pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &wavpack_bfi, 
       "combo-mode",  NULL);
   pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &wavpack_bfi, 
@@ -323,7 +328,7 @@ gnac_profiles_wavpack_bitrate_control_on_toggle(GtkToggleButton *togglebutton,
   }
 
   gnac_profiles_wavpack_bitrate_control_on_changed(GTK_COMBO_BOX(user_data));
-  gnac_profiles_wavpack_generate_pipeline(GTK_WIDGET(togglebutton));
+  gnac_profiles_wavpack_generate_pipeline();
 }
 
 
@@ -332,7 +337,7 @@ gnac_profiles_wavpack_joint_stereo_mode_on_toggle(GtkToggleButton *togglebutton,
                                                   gpointer         user_data)
 {
   gnac_profiles_utils_on_toggle_optionnal_property(togglebutton, user_data);
-  gnac_profiles_wavpack_generate_pipeline(GTK_WIDGET(togglebutton));
+  gnac_profiles_wavpack_generate_pipeline();
 }
 
 
diff --git a/src/profiles/gnac-profiles-default.h b/src/profiles/gnac-profiles-default.h
index fcbfc2d..d632d4b 100755
--- a/src/profiles/gnac-profiles-default.h
+++ b/src/profiles/gnac-profiles-default.h
@@ -31,7 +31,7 @@
 G_BEGIN_DECLS
 
 typedef const gchar *(*FormatModuleInitFunc)(UpdateTextBufferFunc update_pipeline_text_buffer);
-typedef void (*FormatModuleGeneratePipelineFunc) (GtkWidget*);
+typedef void (*FormatModuleGeneratePipelineFunc) (void);
 typedef gpointer (*FormatModuleGenerateAudioProfileFunc) (GError**);
 typedef void (*FormatModuleFreeAudioProfileFunc) (gpointer);
 typedef void (*FormatModuleFullfillFieldsFunc) (gpointer);
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index f51fc6e..2a7d1aa 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -300,7 +300,7 @@ gnac_profiles_properties_show(gpointer     profile,
   path = gtk_tree_row_reference_get_path(format_module->tree_ref);
   gtk_tree_model_get_iter(model, &iter, path);
   gtk_combo_box_set_active_iter(GTK_COMBO_BOX(format_combo_box), &iter);
-  format_module->funcs.generate_pipeline(NULL);
+  format_module->funcs.generate_pipeline();
 
   gtk_widget_show(widget);
 
@@ -395,7 +395,7 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
   gtk_label_set_markup(GTK_LABEL(label), format_module->funcs.get_description());
   properties = format_module->funcs.get_widget(NULL);
   gtk_widget_show(properties);
-  format_module->funcs.generate_pipeline(NULL);
+  format_module->funcs.generate_pipeline();
   current_format_module = format_module;
 }
 



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