[gnac/devel] Code refactoring
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code refactoring
- Date: Thu, 3 Nov 2011 15:08:06 +0000 (UTC)
commit 2c411b76e746d8a4fab22a3e29d5c675dc6d8845
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Wed Nov 2 13:21:52 2011 +0000
Code refactoring
data/profiles/ui/gnac-profiles-manager.xml | 1 -
data/profiles/ui/gnac-profiles-properties.xml | 2 +
data/profiles/ui/gnac-profiles-unknown.xml | 1 +
src/gnac-file-list.c | 6 +-
src/gnac-main.c | 1 -
src/gnac-ui.c | 58 +++---
src/gnac-utils.c | 16 ++
src/gnac-utils.h | 8 +
src/profiles/formats/gnac-profiles-aac.c | 83 ++++++--
src/profiles/formats/gnac-profiles-aac.h | 48 ----
src/profiles/formats/gnac-profiles-flac.c | 77 ++++++--
src/profiles/formats/gnac-profiles-flac.h | 45 ----
src/profiles/formats/gnac-profiles-lame.c | 219 ++++++++++++-------
src/profiles/formats/gnac-profiles-lame.h | 54 -----
src/profiles/formats/gnac-profiles-speex.c | 271 +++++++++++++++--------
src/profiles/formats/gnac-profiles-speex.h | 52 -----
src/profiles/formats/gnac-profiles-unknown.c | 150 +++++++------
src/profiles/formats/gnac-profiles-unknown.h | 41 +----
src/profiles/formats/gnac-profiles-vorbis.c | 157 +++++++++-----
src/profiles/formats/gnac-profiles-vorbis.h | 48 ----
src/profiles/formats/gnac-profiles-wav.c | 69 +++++--
src/profiles/formats/gnac-profiles-wav.h | 37 ----
src/profiles/formats/gnac-profiles-wavpack.c | 179 ++++++++++------
src/profiles/formats/gnac-profiles-wavpack.h | 50 -----
src/profiles/gnac-profiles-default.c | 41 ++---
src/profiles/gnac-profiles-default.h | 3 +-
src/profiles/gnac-profiles-manager.c | 246 ++++++++++------------
src/profiles/gnac-profiles-manager.h | 12 +-
src/profiles/gnac-profiles-properties.c | 187 ++++++++--------
src/profiles/gnac-profiles-properties.h | 6 +-
src/profiles/gnac-profiles-utils.c | 170 ++++++++-------
src/profiles/gnac-profiles-utils.h | 15 +-
src/profiles/gnac-profiles-xml-engine.c | 289 ++++++++++++++-----------
src/profiles/gnac-profiles.c | 160 ++++++--------
src/profiles/gnac-profiles.h | 3 +
35 files changed, 1415 insertions(+), 1390 deletions(-)
---
diff --git a/data/profiles/ui/gnac-profiles-manager.xml b/data/profiles/ui/gnac-profiles-manager.xml
index cbd4f8c..0dfbd0d 100644
--- a/data/profiles/ui/gnac-profiles-manager.xml
+++ b/data/profiles/ui/gnac-profiles-manager.xml
@@ -56,7 +56,6 @@
<signal name="key_press_event" handler="gnac_profiles_mgr_list_on_key_pressed"/>
<signal name="row_activated" handler="gnac_profiles_mgr_on_edit"/>
<signal name="drag_data_received" handler="gnac_profiles_mgr_on_drag_data_received"/>
- <signal name="drag_drop" handler="gnac_profiles_mgr_on_drag_drop"/>
</object>
</child>
</object>
diff --git a/data/profiles/ui/gnac-profiles-properties.xml b/data/profiles/ui/gnac-profiles-properties.xml
index d4c3b8c..314737b 100755
--- a/data/profiles/ui/gnac-profiles-properties.xml
+++ b/data/profiles/ui/gnac-profiles-properties.xml
@@ -5,6 +5,7 @@
<object class="GtkWindow" id="window1">
<property name="resizable">False</property>
<signal name="key_press_event" handler="gnac_profiles_properties_on_window_key_pressed"/>
+ <signal name="delete-event" handler="gtk_widget_hide"/>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
@@ -141,6 +142,7 @@
<object class="GtkComboBox" id="format_combo_box">
<property name="visible">True</property>
<property name="model">liststore1</property>
+ <signal name="changed" handler="gnac_profiles_properties_combo_format_on_changed"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/data/profiles/ui/gnac-profiles-unknown.xml b/data/profiles/ui/gnac-profiles-unknown.xml
index 409b5ef..3566d54 100644
--- a/data/profiles/ui/gnac-profiles-unknown.xml
+++ b/data/profiles/ui/gnac-profiles-unknown.xml
@@ -5,6 +5,7 @@
<object class="GtkAlignment" id="properties-alignment">
<property name="visible">True</property>
<property name="left_padding">25</property>
+ <signal name="hide" handler="gnac_profiles_unknown_on_hide"/>
<child>
<object class="GtkTable" id="table-properties">
<property name="visible">True</property>
diff --git a/src/gnac-file-list.c b/src/gnac-file-list.c
index c60dfe4..d84fc3f 100644
--- a/src/gnac-file-list.c
+++ b/src/gnac-file-list.c
@@ -305,8 +305,7 @@ gnac_file_list_get_selected_rows(void)
row_references = g_list_reverse(row_references);
- g_list_foreach(row_path, (GFunc)gtk_tree_path_free, NULL);
- g_list_free(row_path);
+ g_list_free_full(row_path, (GDestroyNotify) gtk_tree_path_free);
return row_references;
}
@@ -324,8 +323,7 @@ gnac_file_list_get_current_row(GtkTreeRowReference **reference)
/* select the first selected row*/
*reference = gtk_tree_row_reference_new(model, (GtkTreePath*)(rows_path->data));
- g_list_foreach(rows_path, (GFunc)gtk_tree_path_free, NULL);
- g_list_free(rows_path);
+ g_list_free_full(rows_path, (GDestroyNotify) gtk_tree_path_free);
return gtk_tree_row_reference_valid(*reference);
}
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 29ef7a8..cbb8398 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -800,7 +800,6 @@ main(gint argc,
gst_pb_utils_init();
gnac_ui_init();
- gnac_profiles_init();
/* Initialise converter and connect signals */
metadata = LIBGNAC_METADATA(libgnac_metadata_new());
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index ad03241..8a528ff 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -85,6 +85,7 @@ enum {
};
#endif /* HAVE_LIBUNIQUE */
+
static void
gnac_ui_file_chooser_unref_filters(void)
{
@@ -599,8 +600,7 @@ gnac_ui_new(void)
file_list = gnac_file_list_new();
/* Add audio profile combo box */
- audio_profile_hbox = GTK_WIDGET(gtk_builder_get_object(gnac_main_builder,
- "audio_profile_hbox"));
+ audio_profile_hbox = gnac_ui_get_widget("audio_profile_hbox");
audio_profile_chooser_combo = gnac_profiles_get_widget(
gnac_ui_get_widget("main_window"));
@@ -651,9 +651,7 @@ void
gnac_ui_set_progress_fraction(gdouble fraction)
{
GtkProgressBar *progress_bar;
-
- progress_bar = GTK_PROGRESS_BAR(
- gtk_builder_get_object(gnac_main_builder, "progressbar"));
+ progress_bar = GTK_PROGRESS_BAR(gnac_ui_get_widget("progressbar"));
gtk_progress_bar_set_fraction(progress_bar, fraction);
}
@@ -662,11 +660,8 @@ void
gnac_ui_set_progress_text(gchar *text)
{
GtkProgressBar *progress_bar;
-
progress_msg = text;
-
- progress_bar = GTK_PROGRESS_BAR(
- gtk_builder_get_object(gnac_main_builder, "progressbar"));
+ progress_bar = GTK_PROGRESS_BAR(gnac_ui_get_widget("progressbar"));
gtk_progress_bar_set_text(progress_bar, progress_msg);
}
@@ -676,8 +671,7 @@ gnac_ui_show_progress(gboolean show)
{
GtkWidget *progress_bar;
- progress_bar = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "progressbar"));
+ progress_bar = gnac_ui_get_widget("progressbar");
if (show) gtk_widget_show(progress_bar);
else gtk_widget_hide(progress_bar);
@@ -691,8 +685,7 @@ gnac_ui_pulse_progress(void)
gchar *progress_text;
if (state == GNAC_AUDIO_FILE_ACTION_STATE) {
- progress_bar = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "progressbar"));
+ progress_bar = gnac_ui_get_widget("progressbar");
gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar));
progress_text = g_strdup_printf(
@@ -713,8 +706,7 @@ gnac_ui_show_pause(gboolean show)
{
GtkWidget *button;
- button = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "pause_button"));
+ button = gnac_ui_get_widget("pause_button");
if (show) gtk_widget_show(button);
else gtk_widget_hide(button);
@@ -726,8 +718,7 @@ gnac_ui_push_status(const gchar *message)
{
GtkStatusbar *status_bar;
- status_bar = GTK_STATUSBAR(
- gtk_builder_get_object(gnac_main_builder, "statusbar"));
+ status_bar = GTK_STATUSBAR(gnac_ui_get_widget("statusbar"));
g_free(status_msg);
status_msg = g_strdup(message);
gtk_statusbar_pop(status_bar, 0);
@@ -741,8 +732,7 @@ gnac_ui_append_status(const gchar *message)
gchar *old_msg;
GtkStatusbar *status_bar;
- status_bar = GTK_STATUSBAR(
- gtk_builder_get_object(gnac_main_builder, "statusbar"));
+ status_bar = GTK_STATUSBAR(gnac_ui_get_widget("statusbar"));
old_msg = g_strdup(status_msg);
g_free(status_msg);
status_msg = g_strdup_printf("%s (%s)", old_msg, message);
@@ -781,8 +771,7 @@ gnac_ui_show_popup_menu(GtkWidget *treeview,
{
GtkWidget * popup_menu;
- popup_menu = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "main_popup"));
+ popup_menu = gnac_ui_get_widget("main_popup");
gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL, NULL, NULL,
(event != NULL) ? event->button : 0,
@@ -795,8 +784,7 @@ gnac_ui_show_about_dialog(void)
{
GtkWidget *about_dialog;
- about_dialog = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "aboutdialog"));
+ about_dialog = gnac_ui_get_widget("aboutdialog");
gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about_dialog), PACKAGE_VERSION);
gtk_widget_show_all(about_dialog);
}
@@ -817,17 +805,24 @@ gnac_about_url_hook(GtkAboutDialog *dialog,
}
+static GObject *
+gnac_ui_get_object(const gchar *object_name)
+{
+ return gtk_builder_get_object(gnac_main_builder, object_name);
+}
+
+
GtkWidget *
gnac_ui_get_widget(const gchar *widget_name)
{
- return GTK_WIDGET(gtk_builder_get_object(gnac_main_builder, widget_name));
+ return GTK_WIDGET(gnac_ui_get_object(widget_name));
}
GtkAction *
-gnac_ui_get_action(const gchar *widget_name)
+gnac_ui_get_action(const gchar *action_name)
{
- return GTK_ACTION(gtk_builder_get_object(gnac_main_builder, widget_name));
+ return GTK_ACTION(gnac_ui_get_object(action_name));
}
@@ -968,9 +963,8 @@ gnac_ui_on_remove_cb(GtkAction *action,
{
GList *rows;
rows = gnac_file_list_get_selected_rows();
- /* References are freed by gnac_remove_track*/
- g_list_foreach(rows, (GFunc) gnac_remove_track, NULL);
- g_list_free(rows);
+ /* References are freed by gnac_remove_track */
+ g_list_free_full(rows, (GDestroyNotify) gnac_remove_track);
}
@@ -1026,8 +1020,7 @@ gnac_ui_message_received_cb(UniqueApp *app,
{
GtkWindow *main_window;
- main_window = GTK_WINDOW(gtk_builder_get_object(gnac_main_builder,
- "main_window"));
+ main_window = GTK_WINDOW(gnac_ui_get_widget("main_window"));
switch (command)
{
@@ -1160,8 +1153,7 @@ gnac_ui_show(void)
gnac_ui_new();
}
- main_window = GTK_WIDGET(
- gtk_builder_get_object(gnac_main_builder, "main_window"));
+ main_window = gnac_ui_get_widget("main_window");
#ifdef HAVE_LIBUNIQUE
unique_app_watch_window(app, GTK_WINDOW(main_window));
diff --git a/src/gnac-utils.c b/src/gnac-utils.c
index 97fc9f1..3116137 100644
--- a/src/gnac-utils.c
+++ b/src/gnac-utils.c
@@ -324,3 +324,19 @@ gnac_utils_string_is_null_or_empty(const gchar *string)
{
return !string || g_str_equal(string, "");
}
+
+
+gboolean
+gnac_utils_str_equal(const gchar *str1,
+ const gchar *str2)
+{
+ return g_strcmp0(str1, str2) == 0;
+}
+
+
+GtkWidget *
+gnac_utils_get_widget(GtkBuilder *builder,
+ const gchar *widget_name)
+{
+ return GTK_WIDGET(gtk_builder_get_object(builder, widget_name));
+}
diff --git a/src/gnac-utils.h b/src/gnac-utils.h
index b41a41e..e0044ed 100644
--- a/src/gnac-utils.h
+++ b/src/gnac-utils.h
@@ -96,6 +96,14 @@ gnac_utils_create_gtk_builder(const gchar *filename);
gboolean
gnac_utils_string_is_null_or_empty(const gchar *string);
+gboolean
+gnac_utils_str_equal(const gchar *str1,
+ const gchar *str2);
+
+GtkWidget *
+gnac_utils_get_widget(GtkBuilder *builder,
+ const gchar *widget_name);
+
G_END_DECLS
#endif /* GNAC_UTILS_H */
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index 9d57d97..ea8b2be 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -24,11 +24,21 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-aac.h"
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gchar *bitrate;
+ gchar *outputformat;
+ gchar *profile;
+ gchar *tns;
+}
+AudioProfileAAC;
+
BasicFormatInfo aac_bfi = {
PKGDATADIR "/profiles/gnac-profiles-aac.xml",
NULL,
@@ -46,9 +56,47 @@ BasicFormatInfo aac_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
+static const gchar *
+gnac_profiles_aac_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_aac_generate_pipeline(GtkWidget *w);
+
+static AudioProfileAAC *
+gnac_profiles_aac_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile);
+
+static void
+gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile);
+
+static gchar *
+gnac_profiles_aac_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_aac_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_aac_get_description(void);
+
+static GtkWidget *
+gnac_profiles_aac_get_widget(AudioProfileAAC *profile);
+
+static void
+gnac_profiles_aac_save_profile(AudioProfileAAC *profile);
+
+static void
+gnac_profiles_aac_clean_up(void);
+
+static AudioProfileAAC *
+gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
FormatModuleFuncs
-gnac_profiles_aac_get_funcs(void) {
+gnac_profiles_aac_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_aac_init,
gnac_profiles_aac_get_description,
@@ -68,7 +116,7 @@ gnac_profiles_aac_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
{
GtkWidget *widget;
@@ -88,8 +136,7 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
widget = gnac_profiles_utils_all_in_one_for_combo(&aac_bfi,
G_CALLBACK(gnac_profiles_aac_generate_pipeline),
"combo-profile", "//variable[ id='profile']/*");
- widget2 = GTK_WIDGET(gtk_builder_get_object(aac_bfi.builder,
- "label-profile")),
+ widget2 = gnac_profiles_utils_get_widget(&aac_bfi, "label-profile"),
gnac_profiles_utils_add_description_tooltip(&aac_bfi,
"//variable[ id='profile']/description", widget, widget2, NULL);
@@ -113,7 +160,7 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
}
-void
+static void
gnac_profiles_aac_generate_pipeline(GtkWidget *w)
{
gchar *pipeline;
@@ -134,7 +181,7 @@ gnac_profiles_aac_generate_pipeline(GtkWidget *w)
}
-void
+static void
gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile)
{
if (profile == NULL) {
@@ -156,16 +203,18 @@ gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile)
}
-gchar *
+static gchar *
gnac_profiles_aac_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&aac_bfi);
}
-void
+static void
gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile->bitrate);
@@ -176,7 +225,7 @@ gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
}
-AudioProfileAAC *
+static AudioProfileAAC *
gnac_profiles_aac_generate_audio_profile(GError **error)
{
AudioProfileAAC *profile;
@@ -200,17 +249,17 @@ gnac_profiles_aac_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_aac_get_widget(AudioProfileAAC *profile)
{
if (profile != NULL) {
gnac_profiles_aac_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile, &aac_bfi);
+ return gnac_profiles_default_get_properties_alignment(&aac_bfi);
}
-void
+static void
gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
{
XMLDoc *doc;
@@ -228,7 +277,7 @@ gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
}
-AudioProfileAAC*
+static AudioProfileAAC*
gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -248,7 +297,7 @@ gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
}
-void
+static void
gnac_profiles_aac_clean_up(void)
{
gnac_profiles_default_clean_up(&aac_bfi);
@@ -260,14 +309,14 @@ gnac_profiles_aac_clean_up(void)
}
-const gchar *
+static const gchar *
gnac_profiles_aac_get_plugin_name(void)
{
return aac_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_aac_get_description(void)
{
return aac_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-aac.h b/src/profiles/formats/gnac-profiles-aac.h
index 9587833..d0677b0 100644
--- a/src/profiles/formats/gnac-profiles-aac.h
+++ b/src/profiles/formats/gnac-profiles-aac.h
@@ -30,57 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gchar *bitrate;
- gchar *outputformat;
- gchar *profile;
- gchar *tns;
-}
-AudioProfileAAC;
-
FormatModuleFuncs
gnac_profiles_aac_get_funcs(void);
-const gchar *
-gnac_profiles_aac_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_aac_generate_pipeline(GtkWidget *w);
-
-AudioProfileAAC *
-gnac_profiles_aac_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile);
-
-void
-gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile);
-
-gchar *
-gnac_profiles_aac_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_aac_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_aac_get_description(void);
-
-GtkWidget *
-gnac_profiles_aac_get_widget(AudioProfileAAC *profile);
-
-void
-gnac_profiles_aac_save_profile(AudioProfileAAC *profile);
-
-AudioProfileAAC *
-gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_aac_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_AAC_H */
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index d064eb6..f3ec8a5 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -24,11 +24,18 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-flac.h"
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gdouble quality;
+}
+AudioProfileFlac;
+
BasicFormatInfo flac_bfi = {
PKGDATADIR "/profiles/gnac-profiles-flac.xml",
NULL,
@@ -46,9 +53,47 @@ BasicFormatInfo flac_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
+static const gchar *
+gnac_profiles_flac_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_flac_generate_pipeline(GtkWidget *w);
+
+static AudioProfileFlac *
+gnac_profiles_flac_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile);
+
+static void
+gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile);
+
+static gchar *
+gnac_profiles_flac_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_flac_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_flac_get_description(void);
+
+static GtkWidget *
+gnac_profiles_flac_get_widget(AudioProfileFlac *profile);
+
+static void
+gnac_profiles_flac_save_profile(AudioProfileFlac *profile);
+
+static void
+gnac_profiles_flac_clean_up(void);
+
+static AudioProfileFlac *
+gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
FormatModuleFuncs
-gnac_profiles_flac_get_funcs(void) {
+gnac_profiles_flac_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_flac_init,
gnac_profiles_flac_get_description,
@@ -68,7 +113,7 @@ gnac_profiles_flac_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
{
update_text_buffer_call_back = call_back;
@@ -88,7 +133,7 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
}
-void
+static void
gnac_profiles_flac_generate_pipeline(GtkWidget *w)
{
gchar *pipeline;
@@ -106,7 +151,7 @@ gnac_profiles_flac_generate_pipeline(GtkWidget *w)
}
-void
+static void
gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile)
{
if (profile == NULL) {
@@ -120,22 +165,24 @@ gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile)
}
-gchar *
+static gchar *
gnac_profiles_flac_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&flac_bfi);
}
-void
+static void
gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile);
}
-AudioProfileFlac *
+static AudioProfileFlac *
gnac_profiles_flac_generate_audio_profile(GError **error)
{
AudioProfileFlac *profile;
@@ -152,17 +199,17 @@ gnac_profiles_flac_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_flac_get_widget(AudioProfileFlac *profile)
{
if (profile != NULL) {
gnac_profiles_flac_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile,&flac_bfi);
+ return gnac_profiles_default_get_properties_alignment(&flac_bfi);
}
-void
+static void
gnac_profiles_flac_save_profile(AudioProfileFlac *profile)
{
XMLDoc *doc;
@@ -179,7 +226,7 @@ gnac_profiles_flac_save_profile(AudioProfileFlac *profile)
}
-AudioProfileFlac*
+static AudioProfileFlac*
gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -201,7 +248,7 @@ gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
}
-void
+static void
gnac_profiles_flac_clean_up(void)
{
gnac_profiles_default_clean_up(&flac_bfi);
@@ -210,14 +257,14 @@ gnac_profiles_flac_clean_up(void)
}
-const gchar *
+static const gchar *
gnac_profiles_flac_get_plugin_name(void)
{
return flac_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_flac_get_description(void)
{
return flac_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-flac.h b/src/profiles/formats/gnac-profiles-flac.h
index 3dc1e2e..555aaa0 100644
--- a/src/profiles/formats/gnac-profiles-flac.h
+++ b/src/profiles/formats/gnac-profiles-flac.h
@@ -30,54 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gdouble quality;
-}
-AudioProfileFlac;
-
FormatModuleFuncs
gnac_profiles_flac_get_funcs(void);
-const gchar *
-gnac_profiles_flac_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_flac_generate_pipeline(GtkWidget *w);
-
-AudioProfileFlac *
-gnac_profiles_flac_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile);
-
-void
-gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile);
-
-gchar *
-gnac_profiles_flac_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_flac_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_flac_get_description(void);
-
-GtkWidget *
-gnac_profiles_flac_get_widget(AudioProfileFlac *profile);
-
-void
-gnac_profiles_flac_save_profile(AudioProfileFlac *profile);
-
-AudioProfileFlac *
-gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_flac_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_FLAC_H */
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index 2b6cbf7..415813f 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -24,11 +24,35 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-lame.h"
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gchar *encoding_mode;
+ gdouble quality;
+ gdouble compression_ratio;
+ gchar *bitrate;
+ gchar *preset;
+ gdouble mean_abr;
+ gdouble mean_bitrate;
+ gchar *min_bitrate;
+ gchar *max_bitrate;
+ gchar *mode;
+}
+AudioProfileLame;
+
+typedef enum {
+ CONSTANT_BITRATE,
+ AVERAGE_BITRATE,
+ VARIABLE_BITRATE,
+ PRESETS,
+ COMPRESSION_RATIO
+} EncodingMode;
+
BasicFormatInfo lame_bfi = {
PKGDATADIR "/profiles/gnac-profiles-lame.xml",
NULL,
@@ -44,6 +68,45 @@ BasicFormatInfo lame_bfi = {
NULL
};
+static UpdateTextBufferFunc update_text_buffer_call_back;
+
+static const gchar *
+gnac_profiles_lame_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_lame_generate_pipeline(GtkWidget *w);
+
+static AudioProfileLame *
+gnac_profiles_lame_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile);
+
+static void
+gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile);
+
+static gchar *
+gnac_profiles_lame_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_lame_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_lame_get_description(void);
+
+static GtkWidget *
+gnac_profiles_lame_get_widget(AudioProfileLame *profile);
+
+static void
+gnac_profiles_lame_save_profile(AudioProfileLame *profile);
+
+static void
+gnac_profiles_lame_clean_up(void);
+
+static AudioProfileLame *
+gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
static void
gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget);
@@ -54,11 +117,10 @@ gnac_profiles_lame_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
static AudioProfileLame *
gnac_profiles_lame_allocate_audio_profile(void);
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
FormatModuleFuncs
-gnac_profiles_lame_get_funcs(void) {
+gnac_profiles_lame_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_lame_init,
gnac_profiles_lame_get_description,
@@ -78,7 +140,7 @@ gnac_profiles_lame_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
{
GtkWidget *widget;
@@ -103,8 +165,7 @@ gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
widget = gnac_profiles_utils_all_in_one_for_slider(&lame_bfi,
G_CALLBACK(gnac_profiles_lame_generate_pipeline),
"slider-compression-ratio", "//variable[ id='compression-ratio']/*");
- widget2 = GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder,
- "label-compression-ratio")),
+ widget2 = gnac_profiles_utils_get_widget(&lame_bfi, "label-compression-ratio"),
gnac_profiles_utils_add_description_tooltip(&lame_bfi,
"//variable[ id='compression-ratio']/description",
widget, widget2, NULL);
@@ -169,36 +230,36 @@ gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget)
{
- gint i;
- gint index;
-
- GtkWidget *widgets_tab[16] = {
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "label-vbr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "hbox-vbr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "label-cbr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "hbox-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "label-preset")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "hbox-preset")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "label-compression-ratio")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "slider-compression-ratio")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "label-mean-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "slider-mean-abr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "checkbutton-mean-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "slider-mean-vbr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "checkbutton-min-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "combo-min-vbr")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "checkbutton-max-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder, "combo-max-vbr"))
+ guint i;
+ EncodingMode encoding_mode;
+
+ GtkWidget *widgets_tab[] = {
+ gnac_profiles_utils_get_widget(&lame_bfi, "label-vbr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "hbox-vbr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "label-cbr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "hbox-bitrate"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "label-preset"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "hbox-preset"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "label-compression-ratio"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "slider-compression-ratio"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "label-mean-bitrate"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "slider-mean-abr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "checkbutton-mean-bitrate"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "slider-mean-vbr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "checkbutton-min-bitrate"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "combo-min-vbr"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "checkbutton-max-bitrate"),
+ gnac_profiles_utils_get_widget(&lame_bfi, "combo-max-vbr")
};
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-
- for (i = 0; i < 16; ++i) {
- if (((index == 2) && ((i >= 10) || (i <= 1)))
- || ((index == 0) && ((i == 2) || (i == 3)))
- || ((index == 1) && (((i > 11) || (i == 8) || (i == 9))))
- || ((index == 3) && ((i == 4) || (i == 5)))
- || ((index == 4) && ((i == 6) || (i == 7))))
+ encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
+ for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
+ if ((encoding_mode == VARIABLE_BITRATE && (i >= 10 || i <= 1)) ||
+ (encoding_mode == CONSTANT_BITRATE && (i == 2 || i == 3)) ||
+ (encoding_mode == AVERAGE_BITRATE && (i > 11 || i == 8 || i == 9)) ||
+ (encoding_mode == PRESETS && (i == 4 || i == 5)) ||
+ (encoding_mode == COMPRESSION_RATIO && (i == 6 || i == 7)))
{
gtk_widget_show(widgets_tab[i]);
} else {
@@ -208,38 +269,35 @@ gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget)
}
-void
+static void
gnac_profiles_lame_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
gchar *pipeline;
- gint index;
+ EncodingMode encoding_mode;
pipeline = gnac_profiles_default_generate_pipeline(&lame_bfi);
- widget = GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder,
- "combo-encoding-mode"));
+ widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
if (w == widget) {
gnac_profiles_lame_vbr_on_changed(GTK_COMBO_BOX(w));
}
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
// Mode
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
"combo-mode", NULL);
- switch (index)
+ switch (encoding_mode)
{
- case 0:
- // CBR
+ case CONSTANT_BITRATE:
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
"combo-encoding-mode", "combo-bitrate", NULL);
break;
- case 1:
- // abr
+ case AVERAGE_BITRATE:
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
"combo-encoding-mode", NULL);
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &lame_bfi,
@@ -253,8 +311,7 @@ gnac_profiles_lame_generate_pipeline(GtkWidget *w)
NULL);
break;
- case 2:
- // VBR
+ case VARIABLE_BITRATE:
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
"combo-encoding-mode", NULL);
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &lame_bfi,
@@ -272,14 +329,12 @@ gnac_profiles_lame_generate_pipeline(GtkWidget *w)
NULL);
break;
- case 3:
- // Presets
+ case PRESETS:
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
"combo-preset", NULL);
break;
- case 4:
- // compression ratio
+ case COMPRESSION_RATIO:
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &lame_bfi,
"slider-compression-ratio", NULL);
break;
@@ -307,7 +362,7 @@ gnac_profiles_lame_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
}
-void
+static void
gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
{
if (profile == NULL) {
@@ -372,14 +427,14 @@ gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
}
-gchar *
+static gchar *
gnac_profiles_lame_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&lame_bfi);
}
-AudioProfileLame *
+static AudioProfileLame *
gnac_profiles_lame_allocate_audio_profile(void)
{
AudioProfileLame *profile;
@@ -401,9 +456,11 @@ gnac_profiles_lame_allocate_audio_profile(void)
}
-void
+static void
gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile->encoding_mode);
@@ -416,7 +473,7 @@ gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile)
}
-AudioProfileLame *
+static AudioProfileLame *
gnac_profiles_lame_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
@@ -433,17 +490,16 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
"combo-mode", &profile->mode,
NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(lame_bfi.builder,
- "combo-encoding-mode"));
+ widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)))
{
- case 0:
+ case CONSTANT_BITRATE:
gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
"combo-bitrate", &profile->bitrate, NULL);
break;
- case 1:
+ case AVERAGE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
"slider-mean-abr", &profile->mean_abr, NULL);
@@ -454,8 +510,7 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
NULL );
break;
- case 2:
- // VBR
+ case VARIABLE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
"slider-vbr-quality", &profile->quality, NULL);
@@ -471,14 +526,12 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
NULL );
break;
- case 3:
- // Presets
+ case PRESETS:
gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
"combo-preset", &profile->preset, NULL);
break;
- case 4:
- // Compression ratio
+ case COMPRESSION_RATIO:
gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
"slider-compression-ratio", &profile->compression_ratio, NULL);
break;
@@ -491,17 +544,17 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_lame_get_widget(AudioProfileLame *profile)
{
if (profile != NULL) {
gnac_profiles_lame_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile, &lame_bfi);
+ return gnac_profiles_default_get_properties_alignment(&lame_bfi);
}
-void
+static void
gnac_profiles_lame_save_profile(AudioProfileLame *profile)
{
XMLDoc *doc;
@@ -527,15 +580,14 @@ gnac_profiles_lame_save_profile(AudioProfileLame *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &lame_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"encoding-mode", profile->encoding_mode,
- "bitrate", (profile->bitrate == NULL) ? "" : profile->bitrate,
- "quality", (quality_str == NULL) ? "" : quality_str,
- "compression-ratio",
- (compression_ratio_str == NULL) ? "" : compression_ratio_str,
- "preset", (profile->preset == NULL) ? "" : profile->preset,
- "mean-abr", (mean_abr_str == NULL) ? "" : mean_abr_str,
- "mean-bitrate", (mean_bitrate_str == NULL) ? "" : mean_bitrate_str,
- "min-bitrate", (profile->min_bitrate == NULL) ? "" : profile->min_bitrate,
- "max-bitrate", (profile->max_bitrate == NULL) ? "" : profile->max_bitrate,
+ "bitrate", profile->bitrate ? profile->bitrate : "",
+ "quality", quality_str ? quality_str : "",
+ "compression-ratio", compression_ratio_str ? compression_ratio_str : "",
+ "preset", profile->preset ? profile->preset : "",
+ "mean-abr", mean_abr_str ? mean_abr_str : "",
+ "mean-bitrate", mean_bitrate_str ? mean_bitrate_str : "",
+ "min-bitrate", profile->min_bitrate ? profile->min_bitrate : "",
+ "max-bitrate", profile->max_bitrate ? profile->max_bitrate : "",
"mode", profile->mode,
NULL);
@@ -549,7 +601,7 @@ gnac_profiles_lame_save_profile(AudioProfileLame *profile)
}
-AudioProfileLame *
+static AudioProfileLame *
gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -597,8 +649,9 @@ gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
}
-void
-gnac_profiles_lame_clean_up(void) {
+static void
+gnac_profiles_lame_clean_up(void)
+{
gnac_profiles_default_clean_up(&lame_bfi);
gnac_profiles_utils_free_combo_values(&lame_bfi,
"combo-mode",
@@ -618,14 +671,14 @@ gnac_profiles_lame_clean_up(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_lame_get_plugin_name(void)
{
return lame_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_lame_get_description(void)
{
return lame_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-lame.h b/src/profiles/formats/gnac-profiles-lame.h
index dea299a..c6ea4f6 100644
--- a/src/profiles/formats/gnac-profiles-lame.h
+++ b/src/profiles/formats/gnac-profiles-lame.h
@@ -30,63 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gchar *encoding_mode;
- gdouble quality;
- gdouble compression_ratio;
- gchar *bitrate;
- gchar *preset;
- gdouble mean_abr;
- gdouble mean_bitrate;
- gchar *min_bitrate;
- gchar *max_bitrate;
- gchar *mode;
-}
-AudioProfileLame;
-
FormatModuleFuncs
gnac_profiles_lame_get_funcs(void);
-const gchar *
-gnac_profiles_lame_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_lame_generate_pipeline(GtkWidget *w);
-
-AudioProfileLame *
-gnac_profiles_lame_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile);
-
-void
-gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile);
-
-gchar *
-gnac_profiles_lame_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_lame_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_lame_get_description(void);
-
-GtkWidget *
-gnac_profiles_lame_get_widget(AudioProfileLame *profile);
-
-void
-gnac_profiles_lame_save_profile(AudioProfileLame *profile);
-
-AudioProfileLame *
-gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_lame_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_LAME_H */
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index 57e45f1..f9816ff 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -24,9 +24,31 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-speex.h"
+#include "libgnac/libgnac-debug.h"
+
+
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gdouble quality_cbr;
+ gdouble quality_vbr;
+ gdouble bitrate_cbr;
+ gdouble bitrate_abr;
+ gchar *mode;
+ gdouble complexity;
+ gchar *vad;
+ gchar *dtx;
+}
+AudioProfileSpeex;
+
+typedef enum {
+ CONSTANT_BITRATE,
+ AVERAGE_BITRATE,
+ VARIABLE_BITRATE
+} BitrateMode;
BasicFormatInfo speex_bfi = {
PKGDATADIR "/profiles/gnac-profiles-speex.xml",
@@ -43,6 +65,45 @@ BasicFormatInfo speex_bfi = {
NULL
};
+static UpdateTextBufferFunc update_text_buffer_call_back;
+
+static const gchar *
+gnac_profiles_speex_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_speex_generate_pipeline(GtkWidget *w);
+
+static AudioProfileSpeex *
+gnac_profiles_speex_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile);
+
+static void
+gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile);
+
+static gchar *
+gnac_profiles_speex_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_speex_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_speex_get_description(void);
+
+static GtkWidget *
+gnac_profiles_speex_get_widget(AudioProfileSpeex *profile);
+
+static void
+gnac_profiles_speex_save_profile(AudioProfileSpeex *profile);
+
+static void
+gnac_profiles_speex_clean_up(void);
+
+static AudioProfileSpeex *
+gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
static void
gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget);
@@ -51,17 +112,19 @@ gnac_profiles_speex_advanced_on_toggle(GtkToggleButton *togglebutton,
gpointer user_data);
static void
+gnac_profiles_speex_display_vad(BitrateMode bitrate_mode);
+
+static void
gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
gpointer user_data);
static AudioProfileSpeex *
gnac_profiles_speex_allocate_audio_profile(void);
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
FormatModuleFuncs
-gnac_profiles_speex_get_funcs(void) {
+gnac_profiles_speex_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_speex_init,
gnac_profiles_speex_get_description,
@@ -81,7 +144,7 @@ gnac_profiles_speex_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
{
GtkWidget *widget;
@@ -125,12 +188,10 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
widget2 = gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
G_CALLBACK(gnac_profiles_speex_generate_pipeline),
"slider-complexity", "//variable[ id='complexity']/*");
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "hbox-complexity"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "hbox-complexity");
gnac_profiles_utils_add_toggle_signal(&speex_bfi, "checkbutton-complexity",
G_CALLBACK(gnac_profiles_speex_advanced_on_toggle), widget);
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-complexity"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-complexity");
gnac_profiles_utils_add_description_tooltip(&speex_bfi,
"//variable[ id='complexity']/description",
widget, widget2, NULL);
@@ -155,7 +216,7 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
widget = gnac_profiles_utils_all_in_one_for_combo(&speex_bfi,
G_CALLBACK(gnac_profiles_speex_generate_pipeline),
"combo-mode", "//variable[ id='mode']/*");
- widget2 = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "hbox-mode"));
+ widget2 = gnac_profiles_utils_get_widget(&speex_bfi, "hbox-mode");
gnac_profiles_utils_add_description_tooltip(&speex_bfi,
"//variable[ id='mode']/description",
widget, widget2, NULL);
@@ -175,94 +236,121 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
}
-void
+static void
gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget)
{
- gint i;
- gint index;
+ guint i;
+ BitrateMode bitrate_mode;
- GtkWidget *widgets_tab[8] = {
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "checkbutton-bitrate-cbr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "slider-bitrate-cbr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "label-quality-cbr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "hbox-quality-cbr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "label-bitrate-abr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "slider-bitrate-abr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "label-quality-vbr")),
- GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder, "hbox-quality-vbr")),
+ guint start_index_of_abr_widgets = 4;
+ guint start_index_of_vbr_widgets = 6;
+
+ GtkWidget *widgets_tab[] = {
+ gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-bitrate-cbr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-cbr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "label-quality-cbr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "hbox-quality-cbr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "label-bitrate-abr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-abr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "label-quality-vbr"),
+ gnac_profiles_utils_get_widget(&speex_bfi, "hbox-quality-vbr"),
};
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-
- for (i = 0; i < 8; ++i) {
- if (((index == 0) && (i < 4))
- || ((index == 1) && ((i == 4) || (i == 5)))
- || ((index == 2) && ((i == 6) || (i == 7))))
- {
- gtk_widget_show(widgets_tab[i]);
- } else {
- gtk_widget_hide(widgets_tab[i]);
+ bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
+ for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
+ switch (bitrate_mode) {
+
+ case CONSTANT_BITRATE:
+ if (i < start_index_of_abr_widgets) {
+ gtk_widget_show(widgets_tab[i]);
+ } else {
+ gtk_widget_hide(widgets_tab[i]);
+ }
+ break;
+
+ case AVERAGE_BITRATE:
+ if (i >= start_index_of_abr_widgets &&
+ i < start_index_of_vbr_widgets)
+ {
+ gtk_widget_show(widgets_tab[i]);
+ } else {
+ gtk_widget_hide(widgets_tab[i]);
+ }
+ break;
+
+ case VARIABLE_BITRATE:
+ if (i >= start_index_of_vbr_widgets) {
+ gtk_widget_show(widgets_tab[i]);
+ } else {
+ gtk_widget_hide(widgets_tab[i]);
+ }
+ break;
+
+ default:
+ libgnac_debug("Unrecognised bitrate mode: %d\n", bitrate_mode);
+ break;
}
}
+ gnac_profiles_speex_display_vad(bitrate_mode);
+}
+
+
+static void
+gnac_profiles_speex_display_vad(BitrateMode bitrate_mode)
+{
GtkWidget *vad;
GtkWidget *dtx;
- vad = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-vad"));
- dtx = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-dtx"));
+ vad = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-vad");
+ dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
- if (index == 0) {
+ if (bitrate_mode == CONSTANT_BITRATE) {
gtk_widget_show(vad);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vad))) {
- gtk_widget_show(dtx);
- } else {
- gtk_widget_hide(dtx);
- }
+ gnac_profiles_speex_vad_on_toggle(GTK_TOGGLE_BUTTON(vad), NULL);
} else {
gtk_widget_hide(vad);
gtk_widget_show(dtx);
}
gnac_profiles_utils_set_active_toggle_button(&speex_bfi,
- (index == 2), "checkbutton-vbr", NULL);
+ (bitrate_mode == VARIABLE_BITRATE), "checkbutton-vbr", NULL);
}
-void
+static void
gnac_profiles_speex_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
+ BitrateMode bitrate_mode;
gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&speex_bfi);
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "combo-bitrate-mode"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
if (w == widget) {
gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(w));
}
- switch (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)))
+ bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
+ switch (bitrate_mode)
{
- case 0:
+ case CONSTANT_BITRATE:
pipeline = gnac_profiles_utils_add_properties_slider(pipeline,
&speex_bfi, "slider-quality-cbr", NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-bitrate-cbr"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-bitrate-cbr");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "slider-bitrate-cbr"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-cbr");
pipeline = gnac_profiles_utils_add_property_slider(pipeline,
"%.0f", 1024, widget);
}
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &speex_bfi,
"checkbutton-vad", NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-vad"));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-vad");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
pipeline = gnac_profiles_utils_add_properties_check(pipeline,
@@ -270,16 +358,15 @@ gnac_profiles_speex_generate_pipeline(GtkWidget *w)
}
break;
- case 1:
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "slider-bitrate-abr"));
+ case AVERAGE_BITRATE:
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-abr");
pipeline = gnac_profiles_utils_add_property_slider(pipeline,
"%.0f", 1024, widget);
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &speex_bfi,
"checkbutton-dtx", NULL);
break;
- case 2:
+ case VARIABLE_BITRATE:
pipeline = gnac_profiles_utils_add_properties_slider_format(pipeline,
&speex_bfi, "%.2f", "slider-quality-vbr", NULL);
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &speex_bfi,
@@ -306,7 +393,7 @@ gnac_profiles_speex_generate_pipeline(GtkWidget *w)
}
-void
+static void
gnac_profiles_speex_advanced_on_toggle(GtkToggleButton *togglebutton,
gpointer user_data)
{
@@ -315,14 +402,13 @@ gnac_profiles_speex_advanced_on_toggle(GtkToggleButton *togglebutton,
}
-void
+static void
gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
gpointer user_data)
{
GtkWidget *dtx;
- dtx = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "checkbutton-dtx"));
+ dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
if (gtk_toggle_button_get_active(togglebutton)) {
gtk_widget_show(dtx);
@@ -332,7 +418,7 @@ gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
}
-void
+static void
gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
{
GtkWidget *widget;
@@ -370,8 +456,7 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
gnac_profiles_utils_set_values_check(&speex_bfi,
"checkbutton-vad", profile->vad, "checkbutton-dtx", profile->dtx, NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "combo-bitrate-mode"));
+ 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",
@@ -382,23 +467,23 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
profile->bitrate_cbr,
NULL);
}
- gtk_combo_box_set_active(GTK_COMBO_BOX(widget), 0);
+ 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), 2);
+ 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), 1);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
}
}
}
-gchar *
+static gchar *
gnac_profiles_speex_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&speex_bfi);
@@ -425,9 +510,11 @@ gnac_profiles_speex_allocate_audio_profile(void)
}
-void
+static void
gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile->mode);
@@ -437,22 +524,21 @@ gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile)
}
-AudioProfileSpeex *
+static AudioProfileSpeex *
gnac_profiles_speex_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
AudioProfileSpeex *profile;
GtkWidget *widget;
- gint index;
+ BitrateMode bitrate_mode;
generic = gnac_profiles_default_generate_audio_profile(&speex_bfi);
profile = gnac_profiles_speex_allocate_audio_profile();
profile->generic = generic;
- widget = GTK_WIDGET(gtk_builder_get_object(speex_bfi.builder,
- "combo-bitrate-mode"));
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
+ 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);
@@ -463,9 +549,9 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
gnac_profiles_utils_get_values_check_and_set(&speex_bfi,
"checkbutton-dtx", &profile->dtx, NULL);
- switch (index)
+ switch (bitrate_mode)
{
- case 0:
+ case CONSTANT_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
"slider-quality-cbr", &profile->quality_cbr,
NULL);
@@ -477,13 +563,13 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
"checkbutton-vad", &profile->vad, NULL);
break;
- case 1:
+ case AVERAGE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
"slider-bitrate-abr", &profile->bitrate_abr,
NULL);
break;
- case 2:
+ case VARIABLE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
"slider-quality-vbr", &profile->quality_vbr,
NULL);
@@ -494,17 +580,17 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_speex_get_widget(AudioProfileSpeex *profile)
{
if (profile != NULL) {
gnac_profiles_speex_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile,&speex_bfi);
+ return gnac_profiles_default_get_properties_alignment(&speex_bfi);
}
-void
+static void
gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
{
XMLDoc *doc;
@@ -536,12 +622,12 @@ gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &speex_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
- "bitrate-cbr", (bitrate_cbr_str == NULL) ? "" : bitrate_cbr_str,
- "quality-cbr", (quality_cbr_str == NULL) ? "" : quality_cbr_str,
- "bitrate-abr", (bitrate_abr_str == NULL) ? "" : bitrate_abr_str,
- "quality-vbr", (quality_vbr_str == NULL) ? "" : quality_vbr_str,
+ "bitrate-cbr", bitrate_cbr_str ? bitrate_cbr_str : "",
+ "quality-cbr", quality_cbr_str ? quality_cbr_str : "",
+ "bitrate-abr", bitrate_abr_str ? bitrate_abr_str : "",
+ "quality-vbr", quality_vbr_str ? quality_vbr_str : "",
"mode", profile->mode,
- "complexity", (complexity_str == NULL) ? "" : complexity_str,
+ "complexity", complexity_str ? complexity_str : "",
"vad", profile->vad,
"dtx", profile->dtx,
NULL);
@@ -558,7 +644,7 @@ gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
}
-AudioProfileSpeex *
+static AudioProfileSpeex *
gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -614,8 +700,9 @@ gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
}
-void
-gnac_profiles_speex_clean_up(void) {
+static void
+gnac_profiles_speex_clean_up(void)
+{
gnac_profiles_default_clean_up(&speex_bfi);
gnac_profiles_utils_free_combo_values(&speex_bfi,
"combo-mode",
@@ -637,14 +724,14 @@ gnac_profiles_speex_clean_up(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_speex_get_plugin_name(void)
{
return speex_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_speex_get_description(void)
{
return speex_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-speex.h b/src/profiles/formats/gnac-profiles-speex.h
index ec468cd..3829ee2 100644
--- a/src/profiles/formats/gnac-profiles-speex.h
+++ b/src/profiles/formats/gnac-profiles-speex.h
@@ -30,61 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gdouble quality_cbr;
- gdouble quality_vbr;
- gdouble bitrate_cbr;
- gdouble bitrate_abr;
- gchar *mode;
- gdouble complexity;
- gchar *vad;
- gchar *dtx;
-}
-AudioProfileSpeex;
-
FormatModuleFuncs
gnac_profiles_speex_get_funcs(void);
-const gchar *
-gnac_profiles_speex_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_speex_generate_pipeline(GtkWidget *w);
-
-AudioProfileSpeex *
-gnac_profiles_speex_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile);
-
-void
-gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile);
-
-gchar *
-gnac_profiles_speex_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_speex_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_speex_get_description(void);
-
-GtkWidget *
-gnac_profiles_speex_get_widget(AudioProfileSpeex *profile);
-
-void
-gnac_profiles_speex_save_profile(AudioProfileSpeex *profile);
-
-AudioProfileSpeex *
-gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_speex_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_SPEEX_H */
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index 59bb7e6..0fd63f3 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -25,7 +25,6 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-main.h"
#include "gnac-utils.h"
@@ -44,7 +43,7 @@ BasicFormatInfo unknown_bfi = {
"audioconvert",
N_("Custom format"),
NULL,
- N_("<i>Use this format to define your own GStreamer pipeline</i>")
+ N_("Use this format to define your own GStreamer pipeline")
};
const gchar *base_pipeline =
@@ -54,17 +53,55 @@ static GtkTextView *pipeline_text_view;
static GtkWidget *pipeline_box;
static gulong text_view_handler_id = 0;
+static const gchar *
+gnac_profiles_unknown_init(UpdateTextBufferFunc call_back);
+
+static AudioProfileGeneric *
+gnac_profiles_unknown_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile);
+
+static void
+gnac_profiles_unknown_generate_pipeline(GtkWidget *widget);
+
+static void
+gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile);
+
+static gchar *
+gnac_profiles_unknown_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_unknown_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_unknown_get_description(void);
+
+static GtkWidget *
+gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile);
+
+static void
+gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile);
+
+static AudioProfileGeneric *
+gnac_profiles_unknown_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
+static void
+gnac_profiles_unknown_clean_up(void);
+
+static void
+gnac_profiles_unknown_set_pipeline_text_view(GtkTextView *text_view,
+ GtkWidget *box);
+
static gboolean
gnac_profiles_unknown_text_view_handler(GtkWidget *widget,
gpointer data);
-static void
-gnac_profiles_unknown_on_hide(GtkWidget *widget,
- gpointer data);
-
FormatModuleFuncs
-gnac_profiles_unknown_get_funcs(void) {
+gnac_profiles_unknown_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_unknown_init,
gnac_profiles_unknown_get_description,
@@ -84,32 +121,17 @@ gnac_profiles_unknown_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_unknown_init(UpdateTextBufferFunc call_back)
{
- GtkWidget *widget;
- GError *error = NULL;
-
- unknown_bfi.builder = gtk_builder_new();
- if (!gtk_builder_add_from_file(unknown_bfi.builder,
- unknown_bfi.gtkbuilder_xml_file, &error))
- {
- g_printerr("%s\n", error->message);
- g_error_free(error);
- gnac_exit(EXIT_FAILURE);
- }
-
- widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
- "properties-alignment"));
-
- g_signal_connect(G_OBJECT(widget), "hide",
- G_CALLBACK(gnac_profiles_unknown_on_hide), NULL);
+ unknown_bfi.builder = gnac_utils_create_gtk_builder(
+ unknown_bfi.gtkbuilder_xml_file);
return unknown_bfi.format_id;
}
-void
+static void
gnac_profiles_unknown_set_pipeline_text_view(GtkTextView *text_view,
GtkWidget *box)
{
@@ -118,89 +140,84 @@ gnac_profiles_unknown_set_pipeline_text_view(GtkTextView *text_view,
}
-void
-gnac_profiles_unknown_generate_pipeline(GtkWidget *w)
+static void
+gnac_profiles_unknown_generate_pipeline(GtkWidget *widget)
{
}
-void
+static void
gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile)
{
GtkWidget *widget;
GtkTextBuffer *text_buffer;
- widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
- "entry-extension"));
+ widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
- if (profile == NULL) {
+ if (!profile) {
gtk_entry_set_text(GTK_ENTRY(widget), "");
- if (unknown_bfi.pipeline != NULL) {
+ if (unknown_bfi.pipeline) {
g_free(unknown_bfi.pipeline);
unknown_bfi.pipeline = NULL;
}
} else {
gtk_entry_set_text(GTK_ENTRY(widget), profile->extension);
-
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pipeline_text_view));
gtk_text_buffer_set_text(text_buffer, profile->pipeline,
- strlen(profile->pipeline));
+ g_utf8_strlen(profile->pipeline, -1));
unknown_bfi.pipeline = g_strdup(profile->pipeline);
}
}
-gchar *
+static gchar *
gnac_profiles_unknown_get_combo_format_name(void)
{
return g_strdup(unknown_bfi.format_name);
}
-void
+static void
gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile)
{
gnac_profiles_utils_free_audio_profile_generic(profile);
}
-AudioProfileGeneric *
+static AudioProfileGeneric *
gnac_profiles_unknown_generate_audio_profile(GError **error)
{
AudioProfileGeneric *profile;
GtkWidget *widget;
const gchar *extension;
- widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
- "entry-extension"));
+ widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
extension = gtk_entry_get_text(GTK_ENTRY(widget));
if (gnac_utils_string_is_null_or_empty(extension)) {
- if ((error) && (*error == NULL)) {
+ if (error && *error == NULL) {
*error = g_error_new(g_quark_from_static_string("gnac"), 0,
_("The extension field must be non-empty"));
}
return NULL;
} else {
profile = gnac_profiles_utils_allocate_audio_profile_generic();
-
profile->extension = g_strdup(extension);
profile->format_id = g_strdup(unknown_bfi.format_id);
profile->format_name = g_strdup(unknown_bfi.format_name);
profile->channels = g_strdup("-1");
profile->rate = g_strdup("-1");
-
return profile;
}
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
{
gtk_text_view_set_editable(pipeline_text_view, TRUE);
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_unknown_fullfill_fields(profile);
}
@@ -209,9 +226,7 @@ gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
{
GtkTextBuffer *text_buffer;
- #ifndef GNOME_ENABLE_DEBUG
- gtk_widget_show(GTK_WIDGET(pipeline_box));
- #endif /* GNOME_ENABLE_DEBUG */
+ gtk_widget_show(GTK_WIDGET(pipeline_box));
text_view_handler_id = g_signal_connect(G_OBJECT(pipeline_text_view),
"focus-out-event",
@@ -220,24 +235,23 @@ gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pipeline_text_view));
- if (unknown_bfi.pipeline != NULL) {
+ if (unknown_bfi.pipeline) {
gtk_text_buffer_set_text(text_buffer, unknown_bfi.pipeline,
- strlen(unknown_bfi.pipeline));
+ g_utf8_strlen(unknown_bfi.pipeline, -1));
} else {
gtk_text_buffer_set_text(text_buffer, base_pipeline,
- strlen(base_pipeline));
+ g_utf8_strlen(base_pipeline, -1));
}
}
- return gnac_profiles_default_get_widget(profile, &unknown_bfi);
+ return gnac_profiles_default_get_properties_alignment(&unknown_bfi);
}
-void
+static void
gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile)
{
XMLDoc *doc;
-
doc = gnac_profiles_default_save_profile((AudioProfileGeneric*) profile,
&unknown_bfi);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
@@ -245,7 +259,7 @@ gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile)
}
-AudioProfileGeneric *
+static AudioProfileGeneric *
gnac_profiles_unknown_load_specific_properties(
XMLDoc *doc G_GNUC_UNUSED,
AudioProfileGeneric *generic)
@@ -254,26 +268,25 @@ gnac_profiles_unknown_load_specific_properties(
}
-void
-gnac_profiles_unknown_clean_up(void) {
+static void
+gnac_profiles_unknown_clean_up(void)
+{
GtkWidget *widget;
-
- widget = GTK_WIDGET(gtk_builder_get_object(unknown_bfi.builder,
- "properties-alignment"));
+ widget = gnac_profiles_utils_get_widget(&unknown_bfi, "properties-alignment");
g_free(unknown_bfi.pipeline);
g_object_unref(unknown_bfi.builder);
gtk_widget_destroy(widget);
}
-const gchar *
+static const gchar *
gnac_profiles_unknown_get_plugin_name(void)
{
return unknown_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_unknown_get_description(void)
{
return unknown_bfi.description;
@@ -284,23 +297,16 @@ static gboolean
gnac_profiles_unknown_text_view_handler(GtkWidget *widget,
gpointer data)
{
- GtkTextBuffer *text_buffer;
- GtkTextIter start;
- GtkTextIter end;
-
g_free(unknown_bfi.pipeline);
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pipeline_text_view));
- gtk_text_buffer_get_start_iter(text_buffer, &start);
- gtk_text_buffer_get_end_iter(text_buffer, &end);
- unknown_bfi.pipeline = gtk_text_buffer_get_text(text_buffer,
- &start, &end, FALSE);
+ unknown_bfi.pipeline = gnac_profiles_utils_text_view_get_text(
+ GTK_TEXT_VIEW(pipeline_text_view));
return FALSE;
}
-static void
+void
gnac_profiles_unknown_on_hide(GtkWidget *widget,
gpointer data)
{
diff --git a/src/profiles/formats/gnac-profiles-unknown.h b/src/profiles/formats/gnac-profiles-unknown.h
index 4871b2c..c2cb9f1 100644
--- a/src/profiles/formats/gnac-profiles-unknown.h
+++ b/src/profiles/formats/gnac-profiles-unknown.h
@@ -33,46 +33,9 @@ G_BEGIN_DECLS
FormatModuleFuncs
gnac_profiles_unknown_get_funcs(void);
-const gchar *
-gnac_profiles_unknown_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_unknown_generate_pipeline(GtkWidget *w);
-
-AudioProfileGeneric *
-gnac_profiles_unknown_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile);
-
-void
-gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile);
-
-gchar *
-gnac_profiles_unknown_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_unknown_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_unknown_get_description(void);
-
-GtkWidget *
-gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile);
-
-void
-gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile);
-
-AudioProfileGeneric *
-gnac_profiles_unknown_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_unknown_clean_up(void);
-
void
-gnac_profiles_unknown_set_pipeline_text_view(GtkTextView *text_view,
- GtkWidget *box);
+gnac_profiles_unknown_on_hide(GtkWidget *widget,
+ gpointer data);
G_END_DECLS
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index df251e5..763e575 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -24,11 +24,26 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-vorbis.h"
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gdouble quality;
+ gchar *bitrate;
+ gchar *min_bitrate;
+ gchar *max_bitrate;
+}
+AudioProfileVorbis;
+
+typedef enum {
+ VARIABLE_BITRATE,
+ CONSTANT_BITRATE
+} EncodingMode;
+
BasicFormatInfo vorbis_bfi = {
PKGDATADIR "/profiles/gnac-profiles-vorbis.xml",
NULL,
@@ -44,6 +59,45 @@ BasicFormatInfo vorbis_bfi = {
NULL
};
+static UpdateTextBufferFunc update_text_buffer_call_back;
+
+static const gchar *
+gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_vorbis_generate_pipeline(GtkWidget *w);
+
+static AudioProfileVorbis *
+gnac_profiles_vorbis_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile);
+
+static void
+gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile);
+
+static gchar *
+gnac_profiles_vorbis_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_vorbis_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_vorbis_get_description(void);
+
+static GtkWidget *
+gnac_profiles_vorbis_get_widget(AudioProfileVorbis *profile);
+
+static void
+gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile);
+
+static AudioProfileVorbis *
+gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
+static void
+gnac_profiles_vorbis_clean_up(void);
+
static void
gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget);
@@ -54,11 +108,10 @@ gnac_profiles_vorbis_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
static AudioProfileVorbis *
gnac_profiles_vorbis_allocate_audio_profile(void);
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
FormatModuleFuncs
-gnac_profiles_vorbis_get_funcs(void) {
+gnac_profiles_vorbis_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_vorbis_init,
gnac_profiles_vorbis_get_description,
@@ -78,7 +131,7 @@ gnac_profiles_vorbis_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
{
GtkWidget *widget;
@@ -135,25 +188,25 @@ gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
{
- gint index;
- gint i;
+ guint i;
+ EncodingMode encoding_mode;
- GtkWidget *widgets_tab[8] = {
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "label-quality")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "hbox-quality")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "label-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "hbox-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "checkbutton-min-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "checkbutton-max-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "combo-max-vbr")),
- GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder, "combo-min-vbr"))
+ GtkWidget *widgets_tab[] = {
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "label-quality"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "hbox-quality"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "label-bitrate"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "hbox-bitrate"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "checkbutton-min-bitrate"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "checkbutton-max-bitrate"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-max-vbr"),
+ gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-min-vbr")
};
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- for (i = 0; i < 8; ++i) {
- if (((index == 0) && ((i >= 4) || (i <= 1)))
- || ((index == 1) && ((i == 2) || (i == 3))))
+ for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
+ if ((encoding_mode == VARIABLE_BITRATE && (i >= 4 || i <= 1)) ||
+ (encoding_mode == CONSTANT_BITRATE && (i == 2 || i == 3)))
{
gtk_widget_show(widgets_tab[i]);
} else {
@@ -163,28 +216,27 @@ gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
}
-void
+static void
gnac_profiles_vorbis_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
gchar *pipeline;
- gint index;
+ EncodingMode encoding_mode;
pipeline = gnac_profiles_default_generate_pipeline(&vorbis_bfi);
- widget = GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder,
- "combo-encoding-mode"));
+ widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
if (w == widget) {
gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(w));
}
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- if (index == 1) {
+ if (encoding_mode == CONSTANT_BITRATE) {
pipeline = gnac_profiles_utils_add_properties_combo(pipeline,
&vorbis_bfi, "combo-bitrate", NULL);
- } else if (index == 0) {
+ } else if (encoding_mode == VARIABLE_BITRATE) {
pipeline = gnac_profiles_utils_add_properties_slider_format(pipeline,
&vorbis_bfi, "%.1f", "slider-quality", NULL);
@@ -214,7 +266,7 @@ gnac_profiles_vorbis_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
}
-void
+static void
gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
{
GtkWidget *widget;
@@ -237,27 +289,26 @@ gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
NULL);
} else {
- widget = GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder,
- "combo-encoding-mode"));
+ 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), 1);
- } else {
+ 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), 0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
}
}
}
-gchar *
+static gchar *
gnac_profiles_vorbis_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&vorbis_bfi);
@@ -280,9 +331,11 @@ gnac_profiles_vorbis_allocate_audio_profile(void)
}
-void
+static void
gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile->bitrate);
@@ -292,24 +345,23 @@ gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile)
}
-AudioProfileVorbis *
+static AudioProfileVorbis *
gnac_profiles_vorbis_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
AudioProfileVorbis *profile;
GtkWidget *widget;
- gint index;
+ EncodingMode encoding_mode;
generic = gnac_profiles_default_generate_audio_profile(&vorbis_bfi);
profile = gnac_profiles_vorbis_allocate_audio_profile();
profile->generic = generic;
- widget = GTK_WIDGET(gtk_builder_get_object(vorbis_bfi.builder,
- "combo-encoding-mode"));
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
+ encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- if (index == 1) {
+ if (encoding_mode == CONSTANT_BITRATE) {
gnac_profiles_utils_get_values_combo_and_set(&vorbis_bfi,
"combo-bitrate", &profile->bitrate, NULL);
} else {
@@ -326,17 +378,17 @@ gnac_profiles_vorbis_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_vorbis_get_widget(AudioProfileVorbis *profile)
{
if (profile != NULL) {
gnac_profiles_vorbis_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile, &vorbis_bfi);
+ return gnac_profiles_default_get_properties_alignment(&vorbis_bfi);
}
-void
+static void
gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
{
XMLDoc *doc;
@@ -347,9 +399,9 @@ gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &vorbis_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"quality", quality_str,
- "bitrate", (profile->bitrate == NULL) ? "" : profile->bitrate,
- "min-bitrate", (profile->min_bitrate == NULL) ? "" : profile->min_bitrate,
- "max-bitrate", (profile->max_bitrate == NULL) ? "" : profile->max_bitrate,
+ "bitrate", profile->bitrate ? profile->bitrate : "",
+ "min-bitrate", profile->min_bitrate ? profile->min_bitrate : "",
+ "max-bitrate", profile->max_bitrate ? profile->max_bitrate : "",
NULL);
/* Cleanup */
@@ -359,7 +411,7 @@ gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
}
-AudioProfileVorbis *
+static AudioProfileVorbis *
gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -385,8 +437,9 @@ gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
}
-void
-gnac_profiles_vorbis_clean_up(void) {
+static void
+gnac_profiles_vorbis_clean_up(void)
+{
gnac_profiles_default_clean_up(&vorbis_bfi);
gnac_profiles_utils_free_combo_values(&vorbis_bfi,
"combo-bitrate",
@@ -399,14 +452,14 @@ gnac_profiles_vorbis_clean_up(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_vorbis_get_plugin_name(void)
{
return vorbis_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_vorbis_get_description(void)
{
return vorbis_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-vorbis.h b/src/profiles/formats/gnac-profiles-vorbis.h
index 189ccf7..57246c8 100644
--- a/src/profiles/formats/gnac-profiles-vorbis.h
+++ b/src/profiles/formats/gnac-profiles-vorbis.h
@@ -30,57 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gdouble quality;
- gchar *bitrate;
- gchar *min_bitrate;
- gchar *max_bitrate;
-}
-AudioProfileVorbis;
-
FormatModuleFuncs
gnac_profiles_vorbis_get_funcs(void);
-const gchar *
-gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_vorbis_generate_pipeline(GtkWidget *w);
-
-AudioProfileVorbis *
-gnac_profiles_vorbis_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile);
-
-void
-gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile);
-
-gchar *
-gnac_profiles_vorbis_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_vorbis_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_vorbis_get_description(void);
-
-GtkWidget *
-gnac_profiles_vorbis_get_widget(AudioProfileVorbis *profile);
-
-void
-gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile);
-
-AudioProfileVorbis *
-gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_vorbis_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_VORBIS_H */
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index e69fb0c..3103cba 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -24,7 +24,6 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-wav.h"
@@ -46,9 +45,47 @@ BasicFormatInfo wav_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
+static const gchar *
+gnac_profiles_wav_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_wav_generate_pipeline(GtkWidget *w);
+
+static void
+gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile);
+
+static AudioProfileGeneric *
+gnac_profiles_wav_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_wav_free_audio_profile(AudioProfileGeneric *profile);
+
+static gchar *
+gnac_profiles_wav_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_wav_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_wav_get_description(void);
+
+static GtkWidget *
+gnac_profiles_wav_get_widget(AudioProfileGeneric *profile);
+
+static void
+gnac_profiles_wav_save_profile(AudioProfileGeneric *profile);
+
+static AudioProfileGeneric *
+gnac_profiles_wav_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
+static void
+gnac_profiles_wav_clean_up(void);
+
FormatModuleFuncs
-gnac_profiles_wav_get_funcs(void) {
+gnac_profiles_wav_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_wav_init,
gnac_profiles_wav_get_description,
@@ -68,7 +105,7 @@ gnac_profiles_wav_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
{
update_text_buffer_call_back = call_back;
@@ -84,7 +121,7 @@ gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
}
-void
+static void
gnac_profiles_wav_generate_pipeline(GtkWidget *w)
{
gchar *pipeline;
@@ -99,42 +136,44 @@ gnac_profiles_wav_generate_pipeline(GtkWidget *w)
}
-void
+static void
gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile)
{
}
-gchar *
+static gchar *
gnac_profiles_wav_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&wav_bfi);
}
-void
+static void
gnac_profiles_wav_free_audio_profile(AudioProfileGeneric *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
}
-AudioProfileGeneric *
+static AudioProfileGeneric *
gnac_profiles_wav_generate_audio_profile(GError **error)
{
return gnac_profiles_default_generate_audio_profile(&wav_bfi);
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_wav_get_widget(AudioProfileGeneric *profile)
{
- return gnac_profiles_default_get_widget(profile, &wav_bfi);
+ return gnac_profiles_default_get_properties_alignment(&wav_bfi);
}
-void
+static void
gnac_profiles_wav_save_profile(AudioProfileGeneric *profile)
{
XMLDoc *doc;
@@ -146,7 +185,7 @@ gnac_profiles_wav_save_profile(AudioProfileGeneric *profile)
}
-AudioProfileGeneric *
+static AudioProfileGeneric *
gnac_profiles_wav_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -154,7 +193,7 @@ gnac_profiles_wav_load_specific_properties(XMLDoc *doc,
}
-void
+static void
gnac_profiles_wav_clean_up(void)
{
gnac_profiles_default_clean_up(&wav_bfi);
@@ -162,14 +201,14 @@ gnac_profiles_wav_clean_up(void)
}
-const gchar *
+static const gchar *
gnac_profiles_wav_get_plugin_name(void)
{
return wav_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_wav_get_description(void)
{
return wav_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-wav.h b/src/profiles/formats/gnac-profiles-wav.h
index a5c52f9..15919c9 100644
--- a/src/profiles/formats/gnac-profiles-wav.h
+++ b/src/profiles/formats/gnac-profiles-wav.h
@@ -33,43 +33,6 @@ G_BEGIN_DECLS
FormatModuleFuncs
gnac_profiles_wav_get_funcs(void);
-const gchar *
-gnac_profiles_wav_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_wav_generate_pipeline(GtkWidget *w);
-
-AudioProfileGeneric *
-gnac_profiles_wav_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_wav_free_audio_profile(AudioProfileGeneric *profile);
-
-void
-gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile);
-
-gchar *
-gnac_profiles_wav_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_wav_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_wav_get_description(void);
-
-GtkWidget *
-gnac_profiles_wav_get_widget(AudioProfileGeneric *profile);
-
-void
-gnac_profiles_wav_save_profile(AudioProfileGeneric *profile);
-
-AudioProfileGeneric *
-gnac_profiles_wav_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_wav_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_WAV_H */
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index aa6a084..6e60428 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -24,11 +24,28 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-profiles-wavpack.h"
+typedef struct
+{
+ AudioProfileGeneric *generic;
+
+ gchar *mode;
+ gdouble bitrate;
+ gdouble bits_per_sample;
+ gdouble extra_processing;
+ gchar *joint_stereo_mode;
+ gchar *md5;
+}
+AudioProfileWavpack;
+
+typedef enum {
+ AVERAGE_BITRATE,
+ BITS_PER_SAMPLE
+} ControlMethod;
+
BasicFormatInfo wavpack_bfi = {
PKGDATADIR "/profiles/gnac-profiles-wavpack.xml",
NULL,
@@ -44,6 +61,45 @@ BasicFormatInfo wavpack_bfi = {
NULL
};
+static UpdateTextBufferFunc update_text_buffer_call_back;
+
+static const gchar *
+gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back);
+
+static void
+gnac_profiles_wavpack_generate_pipeline(GtkWidget *w);
+
+static AudioProfileWavpack *
+gnac_profiles_wavpack_generate_audio_profile(GError **error);
+
+static void
+gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile);
+
+static void
+gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile);
+
+static gchar *
+gnac_profiles_wavpack_get_combo_format_name(void);
+
+static const gchar *
+gnac_profiles_wavpack_get_plugin_name(void);
+
+static const gchar *
+gnac_profiles_wavpack_get_description(void);
+
+static GtkWidget *
+gnac_profiles_wavpack_get_widget(AudioProfileWavpack *profile);
+
+static void
+gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile);
+
+static AudioProfileWavpack *
+gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
+ AudioProfileGeneric *generic);
+
+static void
+gnac_profiles_wavpack_clean_up(void);
+
static void
gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget);
@@ -58,11 +114,10 @@ gnac_profiles_wavpack_joint_stereo_mode_on_toggle(GtkToggleButton *togglebutton,
static AudioProfileWavpack *
gnac_profiles_wavpack_allocate_audio_profile(void);
-static UpdateTextBufferFunc update_text_buffer_call_back;
-
FormatModuleFuncs
-gnac_profiles_wavpack_get_funcs(void) {
+gnac_profiles_wavpack_get_funcs(void)
+{
FormatModuleFuncs funcs = {
gnac_profiles_wavpack_init,
gnac_profiles_wavpack_get_description,
@@ -82,7 +137,7 @@ gnac_profiles_wavpack_get_funcs(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
{
GtkWidget *widget;
@@ -112,8 +167,7 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
widget = gnac_profiles_utils_all_in_one_for_slider(&wavpack_bfi,
G_CALLBACK(gnac_profiles_wavpack_generate_pipeline),
"slider-extra-processing", "//variable[ id='extra-processing']/*");
- widget2 = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "label-extra-processing")),
+ widget2 = gnac_profiles_utils_get_widget(&wavpack_bfi, "label-extra-processing"),
gnac_profiles_utils_add_description_tooltip(&wavpack_bfi,
"//variable[ id='extra-processing']/description",
widget, widget2, NULL);
@@ -156,25 +210,27 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
{
- gint index;
- gint i;
- GtkWidget *check;
+ guint i;
+ ControlMethod control_method;
+ gboolean bitrate_ctrl_enabled;
+ GtkToggleButton *bitrate_ctrl_btn;
- GtkWidget *widgets_tab[4] = {
- GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder, "label-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder, "slider-bitrate")),
- GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder, "label-bits-per-sample")),
- GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder, "slider-bits-per-sample")),
+ GtkWidget *widgets_tab[] = {
+ gnac_profiles_utils_get_widget(&wavpack_bfi, "label-bitrate"),
+ gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bitrate"),
+ gnac_profiles_utils_get_widget(&wavpack_bfi, "label-bits-per-sample"),
+ gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bits-per-sample"),
};
- check = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "checkbutton-bitrate-control"));
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ bitrate_ctrl_btn = GTK_TOGGLE_BUTTON(
+ gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control"));
+ bitrate_ctrl_enabled = gtk_toggle_button_get_active(bitrate_ctrl_btn);
+ control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- for (i = 0; i < 4; ++i) {
- if (((gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))))
- && (((index == 0) && (i < 2))
- || ((index == 1) && (i >= 2))))
+ for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
+ if (bitrate_ctrl_enabled &&
+ ((control_method == AVERAGE_BITRATE && i < 2) ||
+ (control_method == BITS_PER_SAMPLE && i >= 2)))
{
gtk_widget_show(widgets_tab[i]);
} else {
@@ -184,18 +240,17 @@ gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
}
-void
+static void
gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
GtkWidget *check;
gchar *pipeline;
- gint index;
+ ControlMethod control_method;
pipeline = gnac_profiles_default_generate_pipeline(&wavpack_bfi);
- widget = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "combo-bitrate-control"));
+ 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));
@@ -212,14 +267,12 @@ gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &wavpack_bfi,
"checkbutton-md5", NULL);
- check = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "checkbutton-bitrate-control"));
+ check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- if (index == 0) {
- widget = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "slider-bitrate"));
+ control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ if (control_method == AVERAGE_BITRATE) {
+ widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bitrate");
pipeline = gnac_profiles_utils_add_property_slider(pipeline,
"%.0f", 1000, widget);
} else {
@@ -243,10 +296,8 @@ gnac_profiles_wavpack_bitrate_control_on_toggle(GtkToggleButton *togglebutton,
GtkWidget *label;
GtkWidget *hbox;
- label = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "label-control-method"));
- hbox = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "hbox-control-method"));
+ label = gnac_profiles_utils_get_widget(&wavpack_bfi, "label-control-method");
+ hbox = gnac_profiles_utils_get_widget(&wavpack_bfi, "hbox-control-method");
if (gtk_toggle_button_get_active(togglebutton)) {
gtk_widget_show(hbox);
@@ -270,7 +321,7 @@ gnac_profiles_wavpack_joint_stereo_mode_on_toggle(GtkToggleButton *togglebutton,
}
-void
+static void
gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
{
GtkWidget *widget;
@@ -308,27 +359,25 @@ gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
gnac_profiles_utils_set_values_check(&wavpack_bfi,
"checkbutton-md5", profile->md5, NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "combo-bitrate-control"));
- check = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "checkbutton-bitrate-control"));
+ widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
+ 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), 0);
+ 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), 1);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(widget), BITS_PER_SAMPLE);
}
}
}
-gchar *
+static gchar *
gnac_profiles_wavpack_get_combo_format_name(void)
{
return gnac_profiles_default_get_combo_format_name(&wavpack_bfi);
@@ -353,9 +402,11 @@ gnac_profiles_wavpack_allocate_audio_profile(void)
}
-void
+static void
gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile)
{
+ if (!profile) return;
+
gnac_profiles_utils_free_audio_profile_generic(profile->generic);
g_free(profile->mode);
@@ -365,14 +416,14 @@ gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile)
}
-AudioProfileWavpack *
+static AudioProfileWavpack *
gnac_profiles_wavpack_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
AudioProfileWavpack *profile;
GtkWidget *widget;
GtkWidget *check;
- gint index;
+ ControlMethod control_method;
generic = gnac_profiles_default_generate_audio_profile(&wavpack_bfi);
@@ -393,14 +444,12 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
gnac_profiles_utils_get_values_check_and_set(&wavpack_bfi,
"checkbutton-md5", &profile->md5, NULL);
- widget = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "combo-bitrate-control"));
- check = GTK_WIDGET(gtk_builder_get_object(wavpack_bfi.builder,
- "checkbutton-bitrate-control"));
+ widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
+ check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
- if (index == 0) {
+ 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,
"slider-bitrate", &profile->bitrate, NULL);
} else {
@@ -413,17 +462,17 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
}
-GtkWidget *
+static GtkWidget *
gnac_profiles_wavpack_get_widget(AudioProfileWavpack *profile)
{
if (profile != NULL) {
gnac_profiles_wavpack_fullfill_fields(profile);
}
- return gnac_profiles_default_get_widget(profile, &wavpack_bfi);
+ return gnac_profiles_default_get_properties_alignment(&wavpack_bfi);
}
-void
+static void
gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
{
XMLDoc *doc;
@@ -443,12 +492,11 @@ gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &wavpack_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"mode", profile->mode,
- "bitrate", (bitrate_str == NULL) ? "" : bitrate_str,
- "bits-per-sample",
- (bits_per_sample_str == NULL) ? "" : bits_per_sample_str,
+ "bitrate", bitrate_str ? bitrate_str : "",
+ "bits-per-sample", bits_per_sample_str ? bits_per_sample_str : "",
"extra-processing", extra_processing_str,
"joint-stereo-mode",
- (profile->joint_stereo_mode) ? "" : profile->joint_stereo_mode,
+ profile->joint_stereo_mode ? profile->joint_stereo_mode : "",
"md5", profile->md5,
NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
@@ -461,7 +509,7 @@ gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
}
-AudioProfileWavpack *
+static AudioProfileWavpack *
gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
@@ -499,8 +547,9 @@ gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
}
-void
-gnac_profiles_wavpack_clean_up(void) {
+static void
+gnac_profiles_wavpack_clean_up(void)
+{
gnac_profiles_default_clean_up(&wavpack_bfi);
gnac_profiles_utils_free_combo_values(&wavpack_bfi,
"combo-bitrate-control",
@@ -517,14 +566,14 @@ gnac_profiles_wavpack_clean_up(void) {
}
-const gchar *
+static const gchar *
gnac_profiles_wavpack_get_plugin_name(void)
{
return wavpack_bfi.format_plugin_name;
}
-const gchar *
+static const gchar *
gnac_profiles_wavpack_get_description(void)
{
return wavpack_bfi.description;
diff --git a/src/profiles/formats/gnac-profiles-wavpack.h b/src/profiles/formats/gnac-profiles-wavpack.h
index 4c16b3e..40ab698 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.h
+++ b/src/profiles/formats/gnac-profiles-wavpack.h
@@ -30,59 +30,9 @@
G_BEGIN_DECLS
-typedef struct
-{
- AudioProfileGeneric *generic;
-
- gchar *mode;
- gdouble bitrate;
- gdouble bits_per_sample;
- gdouble extra_processing;
- gchar *joint_stereo_mode;
- gchar *md5;
-}
-AudioProfileWavpack;
-
FormatModuleFuncs
gnac_profiles_wavpack_get_funcs(void);
-const gchar *
-gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back);
-
-void
-gnac_profiles_wavpack_generate_pipeline(GtkWidget *w);
-
-AudioProfileWavpack *
-gnac_profiles_wavpack_generate_audio_profile(GError **error);
-
-void
-gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile);
-
-void
-gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile);
-
-gchar *
-gnac_profiles_wavpack_get_combo_format_name(void);
-
-const gchar *
-gnac_profiles_wavpack_get_plugin_name(void);
-
-const gchar *
-gnac_profiles_wavpack_get_description(void);
-
-GtkWidget *
-gnac_profiles_wavpack_get_widget(AudioProfileWavpack *profile);
-
-void
-gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile);
-
-AudioProfileWavpack *
-gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
- AudioProfileGeneric *generic);
-
-void
-gnac_profiles_wavpack_clean_up(void);
-
G_END_DECLS
#endif /* GNAC_PROFILES_WAVPACK_H */
diff --git a/src/profiles/gnac-profiles-default.c b/src/profiles/gnac-profiles-default.c
index a64a898..4d2c073 100755
--- a/src/profiles/gnac-profiles-default.c
+++ b/src/profiles/gnac-profiles-default.c
@@ -24,7 +24,6 @@
*/
#include <glib/gstdio.h>
-#include <stdlib.h>
#include "gnac-main.h"
#include "gnac-profiles-default.h"
@@ -50,8 +49,7 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
gnac_exit(EXIT_FAILURE);
}
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "properties-alignment"));
+ widget = gnac_profiles_default_get_properties_alignment(bfi);
if (!gtk_builder_add_from_file(bfi->builder,
PKGDATADIR "/profiles/gnac-profiles-base-advanced.xml", &error))
@@ -61,11 +59,10 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
gnac_exit(EXIT_FAILURE);
}
- profile_advanced_base_widget = GTK_WIDGET(gtk_builder_get_object(
- bfi->builder, "table-advanced-base"));
+ profile_advanced_base_widget = gnac_profiles_utils_get_widget(bfi,
+ "table-advanced-base");
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "properties-table-advanced"));
+ widget = gnac_profiles_utils_get_widget(bfi, "properties-table-advanced");
gtk_table_attach_defaults(GTK_TABLE(widget),
profile_advanced_base_widget, 0, 2, 0, 1);
@@ -122,14 +119,9 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
GtkWidget *
-gnac_profiles_default_get_widget(gpointer profile,
- BasicFormatInfo *bfi)
+gnac_profiles_default_get_properties_alignment(BasicFormatInfo *bfi)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "properties-alignment"));
- return widget;
+ return gnac_profiles_utils_get_widget(bfi, "properties-alignment");
}
@@ -141,16 +133,14 @@ gnac_profiles_default_generate_pipeline(BasicFormatInfo *bfi)
gchar *rate;
gchar *pipeline;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, "combo-channels"));
+ widget = gnac_profiles_utils_get_widget(bfi, "combo-channels");
channels = gnac_profiles_utils_get_value_combo(widget);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "combo-sample-rate"));
+ widget = gnac_profiles_utils_get_widget(bfi, "combo-sample-rate");
rate = gnac_profiles_utils_get_value_combo(widget);
pipeline = gnac_profiles_utils_get_basepipeline(channels, rate);
- /* Cleanup */
g_free(channels);
g_free(rate);
@@ -178,11 +168,10 @@ gnac_profiles_default_fullfill_fields(AudioProfileGeneric *profile,
gnac_profiles_utils_reinit_values_combo(bfi,
"combo-channels", "combo-sample-rate", NULL);
} else {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, "combo-channels"));
+ widget = gnac_profiles_utils_get_widget(bfi, "combo-channels");
gnac_profiles_utils_set_value_combo(widget, profile->channels);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "combo-sample-rate"));
+ widget = gnac_profiles_utils_get_widget(bfi, "combo-sample-rate");
gnac_profiles_utils_set_value_combo(widget, profile->rate);
}
}
@@ -201,10 +190,10 @@ gnac_profiles_default_generate_audio_profile(BasicFormatInfo *bfi)
profile->pipeline = g_strdup(bfi->pipeline);
profile->channels = gnac_profiles_utils_get_value_combo(
- GTK_WIDGET(gtk_builder_get_object(bfi->builder, "combo-channels")));
+ gnac_profiles_utils_get_widget(bfi, "combo-channels"));
profile->rate = gnac_profiles_utils_get_value_combo(
- GTK_WIDGET(gtk_builder_get_object(bfi->builder ,"combo-sample-rate")));
+ gnac_profiles_utils_get_widget(bfi, "combo-sample-rate"));
return profile;
}
@@ -270,10 +259,8 @@ gnac_profiles_default_clean_up(BasicFormatInfo *bfi)
GtkWidget *widget_advanced;
GtkWidget *widget;
- widget_advanced = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "table-advanced-base"));
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder,
- "properties-alignment"));
+ widget_advanced = gnac_profiles_utils_get_widget(bfi, "table-advanced-base");
+ widget = gnac_profiles_default_get_properties_alignment(bfi);
gnac_profiles_utils_free_combo_values(bfi, "combo-channels",
"combo-sample-rate", NULL);
gtk_widget_destroy(widget_advanced);
diff --git a/src/profiles/gnac-profiles-default.h b/src/profiles/gnac-profiles-default.h
index 8772110..fcbfc2d 100755
--- a/src/profiles/gnac-profiles-default.h
+++ b/src/profiles/gnac-profiles-default.h
@@ -68,8 +68,7 @@ gnac_profiles_default_init(BasicFormatInfo *bfi,
GCallback pipeline_callback);
GtkWidget *
-gnac_profiles_default_get_widget(gpointer profile,
- BasicFormatInfo *bfi);
+gnac_profiles_default_get_properties_alignment(BasicFormatInfo *bfi);
gchar *
gnac_profiles_default_get_combo_format_name(BasicFormatInfo *bfi);
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index 1dc9f53..4cfa101 100644
--- a/src/profiles/gnac-profiles-manager.c
+++ b/src/profiles/gnac-profiles-manager.c
@@ -29,9 +29,9 @@
#include <gio/gio.h>
#include <glib/gi18n.h>
-#include <stdlib.h>
#include "gnac-main.h"
+#include "gnac-profiles.h"
#include "gnac-profiles-default.h"
#include "gnac-profiles-manager.h"
#include "gnac-utils.h"
@@ -73,8 +73,6 @@ static GtkTargetEntry target_list[] = {
};
static guint n_targets = G_N_ELEMENTS(target_list);
-static StandardCallBack close_callback;
-static gboolean first_show = TRUE;
static void
gnac_profiles_mgr_populate(void);
@@ -150,18 +148,14 @@ gnac_profiles_mgr_on_treeselection_changed(void);
static GObject *
gnac_profiles_mgr_get_object(const gchar *object_name)
{
- GObject *object;
- object = gtk_builder_get_object(profiles_mgr_builder, object_name);
- return object;
+ return gtk_builder_get_object(profiles_mgr_builder, object_name);
}
static GtkWidget *
gnac_profiles_mgr_get_widget(const gchar *widget_name)
{
- GtkWidget *widget;
- widget = GTK_WIDGET(gnac_profiles_mgr_get_object(widget_name));
- return widget;
+ return GTK_WIDGET(gnac_profiles_mgr_get_object(widget_name));
}
@@ -176,7 +170,7 @@ gnac_profiles_mgr_set_widget_sensitive(const gchar *widget_name,
void
-gnac_profiles_mgr_init(StandardCallBack call_back)
+gnac_profiles_mgr_init(void)
{
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
@@ -184,8 +178,6 @@ gnac_profiles_mgr_init(StandardCallBack call_back)
GtkTreeModel *model;
GtkWidget *widget;
- close_callback = call_back;
-
profiles_mgr_builder = gnac_utils_create_gtk_builder(
PKGDATADIR "/profiles/gnac-profiles-manager.xml");
@@ -231,15 +223,15 @@ gnac_profiles_mgr_init(StandardCallBack call_back)
void
-gnac_profiles_mgr_set_parent(GtkWidget *parent)
+gnac_profiles_mgr_set_parent(GtkWindow *parent)
{
- GtkWidget *widget;
+ GtkWindow *window;
- widget = gnac_profiles_mgr_get_widget("profile_manager_window");
- gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent));
- gtk_window_set_position(GTK_WINDOW(widget), GTK_WIN_POS_CENTER_ON_PARENT);
+ window = GTK_WINDOW(gnac_profiles_mgr_get_widget("profile_manager_window"));
+ gtk_window_set_transient_for(window, parent);
+ gtk_window_set_position(window, GTK_WIN_POS_CENTER_ON_PARENT);
- gnac_profiles_properties_set_parent(widget);
+ gnac_profiles_properties_set_parent(window);
}
@@ -323,10 +315,12 @@ gnac_profiles_mgr_list_profiles(void)
gpointer name = (profile->generic)->name;
profiles = g_slist_append(profiles, name);
}
+
/* Cleanup */
g_free(profile_file_path);
g_free(profile_file_full_path);
}
+
g_object_unref(G_OBJECT(file_info));
}
@@ -342,6 +336,7 @@ gnac_profiles_mgr_list_profiles(void)
{
last_used_profile = NULL;
}
+
GSList *tmp;
for (tmp = profiles; tmp; tmp = g_slist_next(tmp)) {
gint pos = g_slist_position(profiles, tmp);
@@ -350,7 +345,7 @@ gnac_profiles_mgr_list_profiles(void)
* first profile was last used */
gchar *name = tmp->data;
gboolean found = ((pos == 0 && !last_used_profile)
- || (last_used_profile && g_str_equal(name, last_used_profile)));
+ || gnac_utils_str_equal(name, last_used_profile));
g_print("\t%2s) %s\n", found ? "*" : count_str, name);
g_free(count_str);
}
@@ -474,39 +469,40 @@ gnac_profiles_mgr_import_default_profiles(void)
G_FILE_ATTRIBUTE_STANDARD_NAME ","
G_FILE_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE, NULL, &error);
-
- if (files != NULL) {
- while ((file_info = g_file_enumerator_next_file(files, NULL, NULL)) != NULL)
- {
- if (g_file_info_get_file_type(file_info) == G_FILE_TYPE_REGULAR) {
- profile_file = g_file_enumerator_get_container(files);
- profile_file_path = g_file_get_path(profile_file);
- profile_file_name = g_file_info_get_name(file_info);
- profile_file_full_path = g_build_filename(profile_file_path,
- profile_file_name, NULL);
- profile = gnac_profiles_properties_load_profile_from_file(
- profile_file_full_path, profile_file_name, &error);
- if (profile != NULL) {
- gnac_profiles_properties_save_profile(profile);
- } else if (error) {
- libgnac_warning("%s", error->message);
- g_clear_error(&error);
- }
-
- /* Cleanup */
- g_free(profile_file_path);
- g_free(profile_file_full_path);
- gnac_profiles_properties_free_audio_profile(profile);
- }
- g_object_unref(G_OBJECT(file_info));
- }
- } else {
+ if (!files) {
libgnac_warning("%s: %s",
_("Unable to browse the default profiles directory"),
error->message);
g_error_free(error);
return;
}
+
+ while ((file_info = g_file_enumerator_next_file(files, NULL, NULL)) != NULL)
+ {
+ if (g_file_info_get_file_type(file_info) == G_FILE_TYPE_REGULAR) {
+ profile_file = g_file_enumerator_get_container(files);
+ profile_file_path = g_file_get_path(profile_file);
+ profile_file_name = g_file_info_get_name(file_info);
+ profile_file_full_path = g_build_filename(profile_file_path,
+ profile_file_name, NULL);
+ profile = gnac_profiles_properties_load_profile_from_file(
+ profile_file_full_path, profile_file_name, &error);
+ if (profile != NULL) {
+ gnac_profiles_properties_save_profile(profile);
+ } else if (error) {
+ libgnac_warning("%s", error->message);
+ g_clear_error(&error);
+ }
+
+ /* Cleanup */
+ g_free(profile_file_path);
+ g_free(profile_file_full_path);
+ gnac_profiles_properties_free_audio_profile(profile);
+ }
+
+ g_object_unref(G_OBJECT(file_info));
+ }
+
/* Cleanup */
g_object_unref(dir);
g_file_enumerator_close(files, NULL, NULL);
@@ -521,7 +517,7 @@ gnac_profiles_mgr_get_profiles_list(void)
GtkTreeModel *model;
GtkTreeIter iter;
AudioProfileGeneric *profile;
-
+
model = GTK_TREE_MODEL(gnac_profiles_mgr_get_object("liststore"));
if (gtk_tree_model_get_iter_first(model, &iter)) {
do {
@@ -529,6 +525,7 @@ gnac_profiles_mgr_get_profiles_list(void)
list = g_list_append(list, (gpointer) profile);
} while (gtk_tree_model_iter_next(model, &iter));
}
+
return list;
}
@@ -555,6 +552,7 @@ gnac_profiles_mgr_show(void)
{
GtkWidget *window;
GList *selected;
+ static gboolean first_show = TRUE;
if (!first_show) {
gnac_profiles_mgr_populate();
@@ -566,13 +564,12 @@ gnac_profiles_mgr_show(void)
gtk_widget_show(window);
selected = gnac_profiles_mgr_get_selected_rows();
- if (selected == NULL) {
+ if (!selected) {
gnac_profiles_mgr_show_description_frame(FALSE);
gnac_profiles_mgr_activate_buttons(FALSE);
}
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
}
@@ -590,6 +587,7 @@ gnac_profiles_mgr_clear(void)
gnac_profiles_properties_free_audio_profile(profile);
} while (gtk_tree_model_iter_next(model, &iter));
}
+
gtk_list_store_clear(GTK_LIST_STORE(model));
}
@@ -614,6 +612,7 @@ gnac_profiles_mgr_insert(gpointer profile)
2, generic->extension,
3, profile,
-1);
+
g_free(formatted_name);
}
@@ -640,10 +639,7 @@ gnac_profiles_mgr_remove(GtkTreeRowReference *ref)
}
gtk_tree_path_free(path);
-
- if (profile) {
- gnac_profiles_properties_free_audio_profile((AudioProfileGeneric*)profile);
- }
+ gnac_profiles_properties_free_audio_profile((AudioProfileGeneric*)profile);
}
@@ -722,8 +718,8 @@ gnac_profiles_mgr_get_selected_rows(void)
}
row_references = g_list_reverse(row_references);
- g_list_foreach(next_temp, (GFunc) gtk_tree_path_free, NULL);
- g_list_free(next_temp);
+
+ g_list_free_full(next_temp, (GDestroyNotify) gtk_tree_path_free);
return row_references;
}
@@ -782,15 +778,14 @@ static void
gnac_profiles_mgr_set_progress_bar_fraction(gdouble fraction)
{
GtkWidget *widget;
-
widget = gnac_profiles_mgr_get_widget("progressbar-import");
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widget), fraction);
}
static void
-gnac_profiles_mgr_display_status_message(const gchar *ok,
- const gchar *error)
+gnac_profiles_mgr_display_status_message(const gchar *success_message,
+ const gchar *error_message)
{
GtkWidget *frame_status;
GtkWidget *label_status_ok;
@@ -800,30 +795,34 @@ gnac_profiles_mgr_display_status_message(const gchar *ok,
frame_status = gnac_profiles_mgr_get_widget("frame-status");
- if ((ok == NULL) && (error == NULL)) {
+ if (!success_message && !error_message) {
gtk_widget_hide(frame_status);
+ return;
+ }
+
+ gtk_widget_show_all(frame_status);
+
+ label_status_ok = gnac_profiles_mgr_get_widget("label-status-ok");
+ image_status_ok = gnac_profiles_mgr_get_widget("image-status-ok");
+ label_status_error = gnac_profiles_mgr_get_widget("label-status-error");
+ image_status_error = gnac_profiles_mgr_get_widget("image-status-error");
+
+ if (success_message) {
+ gtk_label_set_markup(GTK_LABEL(label_status_ok), success_message);
+ gtk_widget_show(label_status_ok);
+ gtk_widget_show(image_status_ok);
} else {
- gtk_widget_show_all(frame_status);
- label_status_ok = gnac_profiles_mgr_get_widget("label-status-ok");
- image_status_ok = gnac_profiles_mgr_get_widget("image-status-ok");
- label_status_error = gnac_profiles_mgr_get_widget("label-status-error");
- image_status_error = gnac_profiles_mgr_get_widget("image-status-error");
- if (ok != NULL) {
- gtk_label_set_markup(GTK_LABEL(label_status_ok), ok);
- gtk_widget_show(label_status_ok);
- gtk_widget_show(image_status_ok);
- } else {
- gtk_widget_hide(label_status_ok);
- gtk_widget_hide(image_status_ok);
- }
- if (error != NULL) {
- gtk_label_set_markup(GTK_LABEL(label_status_error), error);
- gtk_widget_show(label_status_error);
- gtk_widget_show(image_status_error);
- } else {
- gtk_widget_hide(label_status_error);
- gtk_widget_hide(image_status_error);
- }
+ gtk_widget_hide(label_status_ok);
+ gtk_widget_hide(image_status_ok);
+ }
+
+ if (error_message) {
+ gtk_label_set_markup(GTK_LABEL(label_status_error), error_message);
+ gtk_widget_show(label_status_error);
+ gtk_widget_show(image_status_error);
+ } else {
+ gtk_widget_hide(label_status_error);
+ gtk_widget_hide(image_status_error);
}
}
@@ -842,16 +841,16 @@ gnac_profiles_mgr_on_drag_data_received(GtkWidget *widget,
GError *error = NULL;
ThreadCopyData *tcopy_data;
- tcopy_data = g_malloc(sizeof(ThreadCopyData));
uris = g_uri_list_extract_uris((const gchar*) selection_data->data);
-
- if (uris == NULL) {
- gtk_drag_finish (context, FALSE, FALSE, time);
+ if (!uris) {
+ gtk_drag_finish(context, FALSE, FALSE, time);
return;
}
+ tcopy_data = g_malloc(sizeof(ThreadCopyData));
tcopy_data->uris = uris;
tcopy_data->info = info;
+
g_thread_create((GThreadFunc) gnac_profiles_mgr_copy_and_load_files,
tcopy_data, TRUE, &error);
if (error) {
@@ -885,7 +884,6 @@ gnac_profiles_mgr_copy_and_load_files(gpointer data)
gdk_threads_enter();
gnac_profiles_mgr_set_window_sensitive(FALSE);
gnac_profiles_mgr_show_import_progressbar(TRUE);
- gdk_flush();
gdk_threads_leave();
while (uri != NULL) {
@@ -990,7 +988,6 @@ gnac_profiles_mgr_copy_and_load_files(gpointer data)
gnac_profiles_mgr_set_window_sensitive(TRUE);
gnac_profiles_mgr_show_import_progressbar(FALSE);
gnac_profiles_mgr_display_status_message(oks,errors);
- gdk_flush();
gdk_threads_leave();
/* Cleanup */
@@ -1017,7 +1014,6 @@ gnac_profiles_mgr_on_drag_profile_copied(goffset current_num_bytes,
gdk_threads_enter();
gnac_profiles_mgr_set_progress_bar_fraction(frac);
- gdk_flush();
gdk_threads_leave();
if (current_num_bytes >= total_num_bytes) {
@@ -1031,7 +1027,6 @@ gnac_profiles_mgr_on_drag_profile_copied(goffset current_num_bytes,
gdk_threads_enter();
gnac_profiles_properties_save_profile(profile);
gnac_profiles_mgr_insert(profile);
- gdk_flush();
gdk_threads_leave();
}
file = g_file_new_for_path(copy_data->path);
@@ -1082,25 +1077,12 @@ gnac_profiles_mgr_get_selected_uris(void)
}
uris[i] = NULL;
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
return uris;
}
-gboolean
-gnac_profiles_mgr_on_drag_drop(GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- guint time,
- gpointer user_data)
-{
- return TRUE;
-}
-
-
void
gnac_profiles_mgr_on_add(GtkWidget *widget,
gpointer data)
@@ -1147,6 +1129,7 @@ gnac_profiles_mgr_on_copy(GtkWidget *widget,
src = g_file_new_for_path(full_path);
dst = g_file_new_for_path(new_path);
+ g_free(full_path);
g_file_copy(src, dst, G_FILE_COPY_NONE, NULL, NULL, NULL, &error);
if (error)
@@ -1160,11 +1143,9 @@ gnac_profiles_mgr_on_copy(GtkWidget *widget,
g_clear_error(&error);
g_object_unref(src);
g_object_unref(dst);
- g_free(full_path);
g_free(new_path);
g_free(new_name);
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
return;
}
@@ -1189,11 +1170,9 @@ gnac_profiles_mgr_on_copy(GtkWidget *widget,
/* cleanup */
g_object_unref(src);
g_object_unref(dst);
- g_free(full_path);
g_free(new_path);
g_free(new_name);
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
}
@@ -1210,8 +1189,7 @@ gnac_profiles_mgr_on_edit(GtkWidget *widget,
COL_PROFILE, (gpointer*)&profile);
profile->generic->user_data = selected->data;
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
gnac_profiles_properties_show(profile, _("Edit Profile"),
G_CALLBACK(gnac_profiles_mgr_on_edit_profile));
@@ -1237,7 +1215,7 @@ gnac_profiles_mgr_on_edit_profile(GtkWidget *widget,
profile = (AudioProfileGeneric*) data;
generic = profile->generic;
- if (g_strcmp0(generic->name, old_generic->name)) {
+ if (!gnac_utils_str_equal(generic->name, old_generic->name)) {
gnac_profiles_mgr_delete_profile_file(old_generic->name);
}
@@ -1252,9 +1230,7 @@ gnac_profiles_mgr_on_edit_profile(GtkWidget *widget,
g_free(formatted_name);
gnac_profiles_properties_free_audio_profile(old_profile);
-
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
gnac_profiles_mgr_display_status_message(NULL, NULL);
@@ -1308,8 +1284,7 @@ gnac_profiles_mgr_on_remove(GtkWidget *widget,
/* Cleanup */
gtk_tree_path_free(path);
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
}
}
@@ -1332,30 +1307,28 @@ static void
gnac_profiles_mgr_on_treeselection_changed(void)
{
AudioProfileGeneric *profile;
+ gchar *descr;
GList *selected;
GtkWidget *widget;
selected = gnac_profiles_mgr_get_selected_rows();
- if (selected != NULL) {
- gchar *descr;
+ if (!selected) return;
- gnac_profiles_mgr_activate_buttons(TRUE);
- gnac_profiles_mgr_display_status_message(NULL, NULL);
-
- gnac_profiles_mgr_get((GtkTreeRowReference*)selected->data,
- COL_PROFILE, (gpointer*) &profile);
- widget = gnac_profiles_mgr_get_widget("label-description-content");
- descr = gnac_profiles_properties_filter_text_for_displaying(
- profile->generic->description, MAX_DESCR_DISPLAY_SIZE);
- gtk_label_set_text(GTK_LABEL(widget), descr);
- g_free(descr);
+ gnac_profiles_mgr_activate_buttons(TRUE);
+ gnac_profiles_mgr_display_status_message(NULL, NULL);
- gnac_profiles_mgr_show_description_frame(TRUE);
-
- /* Cleanup */
- g_list_foreach(selected, (GFunc)gtk_tree_row_reference_free, NULL);
- g_list_free(selected);
- }
+ gnac_profiles_mgr_get((GtkTreeRowReference*)selected->data,
+ COL_PROFILE, (gpointer*) &profile);
+ widget = gnac_profiles_mgr_get_widget("label-description-content");
+ descr = gnac_profiles_properties_filter_text_for_displaying(
+ profile->generic->description, MAX_DESCR_DISPLAY_SIZE);
+ gtk_label_set_text(GTK_LABEL(widget), descr);
+ g_free(descr);
+
+ gnac_profiles_mgr_show_description_frame(TRUE);
+
+ /* Cleanup */
+ g_list_free_full(selected, (GDestroyNotify) gtk_tree_row_reference_free);
}
@@ -1364,10 +1337,9 @@ gnac_profiles_mgr_on_close(GtkWidget *widget,
gpointer data)
{
GtkWidget *window;
-
window = gnac_profiles_mgr_get_widget("profile_manager_window");
gtk_widget_hide(window);
- close_callback(widget, data);
+ gnac_profiles_populate_combo();
}
diff --git a/src/profiles/gnac-profiles-manager.h b/src/profiles/gnac-profiles-manager.h
index 684aa2d..610c1ec 100644
--- a/src/profiles/gnac-profiles-manager.h
+++ b/src/profiles/gnac-profiles-manager.h
@@ -32,10 +32,10 @@
G_BEGIN_DECLS
void
-gnac_profiles_mgr_init(StandardCallBack call_back);
+gnac_profiles_mgr_init(void);
void
-gnac_profiles_mgr_set_parent(GtkWidget *parent);
+gnac_profiles_mgr_set_parent(GtkWindow *parent);
void
gnac_profiles_mgr_list_profiles(void);
@@ -67,14 +67,6 @@ gnac_profiles_mgr_on_drag_data_get(GtkWidget *widget,
guint time,
gpointer user_data);
-gboolean
-gnac_profiles_mgr_on_drag_drop(GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x,
- gint y,
- guint time,
- gpointer user_data);
-
void
gnac_profiles_mgr_on_add(GtkWidget *widget,
gpointer data);
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index 2b35a05..a0183d1 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -30,7 +30,6 @@
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
-#include <stdlib.h>
#include "formats/gnac-profiles-aac.h"
#include "formats/gnac-profiles-flac.h"
@@ -48,7 +47,6 @@
#include "libgnac-debug.h"
-#define NB_PLUGINS 8
#ifdef G_OS_WIN32
static const gchar forbidden_chars[] = {
@@ -61,7 +59,7 @@ static const gchar forbidden_chars[] = { '/', '\n', '\t' };
static const gchar *forbidden_chars_string = " /, <return>, <tab>";
#endif
-static FormatModuleGetFuncs formats_get_funcs[NB_PLUGINS] = {
+static FormatModuleGetFuncs formats_get_funcs[] = {
gnac_profiles_aac_get_funcs,
gnac_profiles_flac_get_funcs,
gnac_profiles_lame_get_funcs,
@@ -81,15 +79,16 @@ static GHashTable *formats;
static FormatModule *current_format_module;
static GtkBuilder *profiles_properties_builder = NULL;
-static gulong save_button_handler_id = 0;
static const gchar *current_profile_name;
static void
gnac_profiles_properties_init_format(void);
static void
-gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
- gpointer user_data);
+gnac_profiles_properties_name_set_text(const gchar *name);
+
+static void
+gnac_profiles_properties_description_set_text(const gchar *description);
static void
gnac_profiles_properties_update_textbuffer(const gchar *pipeline);
@@ -98,6 +97,9 @@ static void
gnac_profiles_properties_display_status_message(const gchar *error);
static gboolean
+gnac_profiles_properties_is_valid_profile_name(const gchar *name);
+
+static gboolean
gnac_profiles_properties_is_valid_filename_chars(const gchar *chars);
static gboolean
@@ -114,6 +116,7 @@ gnac_profiles_properties_name_description_set_text(const gchar *name,
static void
gnac_profiles_properties_reinit(void);
+
static GtkWidget *
gnac_profiles_properties_get_widget(const gchar *widget_name)
{
@@ -127,17 +130,15 @@ gnac_profiles_properties_init(void)
{
GtkWidget *widget;
GtkWidget *combo_format;
- GtkWidget *hbox_properties;
GtkCellRenderer *renderer_format;
profiles_properties_builder = gnac_utils_create_gtk_builder(
PKGDATADIR "/profiles/gnac-profiles-properties.xml");
- formats = g_hash_table_new(g_str_hash,g_str_equal);
+ formats = g_hash_table_new(g_str_hash, g_str_equal);
saved_profiles_dir = g_build_filename(g_get_user_data_dir(),
"gnac", "profiles", NULL);
- hbox_properties = gnac_profiles_properties_get_widget("hbox_properties");
combo_format = gnac_profiles_properties_get_widget("format_combo_box");
renderer_format = gtk_cell_renderer_text_new();
@@ -146,16 +147,9 @@ gnac_profiles_properties_init(void)
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_format),
renderer_format, "text", 0, NULL);
- g_signal_connect(G_OBJECT(combo_format), "changed",
- G_CALLBACK(gnac_profiles_properties_combo_format_on_changed),
- hbox_properties);
-
widget = gnac_profiles_properties_get_widget("window1");
gtk_window_set_type_hint(GTK_WINDOW(widget), GDK_WINDOW_TYPE_HINT_DIALOG);
- g_signal_connect(G_OBJECT (widget), "delete_event",
- G_CALLBACK(gtk_widget_hide), NULL);
-
gnac_profiles_properties_init_format();
gnac_profiles_properties_display_status_message(NULL);
@@ -165,14 +159,14 @@ gnac_profiles_properties_init(void)
void
-gnac_profiles_properties_set_parent(GtkWidget *parent)
+gnac_profiles_properties_set_parent(GtkWindow *parent)
{
- GtkWidget *widget;
+ GtkWindow *window;
- widget = gnac_profiles_properties_get_widget("window1");
+ window = GTK_WINDOW(gnac_profiles_properties_get_widget("window1"));
- gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent));
- gtk_window_set_position(GTK_WINDOW(widget), GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_set_transient_for(window, parent);
+ gtk_window_set_position(window, GTK_WIN_POS_CENTER_ON_PARENT);
}
@@ -187,7 +181,7 @@ gnac_profiles_properties_init_format(void) {
GtkTreePath *tree_path;
const gchar *format_id;
gchar *format_name;
- gint i;
+ guint i;
hbox_properties = gnac_profiles_properties_get_widget("hbox_properties");
format_combo_box = gnac_profiles_properties_get_widget("format_combo_box");
@@ -198,7 +192,7 @@ gnac_profiles_properties_init_format(void) {
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), 2,
GTK_SORT_ASCENDING);
- for (i = 0; i < NB_PLUGINS; ++i) {
+ for (i = 0; i < G_N_ELEMENTS(formats_get_funcs); ++i) {
FormatModule *format_module;
GtkWidget *pipeline_box;
@@ -210,7 +204,7 @@ gnac_profiles_properties_init_format(void) {
g_hash_table_insert(formats, (gpointer) format_id, format_module);
gtk_list_store_append(model, &iter);
- if (g_strcmp0(format_id, "custom-format")) {
+ if (!gnac_utils_str_equal(format_id, "custom-format")) {
gtk_list_store_set(model, &iter,
0, format_name,
1, format_module,
@@ -231,7 +225,7 @@ gnac_profiles_properties_init_format(void) {
GTK_TREE_MODEL(model), tree_path);
gtk_tree_path_free(tree_path);
- if (format_module->funcs.set_pipeline_func != NULL) {
+ if (format_module->funcs.set_pipeline_func) {
widget = gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
pipeline_box = gnac_profiles_properties_get_widget("gstreamer_pipeline_box");
format_module->funcs.set_pipeline_func(GTK_TEXT_VIEW(widget),
@@ -264,19 +258,14 @@ gnac_profiles_properties_show(gpointer profile,
widget = gnac_profiles_properties_get_widget("save-button");
- if (g_signal_handler_is_connected(G_OBJECT(widget), save_button_handler_id))
- {
- g_signal_handler_disconnect(G_OBJECT(widget), save_button_handler_id);
- }
-
- save_button_handler_id = g_signal_connect(G_OBJECT(widget), "clicked",
+ g_signal_connect(G_OBJECT(widget), "clicked",
G_CALLBACK(gnac_profiles_properties_on_save), call_back);
widget = gnac_profiles_properties_get_widget("window1");
gtk_window_set_title(GTK_WINDOW(widget), title);
format_combo_box = gnac_profiles_properties_get_widget("format_combo_box");
- if (profile == NULL) {
+ if (!profile) {
gtk_widget_show(widget);
gtk_combo_box_set_active(GTK_COMBO_BOX(format_combo_box), 0);
} else {
@@ -307,6 +296,8 @@ gnac_profiles_properties_show(gpointer profile,
void
gnac_profiles_properties_free_audio_profile(gpointer profile)
{
+ if (!profile) return;
+
AudioProfileGeneric *p;
const gchar *format_id;
FormatModule *format_module;
@@ -315,10 +306,10 @@ gnac_profiles_properties_free_audio_profile(gpointer profile)
format_id = p->format_id;
if (format_id) {
format_module = g_hash_table_lookup(formats, format_id);
- if (format_module == NULL) {
- libgnac_warning(_("Format not supported"));
- } else {
+ if (format_module) {
format_module->funcs.free_audio_profile(profile);
+ } else {
+ libgnac_warning(_("Format not supported"));
}
}
}
@@ -353,7 +344,7 @@ gnac_profiles_properties_destroy(void)
}
-static void
+void
gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gpointer user_data)
{
@@ -370,8 +361,7 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gnac_profiles_properties_display_status_message(NULL);
- if ((current_format_module != NULL)
- && (format_module != current_format_module))
+ if (current_format_module && format_module != current_format_module)
{
properties = current_format_module->funcs.get_widget(NULL);
gtk_widget_hide(properties);
@@ -379,10 +369,10 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
text_view = gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
- #ifndef GNOME_ENABLE_DEBUG
+ #ifdef GNOME_ENABLE_DEBUG
text_view = gnac_profiles_properties_get_widget("gstreamer_pipeline_box");
gtk_widget_hide(text_view);
- #endif /* GNOME_ENABLE_DEBUG */
+ #endif
label = gnac_profiles_properties_get_widget("format_decription_label");
gtk_label_set_markup(GTK_LABEL(label),
@@ -409,20 +399,20 @@ gnac_profiles_properties_update_textbuffer(const gchar *pipeline)
static void
-gnac_profiles_properties_display_status_message(const gchar *error)
+gnac_profiles_properties_display_status_message(const gchar *error_message)
{
GtkWidget *widget;
widget = gnac_profiles_properties_get_widget("hbox-properties-status");
- if (!error) {
+ if (!error_message) {
gtk_widget_hide(widget);
return;
}
gtk_widget_show_all(widget);
widget = gnac_profiles_properties_get_widget("label-properties-status-error");
- gtk_label_set_text(GTK_LABEL(widget), error);
+ gtk_label_set_text(GTK_LABEL(widget), error_message);
}
@@ -432,12 +422,14 @@ gnac_profiles_properties_reinit(void)
GList *list;
GList *temp;
+ gnac_profiles_properties_display_status_message(NULL);
gnac_profiles_properties_update_textbuffer("");
gnac_profiles_properties_name_description_set_text("", "");
list = g_hash_table_get_values(formats);
for (temp = list; temp != NULL; temp = temp->next) {
((FormatModule*)temp->data)->funcs.fullfill_fields(NULL);
}
+
g_list_free(list);
}
@@ -446,21 +438,35 @@ static void
gnac_profiles_properties_name_description_set_text(const gchar *name,
const gchar *description)
{
- GtkWidget *widget;
+ gnac_profiles_properties_name_set_text(name);
+ gnac_profiles_properties_description_set_text(description);
+}
+
+
+static void
+gnac_profiles_properties_name_set_text(const gchar *name)
+{
+ if (!name) return;
+
+ GtkWidget *widget;
+
+ widget = gnac_profiles_properties_get_widget("name_entry");
+ gtk_entry_set_text(GTK_ENTRY(widget), name);
+ current_profile_name = name;
+}
+
+
+static void
+gnac_profiles_properties_description_set_text(const gchar *description)
+{
+ if (!description) return;
+
GtkTextBuffer *text_buffer;
-
- if (name != NULL) {
- widget = gnac_profiles_properties_get_widget("name_entry");
- gtk_entry_set_text(GTK_ENTRY(widget), name);
- current_profile_name = name;
- }
-
- if (description != NULL) {
- widget = gnac_profiles_properties_get_widget("profile_description_text_view");
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
- gtk_text_buffer_set_text(GTK_TEXT_BUFFER(text_buffer), description,
- g_utf8_strlen(description, -1));
- }
+
+ text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(
+ gnac_profiles_properties_get_widget("profile_description_text_view")));
+ gtk_text_buffer_set_text(text_buffer, description,
+ g_utf8_strlen(description, -1));
}
@@ -468,15 +474,13 @@ static void
gnac_profiles_properties_on_save(GtkWidget *widget,
gpointer data)
{
- GtkWidget *window;
- GtkTextBuffer *text_buffer;
- GtkTextIter start;
- GtkTextIter end;
+ AudioProfileGeneric *generic;
const gchar *name;
- StandardCallBack call_back = (StandardCallBack) data;
gpointer profile;
- AudioProfileGeneric *generic;
+ GtkWidget *text_view;
+ GtkWidget *window;
GError *error = NULL;
+ StandardCallBack call_back = (StandardCallBack) data;
window = gnac_profiles_properties_get_widget("window1");
@@ -489,28 +493,41 @@ gnac_profiles_properties_on_save(GtkWidget *widget,
return;
}
- GtkWidget *text_view;
- GtkTextBuffer *pipeline_text_buffer;
-
text_view = gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
- pipeline_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
-
generic = ((AudioProfileGeneric*) profile)->generic;
- if (generic->pipeline == NULL) {
- gtk_text_buffer_get_start_iter(pipeline_text_buffer, &start);
- gtk_text_buffer_get_end_iter(pipeline_text_buffer, &end);
- generic->pipeline = gtk_text_buffer_get_text(pipeline_text_buffer,
- &start, &end, FALSE);
+ if (!generic->pipeline) {
+ generic->pipeline = gnac_profiles_utils_text_view_get_text(
+ GTK_TEXT_VIEW(text_view));
}
widget = gnac_profiles_properties_get_widget("name_entry");
name = gtk_entry_get_text(GTK_ENTRY(widget));
+ if (!gnac_profiles_properties_is_valid_profile_name(name)) return;
+
+ gnac_profiles_properties_display_status_message(NULL);
+
+ generic->name = g_strdup(name);
+ widget = gnac_profiles_properties_get_widget("profile_description_text_view");
+ generic->description = gnac_profiles_utils_text_view_get_text(
+ GTK_TEXT_VIEW(widget));
+
+ current_format_module->funcs.save_profile_in_file(profile);
+
+ call_back(widget, profile);
+
+ gtk_widget_hide(window);
+}
+
+
+static gboolean
+gnac_profiles_properties_is_valid_profile_name(const gchar *name)
+{
if (gnac_utils_string_is_null_or_empty(name)) {
gnac_profiles_properties_display_status_message(
_("The profile name must be non-empty"));
- return;
+ return FALSE;
}
if (!gnac_profiles_properties_is_valid_filename_chars(name)) {
@@ -520,32 +537,18 @@ gnac_profiles_properties_on_save(GtkWidget *widget,
" ", forbidden_chars_string, NULL);
gnac_profiles_properties_display_status_message(message);
g_free(message);
- return;
+ return FALSE;
}
- if (g_str_equal(current_profile_name, name)
+ if (!gnac_utils_str_equal(current_profile_name, name)
&& gnac_profiles_properties_saved_profiles_contain_name(name, TRUE))
{
gnac_profiles_properties_display_status_message(
_("This name is already used by another profile."));
- return;
+ return FALSE;
}
- gnac_profiles_properties_display_status_message(NULL);
-
- generic->name = g_strdup(name);
- widget = gnac_profiles_properties_get_widget("profile_description_text_view");
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
- gtk_text_buffer_get_start_iter(text_buffer, &start);
- gtk_text_buffer_get_end_iter(text_buffer, &end);
- generic->description = gtk_text_buffer_get_text(text_buffer,
- &start, &end, FALSE);
-
- current_format_module->funcs.save_profile_in_file(profile);
-
- call_back(widget, profile);
-
- gtk_widget_hide(window);
+ return TRUE;
}
diff --git a/src/profiles/gnac-profiles-properties.h b/src/profiles/gnac-profiles-properties.h
index 53776c1..915d5e5 100644
--- a/src/profiles/gnac-profiles-properties.h
+++ b/src/profiles/gnac-profiles-properties.h
@@ -37,7 +37,7 @@ void
gnac_profiles_properties_init(void);
void
-gnac_profiles_properties_set_parent(GtkWidget *parent);
+gnac_profiles_properties_set_parent(GtkWindow *parent);
void
gnac_profiles_properties_show(gpointer profile,
@@ -80,6 +80,10 @@ gchar *
gnac_profiles_properties_filter_text_for_displaying(const gchar *text,
gint length);
+void
+gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
+ gpointer user_data);
+
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 b8ee319..c660900 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -23,8 +23,6 @@
* Boston, MA 02110-1301 USA
*/
-#include <stdlib.h>
-
#include "gnac-profiles-utils.h"
#include "gnac-utils.h"
#include "libgnac-debug.h"
@@ -55,8 +53,8 @@ gnac_profiles_utils_init_name_extension(XMLDoc *doc,
gchar *
-gnac_profiles_utils_get_combo_format_name(gchar *name,
- gchar *extension)
+gnac_profiles_utils_get_combo_format_name(const gchar *name,
+ const gchar *extension)
{
return g_strconcat(name, " (.", extension, ")", NULL);
}
@@ -89,14 +87,15 @@ gnac_profiles_utils_all_in_one_for_combo(BasicFormatInfo *bfi,
{
GtkWidget *widget;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, combo_name));
- if (widget) {
- gnac_profiles_utils_register_combo(widget, bfi->doc, xpath_query,
- call_back, NULL);
- } else {
+ widget = gnac_profiles_utils_get_widget(bfi, combo_name);
+ if (!widget) {
libgnac_warning("Combo %s not found", combo_name);
+ return NULL;
}
+ gnac_profiles_utils_register_combo(widget, bfi->doc, xpath_query,
+ call_back, NULL);
+
return widget;
}
@@ -109,14 +108,15 @@ gnac_profiles_utils_all_in_one_for_slider(BasicFormatInfo *bfi,
{
GtkWidget *widget;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, slider_name));
- if (widget) {
- gnac_profiles_utils_register_slider(widget, bfi->doc, xpath_query,
- call_back, NULL);
- } else {
+ widget = gnac_profiles_utils_get_widget(bfi, slider_name);
+ if (!widget) {
libgnac_warning("Slider %s not found", slider_name);
+ return NULL;
}
+ gnac_profiles_utils_register_slider(widget, bfi->doc, xpath_query,
+ call_back, NULL);
+
return widget;
}
@@ -129,14 +129,15 @@ gnac_profiles_utils_all_in_one_for_check(BasicFormatInfo *bfi,
{
GtkWidget *widget;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, check_name));
- if (widget) {
- gnac_profiles_utils_register_check(widget, bfi->doc, xpath_query,
- call_back, NULL);
- } else {
+ widget = gnac_profiles_utils_get_widget(bfi, check_name);
+ if (!widget) {
libgnac_warning("Check %s not found", check_name);
+ return NULL;
}
+ gnac_profiles_utils_register_check(widget, bfi->doc, xpath_query,
+ call_back, NULL);
+
return widget;
}
@@ -148,7 +149,7 @@ gnac_profiles_utils_add_toggle_signal(BasicFormatInfo *bfi,
gpointer user_data)
{
GtkWidget *widget;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, check));
+ widget = gnac_profiles_utils_get_widget(bfi, check);
g_signal_connect(G_OBJECT(widget), "toggled", callback, user_data);
return widget;
}
@@ -239,7 +240,7 @@ gnac_profiles_utils_register_advanced_channels(GtkBuilder *builder,
{
GtkWidget *widget = NULL;
- widget = GTK_WIDGET(gtk_builder_get_object(builder, "combo-channels"));
+ widget = gnac_utils_get_widget(builder, "combo-channels");
if (widget) {
gnac_profiles_utils_register_combo(widget, doc,
"//variable[ id='channels']/*", call_back, user_data);
@@ -259,7 +260,7 @@ gnac_profiles_utils_register_advanced_sample_rate(GtkBuilder *builder,
{
GtkWidget *widget = NULL;
- widget = GTK_WIDGET(gtk_builder_get_object(builder, "combo-sample-rate"));
+ widget = gnac_utils_get_widget(builder, "combo-sample-rate");
if (widget) {
gnac_profiles_utils_register_combo(widget, doc,
"//variable[ id='sample-rate']/*", call_back, user_data);
@@ -287,7 +288,7 @@ gnac_profiles_utils_add_values_combo(GtkWidget *combo,
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),
(const gchar*) list_names->data);
- if (!g_strcmp0(values->default_value, (const gchar*) list_values->data)) {
+ if (gnac_utils_str_equal(values->default_value, (const gchar*) list_values->data)) {
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
}
@@ -311,7 +312,7 @@ gnac_profiles_utils_reinit_values_combo(BasicFormatInfo *bfi, ...)
while (v != NULL) {
const gchar *combo_name = (const gchar *) v;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, 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);
@@ -335,7 +336,7 @@ gnac_profiles_utils_set_value_combo(GtkWidget *combo,
if (value == NULL) value = values->default_value;
index = 0;
while (list_values != NULL) {
- if (!g_strcmp0(value, (const gchar*) list_values->data)) {
+ if (gnac_utils_str_equal(value, (const gchar*) list_values->data)) {
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
}
list_values = list_values->next;
@@ -358,7 +359,7 @@ gnac_profiles_utils_set_values_combo(BasicFormatInfo *bfi, ...)
value = va_arg(ap, const gchar *);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
gnac_profiles_utils_set_value_combo(widget, value);
name = va_arg(ap, const gchar *);
@@ -384,11 +385,11 @@ gnac_profiles_utils_set_values_checked_combo(BasicFormatInfo *bfi, ...)
value = va_arg(ap, const gchar *);
if (value != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name_combo));
+ widget = gnac_profiles_utils_get_widget(bfi, name_combo);
gnac_profiles_utils_set_value_combo(widget, value);
}
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name_checkbox));
+ 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 *);
@@ -434,7 +435,7 @@ gnac_profiles_utils_get_values_combo_and_set(BasicFormatInfo *bfi, ...)
value = va_arg(ap, gchar **);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
*value = gnac_profiles_utils_get_value_combo(widget);
name = va_arg(ap, const gchar *);
@@ -458,9 +459,9 @@ gnac_profiles_utils_get_values_checked_combo_and_set(BasicFormatInfo *bfi, ...)
checkbox_name = va_arg(ap, const gchar *);
value = va_arg(ap, const gchar **);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
*value = gnac_profiles_utils_get_value_combo(widget);
}
@@ -483,7 +484,7 @@ gnac_profiles_utils_reinit_values_slider(BasicFormatInfo *bfi, ...)
while (v != NULL) {
const gchar *slider_name = (const gchar *) v;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, 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);
@@ -507,7 +508,7 @@ gnac_profiles_utils_set_values_slider(BasicFormatInfo *bfi, ...)
while (name != NULL) {
value = va_arg(ap, gdouble);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
gtk_range_set_value(GTK_RANGE(widget), value);
name = va_arg(ap, const gchar *);
@@ -533,10 +534,10 @@ gnac_profiles_utils_set_values_checked_slider(BasicFormatInfo *bfi, ...)
value = va_arg(ap, gdouble);
if (value != -1) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
gtk_range_set_value(GTK_RANGE(widget), value);
}
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), (value != -1));
name = va_arg(ap, const gchar *);
@@ -559,7 +560,7 @@ gnac_profiles_utils_get_values_slider_and_set(BasicFormatInfo *bfi, ...)
value = va_arg(ap, gdouble*);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
*value = gtk_range_get_value(GTK_RANGE(widget));
name = va_arg(ap, const gchar *);
@@ -583,9 +584,9 @@ gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...)
checkbox_name = va_arg(ap, const gchar *);
value = va_arg(ap, gdouble*);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
*value = gtk_range_get_value(GTK_RANGE(widget));
}
@@ -608,7 +609,7 @@ gnac_profiles_utils_reinit_values_check(BasicFormatInfo *bfi, ...)
while (v != NULL) {
const gchar *check_name = (const gchar *) v;
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, 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),
@@ -633,9 +634,9 @@ gnac_profiles_utils_set_values_check(BasicFormatInfo *bfi, ...)
while (name != NULL) {
value = va_arg(ap, const gchar *);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
- !g_strcmp0(value, "true"));
+ gnac_utils_str_equal(value, "true"));
name = va_arg(ap, const gchar *);
}
@@ -653,10 +654,10 @@ gnac_profiles_utils_get_values_check_and_set(BasicFormatInfo *bfi, ...)
va_start(ap, bfi);
name = va_arg(ap, const gchar *);
- while (name != NULL){
+ while (name != NULL) {
value = va_arg(ap, const gchar **);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
*value = g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ?
"true" : "false");
@@ -693,7 +694,7 @@ gnac_profiles_utils_add_description_tooltip(BasicFormatInfo *bfi,
void
gnac_profiles_utils_init_raw_audioconvert(XMLDoc *doc)
{
- if ((raw == NULL) && (audioconvert == NULL)) {
+ if (!raw && !audioconvert) {
raw = gnac_profiles_xml_engine_get_text_node(doc,
"//process[ id='gstreamer-audio']");
audioconvert = gnac_profiles_xml_engine_get_text_node(doc,
@@ -713,7 +714,7 @@ gnac_profiles_utils_get_basepipeline(const gchar *channels,
gchar *
gnac_profiles_utils_add_pipe(gchar *pipeline,
- gchar *new_pipe)
+ const gchar *new_pipe)
{
gchar *temp;
@@ -750,7 +751,7 @@ gnac_profiles_utils_add_pipes(gchar *pipeline,
list_temp = list_temp->next;
}
- return pipeline;;
+ return pipeline;
}
@@ -785,7 +786,7 @@ gnac_profiles_utils_add_properties_combo(gchar *pipeline,
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_combo(pipeline, widget);
name = va_arg(ap, const gchar *);
@@ -811,9 +812,9 @@ gnac_profiles_utils_add_properties_checked_combo(gchar *pipeline,
while (name != NULL) {
checkbox_name = va_arg(ap, const gchar *);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_combo(pipeline, widget);
}
@@ -864,7 +865,7 @@ gnac_profiles_utils_add_properties_slider(gchar *pipeline,
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_slider(pipeline, "%.0f", 1,
widget);
@@ -890,7 +891,7 @@ gnac_profiles_utils_add_properties_slider_format(gchar *pipeline,
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_slider(pipeline, format, 1,
widget);
@@ -917,9 +918,9 @@ gnac_profiles_utils_add_properties_checked_slider(gchar *pipeline,
while (name != NULL) {
checkbox_name = va_arg(ap, const gchar *);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_slider(pipeline, "%.0f", 1,
widget);
}
@@ -949,9 +950,9 @@ gnac_profiles_utils_add_properties_checked_slider_format(
while (name != NULL) {
checkbox_name = va_arg(ap, const gchar *);
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, checkbox_name));
+ widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_slider(pipeline, format, 1,
widget);
}
@@ -995,7 +996,7 @@ gnac_profiles_utils_add_properties_check(gchar *pipeline,
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
pipeline = gnac_profiles_utils_add_property_check(pipeline, widget);
name = va_arg(ap, const gchar *);
@@ -1018,7 +1019,7 @@ gnac_profiles_utils_set_active_toggle_button(BasicFormatInfo *bfi,
va_start(ap, active);
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), active);
name = va_arg(ap, const gchar *);
@@ -1032,11 +1033,7 @@ gnac_profiles_utils_on_toggle_optionnal_property(GtkToggleButton *togglebutton,
gpointer user_data)
{
GtkWidget *widget = GTK_WIDGET(user_data);
- if (gtk_toggle_button_get_active(togglebutton)) {
- gtk_widget_set_sensitive(widget, TRUE);
- } else {
- gtk_widget_set_sensitive(widget, FALSE);
- }
+ gtk_widget_set_sensitive(widget, gtk_toggle_button_get_active(togglebutton));
}
@@ -1100,17 +1097,17 @@ gnac_profiles_utils_allocate_audio_profile_generic(void)
void
gnac_profiles_utils_free_audio_profile_generic(AudioProfileGeneric *profile)
{
- if (profile) {
- g_free(profile->name);
- g_free(profile->description);
- g_free(profile->format_id);
- g_free(profile->format_name);
- g_free(profile->extension);
- g_free(profile->pipeline);
- g_free(profile->rate);
- g_free(profile->channels);
- g_free(profile);
- }
+ if (!profile) return;
+
+ g_free(profile->name);
+ g_free(profile->description);
+ g_free(profile->format_id);
+ g_free(profile->format_name);
+ g_free(profile->extension);
+ g_free(profile->pipeline);
+ g_free(profile->rate);
+ g_free(profile->channels);
+ g_free(profile);
}
@@ -1143,7 +1140,7 @@ gnac_profiles_utils_free_combo_values(BasicFormatInfo *bfi, ...)
va_start(ap, bfi);
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
values = g_object_get_data(G_OBJECT(widget), "combo-values");
gnac_profiles_xml_engine_free_combo_values(values);
name = va_arg(ap, const gchar *);
@@ -1163,7 +1160,7 @@ gnac_profiles_utils_free_slider_values(BasicFormatInfo *bfi, ...)
va_start(ap, bfi);
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
values = g_object_get_data(G_OBJECT(widget), "slider-values");
gnac_profiles_xml_engine_free_slider_values(values);
name = va_arg(ap, const gchar *);
@@ -1183,7 +1180,7 @@ gnac_profiles_utils_free_check_values(BasicFormatInfo *bfi, ...)
va_start(ap, bfi);
name = va_arg(ap, const gchar *);
while (name != NULL) {
- widget = GTK_WIDGET(gtk_builder_get_object(bfi->builder, name));
+ widget = gnac_profiles_utils_get_widget(bfi, name);
values = g_object_get_data(G_OBJECT(widget), "check-values");
gnac_profiles_xml_engine_free_check_values(values);
name = va_arg(ap, const gchar *);
@@ -1225,3 +1222,24 @@ gnac_profiles_utils_display_error_dialog(GtkWidget *dialog)
gtk_widget_hide(dialog);
gtk_widget_destroy(dialog);
}
+
+
+GtkWidget *
+gnac_profiles_utils_get_widget(BasicFormatInfo *bfi,
+ const gchar *widget_name)
+{
+ return GTK_WIDGET(gtk_builder_get_object(bfi->builder, widget_name));
+}
+
+
+gchar *
+gnac_profiles_utils_text_view_get_text(GtkTextView *text_view)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ buffer = gtk_text_view_get_buffer(text_view);
+ gtk_text_buffer_get_start_iter(buffer, &start);
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+}
diff --git a/src/profiles/gnac-profiles-utils.h b/src/profiles/gnac-profiles-utils.h
index 94f561a..18e2439 100755
--- a/src/profiles/gnac-profiles-utils.h
+++ b/src/profiles/gnac-profiles-utils.h
@@ -77,8 +77,8 @@ gnac_profiles_utils_init_name_extension(XMLDoc *doc,
gchar **extension);
gchar *
-gnac_profiles_utils_get_combo_format_name(gchar *name,
- gchar *extension);
+gnac_profiles_utils_get_combo_format_name(const gchar *name,
+ const gchar *extension);
gchar *
gnac_profiles_utils_init_description(XMLDoc *doc,
@@ -208,8 +208,8 @@ gnac_profiles_utils_get_basepipeline(const gchar *channels,
const gchar *rate);
gchar *
-gnac_profiles_utils_add_pipe(gchar *pipeline,
- gchar *new_pipe);
+gnac_profiles_utils_add_pipe(gchar *pipeline,
+ const gchar *new_pipe);
gchar *
gnac_profiles_utils_add_pipes(gchar *pipeline,
@@ -315,6 +315,13 @@ gnac_profiles_utils_gchararray_to_gdouble(const gchar *value);
void
gnac_profiles_utils_display_error_dialog(GtkWidget *dialog);
+GtkWidget *
+gnac_profiles_utils_get_widget(BasicFormatInfo *bfi,
+ const gchar *widget_name);
+
+gchar *
+gnac_profiles_utils_text_view_get_text(GtkTextView *text_view);
+
G_END_DECLS
#endif /* GNAC_PROFILES_UTILS_H */
diff --git a/src/profiles/gnac-profiles-xml-engine.c b/src/profiles/gnac-profiles-xml-engine.c
index 1028e66..c483be6 100755
--- a/src/profiles/gnac-profiles-xml-engine.c
+++ b/src/profiles/gnac-profiles-xml-engine.c
@@ -44,6 +44,14 @@ gnac_profiles_xml_engine_evaluate_query(const gchar *query,
static gboolean
gnac_profiles_xml_engine_is_i12n_node(xmlNodePtr node);
+static gboolean
+gnac_profiles_xml_engine_str_equal(const xmlChar *str1,
+ const gchar *str2);
+
+static gboolean
+gnac_profiles_xml_engine_node_name_equal(xmlNode *node,
+ const gchar *name);
+
XMLDoc *
gnac_profiles_xml_engine_load_doc_xpath(const gchar *filename)
@@ -53,16 +61,17 @@ gnac_profiles_xml_engine_load_doc_xpath(const gchar *filename)
XMLDoc *dx = NULL;
doc = xmlParseFile(filename);
- if (doc != NULL) {
- xpath = xmlXPathNewContext(doc);
- if (xpath != NULL) {
- dx = g_malloc(sizeof(XMLDoc));
- dx->doc = (gpointer) doc;
- dx->xpath_context = (gpointer) xpath;
- } else {
- xmlFreeDoc(doc);
- }
+ if (!doc) return NULL;
+
+ xpath = xmlXPathNewContext(doc);
+ if (xpath) {
+ dx = g_malloc(sizeof(XMLDoc));
+ dx->doc = (gpointer) doc;
+ dx->xpath_context = (gpointer) xpath;
+ } else {
+ xmlFreeDoc(doc);
}
+
return dx;
}
@@ -74,10 +83,10 @@ gnac_profiles_xml_engine_get_format_id(XMLDoc *dx)
const gchar *expr = "//profiles/profile";
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if ((nodes != NULL) && (nodes->nodeNr > 0)) {
+ if (nodes && nodes->nodeNr > 0) {
gchar *format_id;
xmlNodePtr node;
@@ -87,7 +96,9 @@ gnac_profiles_xml_engine_get_format_id(XMLDoc *dx)
return format_id;
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
+
return NULL;
}
@@ -99,20 +110,22 @@ gnac_profiles_xml_engine_get_text_node(XMLDoc *dx,
xmlXPathObjectPtr xpath_obj;
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if ((nodes != NULL) && (nodes->nodeNr > 0)) {
+ if (nodes && nodes->nodeNr > 0) {
xmlNodePtr node;
node = nodes->nodeTab[0];
- if (node->children != NULL) {
+ if (node->children) {
xmlXPathFreeObject(xpath_obj);
return g_strdup(gettext((const gchar *)node->children->content));
}
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
+
return NULL;
}
@@ -120,7 +133,7 @@ gnac_profiles_xml_engine_get_text_node(XMLDoc *dx,
static gboolean
gnac_profiles_xml_engine_is_i12n_node(xmlNodePtr node)
{
- return !g_strcmp0((const gchar*) node->properties->name, "lang");
+ return gnac_profiles_xml_engine_str_equal(node->properties->name, "lang");
}
@@ -131,16 +144,16 @@ gnac_profiles_xml_engine_get_list_values(XMLDoc *dx,
xmlXPathObjectPtr xpath_obj;
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (nodes != NULL) {
+ if (nodes) {
gint nb_element;
gint i;
GList *list = NULL;
nb_element = nodes->nodeNr;
- for (i = 0; i < nb_element; ++i) {
+ for (i = 0; i < nb_element; i++) {
xmlNode *current_node = nodes->nodeTab[i];
Value *v;
@@ -153,11 +166,15 @@ gnac_profiles_xml_engine_get_list_values(XMLDoc *dx,
list = g_list_append(list, v);
}
}
+
xmlXPathFreeObject(xpath_obj);
+
return list;
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
+
return NULL;
}
@@ -167,9 +184,7 @@ gnac_profiles_xml_engine_evaluate_query(const gchar *query,
xmlXPathContextPtr xpath_context)
{
const xmlChar *expr_cast;
-
expr_cast = BAD_CAST query;
-
return xmlXPathEvalExpression(expr_cast, xpath_context);
}
@@ -182,10 +197,10 @@ gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
xmlXPathObjectPtr xpath_obj;
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (nodes != NULL)
+ if (nodes)
{
gint nb_element;
gint i;
@@ -196,28 +211,35 @@ gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
gchar *variable_name = NULL;
nb_element = nodes->nodeNr;
- for (i = 0; i < nb_element; ++i)
+ for (i = 0; i < nb_element; i++)
{
xmlNode *current_node = nodes->nodeTab[i];
- if (!g_strcmp0("variable-name", (const gchar*) current_node->name)) {
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
variable_name = g_strdup((gchar*) current_node->children->content);
- } else if (!g_strcmp0("control-type", (const gchar*)current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "control-type"))
{
- is_combo = !(g_strcmp0("combo",
- (const gchar*) current_node->children->content));
- } else if (!g_strcmp0("default-value",
- (const gchar*)current_node->name))
+ is_combo = gnac_profiles_xml_engine_str_equal(
+ current_node->children->content, "combo");
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
{
default_value = g_strdup((gchar*) current_node->children->content);
- } else if (!g_strcmp0("possible-values",
- (const gchar*) current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "possible-values"))
{
values_first = current_node->children->next;
values_last = current_node->last;
}
}
- if (is_combo && values_first && values_last
- && default_value && variable_name)
+
+ if (is_combo && values_first && values_last &&
+ default_value && variable_name)
{
gboolean stop = FALSE;
xmlNode *current_node = values_first;
@@ -237,7 +259,9 @@ gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
current_node = current_node->next;
if (current_node == values_last) {
stop = TRUE;
- } else if (!g_strcmp0("text", (const gchar *) current_node->name)) {
+ } else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "text"))
+ {
current_node = current_node->next;
}
} while (!stop);
@@ -246,13 +270,16 @@ gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
combo_values->names = names;
combo_values->default_value = default_value;
combo_values->variable_name = variable_name;
+
xmlXPathFreeObject(xpath_obj);
+
return 0;
}
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+ xmlXPathFreeObject(xpath_obj);
+
return -1;
}
@@ -265,10 +292,10 @@ gnac_profiles_xml_engine_get_slider_values(XMLDoc *dx,
xmlXPathObjectPtr xpath_obj;
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (nodes != NULL) {
+ if (nodes) {
gint nb_element;
gint i;
gboolean is_slider = FALSE;
@@ -279,33 +306,45 @@ gnac_profiles_xml_engine_get_slider_values(XMLDoc *dx,
gchar *variable_name = NULL;
nb_element = nodes->nodeNr;
- for (i = 0; i < nb_element; ++i) {
+ for (i = 0; i < nb_element; i++) {
xmlNode *current_node = nodes->nodeTab[i];
- if (!g_strcmp0("variable-name", (const gchar*) current_node->name)) {
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
variable_name = g_strdup((gchar*) current_node->children->content);
- } else if (!g_strcmp0("control-type", (const gchar*)current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "control-type"))
{
- is_slider = !(g_strcmp0("slider",
- (const gchar*) current_node->children->content));
- } else if (!g_strcmp0("default-value",
- (const gchar*) current_node->name))
+ is_slider = gnac_profiles_xml_engine_str_equal(
+ current_node->children->content, "slider");
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
{
default_value = g_ascii_strtod(
(const gchar*) current_node->children->content, NULL);
- } else if (!g_strcmp0("min-value", (const gchar*) current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "min-value"))
{
min = g_ascii_strtod(
(const gchar*) current_node->children->content, NULL);
- } else if (!g_strcmp0("max-value", (const gchar*) current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "max-value"))
{
max = g_ascii_strtod(
(const gchar*) current_node->children->content, NULL);
- } else if (!g_strcmp0("step-value", (const gchar*) current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "step-value"))
{
step = g_ascii_strtod(
(const gchar*) current_node->children->content, NULL);
}
}
+
if (is_slider && variable_name)
{
slider_values->min = min;
@@ -313,12 +352,16 @@ gnac_profiles_xml_engine_get_slider_values(XMLDoc *dx,
slider_values->step = step;
slider_values->default_value = default_value;
slider_values->variable_name = variable_name;
+
xmlXPathFreeObject(xpath_obj);
+
return 0;
}
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
+
return -1;
}
@@ -331,10 +374,10 @@ gnac_profiles_xml_engine_get_check_values(XMLDoc *dx,
xmlXPathObjectPtr xpath_obj;
xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if ((xpath_obj != NULL) && !xpath_obj->boolval) {
+ if (xpath_obj && !xpath_obj->boolval) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (nodes != NULL) {
+ if (nodes) {
gint nb_element;
gint i;
gchar *variable_name = NULL;
@@ -342,31 +385,41 @@ gnac_profiles_xml_engine_get_check_values(XMLDoc *dx,
gboolean default_value = FALSE;
nb_element = nodes->nodeNr;
- for (i = 0; i < nb_element; ++i) {
+ for (i = 0; i < nb_element; i++) {
xmlNode *current_node = nodes->nodeTab[i];
- if (!g_strcmp0("variable-name", (const gchar*) current_node->name)) {
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
variable_name = g_strdup((gchar*) current_node->children->content);
- } else if (!g_strcmp0("control-type", (const gchar*)current_node->name))
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "control-type"))
{
- is_check = !(g_strcmp0("check",
- (const gchar*) current_node->children->content));
- } else if (!g_strcmp0("default-value",
- (const gchar*) current_node->name))
+ is_check = gnac_profiles_xml_engine_str_equal(
+ current_node->children->content, "check");
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
{
- default_value = !g_strcmp0(
- (const gchar*) current_node->children->content,"true");
+ default_value = gnac_profiles_xml_engine_str_equal(
+ current_node->children->content, "true");
}
}
+
if (is_check && variable_name)
{
check_values->default_value = default_value;
check_values->variable_name = variable_name;
+
xmlXPathFreeObject(xpath_obj);
+
return 0;
}
}
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
+
return -1;
}
@@ -390,17 +443,19 @@ gnac_profiles_xml_engine_modify_values(XMLDoc *dx,
va_start(ap, expr);
value = va_arg(ap, const gchar *);
- for (i = nbElement-1; i >= 0; --i) {
- gchar *value_formated = gnac_profiles_xml_engine_format_text_to_xml(value);
- xmlNodeSetContent(nodes->nodeTab[i], BAD_CAST value_formated);
- g_free(value_formated);
+
+ for (i = nbElement-1; i >= 0; i--) {
+ gchar *value_formatted = gnac_profiles_xml_engine_format_text_to_xml(value);
+ xmlNodeSetContent(nodes->nodeTab[i], BAD_CAST value_formatted);
+ g_free(value_formatted);
if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
nodes->nodeTab[i] = NULL;
value = va_arg(ap, const gchar *);
}
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+
+ xmlXPathFreeObject(xpath_obj);
}
@@ -428,12 +483,14 @@ gnac_profiles_xml_engine_add_values(XMLDoc *dx,
xmlAddChild(format_node, xmlNewText(BAD_CAST " "));
name = va_arg(ap, const xmlChar *);
- while (name != NULL) {
+
+ while (name) {
value = va_arg(ap, const gchar *);
node = xmlNewNode(format_node->ns, name);
node = xmlAddChild(format_node, node);
+
if (!gnac_utils_string_is_null_or_empty(value)) {
gchar *formatted = gnac_profiles_xml_engine_format_text_to_xml(value);
xmlNodeSetContent(node, BAD_CAST formatted);
@@ -441,71 +498,25 @@ gnac_profiles_xml_engine_add_values(XMLDoc *dx,
}
name = va_arg(ap, const xmlChar *);
- if (name != NULL) {
+ if (name) {
xmlAddChild(format_node, xmlNewText(properties_indent));
} else {
xmlAddChild(format_node, xmlNewText(base_indent));
}
}
+
va_end(ap);
+
g_free(properties_indent);
- if (xpath_obj != NULL) xmlXPathFreeObject(xpath_obj);
+ xmlXPathFreeObject(xpath_obj);
}
gchar *
-gnac_profiles_xml_engine_format_text_to_xml(const gchar *text) {
- if (text != NULL) {
- gchar *text_return = NULL;
- glong text_size;
- const gchar *replacement;
- gchar *temp;
- gint last_replacement = 0;
- gint i;
-
- text_size = g_utf8_strlen(text, -1);
- for (i = 0; i < text_size; ++i) {
- switch (text[i])
- {
- case '&':
- replacement = "&";
- break;
-
- case '<':
- replacement = "<";
- break;
-
- case '>':
- replacement = ">";
- break;
-
- default:
- replacement = NULL;
- break;
- }
- if (replacement != NULL) {
- temp = g_strndup(&(text[last_replacement]), i-last_replacement);
- if (text_return != NULL) {
- gchar *temp2;
-
- temp2 = text_return;
- text_return = g_strconcat(text_return, temp, replacement, NULL);
- g_free(temp2);
- } else {
- text_return = g_strconcat(temp, replacement, NULL);
- }
- g_free(temp);
- last_replacement = i+1;
- }
- }
- if (text_return == NULL) {
- return g_strdup(text);
- } else {
- return text_return;
- }
- } else {
- return NULL;
- }
+gnac_profiles_xml_engine_format_text_to_xml(const gchar *text)
+{
+ if (!text) return NULL;
+ return g_markup_escape_text(text, -1);
}
@@ -514,10 +525,8 @@ gnac_profiles_xml_engine_save_doc(XMLDoc *dx,
const gchar *filename)
{
gchar *xml_filename;
-
xml_filename = g_strconcat(GNAC_SAVED_PROFILES_URL_WITH_EXT(filename), NULL);
- xmlSaveFormatFile(xml_filename,dx->doc, 0);
-
+ xmlSaveFormatFile(xml_filename, dx->doc, 0);
g_free(xml_filename);
}
@@ -536,10 +545,10 @@ gnac_profiles_xml_engine_free_doc_xpath(XMLDoc *doc)
void
gnac_profiles_xml_engine_free_combo_values(ComboValues *values)
{
- g_list_foreach(values->values, (GFunc) g_free, NULL);
- g_list_free(values->values);
- g_list_foreach(values->names, (GFunc) g_free, NULL);
- g_list_free(values->names);
+ if (!values) return;
+
+ g_list_free_full(values->values, (GDestroyNotify) g_free);
+ g_list_free_full(values->names, (GDestroyNotify) g_free);
g_free(values->default_value);
g_free(values->variable_name);
g_free(values);
@@ -549,6 +558,8 @@ gnac_profiles_xml_engine_free_combo_values(ComboValues *values)
void
gnac_profiles_xml_engine_free_slider_values(SliderValues *values)
{
+ if (!values) return;
+
g_free(values->variable_name);
g_free(values);
}
@@ -557,6 +568,24 @@ gnac_profiles_xml_engine_free_slider_values(SliderValues *values)
void
gnac_profiles_xml_engine_free_check_values(CheckValues *values)
{
+ if (!values) return;
+
g_free(values->variable_name);
g_free(values);
}
+
+
+static gboolean
+gnac_profiles_xml_engine_str_equal(const xmlChar *str1,
+ const gchar *str2)
+{
+ return gnac_utils_str_equal((const gchar *)str1, str2);
+}
+
+
+static gboolean
+gnac_profiles_xml_engine_node_name_equal(xmlNode *node,
+ const gchar *name)
+{
+ return gnac_profiles_xml_engine_str_equal(node->name, name);
+}
diff --git a/src/profiles/gnac-profiles.c b/src/profiles/gnac-profiles.c
index 746e069..11eee50 100755
--- a/src/profiles/gnac-profiles.c
+++ b/src/profiles/gnac-profiles.c
@@ -23,22 +23,21 @@
* Boston, MA 02110-1301 USA
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gi18n.h>
+
#include "gnac-profiles.h"
#include "gnac-profiles-manager.h"
#include "gnac-utils.h"
-static void
-gnac_profiles_populate_combo(void);
-
static AudioProfileGeneric *
gnac_profiles_get_active_profile(void);
static void
-gnac_profiles_on_profiles_managed_closed(GtkWidget *widget,
- gpointer data);
-
-static void
gnac_profiles_on_combo_profile_changed(GtkWidget *widget,
gpointer data);
@@ -65,8 +64,7 @@ gnac_profiles_init(void)
g_signal_connect(G_OBJECT(combo_profile), "changed",
G_CALLBACK(gnac_profiles_on_combo_profile_changed), NULL);
- gnac_profiles_mgr_init(
- (StandardCallBack) gnac_profiles_on_profiles_managed_closed);
+ gnac_profiles_mgr_init();
gnac_profiles_populate_combo();
}
@@ -87,7 +85,7 @@ gnac_profiles_get_widget(GtkWidget *parent)
gnac_profiles_init();
}
- gnac_profiles_mgr_set_parent(parent);
+ gnac_profiles_mgr_set_parent(GTK_WINDOW(parent));
return combo_profile;
}
@@ -102,7 +100,7 @@ gnac_profiles_get_display_name(void)
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_profile), &iter)) {
- gtk_tree_model_get(model, &iter, 0, (gpointer*)&name, -1);
+ gtk_tree_model_get(model, &iter, 0, &name, -1);
return name;
}
@@ -119,7 +117,7 @@ gnac_profiles_get_active_profile(void)
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_profile), &iter)) {
- gtk_tree_model_get(model, &iter, 1, (gpointer*)&profile, -1);
+ gtk_tree_model_get(model, &iter, 1, &profile, -1);
return profile->generic;
}
@@ -133,11 +131,9 @@ gnac_profiles_get_pipeline(void)
AudioProfileGeneric *profile;
profile = gnac_profiles_get_active_profile();
- if (profile != NULL) {
- return profile->pipeline;
- }
+ if (!profile) return NULL;
- return NULL;
+ return profile->pipeline;
}
@@ -147,11 +143,9 @@ gnac_profiles_get_extension(void)
AudioProfileGeneric *profile;
profile = gnac_profiles_get_active_profile();
- if (profile != NULL) {
- return profile->extension;
- }
+ if (!profile) return NULL;
- return NULL;
+ return profile->extension;
}
@@ -161,11 +155,9 @@ gnac_profiles_get_name(void)
AudioProfileGeneric *profile;
profile = gnac_profiles_get_active_profile();
- if (profile != NULL) {
- return profile->name;
- }
+ if (!profile) return NULL;
- return NULL;
+ return profile->name;
}
@@ -179,8 +171,8 @@ gnac_profiles_set_current_profile(const gchar *name)
model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
if (gtk_tree_model_get_iter_first(model, &iter)) {
do {
- gtk_tree_model_get(model, &iter, 1, (gpointer*)&profile, -1);
- if (!g_strcmp0(profile->name, name)) {
+ gtk_tree_model_get(model, &iter, 1, &profile, -1);
+ if (gnac_utils_str_equal(profile->name, name)) {
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_profile), &iter);
break;
}
@@ -189,62 +181,62 @@ gnac_profiles_set_current_profile(const gchar *name)
}
-static void
+void
gnac_profiles_populate_combo(void)
{
GtkListStore *model;
GtkTreeIter iter;
- GList *list;
+ GList *profiles;
GList *temp;
- gchar *active_text;
+ gchar *display_name;
gboolean set_active;
model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile)));
- active_text = gnac_profiles_get_display_name();
+ display_name = gnac_profiles_get_display_name();
gtk_list_store_clear(model);
- list = gnac_profiles_mgr_get_profiles_list();
- if (list != NULL) {
- gtk_widget_set_sensitive(combo_profile, TRUE);
- set_active = FALSE;
- for (temp = list; temp != NULL; temp = temp->next) {
- gchar *str;
- gchar *formated_name;
- AudioProfileGeneric *profile;
-
- profile = ((AudioProfileGeneric*)temp->data)->generic;
- formated_name = gnac_profiles_properties_filter_text_for_displaying(
- profile->name, MAX_NAME_DISPLAY_SIZE);
- str = g_strconcat(formated_name, " (.", profile->extension, ")", NULL);
- gtk_list_store_append(model, &iter);
- gtk_list_store_set(model, &iter, 0, str, 1, profile, -1);
- if (active_text != NULL) {
- if (!g_strcmp0(str, active_text)) {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_profile), &iter);
- g_free(active_text);
- active_text = NULL;
- set_active = TRUE;
- }
- }
- /* Cleanup */
- g_free(str);
- g_free(formated_name);
+ profiles = gnac_profiles_mgr_get_profiles_list();
+ if (!profiles) {
+ gtk_widget_set_sensitive(combo_profile, FALSE);
+ g_free(display_name);
+ return;
+ }
+
+ gtk_widget_set_sensitive(combo_profile, TRUE);
+ set_active = FALSE;
+
+ for (temp = profiles; temp != NULL; temp = temp->next) {
+ gchar *name;
+ gchar *formatted_name;
+ AudioProfileGeneric *profile;
+
+ profile = ((AudioProfileGeneric*)temp->data)->generic;
+ formatted_name = gnac_profiles_properties_filter_text_for_displaying(
+ profile->name, MAX_NAME_DISPLAY_SIZE);
+ name = gnac_profiles_utils_get_combo_format_name(formatted_name,
+ profile->extension);
+ gtk_list_store_append(model, &iter);
+ gtk_list_store_set(model, &iter, 0, name, 1, profile, -1);
+ if (gnac_utils_str_equal(name, display_name)) {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_profile), &iter);
+ g_free(display_name);
+ display_name = NULL;
+ set_active = TRUE;
}
- if (!set_active) {
- if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_profile), &iter);
- }
+ g_free(name);
+ g_free(formatted_name);
+ }
+
+ if (!set_active) {
+ if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo_profile), &iter);
}
-
- g_list_free(list);
- } else {
- gtk_widget_set_sensitive(combo_profile, FALSE);
}
- /* Cleanup */
- g_free(active_text);
+ g_list_free(profiles);
+ g_free(display_name);
}
@@ -264,28 +256,20 @@ gnac_profiles_on_combo_profile_changed(GtkWidget *widget,
gchar *formatted;
profile = gnac_profiles_get_active_profile();
- if (profile != NULL) {
- if (gnac_utils_string_is_null_or_empty(profile->description)) {
- desc = g_strdup("No description");
- } else {
- formatted = gnac_profiles_properties_filter_text_for_displaying(
- profile->description, MAX_DESCR_DISPLAY_SIZE);
- desc = gnac_profiles_xml_engine_format_text_to_xml(formatted);
- g_free(formatted);
- formatted = desc;
- desc = g_strconcat("<i>", formatted, "</i>", NULL);
- g_free(formatted);
- }
-
- gtk_widget_set_tooltip_markup(widget, desc);
- g_free(desc);
- }
-}
+ if (!profile) return;
+ if (gnac_utils_string_is_null_or_empty(profile->description)) {
+ desc = g_strdup(_("No description available"));
+ } else {
+ formatted = gnac_profiles_properties_filter_text_for_displaying(
+ profile->description, MAX_DESCR_DISPLAY_SIZE);
+ desc = gnac_profiles_xml_engine_format_text_to_xml(formatted);
+ g_free(formatted);
+ formatted = desc;
+ desc = g_strconcat("<i>", formatted, "</i>", NULL);
+ g_free(formatted);
+ }
-static void
-gnac_profiles_on_profiles_managed_closed(GtkWidget *widget,
- gpointer data)
-{
- gnac_profiles_populate_combo();
+ gtk_widget_set_tooltip_markup(widget, desc);
+ g_free(desc);
}
diff --git a/src/profiles/gnac-profiles.h b/src/profiles/gnac-profiles.h
index 67b18f2..0880a31 100755
--- a/src/profiles/gnac-profiles.h
+++ b/src/profiles/gnac-profiles.h
@@ -36,6 +36,9 @@ gnac_profiles_init(void);
void
gnac_profiles_destroy(void);
+void
+gnac_profiles_populate_combo(void);
+
GtkWidget *
gnac_profiles_get_widget(GtkWidget *parent);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]