[easytag/wip/application-window: 37/79] Store process fields conversions in GSettings
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 37/79] Store process fields conversions in GSettings
- Date: Fri, 1 Aug 2014 16:54:39 +0000 (UTC)
commit 8bfe10e54b649d745c0c3794b58413f8005b69cb
Author: David King <amigadave amigadave com>
Date: Sun Jun 15 16:35:20 2014 -0400
Store process fields conversions in GSettings
data/org.gnome.EasyTAG.gschema.xml | 8 ++--
src/scan_dialog.c | 65 ++++++++++++++++++++++++++----------
src/setting.c | 9 -----
src/setting.h | 12 ++++--
4 files changed, 59 insertions(+), 35 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gschema.xml b/data/org.gnome.EasyTAG.gschema.xml
index 4f5f2fa..241245d 100644
--- a/data/org.gnome.EasyTAG.gschema.xml
+++ b/data/org.gnome.EasyTAG.gschema.xml
@@ -512,10 +512,10 @@
<default>['title','artist','album-artist','album','genre','comment','composer','original-artist','copyright','url','encoded-by']</default>
</key>
- <key name="process-convert-spaces" enum="org.gnome.EasyTAG.EtConvertSpaces">
- <summary>Convert spaces and underscores in tags</summary>
- <description>Whether to convert to spaces (and %20) or underscores when
- processing tag fields</description>
+ <key name="process-convert" enum="org.gnome.EasyTAG.EtProcessFieldsConvert">
+ <summary>Convert tag fields when processing</summary>
+ <description>Whether to convert to spaces (and %20), underscores or other
+ characters when processing tag fields</description>
<default>'spaces'</default>
</key>
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 76e1c7d..9269e07 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1103,18 +1103,29 @@ static void
Scan_Process_Fields_Functions (EtScanDialog *self, gchar **string)
{
EtScanDialogPrivate *priv;
+ EtProcessFieldsConvert process;
priv = et_scan_dialog_get_instance_private (self);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_space_toggle)))
+ process = g_settings_get_enum (MainSettings, "process-convert");
+
+ switch (process)
{
- Scan_Convert_Underscore_Into_Space(*string);
- Scan_Convert_P20_Into_Space(*string);
+ case ET_PROCESS_FIELDS_CONVERT_SPACES:
+ Scan_Convert_Underscore_Into_Space (*string);
+ Scan_Convert_P20_Into_Space (*string);
+ break;
+ case ET_PROCESS_FIELDS_CONVERT_UNDERSCORES:
+ Scan_Convert_Space_Into_Underscore (*string);
+ break;
+ case ET_PROCESS_FIELDS_CONVERT_CHARACTERS:
+ Scan_Convert_Character (self, string);
+ break;
+ case ET_PROCESS_FIELDS_CONVERT_NO_CHANGE:
+ break;
}
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_underscores_toggle)))
- Scan_Convert_Space_Into_Underscore (*string);
-
+ /* FIXME: Use GSettings keys instead of toggle buton states. */
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_insert_space_toggle)))
{
gchar *res;
@@ -1126,9 +1137,6 @@ Scan_Process_Fields_Functions (EtScanDialog *self, gchar **string)
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_insert_one_space_toggle)))
Scan_Process_Fields_Keep_One_Space(*string);
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_convert_toggle)))
- Scan_Convert_Character (self, string);
-
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_all_uppercase_toggle)))
{
gchar *res;
@@ -2830,8 +2838,11 @@ create_scan_dialog (EtScanDialog *self)
group = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start (GTK_BOX (VBox), group, FALSE, FALSE, 0);
priv->process_convert_to_space_toggle = gtk_radio_button_new_with_label_from_widget (NULL, _("Convert
'_' and '%20' to spaces"));
+ gtk_widget_set_name (priv->process_convert_to_space_toggle, "spaces");
priv->process_convert_to_underscores_toggle = gtk_radio_button_new_with_label_from_widget
(GTK_RADIO_BUTTON (priv->process_convert_to_space_toggle),
_("Convert ' ' to '_'"));
+ gtk_widget_set_name (priv->process_convert_to_underscores_toggle,
+ "underscores");
gtk_box_pack_start (GTK_BOX (group), priv->process_convert_to_space_toggle, FALSE,
FALSE, 0);
gtk_box_pack_start (GTK_BOX (group), priv->process_convert_to_underscores_toggle, FALSE,
@@ -2840,6 +2851,7 @@ create_scan_dialog (EtScanDialog *self)
gtk_box_pack_start (GTK_BOX (group), hbox, FALSE, FALSE, 0);
priv->process_convert_toggle = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
(priv->process_convert_to_space_toggle),
_("Convert:"));
+ gtk_widget_set_name (priv->process_convert_toggle, "characters");
priv->process_convert_to_entry = gtk_entry_new();
/* FIXME Use translation context. A "space" at the end to allow another
* translation for "to :" (needed in French!) */
@@ -2851,6 +2863,7 @@ create_scan_dialog (EtScanDialog *self)
gtk_widget_set_size_request(priv->process_convert_from_entry,120,-1);
process_fields_convert_none = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON
(priv->process_convert_to_space_toggle),
_("Do not convert"));
+ gtk_widget_set_name (process_fields_convert_none, "no-change");
gtk_box_pack_start(GTK_BOX(hbox),priv->process_convert_toggle, FALSE,FALSE,0);
gtk_box_pack_start(GTK_BOX(hbox),priv->process_convert_from_entry, FALSE,FALSE,0);
gtk_box_pack_start (GTK_BOX (hbox), priv->process_convert_label, FALSE,
@@ -2864,11 +2877,31 @@ create_scan_dialog (EtScanDialog *self)
G_CALLBACK (Process_Fields_Convert_Check_Button_Toggled),
self);
/* Set check buttons to init value */
-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_space_toggle),PF_CONVERT_INTO_SPACE);
-
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_underscores_toggle),PF_CONVERT_SPACE);
- g_settings_bind (MainSettings, "process-convert-characters",
- priv->process_convert_toggle, "active",
- G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind_with_mapping (MainSettings, "process-convert",
+ priv->process_convert_to_space_toggle,
+ "active", G_SETTINGS_BIND_DEFAULT,
+ et_settings_enum_radio_get,
+ et_settings_enum_radio_set,
+ priv->process_convert_to_space_toggle, NULL);
+ g_settings_bind_with_mapping (MainSettings, "process-convert",
+ priv->process_convert_to_underscores_toggle,
+ "active", G_SETTINGS_BIND_DEFAULT,
+ et_settings_enum_radio_get,
+ et_settings_enum_radio_set,
+ priv->process_convert_to_underscores_toggle,
+ NULL);
+ g_settings_bind_with_mapping (MainSettings, "process-convert",
+ priv->process_convert_toggle,
+ "active", G_SETTINGS_BIND_DEFAULT,
+ et_settings_enum_radio_get,
+ et_settings_enum_radio_set,
+ priv->process_convert_toggle, NULL);
+ g_settings_bind_with_mapping (MainSettings, "process-convert",
+ process_fields_convert_none,
+ "active", G_SETTINGS_BIND_DEFAULT,
+ et_settings_enum_radio_get,
+ et_settings_enum_radio_set,
+ process_fields_convert_none, NULL);
g_settings_bind (MainSettings, "process-convert-characters-from",
priv->process_convert_from_entry, "text",
G_SETTINGS_BIND_DEFAULT);
@@ -3227,10 +3260,6 @@ et_scan_dialog_apply_changes (EtScanDialog *self)
priv = et_scan_dialog_get_instance_private (self);
- /* Group: convert one character */
- PF_CONVERT_INTO_SPACE =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_space_toggle));
- PF_CONVERT_SPACE =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->process_convert_to_underscores_toggle));
-
/* Save default masks. */
if (SCAN_TAG_DEFAULT_MASK) g_free(SCAN_TAG_DEFAULT_MASK);
SCAN_TAG_DEFAULT_MASK =
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(priv->scan_tag_mask_combo)))));
diff --git a/src/setting.c b/src/setting.c
index dd6ac63..b3efa26 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -115,9 +115,6 @@ static const tConfigVariable Config_Variables[] =
{"audio_file_player", CV_TYPE_STRING,&AUDIO_FILE_PLAYER },
- {"pf_convert_into_space", CV_TYPE_BOOL, &PF_CONVERT_INTO_SPACE },
- {"pf_convert_space", CV_TYPE_BOOL, &PF_CONVERT_SPACE },
-
{"playlist_name", CV_TYPE_STRING, &PLAYLIST_NAME },
{"playlist_content_mask_value", CV_TYPE_STRING, &PLAYLIST_CONTENT_MASK_VALUE },
@@ -189,12 +186,6 @@ void Init_Config_Variables (void)
FILE_WRITING_ID3V1_CHARACTER_SET = g_strdup("ISO-8859-1");
/*
- * Scanner window
- */
- PF_CONVERT_INTO_SPACE = 1;
- PF_CONVERT_SPACE = 0;
-
- /*
* Playlist window
*/
PLAYLIST_NAME = g_strdup("playlist_%a_-_%b");
diff --git a/src/setting.h b/src/setting.h
index a2f27d7..a5bd252 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -113,6 +113,14 @@ typedef enum
ET_PROCESS_FIELD_ENCODED_BY = 1 << 11
} EtProcessField;
+typedef enum
+{
+ ET_PROCESS_FIELDS_CONVERT_SPACES,
+ ET_PROCESS_FIELDS_CONVERT_UNDERSCORES,
+ ET_PROCESS_FIELDS_CONVERT_CHARACTERS,
+ ET_PROCESS_FIELDS_CONVERT_NO_CHANGE
+} EtProcessFieldsConvert;
+
/* Content of generated playlists. */
typedef enum
{
@@ -211,10 +219,6 @@ gchar *FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET;
gchar *FILE_WRITING_ID3V1_CHARACTER_SET;
-/* Scanner window */
-gint PF_CONVERT_INTO_SPACE;
-gint PF_CONVERT_SPACE;
-
/* Playlist window */
gchar *PLAYLIST_NAME;
gchar *PLAYLIST_CONTENT_MASK_VALUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]