[gnac/devel] Code refactoring
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code refactoring
- Date: Sat, 26 Nov 2011 11:33:49 +0000 (UTC)
commit ad720754647403310d137da47047868d68fdcbc8
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Fri Nov 25 21:05:12 2011 +0000
Code refactoring
data/profiles/aac.xml.in | 12 +-
data/profiles/base.xml.in | 6 +-
data/profiles/flac.xml.in | 3 +-
data/profiles/mp3-lame.xml.in | 27 +-
data/profiles/speex.xml.in | 30 +-
data/profiles/ui/gnac-profiles-manager.xml | 3 +
data/profiles/vorbis.xml.in | 15 +-
data/profiles/wavpack.xml.in | 21 +-
src/profiles/formats/gnac-profiles-aac.c | 112 ++----
src/profiles/formats/gnac-profiles-flac.c | 124 ++----
src/profiles/formats/gnac-profiles-lame.c | 271 +++++--------
src/profiles/formats/gnac-profiles-speex.c | 325 ++++++---------
src/profiles/formats/gnac-profiles-unknown.c | 121 ++----
src/profiles/formats/gnac-profiles-vorbis.c | 185 +++------
src/profiles/formats/gnac-profiles-wav.c | 93 ++---
src/profiles/formats/gnac-profiles-wavpack.c | 269 +++++--------
src/profiles/gnac-profiles-default.c | 48 +--
src/profiles/gnac-profiles-properties.c | 190 ++++-----
src/profiles/gnac-profiles-utils.c | 311 +++++---------
src/profiles/gnac-profiles-utils.h | 28 +-
src/profiles/gnac-profiles-xml-engine.c | 586 ++++++++++++--------------
src/profiles/gnac-profiles-xml-engine.h | 39 +-
src/profiles/gnac-profiles.c | 103 ++---
23 files changed, 1101 insertions(+), 1821 deletions(-)
---
diff --git a/data/profiles/aac.xml.in b/data/profiles/aac.xml.in
index ade9b99..dfc6d3b 100644
--- a/data/profiles/aac.xml.in
+++ b/data/profiles/aac.xml.in
@@ -13,9 +13,8 @@
<process id="multiplexer">
<value value="ffmux_mp4">...</value>
</process>
- <variable id="bitrate">
+ <variable id="bitrate" type="combo">
<name>Bitrate</name>
- <control-type>combo</control-type>
<variable-name>bitrate</variable-name>
<default-value>128000</default-value>
<possible-values>
@@ -38,10 +37,9 @@
<value value="320000">320 Kbps</value>
</possible-values>
</variable>
- <variable id="profile">
+ <variable id="profile" type="combo">
<name>Profile</name>
<_description>AAC takes a modular approach to encoding. There are four default profiles using different tools: (LC) -> the simplest and most widely used and supported; (MAIN) -> like the LC profile, with the addition of backwards prediction; (SRS) -> a.k.a. Scalable Sample Rate (MPEG-4 AAC-SSR); (LTP) -> an improvement of the MAIN profile using a forward predictor with lower computational complexity.</_description>
- <control-type>combo</control-type>
<variable-name>profile</variable-name>
<default-value>1</default-value>
<possible-values>
@@ -51,17 +49,15 @@
<value value="4">Long term prediction (LTP)</value>
</possible-values>
</variable>
- <variable id="tns">
+ <variable id="tns" type="check">
<name>Temporal noise shaping</name>
<_description>Conventional transform coding schemes often encounter problems with signals that vary heavily over time, especially speech signals. Temporal noise shaping can be viewed as a postprocessing step which goal is to overcome this limitation.</_description>
<variable-name>tns</variable-name>
- <control-type>check</control-type>
<default-value>false</default-value>
</variable>
- <variable id="outputformat">
+ <variable id="outputformat" type="combo">
<name>Output format</name>
<variable-name>outputformat</variable-name>
- <control-type>combo</control-type>
<default-value>1</default-value>
<possible-values>
<_value value="1">ADTS headers</_value>
diff --git a/data/profiles/base.xml.in b/data/profiles/base.xml.in
index 0be0dcb..70665c3 100755
--- a/data/profiles/base.xml.in
+++ b/data/profiles/base.xml.in
@@ -1,20 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<audio-profiles>
<preset-variables>
- <variable id="channels">
+ <variable id="channels" type="combo">
<name>Channels</name>
<variable-name>channels</variable-name>
- <control-type>combo</control-type>
<default-value>2</default-value>
<possible-values>
<_value value="1">1 (mono)</_value>
<_value value="2">2 (stereo)</_value>
</possible-values>
</variable>
- <variable id="sample-rate">
+ <variable id="sample-rate" type="combo">
<name>Sample Rate</name>
<variable-name>rate</variable-name>
- <control-type>combo</control-type>
<default-value>44100</default-value>
<possible-values>
<value value="44100">44.1 kHz</value>
diff --git a/data/profiles/flac.xml.in b/data/profiles/flac.xml.in
index 2a2921a..89ac996 100755
--- a/data/profiles/flac.xml.in
+++ b/data/profiles/flac.xml.in
@@ -11,10 +11,9 @@
<mimetype>audio/x-flac</mimetype>
<pipeline>
<process id="gstreamer-audio">flacenc name=enc</process>
- <variable id="compression">
+ <variable id="compression" type="slider">
<name>Compression</name>
<variable-name>quality</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>8.0</max-value>
<step-value>1.0</step-value>
diff --git a/data/profiles/mp3-lame.xml.in b/data/profiles/mp3-lame.xml.in
index b8403a9..e4e9d09 100644
--- a/data/profiles/mp3-lame.xml.in
+++ b/data/profiles/mp3-lame.xml.in
@@ -18,10 +18,9 @@
<value value="xingmux">Add Xing header</value>
<value value="id3v2mux">Add id3v2 header</value>
</process>
- <variable id="preset">
+ <variable id="preset" type="combo">
<name>Preset</name>
<variable-name>preset</variable-name>
- <control-type>combo</control-type>
<default-value>1006</default-value>
<possible-values>
<_value value="1006">Medium</_value>
@@ -30,10 +29,9 @@
<_value value="1003">Insane</_value>
</possible-values>
</variable>
- <variable id="encoding-mode">
+ <variable id="encoding-mode" type="combo">
<name>Bitrate mode</name>
<variable-name>vbr</variable-name>
- <control-type>combo</control-type>
<default-value>0</default-value>
<possible-values>
<_value value="0">Constant bitrate (CBR)</_value>
@@ -43,38 +41,34 @@
<_value value="6">Compression ratio</_value>
</possible-values>
</variable>
- <variable id="quality">
+ <variable id="quality" type="slider">
<name>VBR quality</name>
<variable-name>vbr-quality</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>9.0</max-value>
<step-value>1.0</step-value>
<default-value>3.0</default-value>
</variable>
- <variable id="compression-ratio">
+ <variable id="compression-ratio" type="slider">
<name>Compression ratio</name>
<_description>Let lame choose bitrate to achieve selected compression ratio.</_description>
<variable-name>compression-ratio</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>200</max-value>
<step-value>1.0</step-value>
<default-value>0.0</default-value>
</variable>
- <variable id="mean-bitrate">
+ <variable id="mean-bitrate" type="slider">
<name>VBR mean bitrate</name>
<variable-name>vbr-mean-bitrate</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>330.0</max-value>
<step-value>1.0</step-value>
<default-value>192</default-value>
</variable>
- <variable id="bitrate">
+ <variable id="bitrate" type="combo">
<name>Bitrate</name>
<variable-name>bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>128</default-value>
<possible-values>
<value value="8">8 Kbps</value>
@@ -96,10 +90,9 @@
<value value="320">320 Kbps</value>
</possible-values>
</variable>
- <variable id="min-bitrate">
+ <variable id="min-bitrate" type="combo">
<name>VBR minimum bitrate</name>
<variable-name>vbr-min-bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>128</default-value>
<possible-values>
<value value="8">8 Kbps</value>
@@ -121,10 +114,9 @@
<value value="320">320 Kbps</value>
</possible-values>
</variable>
- <variable id="max-bitrate">
+ <variable id="max-bitrate" type="combo">
<name>VBR maximum bitrate</name>
<variable-name>vbr-max-bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>128</default-value>
<possible-values>
<value value="8">8 Kbps</value>
@@ -146,10 +138,9 @@
<value value="320">320 Kbps</value>
</possible-values>
</variable>
- <variable id="mode">
+ <variable id="mode" type="combo">
<name>Mode</name>
<variable-name>mode</variable-name>
- <control-type>combo</control-type>
<default-value>4</default-value>
<possible-values>
<_value value="0">Stereo</_value>
diff --git a/data/profiles/speex.xml.in b/data/profiles/speex.xml.in
index 75bbb98..b582d91 100644
--- a/data/profiles/speex.xml.in
+++ b/data/profiles/speex.xml.in
@@ -12,10 +12,9 @@
<process id="multiplexer">
<value value="oggmux">Merge audio and video streams</value>
</process>
- <variable id="bitrate-mode">
+ <variable id="bitrate-mode" type="combo">
<name>Bitrate mode</name>
<variable-name>vbr</variable-name>
- <control-type>combo</control-type>
<default-value>0</default-value>
<possible-values>
<_value value="0">Constant bitrate (CBR)</_value>
@@ -23,53 +22,47 @@
<_value value="2">Variable bitrate (VBR)</_value>
</possible-values>
</variable>
- <variable id="quality-cbr">
+ <variable id="quality-cbr" type="slider">
<name>Audio Quality</name>
<variable-name>quality</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>10.0</max-value>
<step-value>1.0</step-value>
<default-value>8.0</default-value>
</variable>
- <variable id="quality-vbr">
+ <variable id="quality-vbr" type="slider">
<name>Audio Quality</name>
<variable-name>quality</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>10.0</max-value>
<step-value>0.05</step-value>
<default-value>8.0</default-value>
</variable>
- <variable id="bitrate">
+ <variable id="bitrate" type="slider">
<name>Bitrate</name>
<variable-name>bitrate</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>64.0</max-value>
<step-value>1.0</step-value>
<default-value>0.0</default-value>
</variable>
- <variable id="abr">
+ <variable id="abr" type="slider">
<name>Bitrate</name>
<variable-name>abr</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>64.0</max-value>
<step-value>1.0</step-value>
<default-value>44.0</default-value>
</variable>
- <variable id="vbr">
+ <variable id="vbr" type="check">
<name>Bitrate mode</name>
<variable-name>vbr</variable-name>
- <control-type>check</control-type>
<default-value>false</default-value>
</variable>
- <variable id="mode">
+ <variable id="mode" type="combo">
<name>Mode</name>
<_description>Encoding mode</_description>
<variable-name>mode</variable-name>
- <control-type>combo</control-type>
<default-value>0</default-value>
<possible-values>
<value value="0">Auto</value>
@@ -78,28 +71,25 @@
<value value="3">Narrow Band</value>
</possible-values>
</variable>
- <variable id="complexity">
+ <variable id="complexity" type="slider">
<name>Complexity</name>
<_description>Specify the complexity allowed for the encoder. The cpu requirement for a complexity of 10 is about five times higher than for 1.</_description>
<variable-name>complexity</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>10.0</max-value>
<step-value>1.0</step-value>
<default-value>3.0</default-value>
</variable>
- <variable id="vad">
+ <variable id="vad" type="check">
<name>Voice activity detection</name>
<_description>Voice activity detection detects non-speech periods and encodes them with just enough bits to reproduce the background noise. Implicitly activated in vbr mode.</_description>
<variable-name>vad</variable-name>
- <control-type>check</control-type>
<default-value>false</default-value>
</variable>
- <variable id="dtx">
+ <variable id="dtx" type="check">
<name>Discontinuous transmission</name>
<_description>Allows to stop transmitting completely when the background noise is stationary. Non transmission periods are encoded with 5 bits per sample that is equivalent to a bitrate of about 250 bits/s.</_description>
<variable-name>dtx</variable-name>
- <control-type>check</control-type>
<default-value>false</default-value>
</variable>
</pipeline>
diff --git a/data/profiles/ui/gnac-profiles-manager.xml b/data/profiles/ui/gnac-profiles-manager.xml
index 0eb820c..42b8606 100644
--- a/data/profiles/ui/gnac-profiles-manager.xml
+++ b/data/profiles/ui/gnac-profiles-manager.xml
@@ -170,6 +170,9 @@
<property name="ypad">5</property>
<property name="justify">fill</property>
<property name="wrap">True</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
</object>
</child>
</object>
diff --git a/data/profiles/vorbis.xml.in b/data/profiles/vorbis.xml.in
index f6419e5..b220caf 100755
--- a/data/profiles/vorbis.xml.in
+++ b/data/profiles/vorbis.xml.in
@@ -18,29 +18,26 @@
<process id="multiplexer">
<value value="oggmux">Merge audio and video streams</value>
</process>
- <variable id="vbr">
+ <variable id="vbr" type="combo">
<name>Bitrate mode</name>
<variable-name>vbr</variable-name>
- <control-type>combo</control-type>
<default-value>1</default-value>
<possible-values>
<_value value="1">Variable bitrate (VBR)</_value>
<_value value="0">Constant bitrate (CBR)</_value>
</possible-values>
</variable>
- <variable id="quality">
+ <variable id="quality" type="slider">
<name>Audio Quality</name>
<variable-name>quality</variable-name>
- <control-type>slider</control-type>
<min-value>-0.1</min-value>
<max-value>1.0</max-value>
<step-value>0.1</step-value>
<default-value>0.3</default-value>
</variable>
- <variable id="bitrate">
+ <variable id="bitrate" type="combo">
<name>Bitrate</name>
<variable-name>bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>163840</default-value>
<possible-values>
<value value="8192">8 Kbps</value>
@@ -61,10 +58,9 @@
<value value="250000">244 Kbps</value>
</possible-values>
</variable>
- <variable id="vbr-min-bitrate">
+ <variable id="vbr-min-bitrate" type="combo">
<name>VBR minimum bitrate</name>
<variable-name>min-bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>163840</default-value>
<possible-values>
<value value="8192">8 Kbps</value>
@@ -85,10 +81,9 @@
<value value="250000">244 Kbps</value>
</possible-values>
</variable>
- <variable id="vbr-max-bitrate">
+ <variable id="vbr-max-bitrate" type="combo">
<name>VBR maximum bitrate</name>
<variable-name>max-bitrate</variable-name>
- <control-type>combo</control-type>
<default-value>163840</default-value>
<possible-values>
<value value="8192">8 Kbps</value>
diff --git a/data/profiles/wavpack.xml.in b/data/profiles/wavpack.xml.in
index 6da6d9b..e9a1cc8 100644
--- a/data/profiles/wavpack.xml.in
+++ b/data/profiles/wavpack.xml.in
@@ -10,10 +10,9 @@
<mimetype>application/x-wavpack</mimetype>
<pipeline>
<process id="gstreamer-audio">wavpackenc name=enc</process>
- <variable id="mode">
+ <variable id="mode" type="combo">
<name>Compression mode</name>
<variable-name>mode</variable-name>
- <control-type>combo</control-type>
<default-value>2</default-value>
<possible-values>
<_value value="1">Fast compression</_value>
@@ -22,55 +21,49 @@
<_value value="4">Very high compression</_value>
</possible-values>
</variable>
- <variable id="bitrate-control">
+ <variable id="bitrate-control" type="combo">
<name>Enable bitrate control</name>
<variable-name>none</variable-name>
- <control-type>combo</control-type>
<default-value>0</default-value>
<possible-values>
<_value value="0">Average bitrate (ABR)</_value>
<_value value="1">Bits per sample</_value>
</possible-values>
</variable>
- <variable id="bitrate">
+ <variable id="bitrate" type="slider">
<name>Average bitrate</name>
<variable-name>bitrate</variable-name>
- <control-type>slider</control-type>
<min-value>24.0</min-value>
<max-value>9610.0</max-value>
<step-value>8.0</step-value>
<default-value>24.0</default-value>
</variable>
- <variable id="bits-per-sample">
+ <variable id="bits-per-sample" type="slider">
<name>Bits per sample</name>
<variable-name>bits-per-sample</variable-name>
- <control-type>slider</control-type>
<min-value>2.0</min-value>
<max-value>24.0</max-value>
<step-value>1.0</step-value>
<default-value>2.0</default-value>
</variable>
- <variable id="extra-processing">
+ <variable id="extra-processing" type="slider">
<name>Extra processing</name>
<_description>Use better but slower filters for better compression/quality. Worst: 0; Best: 6.</_description>
<variable-name>extra-processing</variable-name>
- <control-type>slider</control-type>
<min-value>0.0</min-value>
<max-value>6.0</max-value>
<step-value>1.0</step-value>
<default-value>0.0</default-value>
</variable>
- <variable id="md5">
+ <variable id="md5" type="check">
<name>MD5 sum</name>
<_description>Store MD5 hash of raw samples within the file. It can be used by wavpack during decompression to verify the data integrity of lossless files.</_description>
<variable-name>md5</variable-name>
- <control-type>check</control-type>
<default-value>false</default-value>
</variable>
- <variable id="joint-stereo-mode">
+ <variable id="joint-stereo-mode" type="combo">
<name>Joint stereo mode</name>
<variable-name>joint-stereo-mode</variable-name>
- <control-type>combo</control-type>
<default-value>0</default-value>
<possible-values>
<_value value="0">Auto</_value>
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index becbe40..acab91d 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -56,63 +56,6 @@ BasicFormatInfo aac_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_aac_init(UpdateTextBufferFunc call_back);
-
-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)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_aac_init,
- gnac_profiles_aac_get_description,
- gnac_profiles_aac_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_aac_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_aac_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_aac_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_aac_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_aac_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_aac_load_specific_properties,
- gnac_profiles_aac_clean_up,
- NULL,
- gnac_profiles_aac_get_combo_format_name,
- gnac_profiles_aac_get_plugin_name
- };
-
- return funcs;
-}
-
static const gchar *
gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
@@ -125,25 +68,25 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&aac_bfi);
// Bitrate
- gnac_profiles_utils_all_in_one_for_combo(&aac_bfi,
- "combo-bitrate", "//variable[ id='bitrate']/*");
+ gnac_profiles_utils_init_widget(&aac_bfi, "combo-bitrate",
+ "//variable[ id='bitrate']");
// Profile
- widget = gnac_profiles_utils_all_in_one_for_combo(&aac_bfi,
- "combo-profile", "//variable[ id='profile']/*");
+ widget = gnac_profiles_utils_init_widget(&aac_bfi, "combo-profile",
+ "//variable[ id='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);
// Tns
- widget = gnac_profiles_utils_all_in_one_for_check(&aac_bfi,
- "checkbutton-tns", "//variable[ id='tns']/*");
+ widget = gnac_profiles_utils_init_widget(&aac_bfi, "checkbutton-tns",
+ "//variable[ id='tns']");
gnac_profiles_utils_add_description_tooltip(&aac_bfi,
"//variable[ id='tns']/description", widget, NULL);
// Outputformat
- widget = gnac_profiles_utils_all_in_one_for_combo(&aac_bfi,
- "combo-outputformat", "//variable[ id='outputformat']/*");
+ gnac_profiles_utils_init_widget(&aac_bfi, "combo-outputformat",
+ "//variable[ id='outputformat']");
gnac_profiles_xml_engine_free_doc_xpath(aac_bfi.doc);
aac_bfi.doc = NULL;
@@ -218,11 +161,9 @@ gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
static AudioProfileAAC *
gnac_profiles_aac_generate_audio_profile(GError **error)
{
- AudioProfileAAC *profile;
- AudioProfileGeneric *generic;
-
- generic = gnac_profiles_default_generate_audio_profile(&aac_bfi);
- profile = g_malloc(sizeof(AudioProfileAAC));
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &aac_bfi);
+ AudioProfileAAC *profile = g_malloc(sizeof(AudioProfileAAC));
if (!profile) return NULL;
profile->generic = generic;
@@ -255,9 +196,7 @@ gnac_profiles_aac_get_widget(AudioProfileAAC *profile)
static void
gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
{
- XMLDoc *doc;
-
- doc = gnac_profiles_default_save_profile(profile->generic, &aac_bfi);
+ XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &aac_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"bitrate", profile->bitrate,
"outputformat", profile->outputformat,
@@ -274,9 +213,7 @@ static AudioProfileAAC *
gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileAAC *profile;
-
- profile = g_malloc(sizeof(AudioProfileAAC));
+ AudioProfileAAC *profile = g_malloc(sizeof(AudioProfileAAC));
if (!profile) return NULL;
profile->generic = generic;
@@ -316,3 +253,26 @@ gnac_profiles_aac_get_description(void)
{
return aac_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_aac_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_aac_init,
+ gnac_profiles_aac_get_description,
+ gnac_profiles_aac_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_aac_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_aac_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_aac_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_aac_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_aac_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_aac_load_specific_properties,
+ gnac_profiles_aac_clean_up,
+ NULL,
+ gnac_profiles_aac_get_combo_format_name,
+ gnac_profiles_aac_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index 090dc47..3e33b4e 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -53,63 +53,6 @@ BasicFormatInfo flac_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_flac_init(UpdateTextBufferFunc call_back);
-
-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)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_flac_init,
- gnac_profiles_flac_get_description,
- gnac_profiles_flac_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_flac_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_flac_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_flac_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_flac_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_flac_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_flac_load_specific_properties,
- gnac_profiles_flac_clean_up,
- NULL,
- gnac_profiles_flac_get_combo_format_name,
- gnac_profiles_flac_get_plugin_name
- };
-
- return funcs;
-}
-
static const gchar *
gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
@@ -118,8 +61,8 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&flac_bfi);
- gnac_profiles_utils_all_in_one_for_slider(&flac_bfi,
- "slider-compression", "//variable[ id='compression']/*");
+ gnac_profiles_utils_init_widget(&flac_bfi, "slider-compression",
+ "//variable[ id='compression']");
gnac_profiles_xml_engine_free_doc_xpath(flac_bfi.doc);
flac_bfi.doc = NULL;
@@ -131,9 +74,7 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
void
gnac_profiles_flac_generate_pipeline(void)
{
- gchar *pipeline;
-
- pipeline = gnac_profiles_default_generate_pipeline(&flac_bfi);
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&flac_bfi);
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &flac_bfi,
"slider-compression", NULL);
update_text_buffer_call_back(pipeline);
@@ -178,11 +119,9 @@ gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile)
static AudioProfileFlac *
gnac_profiles_flac_generate_audio_profile(GError **error)
{
- AudioProfileFlac *profile;
- AudioProfileGeneric *generic;
-
- generic = gnac_profiles_default_generate_audio_profile(&flac_bfi);
- profile = g_malloc(sizeof(AudioProfileFlac));
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &flac_bfi);
+ AudioProfileFlac *profile = g_malloc(sizeof(AudioProfileFlac));
if (!profile) return NULL;
profile->generic = generic;
@@ -208,17 +147,13 @@ gnac_profiles_flac_get_widget(AudioProfileFlac *profile)
static void
gnac_profiles_flac_save_profile(AudioProfileFlac *profile)
{
- XMLDoc *doc;
- gchar *quality_str;
-
- quality_str = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
- doc = gnac_profiles_default_save_profile(profile->generic, &flac_bfi);
+ gchar *quality = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
+ XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &flac_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
- "quality", quality_str, NULL);
-
+ "quality", quality, NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
- g_free(quality_str);
+ g_free(quality);
}
@@ -226,20 +161,18 @@ static AudioProfileFlac*
gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileFlac *profile;
- gchar *quality_str;
-
- profile = g_malloc(sizeof(AudioProfileFlac));
+ AudioProfileFlac *profile = g_malloc(sizeof(AudioProfileFlac));
if (!profile) return NULL;
profile->generic = generic;
+
+ gchar *quality;
gnac_profiles_utils_load_saved_profile(doc,
- "/audio-profile/format-specific/",
- "quality", &quality_str, NULL);
+ "/audio-profile/format-specific/", "quality", &quality, NULL);
- if (quality_str) {
- profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
- g_free(quality_str);
+ if (quality) {
+ profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality);
+ g_free(quality);
}
return profile;
@@ -267,3 +200,26 @@ gnac_profiles_flac_get_description(void)
{
return flac_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_flac_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_flac_init,
+ gnac_profiles_flac_get_description,
+ gnac_profiles_flac_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_flac_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_flac_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_flac_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_flac_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_flac_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_flac_load_specific_properties,
+ gnac_profiles_flac_clean_up,
+ NULL,
+ gnac_profiles_flac_get_combo_format_name,
+ gnac_profiles_flac_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index 5af0da8..1ed4afa 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -70,68 +70,12 @@ BasicFormatInfo lame_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_lame_init(UpdateTextBufferFunc call_back);
-
-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);
static AudioProfileLame *
-gnac_profiles_lame_allocate_audio_profile(void);
-
-
-FormatModuleFuncs
-gnac_profiles_lame_get_funcs(void)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_lame_init,
- gnac_profiles_lame_get_description,
- gnac_profiles_lame_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_lame_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_lame_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_lame_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_lame_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_lame_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_lame_load_specific_properties,
- gnac_profiles_lame_clean_up,
- NULL,
- gnac_profiles_lame_get_combo_format_name,
- gnac_profiles_lame_get_plugin_name
- };
-
- return funcs;
-}
+gnac_profiles_lame_audio_profile_new(void);
void
@@ -154,48 +98,49 @@ gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
update_text_buffer_call_back = call_back;
// Bitrate
- gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-bitrate", "//variable[ id='bitrate']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "combo-bitrate",
+ "//variable[ id='bitrate']");
// Quality
- gnac_profiles_utils_all_in_one_for_slider(&lame_bfi,
- "slider-vbr-quality", "//variable[ id='quality']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "slider-vbr-quality",
+ "//variable[ id='quality']");
// Compression ratio
- widget = gnac_profiles_utils_all_in_one_for_slider(&lame_bfi,
- "slider-compression-ratio", "//variable[ id='compression-ratio']/*");
- widget2 = gnac_profiles_utils_get_widget(&lame_bfi, "label-compression-ratio"),
+ widget = gnac_profiles_utils_init_widget(&lame_bfi,
+ "slider-compression-ratio", "//variable[ id='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);
// Preset
- gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-preset", "//variable[ id='preset']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "combo-preset",
+ "//variable[ id='preset']");
// Abr bitrate
- widget = gnac_profiles_utils_all_in_one_for_slider(&lame_bfi,
- "slider-mean-abr", "//variable[ id='mean-bitrate']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "slider-mean-abr",
+ "//variable[ id='mean-bitrate']");
// Mode
- gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-mode", "//variable[ id='mode']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "combo-mode",
+ "//variable[ id='mode']");
// Mean bitrate
- widget = gnac_profiles_utils_all_in_one_for_slider(&lame_bfi,
- "slider-mean-vbr", "//variable[ id='mean-bitrate']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "slider-mean-vbr",
+ "//variable[ id='mean-bitrate']");
// Min bitrate
- widget = gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-min-vbr", "//variable[ id='min-bitrate']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "combo-min-vbr",
+ "//variable[ id='min-bitrate']");
// Max bitrate
- widget = gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-max-vbr", "//variable[ id='max-bitrate']/*");
+ gnac_profiles_utils_init_widget(&lame_bfi, "combo-max-vbr",
+ "//variable[ id='max-bitrate']");
// Encoding mode
- widget = gnac_profiles_utils_all_in_one_for_combo(&lame_bfi,
- "combo-encoding-mode", "//variable[ id='encoding-mode']/*");
+ widget = gnac_profiles_utils_init_widget(&lame_bfi, "combo-encoding-mode",
+ "//variable[ id='encoding-mode']");
gnac_profiles_lame_vbr_on_changed(GTK_COMBO_BOX(widget));
@@ -313,14 +258,10 @@ gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget)
void
gnac_profiles_lame_generate_pipeline(void)
{
- EncodingMode encoding_mode;
- gchar *pipeline;
- GtkWidget *widget;
-
- pipeline = gnac_profiles_default_generate_pipeline(&lame_bfi);
- widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
-
- encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&lame_bfi);
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&lame_bfi,
+ "combo-encoding-mode");
+ EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
// Mode
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &lame_bfi,
@@ -397,29 +338,18 @@ gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
{
if (!profile) {
gnac_profiles_utils_reinit_values_combo(&lame_bfi,
- "combo-mode",
- "combo-bitrate",
- "combo-min-vbr",
- "combo-max-vbr",
- "combo-preset",
- "combo-encoding-mode",
- NULL);
+ "combo-mode", "combo-bitrate", "combo-min-vbr", "combo-max-vbr",
+ "combo-preset", "combo-encoding-mode", NULL);
gnac_profiles_utils_reinit_values_slider(&lame_bfi,
- "slider-vbr-quality",
- "slider-compression-ratio",
- "slider-mean-vbr",
- "slider-mean-abr",
- NULL);
+ "slider-vbr-quality", "slider-compression-ratio",
+ "slider-mean-vbr", "slider-mean-abr", NULL);
gnac_profiles_utils_set_active_toggle_button(&lame_bfi, FALSE,
- "checkbutton-mean-bitrate",
- "checkbutton-min-bitrate",
- "checkbutton-max-bitrate",
- NULL);
+ "checkbutton-mean-bitrate", "checkbutton-min-bitrate",
+ "checkbutton-max-bitrate", NULL);
} else {
gnac_profiles_utils_set_values_combo(&lame_bfi,
"combo-encoding-mode", profile->encoding_mode,
- "combo-mode", profile->mode,
- NULL);
+ "combo-mode", profile->mode, NULL);
if (profile->bitrate)
{
@@ -469,11 +399,9 @@ gnac_profiles_lame_get_combo_format_name(void)
static AudioProfileLame *
-gnac_profiles_lame_allocate_audio_profile(void)
+gnac_profiles_lame_audio_profile_new(void)
{
- AudioProfileLame *profile;
-
- profile = g_malloc(sizeof(AudioProfileLame));
+ AudioProfileLame *profile = g_malloc(sizeof(AudioProfileLame));
if (!profile) return NULL;
profile->encoding_mode = NULL;
@@ -511,12 +439,9 @@ gnac_profiles_lame_free_audio_profile(AudioProfileLame *profile)
static AudioProfileLame *
gnac_profiles_lame_generate_audio_profile(GError **error)
{
- AudioProfileGeneric *generic;
- AudioProfileLame *profile;
- GtkWidget *widget;
-
- generic = gnac_profiles_default_generate_audio_profile(&lame_bfi);
- profile = gnac_profiles_lame_allocate_audio_profile();
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &lame_bfi);
+ AudioProfileLame *profile = gnac_profiles_lame_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_get_values_combo_and_set(&lame_bfi,
@@ -524,7 +449,8 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
"combo-mode", &profile->mode,
NULL);
- widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&lame_bfi,
+ "combo-encoding-mode");
switch (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)))
{
@@ -586,39 +512,38 @@ gnac_profiles_lame_get_widget(AudioProfileLame *profile)
static void
gnac_profiles_lame_save_profile(AudioProfileLame *profile)
{
- XMLDoc *doc;
- gchar *quality_str = NULL;
- gchar *mean_bitrate_str = NULL;
- gchar *mean_abr_str = NULL;
- gchar *compression_ratio_str = NULL;
+ gchar *quality = NULL;
+ gchar *mean_bitrate = NULL;
+ gchar *mean_abr = NULL;
+ gchar *compression_ratio = NULL;
if (profile->quality != -1)
{
- quality_str = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
+ quality = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
if (profile->mean_bitrate != -1) {
- mean_bitrate_str = gnac_profiles_utils_gdouble_to_gchararray(
+ mean_bitrate = gnac_profiles_utils_gdouble_to_gchararray(
profile->mean_bitrate);
}
}
else if (profile->mean_abr != -1)
{
- mean_abr_str = gnac_profiles_utils_gdouble_to_gchararray(profile->mean_abr);
+ mean_abr = gnac_profiles_utils_gdouble_to_gchararray(profile->mean_abr);
}
else if (profile->compression_ratio != -1) {
- compression_ratio_str = gnac_profiles_utils_gdouble_to_gchararray(
+ compression_ratio = gnac_profiles_utils_gdouble_to_gchararray(
profile->compression_ratio);
}
- doc = gnac_profiles_default_save_profile(profile->generic, &lame_bfi);
+ XMLDoc *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,
- "quality", quality_str,
- "compression-ratio", compression_ratio_str,
+ "quality", quality,
+ "compression-ratio", compression_ratio,
"preset", profile->preset,
- "mean-abr", mean_abr_str,
- "mean-bitrate", mean_bitrate_str,
+ "mean-abr", mean_abr,
+ "mean-bitrate", mean_bitrate,
"min-bitrate", profile->min_bitrate,
"max-bitrate", profile->max_bitrate,
"mode", profile->mode,
@@ -627,9 +552,9 @@ gnac_profiles_lame_save_profile(AudioProfileLame *profile)
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
- g_free(quality_str);
- g_free(mean_bitrate_str);
- g_free(compression_ratio_str);
+ g_free(quality);
+ g_free(mean_bitrate);
+ g_free(compression_ratio);
}
@@ -637,44 +562,43 @@ static AudioProfileLame *
gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileLame *profile;
- gchar *quality_str = NULL;
- gchar *mean_bitrate_str = NULL;
- gchar *mean_abr_str = NULL;
- gchar *compression_ratio_str = NULL;
+ gchar *quality;
+ gchar *mean_bitrate;
+ gchar *mean_abr;
+ gchar *compression_ratio;
- profile = gnac_profiles_lame_allocate_audio_profile();
+ AudioProfileLame *profile = gnac_profiles_lame_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
"encoding-mode", &profile->encoding_mode,
"bitrate", &profile->bitrate,
- "quality", &quality_str,
- "compression-ratio", &compression_ratio_str,
+ "quality", &quality,
+ "compression-ratio", &compression_ratio,
"preset", &profile->preset,
- "mean-abr", &mean_abr_str,
- "mean-bitrate", &mean_bitrate_str,
+ "mean-abr", &mean_abr,
+ "mean-bitrate", &mean_bitrate,
"min-bitrate", &profile->min_bitrate,
"max-bitrate", &profile->max_bitrate,
"mode", &profile->mode,
NULL);
- if (quality_str) {
- profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
- g_free(quality_str);
+ if (quality) {
+ profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality);
+ g_free(quality);
- if (mean_bitrate_str) {
+ if (mean_bitrate) {
profile->mean_bitrate = gnac_profiles_utils_gchararray_to_gdouble(
- mean_bitrate_str);
- g_free(mean_bitrate_str);
+ mean_bitrate);
+ g_free(mean_bitrate);
}
- } else if (mean_abr_str) {
- profile->mean_abr = gnac_profiles_utils_gchararray_to_gdouble(mean_abr_str);
- g_free(mean_abr_str);
- } else if (compression_ratio_str) {
+ } else if (mean_abr) {
+ profile->mean_abr = gnac_profiles_utils_gchararray_to_gdouble(mean_abr);
+ g_free(mean_abr);
+ } else if (compression_ratio) {
profile->compression_ratio = gnac_profiles_utils_gchararray_to_gdouble(
- compression_ratio_str);
- g_free(compression_ratio_str);
+ compression_ratio);
+ g_free(compression_ratio);
}
return profile;
@@ -686,19 +610,11 @@ gnac_profiles_lame_clean_up(void)
{
gnac_profiles_default_clean_up(&lame_bfi);
gnac_profiles_utils_free_combo_values(&lame_bfi,
- "combo-mode",
- "combo-bitrate",
- "combo-min-vbr",
- "combo-max-vbr",
- "combo-preset",
- "combo-encoding-mode",
- NULL);
+ "combo-mode", "combo-bitrate", "combo-min-vbr", "combo-max-vbr",
+ "combo-preset", "combo-encoding-mode", NULL);
gnac_profiles_utils_free_slider_values(&lame_bfi,
- "slider-vbr-quality",
- "slider-compression-ratio",
- "slider-mean-vbr",
- "slider-mean-abr",
- NULL);
+ "slider-vbr-quality", "slider-compression-ratio",
+ "slider-mean-vbr", "slider-mean-abr", NULL);
gnac_profiles_utils_free_basic_format_info_content(&lame_bfi);
}
@@ -715,3 +631,26 @@ gnac_profiles_lame_get_description(void)
{
return lame_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_lame_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_lame_init,
+ gnac_profiles_lame_get_description,
+ gnac_profiles_lame_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_lame_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_lame_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_lame_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_lame_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_lame_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_lame_load_specific_properties,
+ gnac_profiles_lame_clean_up,
+ NULL,
+ gnac_profiles_lame_get_combo_format_name,
+ gnac_profiles_lame_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index bb78c0f..d6cd013 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -66,39 +66,6 @@ BasicFormatInfo speex_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_speex_init(UpdateTextBufferFunc call_back);
-
-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);
@@ -107,30 +74,7 @@ static void
gnac_profiles_speex_display_vad(BitrateMode bitrate_mode);
static AudioProfileSpeex *
-gnac_profiles_speex_allocate_audio_profile(void);
-
-
-FormatModuleFuncs
-gnac_profiles_speex_get_funcs(void)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_speex_init,
- gnac_profiles_speex_get_description,
- gnac_profiles_speex_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_speex_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_speex_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_speex_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_speex_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_speex_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_speex_load_specific_properties,
- gnac_profiles_speex_clean_up,
- NULL,
- gnac_profiles_speex_get_combo_format_name,
- gnac_profiles_speex_get_plugin_name
- };
-
- return funcs;
-}
+gnac_profiles_speex_audio_profile_new(void);
void
@@ -153,58 +97,57 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&speex_bfi);
// Bitrate
- widget = gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
- "slider-bitrate-cbr", "//variable[ id='bitrate']/*");
+ gnac_profiles_utils_init_widget(&speex_bfi, "slider-bitrate-cbr",
+ "//variable[ id='bitrate']");
// Bitrate-abr
- gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
- "slider-bitrate-abr", "//variable[ id='abr']/*");
+ gnac_profiles_utils_init_widget(&speex_bfi, "slider-bitrate-abr",
+ "//variable[ id='abr']");
// Quality-cbr
- widget = gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
- "slider-quality-cbr", "//variable[ id='quality-cbr']/*");
+ gnac_profiles_utils_init_widget(&speex_bfi, "slider-quality-cbr",
+ "//variable[ id='quality-cbr']");
// Quality-vbr
- widget = gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
- "slider-quality-vbr", "//variable[ id='quality-vbr']/*");
+ widget = gnac_profiles_utils_init_widget(&speex_bfi, "slider-quality-vbr",
+ "//variable[ id='quality-vbr']");
gtk_scale_set_digits(GTK_SCALE(widget), 2);
// vbr
- widget = gnac_profiles_utils_all_in_one_for_check(&speex_bfi,
- "checkbutton-vbr", "//variable[ id='vbr']/*");
+ gnac_profiles_utils_init_widget(&speex_bfi, "checkbutton-vbr",
+ "//variable[ id='vbr']");
// Complexity
- widget2 = gnac_profiles_utils_all_in_one_for_slider(&speex_bfi,
- "slider-complexity", "//variable[ id='complexity']/*");
widget = gnac_profiles_utils_get_widget(&speex_bfi, "hbox-complexity");
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-complexity");
+ widget2 = gnac_profiles_utils_init_widget(&speex_bfi, "slider-complexity",
+ "//variable[ id='complexity']");
gnac_profiles_utils_add_description_tooltip(&speex_bfi,
"//variable[ id='complexity']/description",
widget, widget2, NULL);
// vad
- widget = gnac_profiles_utils_all_in_one_for_check(&speex_bfi,
- "checkbutton-vad", "//variable[ id='vad']/*");
+ widget = gnac_profiles_utils_init_widget(&speex_bfi, "checkbutton-vad",
+ "//variable[ id='vad']");
gnac_profiles_utils_add_description_tooltip(&speex_bfi,
"//variable[ id='vad']/description", widget, NULL);
// dtx
- widget = gnac_profiles_utils_all_in_one_for_check(&speex_bfi,
- "checkbutton-dtx", "//variable[ id='dtx']/*");
+ widget = gnac_profiles_utils_init_widget(&speex_bfi, "checkbutton-dtx",
+ "//variable[ id='dtx']");
gnac_profiles_utils_add_description_tooltip(&speex_bfi,
"//variable[ id='dtx']/description", widget, NULL);
// mode
- widget = gnac_profiles_utils_all_in_one_for_combo(&speex_bfi,
- "combo-mode", "//variable[ id='mode']/*");
+ widget = gnac_profiles_utils_init_widget(&speex_bfi, "combo-mode",
+ "//variable[ id='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);
// Bitrate mode
- widget = gnac_profiles_utils_all_in_one_for_combo(&speex_bfi,
- "combo-bitrate-mode", "//variable[ id='bitrate-mode']/*");
+ widget = gnac_profiles_utils_init_widget(&speex_bfi, "combo-bitrate-mode",
+ "//variable[ id='bitrate-mode']");
gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(widget));
@@ -281,11 +224,8 @@ gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget)
static void
gnac_profiles_speex_display_vad(BitrateMode bitrate_mode)
{
- GtkWidget *vad;
- GtkWidget *dtx;
-
- vad = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-vad");
- dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
+ GtkWidget *vad = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-vad");
+ GtkWidget *dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
if (bitrate_mode == CONSTANT_BITRATE) {
gtk_widget_show(vad);
@@ -303,11 +243,9 @@ gnac_profiles_speex_display_vad(BitrateMode bitrate_mode)
void
gnac_profiles_speex_generate_pipeline(void)
{
- gchar *pipeline;
- GtkWidget *widget;
-
- pipeline = gnac_profiles_default_generate_pipeline(&speex_bfi);
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&speex_bfi);
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&speex_bfi,
+ "combo-bitrate-mode");
BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
@@ -382,9 +320,7 @@ void
gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
gpointer user_data)
{
- GtkWidget *dtx;
-
- dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
+ GtkWidget *dtx = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-dtx");
if (gtk_toggle_button_get_active(togglebutton)) {
gtk_widget_show(dtx);
@@ -399,38 +335,30 @@ gnac_profiles_speex_vad_on_toggle(GtkToggleButton *togglebutton,
static void
gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
{
- GtkWidget *widget;
-
if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &speex_bfi);
gnac_profiles_utils_reinit_values_combo(&speex_bfi,
- "combo-bitrate-mode",
- "combo-mode",
- NULL);
+ "combo-bitrate-mode", "combo-mode", NULL);
gnac_profiles_utils_reinit_values_slider(&speex_bfi,
- "slider-quality-cbr",
- "slider-quality-vbr",
- "slider-bitrate-cbr",
- "slider-bitrate-abr",
- "slider-complexity",
- NULL);
+ "slider-quality-cbr", "slider-quality-vbr", "slider-bitrate-cbr",
+ "slider-bitrate-abr", "slider-complexity", NULL);
gnac_profiles_utils_reinit_values_check(&speex_bfi,
- "checkbutton-vad",
- "checkbutton-dtx",
- NULL);
+ "checkbutton-vad", "checkbutton-dtx", NULL);
gnac_profiles_utils_set_active_toggle_button(&speex_bfi, FALSE,
"checkbutton-complexity", "checkbutton-bitrate-cbr", NULL);
} else {
gnac_profiles_default_fullfill_fields(profile->generic, &speex_bfi);
gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
- "slider-complexity", "checkbutton-complexity", profile->complexity,
- NULL);
+ "slider-complexity", "checkbutton-complexity",
+ profile->complexity, NULL);
gnac_profiles_utils_set_values_combo(&speex_bfi,
"combo-mode", profile->mode, NULL);
gnac_profiles_utils_set_values_check(&speex_bfi,
- "checkbutton-vad", profile->vad, "checkbutton-dtx", profile->dtx, NULL);
+ "checkbutton-vad", profile->vad,
+ "checkbutton-dtx", profile->dtx, NULL);
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&speex_bfi,
+ "combo-bitrate-mode");
if (profile->quality_cbr != -1)
{
@@ -440,8 +368,7 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
if (profile->bitrate_cbr != 1) {
gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
"slider-bitrate-cbr", "checkbutton-bitrate-cbr",
- profile->bitrate_cbr,
- NULL);
+ profile->bitrate_cbr, NULL);
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
@@ -472,11 +399,9 @@ gnac_profiles_speex_get_combo_format_name(void)
static AudioProfileSpeex *
-gnac_profiles_speex_allocate_audio_profile(void)
+gnac_profiles_speex_audio_profile_new(void)
{
- AudioProfileSpeex *profile;
-
- profile = g_malloc(sizeof(AudioProfileSpeex));
+ AudioProfileSpeex *profile = g_malloc(sizeof(AudioProfileSpeex));
if (!profile) return NULL;
profile->quality_cbr = -1;
@@ -509,22 +434,18 @@ gnac_profiles_speex_free_audio_profile(AudioProfileSpeex *profile)
static AudioProfileSpeex *
gnac_profiles_speex_generate_audio_profile(GError **error)
{
- AudioProfileGeneric *generic;
- AudioProfileSpeex *profile;
- GtkWidget *widget;
- BitrateMode bitrate_mode;
-
- generic = gnac_profiles_default_generate_audio_profile(&speex_bfi);
- profile = gnac_profiles_speex_allocate_audio_profile();
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &speex_bfi);
+ AudioProfileSpeex *profile = gnac_profiles_speex_audio_profile_new();
profile->generic = generic;
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
- bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&speex_bfi,
+ "combo-bitrate-mode");
+ BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
gnac_profiles_utils_get_values_combo_and_set(&speex_bfi,
"combo-mode", &profile->mode, NULL);
gnac_profiles_utils_get_values_checked_slider_and_set(&speex_bfi,
- "slider-complexity", "checkbutton-complexity", &profile->complexity,
- NULL);
+ "slider-complexity", "checkbutton-complexity", &profile->complexity, NULL);
gnac_profiles_utils_get_values_check_and_set(&speex_bfi,
"checkbutton-dtx", &profile->dtx, NULL);
@@ -532,26 +453,22 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
{
case CONSTANT_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
- "slider-quality-cbr", &profile->quality_cbr,
- NULL);
+ "slider-quality-cbr", &profile->quality_cbr, NULL);
gnac_profiles_utils_get_values_checked_slider_and_set(&speex_bfi,
"slider-bitrate-cbr", "checkbutton-bitrate-cbr",
- &profile->bitrate_cbr,
- NULL);
+ &profile->bitrate_cbr, NULL);
gnac_profiles_utils_get_values_check_and_set(&speex_bfi,
"checkbutton-vad", &profile->vad, NULL);
break;
case AVERAGE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
- "slider-bitrate-abr", &profile->bitrate_abr,
- NULL);
+ "slider-bitrate-abr", &profile->bitrate_abr, NULL);
break;
case VARIABLE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&speex_bfi,
- "slider-quality-vbr", &profile->quality_vbr,
- NULL);
+ "slider-quality-vbr", &profile->quality_vbr, NULL);
break;
}
@@ -573,59 +490,53 @@ gnac_profiles_speex_get_widget(AudioProfileSpeex *profile)
static void
gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
{
- XMLDoc *doc;
- gchar *quality_cbr_str = NULL;
- gchar *bitrate_cbr_str = NULL;
- gchar *bitrate_abr_str = NULL;
- gchar *quality_vbr_str = NULL;
- gchar *complexity_str = NULL;
+ gchar *quality_cbr = NULL;
+ gchar *bitrate_cbr = NULL;
+ gchar *bitrate_abr = NULL;
+ gchar *quality_vbr = NULL;
+ gchar *complexity = NULL;
if (profile->quality_cbr != -1)
{
- quality_cbr_str = gnac_profiles_utils_gdouble_to_gchararray(
+ quality_cbr = gnac_profiles_utils_gdouble_to_gchararray(
profile->quality_cbr);
if (profile->bitrate_cbr != -1) {
- bitrate_cbr_str = gnac_profiles_utils_gdouble_to_gchararray(
+ bitrate_cbr = gnac_profiles_utils_gdouble_to_gchararray(
profile->bitrate_cbr);
}
}
else if (profile->quality_vbr != -1)
{
- quality_vbr_str = gnac_profiles_utils_gdouble_to_gchararray_format(
+ quality_vbr = gnac_profiles_utils_gdouble_to_gchararray_format(
profile->quality_vbr, "%.2f");
}
else
{
- bitrate_abr_str = gnac_profiles_utils_gdouble_to_gchararray(
+ bitrate_abr = gnac_profiles_utils_gdouble_to_gchararray(
profile->bitrate_abr);
}
if (profile->complexity != -1) {
- complexity_str = gnac_profiles_utils_gdouble_to_gchararray(
+ complexity = gnac_profiles_utils_gdouble_to_gchararray(
profile->complexity);
}
- doc = gnac_profiles_default_save_profile(profile->generic, &speex_bfi);
+ XMLDoc *doc = gnac_profiles_default_save_profile(profile->generic, &speex_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
- "bitrate-cbr", bitrate_cbr_str,
- "quality-cbr", quality_cbr_str,
- "bitrate-abr", bitrate_abr_str,
- "quality-vbr", quality_vbr_str,
- "mode", profile->mode,
- "complexity", complexity_str,
- "vad", profile->vad,
- "dtx", profile->dtx,
- NULL);
+ "bitrate-cbr", bitrate_cbr, "quality-cbr", quality_cbr,
+ "bitrate-abr", bitrate_abr, "quality-vbr", quality_vbr,
+ "mode", profile->mode, "complexity", complexity,
+ "vad", profile->vad, "dtx", profile->dtx, NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
- g_free(quality_cbr_str);
- g_free(quality_vbr_str);
- g_free(bitrate_cbr_str);
- g_free(bitrate_abr_str);
- g_free(complexity_str);
+ g_free(quality_cbr);
+ g_free(quality_vbr);
+ g_free(bitrate_cbr);
+ g_free(bitrate_abr);
+ g_free(complexity);
}
@@ -633,57 +544,51 @@ static AudioProfileSpeex *
gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileSpeex *profile;
- gchar *quality_cbr_str;
- gchar *bitrate_cbr_str;
- gchar *bitrate_abr_str;
- gchar *quality_vbr_str;
- gchar *complexity_str;
+ gchar *quality_cbr;
+ gchar *bitrate_cbr;
+ gchar *bitrate_abr;
+ gchar *quality_vbr;
+ gchar *complexity;
- profile = gnac_profiles_speex_allocate_audio_profile();
+ AudioProfileSpeex *profile = gnac_profiles_speex_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
- "bitrate-cbr", &bitrate_cbr_str,
- "quality-cbr", &quality_cbr_str,
- "bitrate-abr", &bitrate_abr_str,
- "quality-vbr", &quality_vbr_str,
- "mode", &profile->mode,
- "complexity", &complexity_str,
- "vad", &profile->vad,
- "dtx", &profile->dtx,
- NULL);
+ "bitrate-cbr", &bitrate_cbr, "quality-cbr", &quality_cbr,
+ "bitrate-abr", &bitrate_abr, "quality-vbr", &quality_vbr,
+ "mode", &profile->mode, "complexity", &complexity,
+ "vad", &profile->vad, "dtx", &profile->dtx, NULL);
- if (complexity_str) {
+ if (complexity) {
profile->complexity = gnac_profiles_utils_gchararray_to_gdouble(
- complexity_str);
- g_free(complexity_str);
+ complexity);
+ g_free(complexity);
}
- if (quality_cbr_str)
+ if (quality_cbr)
{
profile->quality_cbr = gnac_profiles_utils_gchararray_to_gdouble(
- quality_cbr_str);
+ quality_cbr);
- if (bitrate_cbr_str) {
+ if (bitrate_cbr) {
profile->bitrate_cbr = gnac_profiles_utils_gchararray_to_gdouble(
- bitrate_cbr_str);
- g_free(bitrate_cbr_str);
+ bitrate_cbr);
+ g_free(bitrate_cbr);
}
- g_free(quality_cbr_str);
+ g_free(quality_cbr);
}
- else if (quality_vbr_str)
+ else if (quality_vbr)
{
profile->quality_vbr = gnac_profiles_utils_gchararray_to_gdouble(
- quality_vbr_str);
- g_free(quality_vbr_str);
+ quality_vbr);
+ g_free(quality_vbr);
}
else
{
profile->bitrate_abr = gnac_profiles_utils_gchararray_to_gdouble(
- bitrate_abr_str);
- g_free(bitrate_abr_str);
+ bitrate_abr);
+ g_free(bitrate_abr);
}
return profile;
@@ -695,21 +600,12 @@ gnac_profiles_speex_clean_up(void)
{
gnac_profiles_default_clean_up(&speex_bfi);
gnac_profiles_utils_free_combo_values(&speex_bfi,
- "combo-mode",
- "combo-bitrate-mode",
- NULL);
+ "combo-mode", "combo-bitrate-mode", NULL);
gnac_profiles_utils_free_slider_values(&speex_bfi,
- "slider-quality-cbr",
- "slider-quality-vbr",
- "slider-bitrate-cbr",
- "slider-bitrate-abr",
- "slider-complexity",
- NULL);
+ "slider-quality-cbr", "slider-quality-vbr", "slider-bitrate-cbr",
+ "slider-bitrate-abr", "slider-complexity", NULL);
gnac_profiles_utils_free_check_values(&speex_bfi,
- "checkbutton-vad",
- "checkbutton-dtx",
- "checkbutton-vbr",
- NULL);
+ "checkbutton-vad", "checkbutton-dtx", "checkbutton-vbr", NULL);
gnac_profiles_utils_free_basic_format_info_content(&speex_bfi);
}
@@ -726,3 +622,26 @@ gnac_profiles_speex_get_description(void)
{
return speex_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_speex_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_speex_init,
+ gnac_profiles_speex_get_description,
+ gnac_profiles_speex_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_speex_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_speex_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_speex_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_speex_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_speex_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_speex_load_specific_properties,
+ gnac_profiles_speex_clean_up,
+ NULL,
+ gnac_profiles_speex_get_combo_format_name,
+ gnac_profiles_speex_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index 4683e39..2412109 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -55,75 +55,12 @@ 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(void);
-
-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);
-FormatModuleFuncs
-gnac_profiles_unknown_get_funcs(void)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_unknown_init,
- gnac_profiles_unknown_get_description,
- gnac_profiles_unknown_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_unknown_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_unknown_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_unknown_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_unknown_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_unknown_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_unknown_load_specific_properties,
- gnac_profiles_unknown_clean_up,
- gnac_profiles_unknown_set_pipeline_text_view,
- gnac_profiles_unknown_get_combo_format_name,
- gnac_profiles_unknown_get_plugin_name
- };
-
- return funcs;
-}
-
-
static const gchar *
gnac_profiles_unknown_init(UpdateTextBufferFunc call_back)
{
@@ -153,10 +90,8 @@ gnac_profiles_unknown_generate_pipeline(void)
static void
gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile)
{
- GtkWidget *widget;
- GtkTextBuffer *text_buffer;
-
- widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&unknown_bfi,
+ "entry-extension");
if (!profile) {
gtk_entry_set_text(GTK_ENTRY(widget), "");
@@ -166,7 +101,8 @@ gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile)
}
} else {
gtk_entry_set_text(GTK_ENTRY(widget), profile->extension);
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pipeline_text_view));
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
+ GTK_TEXT_VIEW(pipeline_text_view));
gtk_text_buffer_set_text(text_buffer, profile->pipeline,
g_utf8_strlen(profile->pipeline, -1));
unknown_bfi.pipeline = g_strdup(profile->pipeline);
@@ -191,12 +127,9 @@ gnac_profiles_unknown_free_audio_profile(AudioProfileGeneric *profile)
static AudioProfileGeneric *
gnac_profiles_unknown_generate_audio_profile(GError **error)
{
- AudioProfileGeneric *profile;
- const gchar *extension;
- GtkWidget *widget;
-
- widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
- extension = gtk_entry_get_text(GTK_ENTRY(widget));
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&unknown_bfi,
+ "entry-extension");
+ const gchar *extension = gtk_entry_get_text(GTK_ENTRY(widget));
if (gnac_utils_string_is_null_or_empty(extension)) {
if (error && !*error) {
@@ -206,7 +139,7 @@ gnac_profiles_unknown_generate_audio_profile(GError **error)
return NULL;
}
- profile = gnac_profiles_utils_allocate_audio_profile_generic();
+ AudioProfileGeneric *profile = gnac_profiles_utils_audio_profile_generic_new();
profile->extension = g_strdup(extension);
profile->format_id = g_strdup(unknown_bfi.format_id);
profile->format_name = g_strdup(unknown_bfi.format_name);
@@ -229,8 +162,6 @@ gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
if (!g_signal_handler_is_connected(G_OBJECT(pipeline_text_view),
text_view_handler_id))
{
- GtkTextBuffer *text_buffer;
-
gtk_widget_show(GTK_WIDGET(pipeline_box));
text_view_handler_id = g_signal_connect(G_OBJECT(pipeline_text_view),
@@ -238,7 +169,8 @@ gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
G_CALLBACK(gnac_profiles_unknown_text_view_handler),
NULL);
- text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pipeline_text_view));
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(
+ GTK_TEXT_VIEW(pipeline_text_view));
if (unknown_bfi.pipeline) {
gtk_text_buffer_set_text(text_buffer, unknown_bfi.pipeline,
@@ -256,12 +188,8 @@ gnac_profiles_unknown_get_widget(AudioProfileGeneric *profile)
static void
gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile)
{
- XMLDoc *doc;
-
- doc = gnac_profiles_default_save_profile((AudioProfileGeneric*) profile,
- &unknown_bfi);
+ XMLDoc *doc = gnac_profiles_default_save_profile(profile, &unknown_bfi);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
-
gnac_profiles_xml_engine_free_doc_xpath(doc);
}
@@ -278,8 +206,8 @@ gnac_profiles_unknown_load_specific_properties(
static void
gnac_profiles_unknown_clean_up(void)
{
- GtkWidget *widget;
- widget = gnac_profiles_utils_get_widget(&unknown_bfi, "properties-alignment");
+ GtkWidget *widget = gnac_profiles_default_get_properties_alignment(
+ &unknown_bfi);
g_free(unknown_bfi.pipeline);
g_object_unref(unknown_bfi.builder);
gtk_widget_destroy(widget);
@@ -324,3 +252,26 @@ gnac_profiles_unknown_on_hide(GtkWidget *widget,
text_view_handler_id);
}
}
+
+
+FormatModuleFuncs
+gnac_profiles_unknown_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_unknown_init,
+ gnac_profiles_unknown_get_description,
+ gnac_profiles_unknown_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_unknown_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_unknown_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_unknown_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_unknown_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_unknown_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_unknown_load_specific_properties,
+ gnac_profiles_unknown_clean_up,
+ gnac_profiles_unknown_set_pipeline_text_view,
+ gnac_profiles_unknown_get_combo_format_name,
+ gnac_profiles_unknown_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index 624c7b4..423e3c0 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -61,68 +61,12 @@ BasicFormatInfo vorbis_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back);
-
-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);
static AudioProfileVorbis *
-gnac_profiles_vorbis_allocate_audio_profile(void);
-
-
-FormatModuleFuncs
-gnac_profiles_vorbis_get_funcs(void)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_vorbis_init,
- gnac_profiles_vorbis_get_description,
- gnac_profiles_vorbis_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_vorbis_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_vorbis_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_vorbis_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_vorbis_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_vorbis_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_vorbis_load_specific_properties,
- gnac_profiles_vorbis_clean_up,
- NULL,
- gnac_profiles_vorbis_get_combo_format_name,
- gnac_profiles_vorbis_get_plugin_name
- };
-
- return funcs;
-}
+gnac_profiles_vorbis_audio_profile_new(void);
void
@@ -180,25 +124,25 @@ gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&vorbis_bfi);
// Bitrate
- gnac_profiles_utils_all_in_one_for_combo(&vorbis_bfi,
- "combo-bitrate", "//variable[ id='bitrate']/*");
+ gnac_profiles_utils_init_widget(&vorbis_bfi, "combo-bitrate",
+ "//variable[ id='bitrate']");
// Quality
- widget = gnac_profiles_utils_all_in_one_for_slider(&vorbis_bfi,
- "slider-quality", "//variable[ id='quality']/*");
+ widget = gnac_profiles_utils_init_widget(&vorbis_bfi, "slider-quality",
+ "//variable[ id='quality']");
gtk_scale_set_digits(GTK_SCALE(widget), 1);
// Min bitrate
- widget = gnac_profiles_utils_all_in_one_for_combo(&vorbis_bfi,
- "combo-min-vbr", "//variable[ id='vbr-min-bitrate']/*");
+ gnac_profiles_utils_init_widget(&vorbis_bfi, "combo-min-vbr",
+ "//variable[ id='vbr-min-bitrate']");
// Max bitrate
- widget = gnac_profiles_utils_all_in_one_for_combo(&vorbis_bfi,
- "combo-max-vbr", "//variable[ id='vbr-max-bitrate']/*");
+ gnac_profiles_utils_init_widget(&vorbis_bfi, "combo-max-vbr",
+ "//variable[ id='vbr-max-bitrate']");
// Encoding mode
- widget = gnac_profiles_utils_all_in_one_for_combo(&vorbis_bfi,
- "combo-encoding-mode", "//variable[ id='vbr']/*");
+ widget = gnac_profiles_utils_init_widget(&vorbis_bfi, "combo-encoding-mode",
+ "//variable[ id='vbr']");
gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(widget));
@@ -222,12 +166,9 @@ gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
void
gnac_profiles_vorbis_generate_pipeline(void)
{
- GtkWidget *widget;
- gchar *pipeline;
-
- pipeline = gnac_profiles_default_generate_pipeline(&vorbis_bfi);
- widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
-
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&vorbis_bfi);
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&vorbis_bfi,
+ "combo-encoding-mode");
EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (encoding_mode == CONSTANT_BITRATE) {
@@ -265,25 +206,18 @@ gnac_profiles_vorbis_advanced_bitrate_on_toggle(GtkWidget *widget,
static void
gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
{
- GtkWidget *widget;
-
if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &vorbis_bfi);
gnac_profiles_utils_reinit_values_combo(&vorbis_bfi,
- "combo-encoding-mode",
- "combo-bitrate",
- "combo-min-vbr",
- "combo-max-vbr",
- NULL);
+ "combo-encoding-mode", "combo-bitrate",
+ "combo-min-vbr", "combo-max-vbr", NULL);
gnac_profiles_utils_reinit_values_slider(&vorbis_bfi,
- "slider-quality",
- NULL);
+ "slider-quality", NULL);
gnac_profiles_utils_set_active_toggle_button(&vorbis_bfi, FALSE,
- "checkbutton-min-bitrate",
- "checkbutton-max-bitrate",
- NULL);
+ "checkbutton-min-bitrate", "checkbutton-max-bitrate", NULL);
} else {
- widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&vorbis_bfi,
+ "combo-encoding-mode");
gnac_profiles_default_fullfill_fields(profile->generic, &vorbis_bfi);
if (profile->quality == -1) {
@@ -311,11 +245,9 @@ gnac_profiles_vorbis_get_combo_format_name(void)
static AudioProfileVorbis *
-gnac_profiles_vorbis_allocate_audio_profile(void)
+gnac_profiles_vorbis_audio_profile_new(void)
{
- AudioProfileVorbis *profile;
-
- profile = g_malloc(sizeof(AudioProfileVorbis));
+ AudioProfileVorbis *profile = g_malloc(sizeof(AudioProfileVorbis));
if (!profile) return NULL;
profile->quality = -1;
@@ -344,16 +276,13 @@ gnac_profiles_vorbis_free_audio_profile(AudioProfileVorbis *profile)
static AudioProfileVorbis *
gnac_profiles_vorbis_generate_audio_profile(GError **error)
{
- AudioProfileGeneric *generic;
- AudioProfileVorbis *profile;
- GtkWidget *widget;
- EncodingMode encoding_mode;
-
- generic = gnac_profiles_default_generate_audio_profile(&vorbis_bfi);
- profile = gnac_profiles_vorbis_allocate_audio_profile();
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &vorbis_bfi);
+ AudioProfileVorbis *profile = gnac_profiles_vorbis_audio_profile_new();
profile->generic = generic;
- widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
- encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&vorbis_bfi,
+ "combo-encoding-mode");
+ EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (encoding_mode == CONSTANT_BITRATE) {
gnac_profiles_utils_get_values_combo_and_set(&vorbis_bfi,
@@ -385,22 +314,17 @@ gnac_profiles_vorbis_get_widget(AudioProfileVorbis *profile)
static void
gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
{
- XMLDoc *doc;
- gchar *quality_str;
-
- quality_str = gnac_profiles_utils_gdouble_to_gchararray_format(
+ gchar *quality = gnac_profiles_utils_gdouble_to_gchararray_format(
profile->quality, "%.1f");
- doc = gnac_profiles_default_save_profile(profile->generic, &vorbis_bfi);
+ XMLDoc *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,
+ "quality", quality, "bitrate", profile->bitrate,
"min-bitrate", profile->min_bitrate,
- "max-bitrate", profile->max_bitrate,
- NULL);
+ "max-bitrate", profile->max_bitrate, NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
- g_free(quality_str);
+ g_free(quality);
}
@@ -408,22 +332,21 @@ static AudioProfileVorbis *
gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileVorbis *profile;
- gchar *quality_str;
+ gchar *quality;
- profile = gnac_profiles_vorbis_allocate_audio_profile();
+ AudioProfileVorbis *profile = gnac_profiles_vorbis_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
- "quality", &quality_str,
+ "quality", &quality,
"bitrate", &profile->bitrate,
"min-bitrate", &profile->min_bitrate,
"max-bitrate", &profile->max_bitrate,
NULL);
- if (quality_str) {
- profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
- g_free(quality_str);
+ if (quality) {
+ profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality);
+ g_free(quality);
}
return profile;
@@ -435,11 +358,8 @@ gnac_profiles_vorbis_clean_up(void)
{
gnac_profiles_default_clean_up(&vorbis_bfi);
gnac_profiles_utils_free_combo_values(&vorbis_bfi,
- "combo-bitrate",
- "combo-min-vbr",
- "combo-max-vbr",
- "combo-encoding-mode",
- NULL);
+ "combo-bitrate", "combo-min-vbr", "combo-max-vbr",
+ "combo-encoding-mode", NULL);
gnac_profiles_utils_free_slider_values(&vorbis_bfi, "slider-quality", NULL);
gnac_profiles_utils_free_basic_format_info_content(&vorbis_bfi);
}
@@ -457,3 +377,26 @@ gnac_profiles_vorbis_get_description(void)
{
return vorbis_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_vorbis_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_vorbis_init,
+ gnac_profiles_vorbis_get_description,
+ gnac_profiles_vorbis_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_vorbis_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_vorbis_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_vorbis_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_vorbis_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_vorbis_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_vorbis_load_specific_properties,
+ gnac_profiles_vorbis_clean_up,
+ NULL,
+ gnac_profiles_vorbis_get_combo_format_name,
+ gnac_profiles_vorbis_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index c8fc0b2..b77ceca 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -45,66 +45,6 @@ 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(void);
-
-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)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_wav_init,
- gnac_profiles_wav_get_description,
- gnac_profiles_wav_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wav_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_wav_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_wav_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_wav_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_wav_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wav_load_specific_properties,
- gnac_profiles_wav_clean_up,
- NULL,
- gnac_profiles_wav_get_combo_format_name,
- gnac_profiles_wav_get_plugin_name
- };
-
- return funcs;
-}
-
static const gchar *
gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
@@ -123,9 +63,7 @@ gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_wav_generate_pipeline(void)
{
- gchar *pipeline;
-
- pipeline = gnac_profiles_default_generate_pipeline(&wav_bfi);
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&wav_bfi);
update_text_buffer_call_back(pipeline);
g_free(wav_bfi.pipeline);
@@ -137,7 +75,6 @@ gnac_profiles_wav_generate_pipeline(void)
static void
gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile G_GNUC_UNUSED)
{
-
}
@@ -174,11 +111,8 @@ gnac_profiles_wav_get_widget(AudioProfileGeneric *profile)
static void
gnac_profiles_wav_save_profile(AudioProfileGeneric *profile)
{
- XMLDoc *doc;
-
- doc = gnac_profiles_default_save_profile(profile, &wav_bfi);
+ XMLDoc *doc = gnac_profiles_default_save_profile(profile, &wav_bfi);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
-
gnac_profiles_xml_engine_free_doc_xpath(doc);
}
@@ -211,3 +145,26 @@ gnac_profiles_wav_get_description(void)
{
return wav_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_wav_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_wav_init,
+ gnac_profiles_wav_get_description,
+ gnac_profiles_wav_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wav_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_wav_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_wav_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_wav_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_wav_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wav_load_specific_properties,
+ gnac_profiles_wav_clean_up,
+ NULL,
+ gnac_profiles_wav_get_combo_format_name,
+ gnac_profiles_wav_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index ab7ab24..4a546c4 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -63,68 +63,12 @@ BasicFormatInfo wavpack_bfi = {
static UpdateTextBufferFunc update_text_buffer_call_back;
-static const gchar *
-gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back);
-
-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);
static AudioProfileWavpack *
-gnac_profiles_wavpack_allocate_audio_profile(void);
-
-
-FormatModuleFuncs
-gnac_profiles_wavpack_get_funcs(void)
-{
- FormatModuleFuncs funcs = {
- gnac_profiles_wavpack_init,
- gnac_profiles_wavpack_get_description,
- gnac_profiles_wavpack_generate_pipeline,
- (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wavpack_generate_audio_profile,
- (FormatModuleFreeAudioProfileFunc) gnac_profiles_wavpack_free_audio_profile,
- (FormatModuleFullfillFieldsFunc) gnac_profiles_wavpack_fullfill_fields,
- (FormatModuleGetWidgetFunc) gnac_profiles_wavpack_get_widget,
- (FormatModuleSaveInFileFunc) gnac_profiles_wavpack_save_profile,
- (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wavpack_load_specific_properties,
- gnac_profiles_wavpack_clean_up,
- NULL,
- gnac_profiles_wavpack_get_combo_format_name,
- gnac_profiles_wavpack_get_plugin_name
- };
-
- return funcs;
-}
+gnac_profiles_wavpack_audio_profile_new(void);
void
@@ -147,38 +91,39 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&wavpack_bfi);
// Encoding mode
- gnac_profiles_utils_all_in_one_for_combo(&wavpack_bfi,
- "combo-mode", "//variable[ id='mode']/*");
+ gnac_profiles_utils_init_widget(&wavpack_bfi, "combo-mode",
+ "//variable[ id='mode']");
// Bitrate
- gnac_profiles_utils_all_in_one_for_slider(&wavpack_bfi,
- "slider-bitrate", "//variable[ id='bitrate']/*");
+ gnac_profiles_utils_init_widget(&wavpack_bfi, "slider-bitrate",
+ "//variable[ id='bitrate']");
// Bits per sample
- gnac_profiles_utils_all_in_one_for_slider(&wavpack_bfi,
- "slider-bits-per-sample", "//variable[ id='bits-per-sample']/*");
+ gnac_profiles_utils_init_widget(&wavpack_bfi, "slider-bits-per-sample",
+ "//variable[ id='bits-per-sample']");
// Extra processing
- widget = gnac_profiles_utils_all_in_one_for_slider(&wavpack_bfi,
- "slider-extra-processing", "//variable[ id='extra-processing']/*");
- widget2 = gnac_profiles_utils_get_widget(&wavpack_bfi, "label-extra-processing"),
+ widget = gnac_profiles_utils_init_widget(&wavpack_bfi,
+ "slider-extra-processing", "//variable[ id='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);
// Joint stereo mode
- widget = gnac_profiles_utils_all_in_one_for_combo(&wavpack_bfi,
- "combo-joint-stereo-mode", "//variable[ id='joint-stereo-mode']/*");
+ gnac_profiles_utils_init_widget(&wavpack_bfi,
+ "combo-joint-stereo-mode", "//variable[ id='joint-stereo-mode']");
// MD5
- widget = gnac_profiles_utils_all_in_one_for_check(&wavpack_bfi,
- "checkbutton-md5", "//variable[ id='md5']/*");
+ widget = gnac_profiles_utils_init_widget(&wavpack_bfi, "checkbutton-md5",
+ "//variable[ id='md5']");
gnac_profiles_utils_add_description_tooltip(&wavpack_bfi,
"//variable[ id='md5']/description", widget, NULL);
// Bitrate control
- widget = gnac_profiles_utils_all_in_one_for_combo(&wavpack_bfi,
- "combo-bitrate-control", "//variable[ id='bitrate-control']/*");
+ widget = gnac_profiles_utils_init_widget(&wavpack_bfi,
+ "combo-bitrate-control", "//variable[ id='bitrate-control']");
widget2 = gnac_profiles_utils_get_widget(&wavpack_bfi,
"checkbutton-bitrate-control");
gnac_profiles_wavpack_bitrate_control_on_toggle(widget,
@@ -243,13 +188,9 @@ gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
void
gnac_profiles_wavpack_generate_pipeline(void)
{
- GtkWidget *widget;
- GtkWidget *check;
- gchar *pipeline;
- ControlMethod control_method;
-
- pipeline = gnac_profiles_default_generate_pipeline(&wavpack_bfi);
- widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
+ gchar *pipeline = gnac_profiles_default_generate_pipeline(&wavpack_bfi);
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "combo-bitrate-control");
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &wavpack_bfi,
"combo-mode", NULL);
@@ -261,10 +202,11 @@ gnac_profiles_wavpack_generate_pipeline(void)
NULL);
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &wavpack_bfi,
"checkbutton-md5", NULL);
- check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
+ GtkWidget *check = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "checkbutton-bitrate-control");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
- control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ ControlMethod 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");
@@ -288,11 +230,10 @@ void
gnac_profiles_wavpack_bitrate_control_on_toggle(GtkWidget *widget,
GtkToggleButton *togglebutton)
{
- GtkWidget *label;
- GtkWidget *hbox;
-
- label = gnac_profiles_utils_get_widget(&wavpack_bfi, "label-control-method");
- hbox = gnac_profiles_utils_get_widget(&wavpack_bfi, "hbox-control-method");
+ GtkWidget *label = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "label-control-method");
+ GtkWidget *hbox = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "hbox-control-method");
if (gtk_toggle_button_get_active(togglebutton)) {
gtk_widget_show(hbox);
@@ -319,41 +260,32 @@ gnac_profiles_wavpack_joint_stereo_mode_on_toggle(GtkWidget *widget,
static void
gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
{
- GtkWidget *widget;
- GtkWidget *check;
-
if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &wavpack_bfi);
gnac_profiles_utils_reinit_values_combo(&wavpack_bfi,
- "combo-mode",
- "combo-bitrate-control",
- "combo-joint-stereo-mode",
- NULL);
+ "combo-mode", "combo-bitrate-control", "combo-joint-stereo-mode", NULL);
gnac_profiles_utils_reinit_values_check(&wavpack_bfi,
- "checkbutton-md5",
- NULL);
+ "checkbutton-md5", NULL);
gnac_profiles_utils_reinit_values_slider(&wavpack_bfi,
- "slider-bitrate",
- "slider-bits-per-sample",
- "slider-extra-processing",
- NULL);
+ "slider-bitrate", "slider-bits-per-sample",
+ "slider-extra-processing", NULL);
gnac_profiles_utils_set_active_toggle_button(&wavpack_bfi, FALSE,
"checkbutton-bitrate-control", NULL);
} else {
gnac_profiles_utils_set_values_combo(&wavpack_bfi,
- "combo-mode", profile->mode,
- NULL);
+ "combo-mode", profile->mode, NULL);
gnac_profiles_utils_set_values_checked_combo(&wavpack_bfi,
"combo-joint-stereo-mode", "checkbutton-joint-stereo-mode",
- profile->joint_stereo_mode,
- NULL);
+ profile->joint_stereo_mode, NULL);
gnac_profiles_utils_set_values_slider(&wavpack_bfi,
"slider-extra-processing", profile->extra_processing, NULL);
gnac_profiles_utils_set_values_check(&wavpack_bfi,
"checkbutton-md5", profile->md5, NULL);
- widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
- check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "combo-bitrate-control");
+ GtkWidget *check = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "checkbutton-bitrate-control");
if (profile->bitrate != -1.0) {
gnac_profiles_utils_set_values_slider(&wavpack_bfi,
@@ -378,11 +310,9 @@ gnac_profiles_wavpack_get_combo_format_name(void)
static AudioProfileWavpack *
-gnac_profiles_wavpack_allocate_audio_profile(void)
+gnac_profiles_wavpack_audio_profile_new(void)
{
- AudioProfileWavpack *profile;
-
- profile = g_malloc(sizeof(AudioProfileWavpack));
+ AudioProfileWavpack *profile = g_malloc(sizeof(AudioProfileWavpack));
if (!profile) return NULL;
profile->mode = NULL;
@@ -413,34 +343,28 @@ gnac_profiles_wavpack_free_audio_profile(AudioProfileWavpack *profile)
static AudioProfileWavpack *
gnac_profiles_wavpack_generate_audio_profile(GError **error)
{
- AudioProfileGeneric *generic;
- AudioProfileWavpack *profile;
- GtkWidget *widget;
- GtkWidget *check;
- ControlMethod control_method;
-
- generic = gnac_profiles_default_generate_audio_profile(&wavpack_bfi);
- profile = gnac_profiles_wavpack_allocate_audio_profile();
+ AudioProfileGeneric *generic = gnac_profiles_default_generate_audio_profile(
+ &wavpack_bfi);
+ AudioProfileWavpack *profile = gnac_profiles_wavpack_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_get_values_combo_and_set(&wavpack_bfi,
- "combo-mode", &profile->mode,
- NULL);
+ "combo-mode", &profile->mode, NULL);
gnac_profiles_utils_get_values_checked_combo_and_set(&wavpack_bfi,
"combo-joint-stereo-mode", "checkbutton-joint-stereo-mode",
- &profile->joint_stereo_mode,
- NULL);
+ &profile->joint_stereo_mode, NULL);
gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
- "slider-extra-processing", &profile->extra_processing,
- NULL);
+ "slider-extra-processing", &profile->extra_processing, NULL);
gnac_profiles_utils_get_values_check_and_set(&wavpack_bfi,
"checkbutton-md5", &profile->md5, NULL);
- widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
- check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
+ GtkWidget *widget = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "combo-bitrate-control");
+ GtkWidget *check = gnac_profiles_utils_get_widget(&wavpack_bfi,
+ "checkbutton-bitrate-control");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
- control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ ControlMethod control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (control_method == AVERAGE_BITRATE) {
gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
@@ -469,36 +393,35 @@ gnac_profiles_wavpack_get_widget(AudioProfileWavpack *profile)
static void
gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
{
- XMLDoc *doc;
- gchar *bitrate_str = NULL;
- gchar *bits_per_sample_str = NULL;
- gchar *extra_processing_str;
+ gchar *bitrate = NULL;
+ gchar *bits_per_sample = NULL;
if (profile->bitrate != -1) {
- bitrate_str = gnac_profiles_utils_gdouble_to_gchararray(profile->bitrate);
+ bitrate = gnac_profiles_utils_gdouble_to_gchararray(profile->bitrate);
} else if (profile->bits_per_sample != -1) {
- bits_per_sample_str = gnac_profiles_utils_gdouble_to_gchararray(
+ bits_per_sample = gnac_profiles_utils_gdouble_to_gchararray(
profile->bits_per_sample);
}
- extra_processing_str = gnac_profiles_utils_gdouble_to_gchararray(
+ gchar *extra_processing = gnac_profiles_utils_gdouble_to_gchararray(
profile->extra_processing);
- doc = gnac_profiles_default_save_profile(profile->generic, &wavpack_bfi);
+ XMLDoc *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,
- "bits-per-sample", bits_per_sample_str,
- "extra-processing", extra_processing_str,
+ "bitrate", bitrate,
+ "bits-per-sample", bits_per_sample,
+ "extra-processing", extra_processing,
"joint-stereo-mode", profile->joint_stereo_mode,
"md5", profile->md5,
NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
- g_free(bitrate_str);
- g_free(bits_per_sample_str);
- g_free(extra_processing_str);
+ g_free(bitrate);
+ g_free(bits_per_sample);
+ g_free(extra_processing);
}
@@ -506,35 +429,33 @@ static AudioProfileWavpack *
gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
- AudioProfileWavpack *profile;
- gchar *bitrate_str;
- gchar *bits_per_sample_str;
- gchar *extra_processing_str;
+ gchar *bitrate;
+ gchar *bits_per_sample;
+ gchar *extra_processing;
- profile = gnac_profiles_wavpack_allocate_audio_profile();
+ AudioProfileWavpack *profile = gnac_profiles_wavpack_audio_profile_new();
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
"mode", &profile->mode,
- "bitrate", &bitrate_str,
- "bits-per-sample", &bits_per_sample_str,
- "extra-processing", &extra_processing_str,
+ "bitrate", &bitrate,
+ "bits-per-sample", &bits_per_sample,
+ "extra-processing", &extra_processing,
"joint-stereo-mode", &profile->joint_stereo_mode,
"md5", &profile->md5,
NULL);
profile->extra_processing = gnac_profiles_utils_gchararray_to_gdouble(
- extra_processing_str);
-
- g_free(extra_processing_str);
+ extra_processing);
+ g_free(extra_processing);
- if (bitrate_str) {
- profile->bitrate = gnac_profiles_utils_gchararray_to_gdouble(bitrate_str);
- g_free(bitrate_str);
- } else if (bits_per_sample_str) {
+ if (bitrate) {
+ profile->bitrate = gnac_profiles_utils_gchararray_to_gdouble(bitrate);
+ g_free(bitrate);
+ } else if (bits_per_sample) {
profile->bits_per_sample = gnac_profiles_utils_gchararray_to_gdouble(
- bits_per_sample_str);
- g_free(bits_per_sample_str);
+ bits_per_sample);
+ g_free(bits_per_sample);
}
return profile;
@@ -546,16 +467,11 @@ gnac_profiles_wavpack_clean_up(void)
{
gnac_profiles_default_clean_up(&wavpack_bfi);
gnac_profiles_utils_free_combo_values(&wavpack_bfi,
- "combo-bitrate-control",
- "combo-mode",
- "combo-joint-stereo-mode",
- NULL);
+ "combo-bitrate-control", "combo-mode", "combo-joint-stereo-mode", NULL);
gnac_profiles_utils_free_check_values(&wavpack_bfi, "checkbutton-md5", NULL);
gnac_profiles_utils_free_slider_values(&wavpack_bfi,
- "slider-bitrate",
- "slider-bits-per-sample",
- "slider-extra-processing",
- NULL);
+ "slider-bitrate", "slider-bits-per-sample",
+ "slider-extra-processing", NULL);
gnac_profiles_utils_free_basic_format_info_content(&wavpack_bfi);
}
@@ -572,3 +488,26 @@ gnac_profiles_wavpack_get_description(void)
{
return wavpack_bfi.description;
}
+
+
+FormatModuleFuncs
+gnac_profiles_wavpack_get_funcs(void)
+{
+ FormatModuleFuncs funcs = {
+ gnac_profiles_wavpack_init,
+ gnac_profiles_wavpack_get_description,
+ gnac_profiles_wavpack_generate_pipeline,
+ (FormatModuleGenerateAudioProfileFunc) gnac_profiles_wavpack_generate_audio_profile,
+ (FormatModuleFreeAudioProfileFunc) gnac_profiles_wavpack_free_audio_profile,
+ (FormatModuleFullfillFieldsFunc) gnac_profiles_wavpack_fullfill_fields,
+ (FormatModuleGetWidgetFunc) gnac_profiles_wavpack_get_widget,
+ (FormatModuleSaveInFileFunc) gnac_profiles_wavpack_save_profile,
+ (FormatModuleLoadSpecificPropertiesFunc) gnac_profiles_wavpack_load_specific_properties,
+ gnac_profiles_wavpack_clean_up,
+ NULL,
+ gnac_profiles_wavpack_get_combo_format_name,
+ gnac_profiles_wavpack_get_plugin_name
+ };
+
+ return funcs;
+}
diff --git a/src/profiles/gnac-profiles-default.c b/src/profiles/gnac-profiles-default.c
index a9c6347..c50315d 100755
--- a/src/profiles/gnac-profiles-default.c
+++ b/src/profiles/gnac-profiles-default.c
@@ -34,16 +34,11 @@
void
gnac_profiles_default_init(BasicFormatInfo *bfi)
{
- GtkWidget *widget;
- XMLDoc *base_values_doc;
- GtkWidget *profile_advanced_base_widget;
- GError *error = NULL;
+ GError *error = NULL;
bfi->builder = gnac_ui_utils_create_gtk_builder(bfi->gtkbuilder_xml_file);
- widget = gnac_profiles_default_get_properties_alignment(bfi);
-
- if (!gtk_builder_add_from_file(bfi->builder,
+ if (!gtk_builder_add_from_file(bfi->builder,
PKGDATADIR "/profiles/gnac-profiles-base-advanced.xml", &error))
{
libgnac_critical("%s", error->message);
@@ -51,16 +46,17 @@ gnac_profiles_default_init(BasicFormatInfo *bfi)
gnac_exit(EXIT_FAILURE);
}
- profile_advanced_base_widget = gnac_profiles_utils_get_widget(bfi,
+ GtkWidget *profile_advanced_base_widget = gnac_profiles_utils_get_widget(bfi,
"table-advanced-base");
- widget = gnac_profiles_utils_get_widget(bfi, "properties-table-advanced");
+ GtkWidget *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);
// Init values
bfi->doc = gnac_profiles_xml_engine_load_doc_xpath(bfi->data_xml_file);
- base_values_doc = gnac_profiles_xml_engine_load_doc_xpath(
+ XMLDoc *base_values_doc = gnac_profiles_xml_engine_load_doc_xpath(
PKGDATADIR "/profiles/base.xml");
// format id
@@ -81,12 +77,12 @@ gnac_profiles_default_init(BasicFormatInfo *bfi)
// Advanced
// channels
- widget = gnac_profiles_utils_register_advanced_channels(bfi->builder,
- base_values_doc);
+ gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
+ "combo-channels", "//variable[ id='channels']");
// sample rate
- widget = gnac_profiles_utils_register_advanced_sample_rate(bfi->builder,
- base_values_doc);
+ gnac_profiles_utils_init_base_widget(bfi->builder, base_values_doc,
+ "combo-sample-rate", "//variable[ id='sample-rate']");
gnac_profiles_utils_init_raw_audioconvert(base_values_doc);
@@ -121,17 +117,14 @@ gchar *
gnac_profiles_default_generate_pipeline(BasicFormatInfo *bfi)
{
GtkWidget *widget;
- gchar *channels;
- gchar *rate;
- gchar *pipeline;
widget = gnac_profiles_utils_get_widget(bfi, "combo-channels");
- channels = gnac_profiles_utils_get_value_combo(widget);
+ gchar *channels = gnac_profiles_utils_get_value_combo(widget);
widget = gnac_profiles_utils_get_widget(bfi, "combo-sample-rate");
- rate = gnac_profiles_utils_get_value_combo(widget);
+ gchar *rate = gnac_profiles_utils_get_value_combo(widget);
- pipeline = gnac_profiles_utils_get_basepipeline(channels, rate);
+ gchar *pipeline = gnac_profiles_utils_get_basepipeline(channels, rate);
g_free(channels);
g_free(rate);
@@ -175,7 +168,7 @@ gnac_profiles_default_generate_audio_profile(BasicFormatInfo *bfi)
{
AudioProfileGeneric *profile;
- profile = gnac_profiles_utils_allocate_audio_profile_generic();
+ profile = gnac_profiles_utils_audio_profile_generic_new();
profile->extension = g_strdup(bfi->file_extension);
profile->format_id = g_strdup(bfi->format_id);
@@ -196,11 +189,8 @@ XMLDoc *
gnac_profiles_default_save_profile(AudioProfileGeneric *profile,
BasicFormatInfo *bfi)
{
- XMLDoc *doc;
- AudioProfileGeneric *generic;
-
- generic = profile->generic;
- doc = gnac_profiles_xml_engine_load_doc_xpath(
+ AudioProfileGeneric *generic = profile->generic;
+ XMLDoc *doc = gnac_profiles_xml_engine_load_doc_xpath(
PKGDATADIR "/profiles/profile-base-save.xml");
gnac_profiles_xml_engine_modify_values(doc, "/audio-profile/base/*",
generic->pipeline,
@@ -222,9 +212,7 @@ gnac_profiles_default_load_generic_audio_profile(
const gchar *filename,
AudioProfileGeneric **generic)
{
- XMLDoc *doc;
-
- doc = gnac_profiles_xml_engine_load_doc_xpath(filename);
+ XMLDoc *doc = gnac_profiles_xml_engine_load_doc_xpath(filename);
if (!doc) {
*generic = NULL;
return NULL;
@@ -232,7 +220,7 @@ gnac_profiles_default_load_generic_audio_profile(
AudioProfileGeneric *profile;
- profile = gnac_profiles_utils_allocate_audio_profile_generic();
+ profile = gnac_profiles_utils_audio_profile_generic_new();
*generic = profile;
gnac_profiles_utils_load_saved_profile(doc, "/audio-profile/base/",
"format-id", &profile->format_id,
diff --git a/src/profiles/gnac-profiles-properties.c b/src/profiles/gnac-profiles-properties.c
index 2e646d3..df062ec 100644
--- a/src/profiles/gnac-profiles-properties.c
+++ b/src/profiles/gnac-profiles-properties.c
@@ -56,16 +56,9 @@ enum {
NUM_COLS
};
-#ifdef G_OS_WIN32
-static const gchar forbidden_chars[] = {
- '\\', '/', ':', '*', '?', '"', '<', '>', '|', '{', '}'
-};
-static const gchar *forbidden_chars_string = "\\ / : * ? \" < > | { }";
-#else
static const guint forbidden_chars_keys[] = { GDK_KEY_slash };
static const gchar forbidden_chars[] = { '/', '\n', '\t' };
static const gchar *forbidden_chars_string = " /, <return>, <tab>";
-#endif
static FormatModuleGetFuncs formats_get_funcs[] = {
gnac_profiles_aac_get_funcs,
@@ -178,35 +171,25 @@ gnac_profiles_properties_set_parent(GtkWindow *parent)
static void
gnac_profiles_properties_init_format(void)
{
- GtkWidget *widget;
- GtkWidget *format_combo_box;
- GtkWidget *hbox_properties;
- GtkWidget *properties;
- GtkListStore *model;
- GtkTreeIter iter;
- GtkTreePath *tree_path;
- const gchar *format_id;
- gchar *format_name;
- guint i;
-
- hbox_properties = gnac_profiles_properties_get_widget("hbox_properties");
- format_combo_box = gnac_profiles_properties_get_widget("format_combo_box");
-
- model = GTK_LIST_STORE(gtk_combo_box_get_model(
+ GtkWidget *hbox_properties =
+ gnac_profiles_properties_get_widget("hbox_properties");
+ GtkWidget *format_combo_box =
+ gnac_profiles_properties_get_widget("format_combo_box");
+ GtkListStore *model = GTK_LIST_STORE(gtk_combo_box_get_model(
GTK_COMBO_BOX(format_combo_box)));
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), 2,
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), COL_ORDER,
GTK_SORT_ASCENDING);
+ guint i;
+ GtkTreeIter iter;
+
for (i = 0; i < G_N_ELEMENTS(formats_get_funcs); ++i) {
- FormatModule *format_module;
- GtkWidget *pipeline_box;
-
- format_module = g_malloc(sizeof(FormatModule));
+ FormatModule *format_module = g_malloc(sizeof(FormatModule));
format_module->funcs = formats_get_funcs[i]();
- format_id = format_module->funcs.init(
+ const gchar *format_id = format_module->funcs.init(
gnac_profiles_properties_update_textbuffer);
- format_name = format_module->funcs.get_combo_format_name();
+ gchar *format_name = format_module->funcs.get_combo_format_name();
g_hash_table_insert(formats, (gpointer) format_id, format_module);
gtk_list_store_append(model, &iter);
@@ -227,23 +210,26 @@ gnac_profiles_properties_init_format(void)
-1);
}
- tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter);
+ g_free(format_name);
+
+ GtkTreePath *tree_path = gtk_tree_model_get_path(
+ GTK_TREE_MODEL(model), &iter);
format_module->tree_ref = gtk_tree_row_reference_new(
GTK_TREE_MODEL(model), tree_path);
gtk_tree_path_free(tree_path);
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");
+ GtkWidget *widget =
+ gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
+ GtkWidget *pipeline_box =
+ gnac_profiles_properties_get_widget("gstreamer_pipeline_box");
format_module->funcs.set_pipeline_func(GTK_TEXT_VIEW(widget),
pipeline_box);
}
- properties = format_module->funcs.get_widget(NULL);
+ GtkWidget *properties = format_module->funcs.get_widget(NULL);
gtk_box_pack_start(GTK_BOX(hbox_properties), properties, TRUE, TRUE, 0);
gtk_widget_hide(properties);
-
- g_free(format_name);
}
}
@@ -254,7 +240,6 @@ gnac_profiles_properties_show(gpointer profile,
GCallback call_back)
{
GtkWidget *widget;
- GtkWidget *format_combo_box;
gnac_profiles_properties_reinit();
@@ -266,7 +251,8 @@ gnac_profiles_properties_show(gpointer profile,
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");
+ GtkWidget *format_combo_box =
+ gnac_profiles_properties_get_widget("format_combo_box");
if (!profile) {
gtk_widget_show(widget);
@@ -274,36 +260,29 @@ gnac_profiles_properties_show(gpointer profile,
return;
}
- AudioProfileGeneric *generic;
- const gchar *format_id;
-
- generic = AUDIO_PROFILE_GET_GENERIC(profile);
- format_id = generic->format_id;
+ AudioProfileGeneric *generic = AUDIO_PROFILE_GET_GENERIC(profile);
+ const gchar *format_id = generic->format_id;
if (!format_id) return;
- FormatModule *format_module;
- GtkTreeIter iter;
- GtkTreeModel *model;
- GtkTreePath *path;
-
- format_module = g_hash_table_lookup(formats, format_id);
+ FormatModule *format_module = g_hash_table_lookup(formats, format_id);
if (!format_module) {
libgnac_warning(_("Format not supported"));
return;
}
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(format_combo_box));
+ GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(format_combo_box));
gnac_profiles_properties_name_description_set_text(generic->name,
generic->description);
format_module->funcs.fullfill_fields(profile);
- path = gtk_tree_row_reference_get_path(format_module->tree_ref);
+
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_row_reference_get_path(format_module->tree_ref);
gtk_tree_model_get_iter(model, &iter, path);
+ gtk_tree_path_free(path);
gtk_combo_box_set_active_iter(GTK_COMBO_BOX(format_combo_box), &iter);
format_module->funcs.generate_pipeline();
gtk_widget_show(widget);
-
- gtk_tree_path_free(path);
}
@@ -312,16 +291,11 @@ gnac_profiles_properties_free_audio_profile(gpointer profile)
{
if (!profile) return;
- AudioProfileGeneric *generic;
- const gchar *format_id;
-
- generic = AUDIO_PROFILE_GET_GENERIC(profile);
- format_id = generic->format_id;
+ AudioProfileGeneric *generic = AUDIO_PROFILE_GET_GENERIC(profile);
+ const gchar *format_id = generic->format_id;
if (!format_id) return;
- FormatModule *format_module;
-
- format_module = g_hash_table_lookup(formats, format_id);
+ FormatModule *format_module = g_hash_table_lookup(formats, format_id);
if (!format_module) {
libgnac_warning(_("Format not supported"));
return;
@@ -336,13 +310,11 @@ gnac_profiles_properties_destroy(void)
{
if (!formats) return;
- GList *list;
GList *temp;
+ GList *list = g_hash_table_get_values(formats);
- list = g_hash_table_get_values(formats);
for (temp = list; temp; temp = temp->next) {
- FormatModule *format_module;
- format_module = (FormatModule *) temp->data;
+ FormatModule *format_module = (FormatModule *) temp->data;
format_module->funcs.clean_up();
g_free(format_module);
}
@@ -362,25 +334,25 @@ void
gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gpointer user_data)
{
- GtkWidget *properties;
- GtkWidget *label;
- GtkWidget *text_view;
- GtkTreeIter iter;
- FormatModule *format_module;
-
GtkTreeModel *model = gtk_combo_box_get_model(widget);
+
+ GtkTreeIter iter;
if (!gtk_combo_box_get_active_iter(widget, &iter)) return;
+ FormatModule *format_module;
gtk_tree_model_get(model, &iter, 1, &format_module, -1);
gnac_profiles_properties_display_status_message(NULL);
+ GtkWidget *properties;
+
if (current_format_module && format_module != current_format_module) {
properties = current_format_module->funcs.get_widget(NULL);
gtk_widget_hide(properties);
}
- text_view = gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
+ GtkWidget *text_view =
+ gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
gtk_text_view_set_editable(GTK_TEXT_VIEW(text_view), FALSE);
#ifdef GNOME_ENABLE_DEBUG
@@ -388,8 +360,9 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
gtk_widget_hide(text_view);
#endif
- label = gnac_profiles_properties_get_widget("format_decription_label");
- gtk_label_set_markup(GTK_LABEL(label), format_module->funcs.get_description());
+ GtkLabel *label = GTK_LABEL(
+ gnac_profiles_properties_get_widget("format_decription_label"));
+ gtk_label_set_markup(label, format_module->funcs.get_description());
properties = format_module->funcs.get_widget(NULL);
gtk_widget_show(properties);
format_module->funcs.generate_pipeline();
@@ -400,11 +373,10 @@ gnac_profiles_properties_combo_format_on_changed(GtkComboBox *widget,
static void
gnac_profiles_properties_update_textbuffer(const gchar *pipeline)
{
- 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));
+ GtkWidget *text_view =
+ gnac_profiles_properties_get_widget("gstreamer_pipeline_text_view");
+ GtkTextBuffer *pipeline_text_buffer =
+ gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view));
gtk_text_buffer_set_text(pipeline_text_buffer, pipeline,
g_utf8_strlen(pipeline, -1));
@@ -431,14 +403,12 @@ gnac_profiles_properties_display_status_message(const gchar *error_message)
static void
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);
+ GList *temp;
+ GList *list = g_hash_table_get_values(formats);
for (temp = list; temp; temp = temp->next) {
((FormatModule *) temp->data)->funcs.fullfill_fields(NULL);
@@ -484,14 +454,11 @@ static void
gnac_profiles_properties_on_save(GtkWidget *widget,
gpointer data)
{
- gpointer profile;
- GError *error = NULL;
-
StandardCallBack call_back = (StandardCallBack) data;
-
GtkWidget *window = gnac_profiles_properties_get_widget("window1");
- profile = current_format_module->funcs.generate_audio_profile(&error);
+ GError *error = NULL;
+ gpointer profile = current_format_module->funcs.generate_audio_profile(&error);
if (!profile) {
if (error) {
gnac_profiles_properties_display_status_message(error->message);
@@ -539,8 +506,7 @@ gnac_profiles_properties_is_valid_profile_name(const gchar *name)
}
if (!gnac_profiles_properties_is_valid_filename_chars(name)) {
- gchar *message;
- message = g_strconcat(
+ gchar *message = g_strconcat(
_("The profile name cannot contain the following characters:"),
" ", forbidden_chars_string, NULL);
gnac_profiles_properties_display_status_message(message);
@@ -566,8 +532,7 @@ gnac_profiles_properties_on_name_entry_key_pressed(GtkWidget *widget,
gpointer data)
{
if (gnac_ui_utils_event_is_return_key(event)) {
- GtkWidget *widget;
- widget = gnac_profiles_properties_get_widget("save-button");
+ GtkWidget *widget = gnac_profiles_properties_get_widget("save-button");
gtk_button_clicked(GTK_BUTTON(widget));
return TRUE;
}
@@ -606,7 +571,6 @@ static gboolean
gnac_profiles_properties_is_valid_filename_char(guint keyval)
{
guint i;
-
for (i = 0; i < G_N_ELEMENTS(forbidden_chars_keys); ++i) {
if (keyval == forbidden_chars_keys[i]) {
return FALSE;
@@ -620,10 +584,9 @@ gnac_profiles_properties_is_valid_filename_char(guint keyval)
static gboolean
gnac_profiles_properties_is_valid_filename_chars(const gchar *chars)
{
- glong len;
guint i, j;
-
- len = g_utf8_strlen(chars, -1);
+ glong len = g_utf8_strlen(chars, -1);
+
for (i = 0; i < len; i++) {
for (j = 0; j < G_N_ELEMENTS(forbidden_chars); j++) {
if (chars[i] == forbidden_chars[j]) {
@@ -652,27 +615,26 @@ gnac_profiles_properties_load_profile_from_file(const gchar *path,
{
g_return_val_if_fail(!error || !*error, NULL);
- XMLDoc *doc;
AudioProfileGeneric *profile;
- FormatModule *format_module;
-
- doc = gnac_profiles_default_load_generic_audio_profile(path, &profile);
+ XMLDoc *doc = gnac_profiles_default_load_generic_audio_profile(path, &profile);
if (!doc || !(profile->format_id)) {
*error = g_error_new(g_quark_from_static_string("gnac"), 0,
_("File \"%s\" is not a valid profile file."), filename);
- } else {
+ gnac_profiles_xml_engine_free_doc_xpath(doc);
+ return NULL;
+ }
- format_module = g_hash_table_lookup(formats, profile->format_id);
- if (!format_module) {
- *error = g_error_new(g_quark_from_static_string("gnac"), 0,
- _("Format defined by id \"%s\" in file \"%s\" is not supported."),
- profile->format_id, filename);
- gnac_profiles_utils_free_audio_profile_generic(profile);
- profile = NULL;
- } else {
- profile = format_module->funcs.load_specific_properties(doc, profile);
- }
+ FormatModule *format_module = g_hash_table_lookup(formats, profile->format_id);
+ if (!format_module) {
+ *error = g_error_new(g_quark_from_static_string("gnac"), 0,
+ _("Format defined by id \"%s\" in file \"%s\" is not supported."),
+ profile->format_id, filename);
+ gnac_profiles_utils_free_audio_profile_generic(profile);
+ gnac_profiles_xml_engine_free_doc_xpath(doc);
+ return NULL;
}
+
+ profile = format_module->funcs.load_specific_properties(doc, profile);
gnac_profiles_xml_engine_free_doc_xpath(doc);
@@ -683,9 +645,7 @@ gnac_profiles_properties_load_profile_from_file(const gchar *path,
gboolean
gnac_profiles_properties_saved_profiles_contain_name(const gchar *name)
{
- gboolean exists;
- gchar *path;
- GFile *file;
+ gchar *path;
if (g_str_has_suffix(name, ".xml")) {
path = g_strconcat(GNAC_SAVED_PROFILES_URL(name), NULL);
@@ -693,8 +653,8 @@ gnac_profiles_properties_saved_profiles_contain_name(const gchar *name)
path = g_strconcat(GNAC_SAVED_PROFILES_URL_WITH_EXT(name), NULL);
}
- file = g_file_new_for_path(path);
- exists = g_file_query_exists(file, NULL);
+ GFile *file = g_file_new_for_path(path);
+ gboolean exists = g_file_query_exists(file, NULL);
g_free(path);
g_object_unref(file);
diff --git a/src/profiles/gnac-profiles-utils.c b/src/profiles/gnac-profiles-utils.c
index 2409b9c..f666723 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -28,8 +28,8 @@
#include "gnac-utils.h"
#include "libgnac-debug.h"
-gchar *raw = NULL;
-gchar *audioconvert = NULL;
+static gchar *raw = NULL;
+static gchar *audioconvert = NULL;
static void
@@ -37,8 +37,7 @@ gnac_profiles_utils_init_name(XMLDoc *doc,
const gchar *format,
gchar **name)
{
- gchar *query;
- query = g_strconcat("//profile[ id='", format, "']/name", NULL);
+ gchar *query = g_strconcat("//profile[ id='", format, "']/name", NULL);
*name = gnac_profiles_xml_engine_get_text_node(doc, query);
g_free(query);
}
@@ -49,9 +48,8 @@ gnac_profiles_utils_init_extension(XMLDoc *doc,
const gchar *format,
gchar **extension)
{
- gchar *query;
- query = g_strconcat("//profile[ id='", format, "']/output-file-extension",
- NULL);
+ gchar *query = g_strconcat("//profile[ id='", format,
+ "']/output-file-extension", NULL);
*extension = gnac_profiles_xml_engine_get_text_node(doc, query);
g_free(query);
}
@@ -69,22 +67,11 @@ gnac_profiles_utils_init_name_extension(XMLDoc *doc,
gchar *
-gnac_profiles_utils_get_combo_format_name(const gchar *name,
- const gchar *extension)
-{
- return g_strconcat(name, " (.", extension, ")", NULL);
-}
-
-
-gchar *
gnac_profiles_utils_init_description(XMLDoc *doc,
const gchar *format)
{
- gchar *query;
- gchar *description;
-
- query = g_strconcat("//profile[ id='", format, "']/description", NULL);
- description = gnac_profiles_xml_engine_get_text_node(doc, query);
+ gchar *query = g_strconcat("//profile[ id='", format, "']/description", NULL);
+ gchar *description = gnac_profiles_xml_engine_get_text_node(doc, query);
g_free(query);
@@ -92,24 +79,29 @@ gnac_profiles_utils_init_description(XMLDoc *doc,
}
+gchar *
+gnac_profiles_utils_get_combo_format_name(const gchar *name,
+ const gchar *extension)
+{
+ return g_strconcat(name, " (.", extension, ")", NULL);
+}
+
+
static void
gnac_profiles_utils_add_values_combo(GtkWidget *combo,
ComboValues *values)
{
gint index = 0;
- GList *list_names;
- GList *list_values;
-
- list_names = values->names;
- list_values = values->values;
+ GList *list_names = values->names;
+ GList *list_values = values->values;
while (list_names) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo),
- (const gchar*) list_names->data);
+ (const gchar *) list_names->data);
if (gnac_utils_str_equal(values->default_value,
- (const gchar*) list_values->data))
+ (const gchar *) list_values->data))
{
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), index);
}
@@ -121,28 +113,21 @@ gnac_profiles_utils_add_values_combo(GtkWidget *combo,
}
-static gint
+static void
gnac_profiles_utils_register_combo(GtkWidget *widget,
XMLDoc *doc,
const gchar *xpath_query)
{
- ComboValues *combo;
- gint result;
-
- combo = g_malloc(sizeof(ComboValues));
- result = gnac_profiles_xml_engine_get_combo_values(doc, xpath_query, combo);
-
- if (result != 0) {
+ ComboValues *combo = gnac_profiles_xml_engine_get_combo_values(doc,
+ xpath_query);
+ if (!combo) {
libgnac_warning("Impossible to register combo with xpath query %s",
xpath_query);
- g_free(combo);
- return result;
+ return;
}
gnac_profiles_utils_add_values_combo(widget, combo);
g_object_set_data(G_OBJECT(widget), "combo-values", combo);
-
- return result;
}
@@ -157,145 +142,72 @@ gnac_profiles_utils_add_values_slider(GtkWidget *slider,
}
-static gint
+static void
gnac_profiles_utils_register_slider(GtkWidget *widget,
XMLDoc *doc,
const gchar *xpath_query)
{
- SliderValues *slider;
- gint result;
-
- slider = g_malloc(sizeof(SliderValues));
- result = gnac_profiles_xml_engine_get_slider_values(doc, xpath_query, slider);
-
- if (result != 0) {
+ SliderValues *slider = gnac_profiles_xml_engine_get_slider_values(doc,
+ xpath_query);
+ if (!slider) {
libgnac_warning("Impossible to register slider with xpath query %s",
xpath_query);
- g_free(slider);
- return result;
+ return;
}
gnac_profiles_utils_add_values_slider(widget, slider);
g_object_set_data(G_OBJECT(widget), "slider-values", slider);
-
- return result;
}
-static gint
+static void
gnac_profiles_utils_register_check(GtkWidget *widget,
XMLDoc *doc,
const gchar *xpath_query)
{
- CheckValues *check;
- gint result;
-
- check = g_malloc(sizeof(CheckValues));
- result = gnac_profiles_xml_engine_get_check_values(doc, xpath_query, check);
- if (result != 0) {
+ CheckValues *check = gnac_profiles_xml_engine_get_check_values(doc,
+ xpath_query);
+ if (!check) {
libgnac_warning("Impossible to register check with xpath query %s",
xpath_query);
- g_free(check);
- return result;
+ return;
}
g_object_set_data(G_OBJECT(widget), "check-values", check);
-
- return result;
}
GtkWidget *
-gnac_profiles_utils_register_advanced_channels(GtkBuilder *builder,
- XMLDoc *doc)
+gnac_profiles_utils_init_base_widget(GtkBuilder *builder,
+ XMLDoc *doc,
+ const gchar *widget_name,
+ const gchar *xpath_query)
{
- GtkWidget *widget;
-
- widget = gnac_ui_utils_get_widget(builder, "combo-channels");
- if (!widget) {
- libgnac_warning("Impossible to find widget %s", "combo-channels");
- return NULL;
+ GtkWidget *widget = gnac_ui_utils_get_widget(builder, widget_name);
+ if (!widget) return NULL;
+
+ gchar *widget_type = gnac_profiles_xml_engine_get_variable_type(doc,
+ xpath_query);
+
+ if (gnac_utils_str_equal(widget_type, "combo")) {
+ gnac_profiles_utils_register_combo(widget, doc, xpath_query);
+ } else if (gnac_utils_str_equal(widget_type, "check")) {
+ gnac_profiles_utils_register_check(widget, doc, xpath_query);
+ } else if (gnac_utils_str_equal(widget_type, "slider")) {
+ gnac_profiles_utils_register_slider(widget, doc, xpath_query);
}
- gnac_profiles_utils_register_combo(widget, doc, "//variable[ id='channels']/*");
-
return widget;
}
GtkWidget *
-gnac_profiles_utils_register_advanced_sample_rate(GtkBuilder *builder,
- XMLDoc *doc)
+gnac_profiles_utils_init_widget(BasicFormatInfo *bfi,
+ const gchar *widget_name,
+ const gchar *xpath_query)
{
- GtkWidget *widget;
-
- widget = gnac_ui_utils_get_widget(builder, "combo-sample-rate");
- if (!widget) {
- libgnac_warning("Impossible to find widget %s", "combo-sample-rate");
- return NULL;
- }
-
- gnac_profiles_utils_register_combo(widget, doc,
- "//variable[ id='sample-rate']/*");
-
- return widget;
-}
-
-
-GtkWidget *
-gnac_profiles_utils_all_in_one_for_combo(BasicFormatInfo *bfi,
- const gchar *combo_name,
- const gchar *xpath_query)
-{
- GtkWidget *widget;
-
- 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);
-
- return widget;
-}
-
-
-GtkWidget *
-gnac_profiles_utils_all_in_one_for_slider(BasicFormatInfo *bfi,
- const gchar *slider_name,
- const gchar *xpath_query)
-{
- GtkWidget *widget;
-
- 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);
-
- return widget;
-}
-
-
-GtkWidget *
-gnac_profiles_utils_all_in_one_for_check(BasicFormatInfo *bfi,
- const gchar *check_name,
- const gchar *xpath_query)
-{
- GtkWidget *widget;
-
- 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);
-
- return widget;
+ return gnac_profiles_utils_init_base_widget(bfi->builder, bfi->doc,
+ widget_name, xpath_query);
}
@@ -327,18 +239,14 @@ void
gnac_profiles_utils_set_value_combo(GtkWidget *combo,
const gchar *value)
{
- ComboValues *values;
- GList *list_values;
- gint index;
-
- values = g_object_get_data(G_OBJECT(combo), "combo-values");
- list_values = values->values;
+ ComboValues *values = g_object_get_data(G_OBJECT(combo), "combo-values");
+ GList *list_values = values->values;
if (!value) value = values->default_value;
- index = 0;
+ gint index = 0;
while (list_values) {
- if (gnac_utils_str_equal(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);
}
@@ -404,11 +312,8 @@ gnac_profiles_utils_set_values_checked_combo(BasicFormatInfo *bfi, ...)
gchar *
gnac_profiles_utils_get_value_combo(GtkWidget *combo)
{
- ComboValues *values;
- gint index;
-
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
- values = g_object_get_data(G_OBJECT(combo), "combo-values");
+ gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
+ ComboValues *values = g_object_get_data(G_OBJECT(combo), "combo-values");
return g_strconcat(g_list_nth_data(values->values, index), NULL);
}
@@ -552,7 +457,7 @@ gnac_profiles_utils_get_values_slider_and_set(BasicFormatInfo *bfi, ...)
name = va_arg(ap, const gchar *);
while (name) {
- value = va_arg(ap, gdouble*);
+ value = va_arg(ap, gdouble *);
widget = gnac_profiles_utils_get_widget(bfi, name);
*value = gtk_range_get_value(GTK_RANGE(widget));
name = va_arg(ap, const gchar *);
@@ -576,7 +481,7 @@ gnac_profiles_utils_get_values_checked_slider_and_set(BasicFormatInfo *bfi, ...)
while (name) {
checkbox_name = va_arg(ap, const gchar *);
- value = va_arg(ap, gdouble*);
+ value = va_arg(ap, gdouble *);
widget = gnac_profiles_utils_get_widget(bfi, checkbox_name);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
@@ -665,22 +570,22 @@ gnac_profiles_utils_add_description_tooltip(BasicFormatInfo *bfi,
const gchar *xpath_query,
...)
{
- GtkWidget *widget;
- gchar *description;
- va_list ap;
-
- description = gnac_profiles_xml_engine_get_text_node(bfi->doc, xpath_query);
+ gchar *description = gnac_profiles_xml_engine_get_text_node(bfi->doc,
+ xpath_query);
if (!description) {
libgnac_warning("Impossible to find description in %s", xpath_query);
return;
}
+ va_list ap;
+ GtkWidget *widget;
+
va_start(ap, xpath_query);
- widget = va_arg(ap, GtkWidget*);
+ widget = va_arg(ap, GtkWidget *);
while (widget) {
gtk_widget_set_tooltip_markup(widget, description);
- widget = va_arg(ap, GtkWidget*);
+ widget = va_arg(ap, GtkWidget *);
}
va_end(ap);
@@ -692,12 +597,12 @@ gnac_profiles_utils_add_description_tooltip(BasicFormatInfo *bfi,
void
gnac_profiles_utils_init_raw_audioconvert(XMLDoc *doc)
{
- if (!raw) {
+ if (G_UNLIKELY(!raw)) {
raw = gnac_profiles_xml_engine_get_text_node(doc,
"//process[ id='gstreamer-audio']");
}
- if (!audioconvert) {
+ if (G_UNLIKELY(!audioconvert)) {
audioconvert = gnac_profiles_xml_engine_get_text_node(doc,
"//process[ id='audioconvert']");
}
@@ -717,9 +622,7 @@ gchar *
gnac_profiles_utils_add_pipe(gchar *pipeline,
const gchar *new_pipe)
{
- gchar *temp;
-
- temp = g_strconcat(pipeline, " ! ", new_pipe, NULL);
+ gchar *temp = g_strconcat(pipeline, " ! ", new_pipe, NULL);
g_free(pipeline);
@@ -760,16 +663,13 @@ static gchar *
gnac_profiles_utils_add_property_combo(gchar *pipeline,
GtkWidget *combo)
{
- gchar *temp;
- gchar *value;
- ComboValues *values;
- gint index;
-
- index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
- values = g_object_get_data(G_OBJECT(combo), "combo-values");
+ gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
+ ComboValues *values = g_object_get_data(G_OBJECT(combo), "combo-values");
if (!values) return pipeline;
- value = g_list_nth_data(values->values, index);
- temp = g_strconcat(pipeline, " ", values->variable_name, "=", value, NULL);
+
+ gchar *value = g_list_nth_data(values->values, index);
+ gchar *temp = g_strconcat(pipeline, " ",
+ values->variable_name, "=", value, NULL);
g_free(pipeline);
@@ -838,17 +738,14 @@ gnac_profiles_utils_add_property_slider(gchar *pipeline,
gdouble factor,
GtkWidget *slider)
{
- gchar *temp;
- gdouble value;
- gchar *value_str;
- SliderValues *values;
-
- value = gtk_range_get_value(GTK_RANGE(slider));
- values = g_object_get_data(G_OBJECT(slider), "slider-values");
+ gdouble value = gtk_range_get_value(GTK_RANGE(slider));
+ SliderValues *values = g_object_get_data(G_OBJECT(slider), "slider-values");
if (!values) return pipeline;
- value_str = gnac_profiles_utils_gdouble_to_gchararray_format(value*factor,
- format);
- temp = g_strconcat(pipeline, " ", values->variable_name, "=", value_str, NULL);
+
+ gchar *value_str = gnac_profiles_utils_gdouble_to_gchararray_format(
+ value * factor, format);
+ gchar *temp = g_strconcat(pipeline, " ",
+ values->variable_name, "=", value_str, NULL);
g_free(pipeline);
g_free(value_str);
@@ -944,16 +841,12 @@ static gchar *
gnac_profiles_utils_add_property_check(gchar *pipeline,
GtkWidget *check)
{
- gchar *temp;
- gboolean checked;
- CheckValues *values;
-
- checked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
- values = g_object_get_data(G_OBJECT(check), "check-values");
+ gboolean checked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check));
+ CheckValues *values = g_object_get_data(G_OBJECT(check), "check-values");
if (!values) return pipeline;
- temp = g_strconcat(pipeline, " ", values->variable_name, "=",
- checked ? "true" : "false", NULL);
+ gchar *temp = g_strconcat(pipeline, " ",
+ values->variable_name, "=", checked ? "true" : "false", NULL);
g_free(pipeline);
@@ -1020,7 +913,6 @@ void
gnac_profiles_utils_save_specific_properties_in_file(XMLDoc *doc, ...)
{
va_list ap;
-
va_start(ap, doc);
gnac_profiles_xml_engine_add_values(doc, "/audio-profile/format-specific", ap);
}
@@ -1052,11 +944,9 @@ gnac_profiles_utils_load_saved_profile(XMLDoc *doc,
AudioProfileGeneric *
-gnac_profiles_utils_allocate_audio_profile_generic(void)
+gnac_profiles_utils_audio_profile_generic_new(void)
{
- AudioProfileGeneric *profile;
-
- profile = g_malloc(sizeof(AudioProfileGeneric));
+ AudioProfileGeneric *profile = g_malloc(sizeof(AudioProfileGeneric));
if (!profile) return NULL;
profile->generic = profile;
@@ -1186,9 +1076,7 @@ gnac_profiles_utils_gdouble_to_gchararray_format(gdouble value,
const gchar *format)
{
gchar buffer[64];
-
g_ascii_formatd(buffer, 64, format, value);
-
return g_strdup(buffer);
}
@@ -1204,19 +1092,24 @@ GtkWidget *
gnac_profiles_utils_get_widget(BasicFormatInfo *bfi,
const gchar *widget_name)
{
- return GTK_WIDGET(gtk_builder_get_object(bfi->builder, widget_name));
+ GObject *object = gtk_builder_get_object(bfi->builder, widget_name);
+ if (!object) {
+ libgnac_debug("Widget %s not found\n", widget_name);
+ return NULL;
+ }
+ return GTK_WIDGET(object);
}
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);
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer(text_view);
+
+ GtkTextIter start;
gtk_text_buffer_get_start_iter(buffer, &start);
+ GtkTextIter end;
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 852daf9..e5f01ba 100755
--- a/src/profiles/gnac-profiles-utils.h
+++ b/src/profiles/gnac-profiles-utils.h
@@ -88,27 +88,15 @@ gnac_profiles_utils_init_description(XMLDoc *doc,
const gchar *format);
GtkWidget *
-gnac_profiles_utils_all_in_one_for_combo(BasicFormatInfo *bfi,
- const gchar *combo_name,
- const gchar *xpath_query);
+gnac_profiles_utils_init_base_widget(GtkBuilder *builder,
+ XMLDoc *doc,
+ const gchar *widget_name,
+ const gchar *xpath_query);
GtkWidget *
-gnac_profiles_utils_all_in_one_for_slider(BasicFormatInfo *bfi,
- const gchar *slider_name,
- const gchar *xpath_query);
-
-GtkWidget *
-gnac_profiles_utils_all_in_one_for_check(BasicFormatInfo *bfi,
- const gchar *check_name,
- const gchar *xpath_query);
-
-GtkWidget *
-gnac_profiles_utils_register_advanced_channels(GtkBuilder *builder,
- XMLDoc *doc);
-
-GtkWidget *
-gnac_profiles_utils_register_advanced_sample_rate(GtkBuilder *builder,
- XMLDoc *doc);
+gnac_profiles_utils_init_widget(BasicFormatInfo *bfi,
+ const gchar *widget_name,
+ const gchar *xpath_query);
void
gnac_profiles_utils_reinit_values_combo(BasicFormatInfo *bfi, ...);
@@ -231,7 +219,7 @@ gnac_profiles_utils_load_saved_profile(XMLDoc *doc,
...);
AudioProfileGeneric *
-gnac_profiles_utils_allocate_audio_profile_generic(void);
+gnac_profiles_utils_audio_profile_generic_new(void);
void
gnac_profiles_utils_free_audio_profile_generic(AudioProfileGeneric *profile);
diff --git a/src/profiles/gnac-profiles-xml-engine.c b/src/profiles/gnac-profiles-xml-engine.c
index 328af19..059e758 100755
--- a/src/profiles/gnac-profiles-xml-engine.c
+++ b/src/profiles/gnac-profiles-xml-engine.c
@@ -30,150 +30,158 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
#include "gnac-profiles-xml-engine.h"
#include "gnac-utils.h"
-static xmlXPathObjectPtr
-gnac_profiles_xml_engine_evaluate_query(const gchar *query,
- xmlXPathContextPtr xpath_context);
-
-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)
{
xmlDocPtr doc;
- xmlXPathContextPtr xpath;
+ xmlXPathContextPtr xpath_context;
XMLDoc *dx;
doc = xmlParseFile(filename);
if (!doc) return NULL;
- xpath = xmlXPathNewContext(doc);
- if (!xpath) {
+ xpath_context = xmlXPathNewContext(doc);
+ if (!xpath_context) {
xmlFreeDoc(doc);
return NULL;
}
dx = g_malloc(sizeof(XMLDoc));
dx->doc = doc;
- dx->xpath_context = xpath;
+ dx->xpath_context = xpath_context;
return dx;
}
-gchar *
-gnac_profiles_xml_engine_get_format_id(XMLDoc *dx)
+static xmlXPathObjectPtr
+gnac_profiles_xml_engine_evaluate_query(const gchar *query,
+ xmlXPathContextPtr xpath_context)
{
- xmlXPathObjectPtr xpath_obj;
- const gchar *expr = "//profiles/profile";
-
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
-
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
-
- if (nodes && nodes->nodeNr > 0) {
- gchar *format_id;
- xmlNodePtr node;
+ return xmlXPathEvalExpression(BAD_CAST query, xpath_context);
+}
- node = nodes->nodeTab[0];
- format_id = g_strdup((const gchar *) node->properties->children->content);
- xmlXPathFreeObject(xpath_obj);
+static gchar *
+gnac_profiles_xml_engine_get_property(XMLDoc *doc,
+ const gchar *query,
+ const gchar *property_name)
+{
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ query, doc->xpath_context);
+ if (!xpath_obj) return NULL;
- return format_id;
- }
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
}
+ xmlChar *property = xmlGetProp(nodes->nodeTab[0], (xmlChar *) property_name);
+
xmlXPathFreeObject(xpath_obj);
- return NULL;
+ return (gchar *) property;
}
gchar *
-gnac_profiles_xml_engine_get_text_node(XMLDoc *dx,
- const gchar *expr)
+gnac_profiles_xml_engine_get_format_id(XMLDoc *doc)
{
- xmlXPathObjectPtr xpath_obj;
+ return gnac_profiles_xml_engine_get_property(doc, "//profiles/profile", "id");
+}
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
-
- if (nodes && nodes->nodeNr > 0) {
- xmlNodePtr node;
+gchar *
+gnac_profiles_xml_engine_get_variable_type(XMLDoc *doc,
+ const gchar *expr)
+{
+ return gnac_profiles_xml_engine_get_property(doc, expr, "type");
+}
- node = nodes->nodeTab[0];
- if (node->children) {
- xmlXPathFreeObject(xpath_obj);
- return g_strdup(gettext((const gchar *) node->children->content));
- }
- }
+gchar *
+gnac_profiles_xml_engine_get_text_node(XMLDoc *doc,
+ const gchar *expr)
+{
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
+ if (!xpath_obj) return NULL;
+
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
+ }
+
+ xmlNodePtr node = nodes->nodeTab[0];
+ if (!node || !(node->children)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
}
xmlXPathFreeObject(xpath_obj);
- return NULL;
+ return gettext((gchar *) xmlNodeGetContent(node->children));
}
static gboolean
-gnac_profiles_xml_engine_is_i12n_node(xmlNodePtr node)
+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);
+}
+
+
+static gboolean
+gnac_profiles_xml_engine_is_i18n_node(xmlNodePtr node)
{
return gnac_profiles_xml_engine_str_equal(node->properties->name, "lang");
}
GList *
-gnac_profiles_xml_engine_get_list_values(XMLDoc *dx,
+gnac_profiles_xml_engine_get_list_values(XMLDoc *doc,
const gchar *expr)
{
- GList *list = NULL;
- xmlXPathObjectPtr xpath_obj;
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
+ if (!xpath_obj) return NULL;
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
+ }
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (!nodes) {
- xmlXPathFreeObject(xpath_obj);
- return NULL;
- }
+ gint i;
+ GList *list = NULL;
+
+ for (i = 0; i < nodes->nodeNr; i++) {
+ xmlNode *current_node = nodes->nodeTab[i];
- gint i;
-
- for (i = 0; i < nodes->nodeNr; i++) {
- xmlNode *current_node = nodes->nodeTab[i];
-
- if (!gnac_profiles_xml_engine_is_i12n_node(current_node)) {
- Value *val;
- val = g_malloc(sizeof(Value));
- val->name = g_strdup(gettext(
- (const gchar*) current_node->children->content));
- val->value = g_strdup(
- (const gchar*) current_node->properties->children->content);
- list = g_list_append(list, val);
- }
+ if (!gnac_profiles_xml_engine_is_i18n_node(current_node)) {
+ Value *val = g_malloc(sizeof(Value));
+ val->name = gettext(
+ (gchar *) xmlNodeGetContent(current_node->children));
+ val->value =
+ (gchar *) xmlNodeGetContent(current_node->properties->children);
+ list = g_list_append(list, val);
}
}
@@ -183,281 +191,243 @@ gnac_profiles_xml_engine_get_list_values(XMLDoc *dx,
}
-static xmlXPathObjectPtr
-gnac_profiles_xml_engine_evaluate_query(const gchar *query,
- xmlXPathContextPtr xpath_context)
+ComboValues *
+gnac_profiles_xml_engine_get_combo_values(XMLDoc *doc,
+ const gchar *expr)
{
- const xmlChar *expr_cast;
- expr_cast = BAD_CAST query;
- return xmlXPathEvalExpression(expr_cast, xpath_context);
-}
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
+ if (!xpath_obj) return NULL;
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
+ }
-gint
-gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
- const gchar *expr,
- ComboValues *combo_values)
-{
- xmlXPathObjectPtr xpath_obj;
+ xmlNode *values_first = NULL;
+ xmlNode *values_last = NULL;
+ gchar *default_value = NULL;
+ gchar *variable_name = NULL;
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlNodePtr current_node = nodes->nodeTab[0]->children;
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
-
- if (!nodes) {
- xmlXPathFreeObject(xpath_obj);
- return -1;
- }
+ while ((current_node = current_node->next)) {
+ gchar *content = (gchar *) xmlNodeGetContent(current_node->children);
- gint i;
- gboolean is_combo = FALSE;
- xmlNode *values_first = NULL;
- xmlNode *values_last = NULL;
- gchar *default_value = NULL;
- gchar *variable_name = NULL;
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
+ variable_name = g_strdup(content);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
+ {
+ default_value = g_strdup(content);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "possible-values"))
+ {
+ values_first = current_node->children->next;
+ values_last = current_node->last;
+ }
- for (i = 0; i < nodes->nodeNr; i++) {
- xmlNode *current_node = nodes->nodeTab[i];
+ g_free(content);
+ }
- if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "variable-name"))
- {
- variable_name = g_strdup((gchar*) current_node->children->content);
- }
- else if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "control-type"))
- {
- 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 (gnac_profiles_xml_engine_node_name_equal(current_node,
- "possible-values"))
- {
- values_first = current_node->children->next;
- values_last = current_node->last;
- }
- }
+ if (values_first && values_last && default_value && variable_name) {
+ GList *values = NULL;
+ GList *names = NULL;
- if (is_combo && values_first && values_last &&
- default_value && variable_name)
- {
- GList *values = NULL;
- GList *names = NULL;
+ xmlNode *current_node = values_first;
- xmlNode *current_node = values_first;
+ while (current_node && current_node != values_last) {
+ if (!gnac_profiles_xml_engine_is_i18n_node(current_node)) {
+ values = g_list_append(values,
+ xmlNodeGetContent(current_node->properties->children));
+ names = g_list_append(names,
+ gettext((gchar *) xmlNodeGetContent(current_node->children)));
+ }
- while (current_node && current_node != values_last) {
- if (!gnac_profiles_xml_engine_is_i12n_node(current_node)) {
- values = g_list_append(values,
- g_strdup((gchar *) current_node->properties->children->content));
+ current_node = current_node->next;
- names = g_list_append(names, g_strdup(gettext(
- (const gchar *) current_node->children->content)));
- }
-
+ if (xmlNodeIsText(current_node)) {
current_node = current_node->next;
-
- if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "text"))
- {
- current_node = current_node->next;
- }
}
+ }
- combo_values->values = values;
- combo_values->names = names;
- combo_values->default_value = default_value;
- combo_values->variable_name = variable_name;
+ xmlXPathFreeObject(xpath_obj);
- xmlXPathFreeObject(xpath_obj);
+ ComboValues *combo_values = g_malloc(sizeof(ComboValues));
+ combo_values->values = values;
+ combo_values->names = names;
+ combo_values->default_value = default_value;
+ combo_values->variable_name = variable_name;
- return 0;
- }
+ return combo_values;
}
xmlXPathFreeObject(xpath_obj);
- return -1;
+ return NULL;
}
-gint
-gnac_profiles_xml_engine_get_slider_values(XMLDoc *dx,
- const gchar *expr,
- SliderValues *slider_values)
+SliderValues *
+gnac_profiles_xml_engine_get_slider_values(XMLDoc *doc,
+ const gchar *expr)
{
- xmlXPathObjectPtr xpath_obj;
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
+ if (!xpath_obj) return NULL;
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
+ }
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (!nodes) {
- xmlXPathFreeObject(xpath_obj);
- return -1;
- }
+ gdouble min = 0.0;
+ gdouble max = 0.0;
+ gdouble step = 0.0;
+ gdouble default_value = 0.0;
+ gchar *variable_name = NULL;
- gint i;
- gboolean is_slider = FALSE;
- gdouble min = 0.0;
- gdouble max = 0.0;
- gdouble step = 0.0;
- gdouble default_value = 0.0;
- gchar *variable_name = NULL;
-
- for (i = 0; i < nodes->nodeNr; i++) {
- xmlNode *current_node = nodes->nodeTab[i];
-
- if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "variable-name"))
- {
- variable_name = g_strdup((gchar*) current_node->children->content);
- }
- else if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "control-type"))
- {
- 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 (gnac_profiles_xml_engine_node_name_equal(current_node,
- "min-value"))
- {
- min = g_ascii_strtod(
- (const gchar *) current_node->children->content, NULL);
- }
- 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 (gnac_profiles_xml_engine_node_name_equal(current_node,
- "step-value"))
- {
- step = g_ascii_strtod(
- (const gchar *) current_node->children->content, NULL);
- }
+ xmlNodePtr current_node = nodes->nodeTab[0]->children;
+
+ while ((current_node = current_node->next)) {
+ gchar *content = (gchar *) xmlNodeGetContent(current_node->children);
+
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
+ variable_name = g_strdup(content);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
+ {
+ default_value = g_ascii_strtod(content, NULL);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "min-value"))
+ {
+ min = g_ascii_strtod(content, NULL);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "max-value"))
+ {
+ max = g_ascii_strtod(content, NULL);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "step-value"))
+ {
+ step = g_ascii_strtod(content, NULL);
}
- if (is_slider && variable_name) {
- slider_values->min = min;
- slider_values->max = max;
- slider_values->step = step;
- slider_values->default_value = default_value;
- slider_values->variable_name = variable_name;
+ g_free(content);
+ }
- xmlXPathFreeObject(xpath_obj);
+ if (variable_name) {
+ xmlXPathFreeObject(xpath_obj);
- return 0;
- }
+ SliderValues *slider_values = g_malloc(sizeof(SliderValues));
+ slider_values->min = min;
+ slider_values->max = max;
+ slider_values->step = step;
+ slider_values->default_value = default_value;
+ slider_values->variable_name = variable_name;
+
+ return slider_values;
}
xmlXPathFreeObject(xpath_obj);
- return -1;
+ return NULL;
}
-gint
-gnac_profiles_xml_engine_get_check_values(XMLDoc *dx,
- const gchar *expr,
- CheckValues *check_values)
+CheckValues *
+gnac_profiles_xml_engine_get_check_values(XMLDoc *doc,
+ const gchar *expr)
{
- xmlXPathObjectPtr xpath_obj;
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
+ if (!xpath_obj) return NULL;
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
+ xmlXPathFreeObject(xpath_obj);
+ return NULL;
+ }
- if (xpath_obj && !xpath_obj->boolval) {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (!nodes) {
- xmlXPathFreeObject(xpath_obj);
- return -1;
- }
+ gchar *variable_name = NULL;
+ gboolean default_value = FALSE;
- gint i;
- gchar *variable_name = NULL;
- gboolean is_check = FALSE;
- gboolean default_value = FALSE;
+ xmlNodePtr current_node = nodes->nodeTab[0]->children;
- for (i = 0; i < nodes->nodeNr; i++) {
- xmlNode *current_node = nodes->nodeTab[i];
+ while ((current_node = current_node->next)) {
+ gchar *content = (gchar *) xmlNodeGetContent(current_node->children);
- if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "variable-name"))
- {
- variable_name = g_strdup((gchar *) current_node->children->content);
- }
- else if (gnac_profiles_xml_engine_node_name_equal(current_node,
- "control-type"))
- {
- 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 = gnac_profiles_xml_engine_str_equal(
- current_node->children->content, "true");
- }
+ if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "variable-name"))
+ {
+ variable_name = g_strdup(content);
+ }
+ else if (gnac_profiles_xml_engine_node_name_equal(current_node,
+ "default-value"))
+ {
+ default_value = gnac_utils_str_equal(content, "true");
}
- if (is_check && variable_name) {
- check_values->default_value = default_value;
- check_values->variable_name = variable_name;
+ g_free(content);
+ }
- xmlXPathFreeObject(xpath_obj);
+ if (variable_name) {
+ xmlXPathFreeObject(xpath_obj);
- return 0;
- }
+ CheckValues *check_values = g_malloc(sizeof(CheckValues));
+ check_values->default_value = default_value;
+ check_values->variable_name = variable_name;
+
+ return check_values;
}
xmlXPathFreeObject(xpath_obj);
- return -1;
+ return NULL;
}
void
-gnac_profiles_xml_engine_modify_values(XMLDoc *dx,
+gnac_profiles_xml_engine_modify_values(XMLDoc *doc,
const gchar *expr,
...)
{
- xmlXPathObjectPtr xpath_obj;
-
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
if (!xpath_obj) return;
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- if (!nodes) {
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
xmlXPathFreeObject(xpath_obj);
return;
}
+ va_list ap;
const gchar *value;
- va_list ap;
+ gint i;
va_start(ap, expr);
value = va_arg(ap, const gchar *);
- gint i;
for (i = nodes->nodeNr-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;
+ if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL) {
+ nodes->nodeTab[i] = NULL;
+ }
value = va_arg(ap, const gchar *);
}
@@ -467,34 +437,30 @@ gnac_profiles_xml_engine_modify_values(XMLDoc *dx,
void
-gnac_profiles_xml_engine_add_values(XMLDoc *dx,
+gnac_profiles_xml_engine_add_values(XMLDoc *doc,
const gchar *expr,
va_list ap)
{
- xmlNodeSetPtr nodes;
- xmlNodePtr format_node;
- xmlNodePtr node;
- xmlXPathObjectPtr xpath_obj;
- const xmlChar *name;
- const gchar *value;
- const xmlChar *base_indent;
- xmlChar *properties_indent;
-
- xpath_obj = gnac_profiles_xml_engine_evaluate_query(expr, dx->xpath_context);
+ xmlXPathObjectPtr xpath_obj = gnac_profiles_xml_engine_evaluate_query(
+ expr, doc->xpath_context);
if (!xpath_obj) return;
- nodes = xpath_obj->nodesetval;
- if (!nodes) {
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ if (xmlXPathNodeSetIsEmpty(nodes)) {
xmlXPathFreeObject(xpath_obj);
return;
}
- format_node = nodes->nodeTab[0];
- base_indent = format_node->prev->content;
- properties_indent = (xmlChar *) g_strconcat((const gchar *) base_indent,
- " ", NULL);
+ xmlNodePtr format_node = nodes->nodeTab[0];
+ const xmlChar *base_indent = format_node->prev->content;
+ xmlChar *properties_indent = (xmlChar *)
+ g_strconcat((const gchar *) base_indent, " ", NULL);
xmlAddChild(format_node, xmlNewText(BAD_CAST " "));
+ const xmlChar *name;
+ const gchar *value;
+ xmlNodePtr node;
+
name = va_arg(ap, const xmlChar *);
while (name) {
@@ -525,18 +491,18 @@ gchar *
gnac_profiles_xml_engine_format_text_to_xml(const gchar *text)
{
if (!text) return NULL;
+
return g_markup_escape_text(text, -1);
}
void
-gnac_profiles_xml_engine_save_doc(XMLDoc *dx,
+gnac_profiles_xml_engine_save_doc(XMLDoc *doc,
const gchar *filename)
{
- gchar *xml_filename;
- xml_filename = g_strconcat(GNAC_SAVED_PROFILES_URL_WITH_EXT(filename), NULL);
- xmlSaveFormatFile(xml_filename, dx->doc, 0);
- g_free(xml_filename);
+ gchar *path = g_strconcat(GNAC_SAVED_PROFILES_URL_WITH_EXT(filename), NULL);
+ xmlSaveFormatFile(path, doc->doc, 0);
+ g_free(path);
}
@@ -582,19 +548,3 @@ gnac_profiles_xml_engine_free_check_values(CheckValues *values)
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-xml-engine.h b/src/profiles/gnac-profiles-xml-engine.h
index 82fa129..73340c8 100755
--- a/src/profiles/gnac-profiles-xml-engine.h
+++ b/src/profiles/gnac-profiles-xml-engine.h
@@ -81,45 +81,46 @@ XMLDoc *
gnac_profiles_xml_engine_load_doc_xpath(const gchar *filename);
gchar *
-gnac_profiles_xml_engine_get_format_id(XMLDoc *dx);
+gnac_profiles_xml_engine_get_format_id(XMLDoc *doc);
gchar *
-gnac_profiles_xml_engine_get_text_node(XMLDoc *dx,
+gnac_profiles_xml_engine_get_variable_type(XMLDoc *doc,
+ const gchar *expr);
+
+gchar *
+gnac_profiles_xml_engine_get_text_node(XMLDoc *doc,
const gchar *expr);
GList *
-gnac_profiles_xml_engine_get_list_values(XMLDoc *dx,
+gnac_profiles_xml_engine_get_list_values(XMLDoc *doc,
const gchar *expr);
-gint
-gnac_profiles_xml_engine_get_combo_values(XMLDoc *dx,
- const gchar *expr,
- ComboValues *combo_values);
-gint
-gnac_profiles_xml_engine_get_slider_values(XMLDoc *dx,
- const gchar *expr,
- SliderValues *slider_values);
-gint
-gnac_profiles_xml_engine_get_check_values(XMLDoc *dx,
- const gchar *expr,
- CheckValues *check_values);
+ComboValues *
+gnac_profiles_xml_engine_get_combo_values(XMLDoc *doc,
+ const gchar *expr) G_GNUC_MALLOC;
+SliderValues *
+gnac_profiles_xml_engine_get_slider_values(XMLDoc *doc,
+ const gchar *expr) G_GNUC_MALLOC;
+CheckValues *
+gnac_profiles_xml_engine_get_check_values(XMLDoc *doc,
+ const gchar *expr) G_GNUC_MALLOC;
void
-gnac_profiles_xml_engine_modify_values(XMLDoc *dx,
+gnac_profiles_xml_engine_modify_values(XMLDoc *doc,
const gchar *expr,
...);
void
-gnac_profiles_xml_engine_add_values(XMLDoc *dx,
+gnac_profiles_xml_engine_add_values(XMLDoc *doc,
const gchar *expr,
va_list ap);
void
-gnac_profiles_xml_engine_save_doc(XMLDoc *dx,
+gnac_profiles_xml_engine_save_doc(XMLDoc *doc,
const gchar *filename);
void
-gnac_profiles_xml_engine_free_doc_xpath(XMLDoc *dx);
+gnac_profiles_xml_engine_free_doc_xpath(XMLDoc *doc);
void
gnac_profiles_xml_engine_free_combo_values(ComboValues *values);
diff --git a/src/profiles/gnac-profiles.c b/src/profiles/gnac-profiles.c
index f739422..a33d3e9 100755
--- a/src/profiles/gnac-profiles.c
+++ b/src/profiles/gnac-profiles.c
@@ -34,28 +34,19 @@
#include "gnac-utils.h"
-static AudioProfileGeneric *
-gnac_profiles_get_active_profile(void);
-
static void
gnac_profiles_on_combo_profile_changed(GtkWidget *widget,
gpointer data);
-static gchar *
-gnac_profiles_get_display_name(void);
-
static GtkWidget *combo_profile = NULL;
void
gnac_profiles_init(void)
{
- GtkCellRenderer *renderer;
- GtkListStore *model;
-
- model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
+ GtkListStore *model = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
combo_profile = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
- renderer = gtk_cell_renderer_text_new();
+ GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_profile), renderer, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_profile),
renderer, "text", 0, NULL);
@@ -94,12 +85,11 @@ gnac_profiles_get_widget(GtkWidget *parent)
static gchar *
gnac_profiles_get_display_name(void)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- gchar *name;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_profile), &iter)) {
+ gchar *name;
gtk_tree_model_get(model, &iter, 0, &name, -1);
return name;
}
@@ -111,12 +101,11 @@ gnac_profiles_get_display_name(void)
static AudioProfileGeneric *
gnac_profiles_get_active_profile(void)
{
- GtkTreeModel *model;
- GtkTreeIter iter;
- AudioProfileGeneric *profile;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo_profile), &iter)) {
+ AudioProfileGeneric *profile;
gtk_tree_model_get(model, &iter, 1, &profile, -1);
return profile->generic;
}
@@ -128,9 +117,7 @@ gnac_profiles_get_active_profile(void)
const gchar *
gnac_profiles_get_pipeline(void)
{
- AudioProfileGeneric *profile;
-
- profile = gnac_profiles_get_active_profile();
+ AudioProfileGeneric *profile = gnac_profiles_get_active_profile();
if (!profile) return NULL;
return profile->pipeline;
@@ -140,9 +127,7 @@ gnac_profiles_get_pipeline(void)
const gchar *
gnac_profiles_get_extension(void)
{
- AudioProfileGeneric *profile;
-
- profile = gnac_profiles_get_active_profile();
+ AudioProfileGeneric *profile = gnac_profiles_get_active_profile();
if (!profile) return NULL;
return profile->extension;
@@ -152,9 +137,7 @@ gnac_profiles_get_extension(void)
const gchar *
gnac_profiles_get_name(void)
{
- AudioProfileGeneric *profile;
-
- profile = gnac_profiles_get_active_profile();
+ AudioProfileGeneric *profile = gnac_profiles_get_active_profile();
if (!profile) return NULL;
return profile->name;
@@ -164,16 +147,14 @@ gnac_profiles_get_name(void)
void
gnac_profiles_set_current_profile(const gchar *name)
{
- gboolean found = FALSE;
- gboolean has_next;
- GtkTreeModel *model;
- GtkTreeIter iter;
- AudioProfileGeneric *profile;
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
+ gboolean has_next = gtk_tree_model_get_iter_first(model, &iter);
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile));
- has_next = gtk_tree_model_get_iter_first(model, &iter);
+ gboolean found = FALSE;
while (has_next && !found) {
+ AudioProfileGeneric *profile;
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);
@@ -187,19 +168,13 @@ gnac_profiles_set_current_profile(const gchar *name)
void
gnac_profiles_populate_combo(void)
{
- GtkListStore *model;
- GtkTreeIter iter;
- GList *profiles;
- GList *temp;
- gchar *display_name;
- gboolean set_active;
-
- model = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile)));
+ GtkListStore *model = GTK_LIST_STORE(
+ gtk_combo_box_get_model(GTK_COMBO_BOX(combo_profile)));
- display_name = gnac_profiles_get_display_name();
+ gchar *display_name = gnac_profiles_get_display_name();
gtk_list_store_clear(model);
- profiles = gnac_profiles_mgr_get_profiles_list();
+ GList *profiles = gnac_profiles_mgr_get_profiles_list();
if (!profiles) {
gtk_widget_set_sensitive(combo_profile, FALSE);
g_free(display_name);
@@ -207,17 +182,17 @@ gnac_profiles_populate_combo(void)
}
gtk_widget_set_sensitive(combo_profile, TRUE);
- set_active = FALSE;
- for (temp = profiles; temp; temp = temp->next) {
- gchar *name;
- gchar *formatted_name;
- AudioProfileGeneric *profile;
+ gboolean set_active = FALSE;
+
+ GList *temp;
+ GtkTreeIter iter;
- profile = AUDIO_PROFILE_GET_GENERIC(temp->data);
- formatted_name = gnac_profiles_properties_filter_text_for_displaying(
+ for (temp = profiles; temp; temp = temp->next) {
+ AudioProfileGeneric *profile = AUDIO_PROFILE_GET_GENERIC(temp->data);
+ gchar *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,
+ gchar *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);
@@ -254,25 +229,21 @@ static void
gnac_profiles_on_combo_profile_changed(GtkWidget *widget,
gpointer data)
{
- AudioProfileGeneric *profile;
- gchar *desc;
- gchar *formatted;
-
- profile = gnac_profiles_get_active_profile();
+ AudioProfileGeneric *profile = gnac_profiles_get_active_profile();
if (!profile) return;
+ gchar *description;
+
if (gnac_utils_string_is_null_or_empty(profile->description)) {
- desc = g_strdup(_("No description available"));
+ description = g_strdup(_("No description available"));
} else {
- formatted = gnac_profiles_properties_filter_text_for_displaying(
+ gchar *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);
+ description = gnac_profiles_xml_engine_format_text_to_xml(formatted);
g_free(formatted);
}
- gtk_widget_set_tooltip_markup(widget, desc);
- g_free(desc);
+ gtk_widget_set_tooltip_markup(widget, description);
+
+ g_free(description);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]