1 /* EasyTAG - Tag editor for audio files
2  * Copyright (C) 2013-2015  David King <amigadave@amigadave.com>
3  * Copyright (C) 2000-2003  Jerome Couderc <easytag@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 51
17  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "config.h"
21 
22 #include "preferences_dialog.h"
23 
24 #include <errno.h>
25 #include <gdk/gdkkeysyms.h>
26 #include <glib/gi18n.h>
27 #include <string.h>
28 
29 #include "application_window.h"
30 #include "setting.h"
31 #include "misc.h"
32 #include "scan_dialog.h"
33 #include "easytag.h"
34 #include "enums.h"
35 #include "browser.h"
36 #include "cddb_dialog.h"
37 #include "charset.h"
38 #include "win32/win32dep.h"
39 
40 typedef struct
41 {
42     GtkWidget *default_path_button;
43     GtkWidget *browser_startup_check;
44     GtkWidget *browser_subdirs_check;
45     GtkWidget *browser_expand_subdirs_check;
46     GtkWidget *browser_hidden_check;
47     GtkWidget *browser_case_check;
48     GtkWidget *log_show_check;
49     GtkWidget *header_show_check;
50     GtkWidget *list_bold_radio;
51     GtkWidget *file_name_replace_check;
52     GtkWidget *name_lower_radio;
53     GtkWidget *name_upper_radio;
54     GtkWidget *name_no_change_radio;
55     GtkWidget *file_preserve_check;
56     GtkWidget *file_parent_check;
57     GtkWidget *file_encoding_try_alternative_radio;
58     GtkWidget *file_encoding_transliterate_radio;
59     GtkWidget *file_encoding_ignore_radio;
60     GtkWidget *tags_auto_date_check;
61     GtkWidget *tags_auto_image_type_check;
62     GtkWidget *tags_track_check;
63     GtkWidget *tags_track_button;
64     GtkWidget *tags_disc_check;
65     GtkWidget *tags_disc_button;
66     GtkWidget *tags_preserve_focus_check;
67     GtkWidget *split_title_check;
68     GtkWidget *split_artist_check;
69     GtkWidget *split_album_check;
70     GtkWidget *split_genre_check;
71     GtkWidget *split_comment_check;
72     GtkWidget *split_composer_check;
73     GtkWidget *split_orig_artist_check;
74     GtkWidget *id3_strip_check;
75     GtkWidget *id3_v2_convert_check;
76     GtkWidget *id3_v2_crc32_check;
77     GtkWidget *id3_v2_compression_check;
78     GtkWidget *id3_v2_genre_check;
79     GtkWidget *id3_v2_check;
80     GtkWidget *id3_v2_version_label;
81     GtkWidget *id3_v2_version_combo;
82     GtkWidget *id3_v2_encoding_label;
83     GtkWidget *id3_v2_unicode_radio;
84     GtkWidget *id3_v2_unicode_encoding_combo;
85     GtkWidget *id3_v2_other_radio;
86     GtkWidget *id3_v2_override_encoding_combo;
87     GtkWidget *id3_v2_iconv_label;
88     GtkWidget *id3_v2_none_radio;
89     GtkWidget *id3_v2_transliterate_radio;
90     GtkWidget *id3_v2_ignore_radio;
91     GtkWidget *id3_v1_check;
92     GtkWidget *id3_v1_encoding_grid;
93     GtkWidget *id3_v1_encoding_combo;
94     GtkWidget *id3_v1_none_radio;
95     GtkWidget *id3_v1_transliterate_radio;
96     GtkWidget *id3_v1_ignore_radio;
97     GtkWidget *id3_read_encoding_check;
98     GtkWidget *id3_read_encoding_combo;
99     GtkWidget *preferences_notebook;
100     GtkWidget *scanner_grid;
101     GtkWidget *fts_underscore_p20_radio;
102     GtkWidget *fts_spaces_radio;
103     GtkWidget *fts_none_radio;
104     GtkWidget *rfs_underscore_p20_radio;
105     GtkWidget *rfs_spaces_radio;
106     GtkWidget *rfs_remove_radio;
107     GtkWidget *pfs_uppercase_prep_check;
108     GtkWidget *overwrite_fields_check;
109     GtkWidget *default_comment_check;
110     GtkWidget *default_comment_entry;
111     GtkWidget *crc32_default_check;
112     GtkWidget *cddb_automatic_host1_combo;
113     GtkWidget *cddb_automatic_port1_button;
114     GtkWidget *cddb_automatic_path1_entry;
115     GtkWidget *cddb_automatic_host2_combo;
116     GtkWidget *cddb_automatic_port2_button;
117     GtkWidget *cddb_automatic_path2_entry;
118     GtkWidget *cddb_manual_host_combo;
119     GtkWidget *cddb_manual_port_button;
120     GtkWidget *cddb_manual_path_entry;
121     GtkWidget *cddb_proxy_check;
122     GtkWidget *cddb_host_entry;
123     GtkWidget *cddb_port_button;
124     GtkWidget *cddb_password_entry;
125     GtkWidget *cddb_user_entry;
126     GtkWidget *cddb_follow_check;
127     GtkWidget *cddb_dlm_check;
128     GtkWidget *confirm_write_check;
129     GtkWidget *confirm_rename_check;
130     GtkWidget *confirm_delete_check;
131     GtkWidget *confirm_write_playlist_check;
132     GtkWidget *confirm_unsaved_files_check;
133     GtkWidget *scanner_dialog_startup_check;
134 
135     GtkListStore *default_path_model;
136     GtkListStore *file_player_model;
137 
138     gint options_notebook_scanner;
139 } EtPreferencesDialogPrivate;
140 
141 G_DEFINE_TYPE_WITH_PRIVATE (EtPreferencesDialog, et_preferences_dialog, GTK_TYPE_DIALOG)
142 
143 /**************
144  * Prototypes *
145  **************/
146 /* Options window */
147 static void notify_id3_settings_active (GObject *object, GParamSpec *pspec, EtPreferencesDialog *self);
148 
149 static void et_preferences_on_response (GtkDialog *dialog, gint response_id,
150                                         gpointer user_data);
151 
152 
153 /*************
154  * Functions *
155  *************/
156 static void
et_prefs_current_folder_changed(EtPreferencesDialog * self,GtkFileChooser * default_path_button)157 et_prefs_current_folder_changed (EtPreferencesDialog *self,
158                                  GtkFileChooser *default_path_button)
159 {
160     gchar *path;
161 
162     /* The path that is currently selected, not that which is currently being
163      * displayed. */
164     path = gtk_file_chooser_get_filename (default_path_button);
165 
166     if (path)
167     {
168         g_settings_set_value (MainSettings, "default-path",
169                               g_variant_new_bytestring (path));
170         g_free (path);
171     }
172 }
173 
174 static void
on_default_path_changed(GSettings * settings,const gchar * key,GtkFileChooserButton * default_path_button)175 on_default_path_changed (GSettings *settings,
176                          const gchar *key,
177                          GtkFileChooserButton *default_path_button)
178 {
179     GVariant *default_path;
180     const gchar *path;
181 
182     default_path = g_settings_get_value (settings, key);
183     path = g_variant_get_bytestring (default_path);
184 
185     gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (default_path_button),
186                                          path);
187     g_variant_unref (default_path);
188 }
189 
190 #ifdef ENABLE_ID3LIB
191 static gboolean
et_preferences_id3v2_version_get(GValue * value,GVariant * variant,gpointer user_data)192 et_preferences_id3v2_version_get (GValue *value,
193                                   GVariant *variant,
194                                   gpointer user_data)
195 {
196     gboolean id3v24;
197 
198     id3v24 = g_variant_get_boolean (variant);
199 
200     g_value_set_int (value, id3v24 ? 1 : 0);
201 
202     return TRUE;
203 }
204 
205 static GVariant *
et_preferences_id3v2_version_set(const GValue * value,const GVariantType * variant_type,gpointer user_data)206 et_preferences_id3v2_version_set (const GValue *value,
207                                   const GVariantType *variant_type,
208                                   gpointer user_data)
209 {
210     GVariant *id3v24;
211     gint active_row;
212 
213     active_row = g_value_get_int (value);
214 
215     id3v24 = g_variant_new_boolean (active_row == 1);
216 
217     return id3v24;
218 }
219 #endif /* ENABLE_ID3LIB */
220 
221 static gboolean
et_preferences_id3v2_unicode_charset_get(GValue * value,GVariant * variant,gpointer user_data)222 et_preferences_id3v2_unicode_charset_get (GValue *value,
223                                           GVariant *variant,
224                                           gpointer user_data)
225 {
226     const gchar *charset;
227 
228     charset = g_variant_get_string (variant, NULL);
229 
230     if (strcmp (charset, "UTF-8") == 0)
231     {
232         g_value_set_int (value, 0);
233     }
234     else if (strcmp (charset, "UTF-16") == 0)
235     {
236         g_value_set_int (value, 1);
237     }
238     else
239     {
240         return FALSE;
241     }
242 
243     return TRUE;
244 }
245 
246 static GVariant *
et_preferences_id3v2_unicode_charset_set(const GValue * value,const GVariantType * variant_type,gpointer user_data)247 et_preferences_id3v2_unicode_charset_set (const GValue *value,
248                                           const GVariantType *variant_type,
249                                           gpointer user_data)
250 {
251     gint active_row;
252 
253     active_row = g_value_get_int (value);
254 
255     switch (active_row)
256     {
257         case 0:
258             return g_variant_new_string ("UTF-8");
259             break;
260         case 1:
261             return g_variant_new_string ("UTF-16");
262             break;
263         default:
264             g_assert_not_reached ();
265     }
266 }
267 
268 /*
269  * The window for options
270  */
271 static void
create_preferences_dialog(EtPreferencesDialog * self)272 create_preferences_dialog (EtPreferencesDialog *self)
273 {
274     EtPreferencesDialogPrivate *priv;
275 
276     priv = et_preferences_dialog_get_instance_private (self);
277 
278     /* The window */
279     gtk_dialog_add_buttons (GTK_DIALOG (self), _("_Close"), GTK_RESPONSE_CLOSE,
280                             NULL);
281     gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
282 
283     /* Browser. */
284     on_default_path_changed (MainSettings, "default-path",
285                              GTK_FILE_CHOOSER_BUTTON (priv->default_path_button));
286     g_signal_connect (MainSettings, "changed::default-path",
287                       G_CALLBACK (on_default_path_changed),
288                       priv->default_path_button);
289 
290     /* Load directory on startup */
291     g_settings_bind (MainSettings, "load-on-startup",
292                      priv->browser_startup_check, "active",
293                      G_SETTINGS_BIND_DEFAULT);
294 
295     /* Browse subdirectories */
296     g_settings_bind (MainSettings, "browse-subdir",
297                      priv->browser_subdirs_check, "active",
298                      G_SETTINGS_BIND_DEFAULT);
299 
300     /* Open the node to show subdirectories */
301     g_settings_bind (MainSettings, "browse-expand-children",
302                      priv->browser_expand_subdirs_check, "active",
303                      G_SETTINGS_BIND_DEFAULT);
304 
305     /* Browse hidden directories */
306     g_settings_bind (MainSettings, "browse-show-hidden",
307                      priv->browser_hidden_check, "active",
308                      G_SETTINGS_BIND_DEFAULT);
309 
310     g_settings_bind (MainSettings, "sort-case-sensitive",
311                      priv->browser_case_check, "active",
312                      G_SETTINGS_BIND_DEFAULT);
313 
314     /* Show / hide log view. */
315     g_settings_bind (MainSettings, "log-show", priv->log_show_check, "active",
316                      G_SETTINGS_BIND_DEFAULT);
317 
318     /* Show header information. */
319     g_settings_bind (MainSettings, "file-show-header", priv->header_show_check,
320                      "active", G_SETTINGS_BIND_DEFAULT);
321 
322     /* Display color mode for changed files in list. */
323     /* Set "new" Gtk+-2.0ish black/bold style for changed items. */
324     g_settings_bind (MainSettings, "file-changed-bold", priv->list_bold_radio,
325                      "active", G_SETTINGS_BIND_DEFAULT);
326     g_signal_connect_swapped (priv->list_bold_radio, "notify::active",
327                               G_CALLBACK (et_application_window_browser_refresh_list),
328                               MainWindow);
329 
330     /*
331      * File Settings
332      */
333     /* File (name) Options */
334     g_settings_bind (MainSettings, "rename-replace-illegal-chars",
335                      priv->file_name_replace_check, "active",
336                      G_SETTINGS_BIND_DEFAULT);
337 
338     /* Extension case (lower/upper?) */
339     g_settings_bind_with_mapping (MainSettings, "rename-extension-mode",
340                                   priv->name_lower_radio, "active",
341                                   G_SETTINGS_BIND_DEFAULT,
342                                   et_settings_enum_radio_get,
343                                   et_settings_enum_radio_set,
344                                   priv->name_lower_radio, NULL);
345     g_settings_bind_with_mapping (MainSettings, "rename-extension-mode",
346                                   priv->name_upper_radio, "active",
347                                   G_SETTINGS_BIND_DEFAULT,
348                                   et_settings_enum_radio_get,
349                                   et_settings_enum_radio_set,
350                                   priv->name_upper_radio, NULL);
351     g_settings_bind_with_mapping (MainSettings, "rename-extension-mode",
352                                   priv->name_no_change_radio, "active",
353                                   G_SETTINGS_BIND_DEFAULT,
354                                   et_settings_enum_radio_get,
355                                   et_settings_enum_radio_set,
356                                   priv->name_no_change_radio, NULL);
357 
358     /* Preserve modification time */
359     g_settings_bind (MainSettings, "file-preserve-modification-time",
360                      priv->file_preserve_check, "active",
361                      G_SETTINGS_BIND_DEFAULT);
362 
363     /* Change directory modification time */
364     g_settings_bind (MainSettings, "file-update-parent-modification-time",
365                      priv->file_parent_check, "active",
366                      G_SETTINGS_BIND_DEFAULT);
367 
368     /* Character Set for Filename */
369     g_settings_bind_with_mapping (MainSettings, "rename-encoding",
370                                   priv->file_encoding_try_alternative_radio,
371                                   "active", G_SETTINGS_BIND_DEFAULT,
372                                   et_settings_enum_radio_get,
373                                   et_settings_enum_radio_set,
374                                   priv->file_encoding_try_alternative_radio,
375                                   NULL);
376     g_settings_bind_with_mapping (MainSettings, "rename-encoding",
377                                   priv->file_encoding_transliterate_radio,
378                                   "active", G_SETTINGS_BIND_DEFAULT,
379                                   et_settings_enum_radio_get,
380                                   et_settings_enum_radio_set,
381                                   priv->file_encoding_transliterate_radio,
382                                   NULL);
383     g_settings_bind_with_mapping (MainSettings, "rename-encoding",
384                                   priv->file_encoding_ignore_radio, "active",
385                                   G_SETTINGS_BIND_DEFAULT,
386                                   et_settings_enum_radio_get,
387                                   et_settings_enum_radio_set,
388                                   priv->file_encoding_ignore_radio, NULL);
389 
390     /*
391      * Tag Settings
392      */
393     /* Tag Options */
394     g_settings_bind (MainSettings, "tag-date-autocomplete",
395                      priv->tags_auto_date_check, "active",
396                      G_SETTINGS_BIND_DEFAULT);
397 
398     g_settings_bind (MainSettings, "tag-image-type-automatic",
399                      priv->tags_auto_image_type_check, "active",
400                      G_SETTINGS_BIND_DEFAULT);
401 
402     /* Track formatting. */
403     g_settings_bind (MainSettings, "tag-number-padded", priv->tags_track_check,
404                      "active", G_SETTINGS_BIND_DEFAULT);
405     g_settings_bind (MainSettings, "tag-number-length",
406                      priv->tags_track_button, "value",
407                      G_SETTINGS_BIND_DEFAULT);
408     g_settings_bind (MainSettings, "tag-number-padded",
409                      priv->tags_track_button, "sensitive",
410                      G_SETTINGS_BIND_GET);
411 
412     /* Disc formatting. */
413     g_settings_bind (MainSettings, "tag-disc-padded", priv->tags_disc_check,
414                      "active", G_SETTINGS_BIND_DEFAULT);
415 
416     g_settings_bind (MainSettings, "tag-disc-length",
417                      priv->tags_disc_button, "value",
418                      G_SETTINGS_BIND_DEFAULT);
419     g_settings_bind (MainSettings, "tag-disc-padded",
420                      priv->tags_disc_button, "sensitive",
421                      G_SETTINGS_BIND_GET);
422     g_signal_emit_by_name (G_OBJECT (priv->tags_disc_check), "toggled");
423 
424     /* Tag field focus */
425     g_settings_bind (MainSettings, "tag-preserve-focus",
426                      priv->tags_preserve_focus_check, "active",
427                      G_SETTINGS_BIND_DEFAULT);
428 
429     /* Tag Splitting */
430     g_settings_bind (MainSettings, "ogg-split-title", priv->split_title_check,
431                      "active", G_SETTINGS_BIND_DEFAULT);
432     g_settings_bind (MainSettings, "ogg-split-artist", priv->split_artist_check,
433                      "active", G_SETTINGS_BIND_DEFAULT);
434     g_settings_bind (MainSettings, "ogg-split-album", priv->split_album_check,
435                      "active", G_SETTINGS_BIND_DEFAULT);
436     g_settings_bind (MainSettings, "ogg-split-genre", priv->split_genre_check,
437                      "active", G_SETTINGS_BIND_DEFAULT);
438     g_settings_bind (MainSettings, "ogg-split-comment",
439                      priv->split_comment_check, "active",
440                      G_SETTINGS_BIND_DEFAULT);
441     g_settings_bind (MainSettings, "ogg-split-composer",
442                      priv->split_composer_check, "active",
443                      G_SETTINGS_BIND_DEFAULT);
444     g_settings_bind (MainSettings, "ogg-split-original-artist",
445                      priv->split_orig_artist_check, "active",
446                      G_SETTINGS_BIND_DEFAULT);
447 
448     /*
449      * ID3 Tag Settings
450      */
451     /* Strip tag when fields (managed by EasyTAG) are empty */
452     g_settings_bind (MainSettings, "id3-strip-empty", priv->id3_strip_check,
453                      "active", G_SETTINGS_BIND_DEFAULT);
454 
455     /* Convert old ID3v2 tag version */
456     g_settings_bind (MainSettings, "id3v2-convert-old",
457                      priv->id3_v2_convert_check, "active",
458                      G_SETTINGS_BIND_DEFAULT);
459 
460     /* Use CRC32 */
461     g_settings_bind (MainSettings, "id3v2-crc32", priv->id3_v2_crc32_check,
462                      "active", G_SETTINGS_BIND_DEFAULT);
463 
464     /* Use Compression */
465     g_settings_bind (MainSettings, "id3v2-compression",
466                      priv->id3_v2_compression_check, "active",
467                      G_SETTINGS_BIND_DEFAULT);
468 
469     /* Write Genre in text */
470     g_settings_bind (MainSettings, "id3v2-text-only-genre",
471                      priv->id3_v2_genre_check, "active",
472                      G_SETTINGS_BIND_DEFAULT);
473 
474     /* Write ID3v2 tag */
475     g_settings_bind (MainSettings, "id3v2-enabled", priv->id3_v2_check,
476                      "active", G_SETTINGS_BIND_DEFAULT);
477     g_signal_connect (priv->id3_v2_check, "notify::active",
478                       G_CALLBACK (notify_id3_settings_active), self);
479 
480 #ifdef ENABLE_ID3LIB
481     /* ID3v2 tag version */
482     g_settings_bind_with_mapping (MainSettings, "id3v2-version-4",
483                                   priv->id3_v2_version_combo, "active",
484                                   G_SETTINGS_BIND_DEFAULT,
485                                   et_preferences_id3v2_version_get,
486                                   et_preferences_id3v2_version_set, self,
487                                   NULL);
488     g_signal_connect (MainSettings, "changed::id3v2-version-4",
489                       G_CALLBACK (notify_id3_settings_active), self);
490 #endif
491 
492     /* Charset */
493     /* Unicode. */
494     g_settings_bind_with_mapping (MainSettings, "id3v2-unicode-charset",
495                                   priv->id3_v2_unicode_encoding_combo,
496                                   "active", G_SETTINGS_BIND_DEFAULT,
497                                   et_preferences_id3v2_unicode_charset_get,
498                                   et_preferences_id3v2_unicode_charset_set,
499                                   NULL, NULL);
500 
501     g_settings_bind (MainSettings, "id3v2-enable-unicode",
502                      priv->id3_v2_other_radio, "active",
503                      G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
504     g_signal_connect (priv->id3_v2_unicode_radio,
505                       "notify::active",
506                       G_CALLBACK (notify_id3_settings_active), self);
507 
508     /* Non-Unicode. */
509     Charset_Populate_Combobox (GTK_COMBO_BOX (priv->id3_v2_override_encoding_combo),
510                                g_settings_get_enum (MainSettings,
511                                                     "id3v2-no-unicode-charset"));
512     g_settings_bind_with_mapping (MainSettings, "id3v2-no-unicode-charset",
513                                   priv->id3_v2_override_encoding_combo,
514                                   "active", G_SETTINGS_BIND_DEFAULT,
515                                   et_settings_enum_get, et_settings_enum_set,
516                                   GSIZE_TO_POINTER (ET_TYPE_CHARSET), NULL);
517     g_signal_connect (priv->id3_v2_other_radio,
518                       "notify::active",
519                       G_CALLBACK (notify_id3_settings_active), self);
520 
521     /* ID3v2 Additional iconv() options. */
522     g_settings_bind_with_mapping (MainSettings, "id3v2-encoding-option",
523                                   priv->id3_v2_none_radio, "active",
524                                   G_SETTINGS_BIND_DEFAULT,
525                                   et_settings_enum_radio_get,
526                                   et_settings_enum_radio_set,
527                                   priv->id3_v2_none_radio, NULL);
528     g_settings_bind_with_mapping (MainSettings, "id3v2-encoding-option",
529                                   priv->id3_v2_transliterate_radio,
530                                   "active", G_SETTINGS_BIND_DEFAULT,
531                                   et_settings_enum_radio_get,
532                                   et_settings_enum_radio_set,
533                                   priv->id3_v2_transliterate_radio, NULL);
534     g_settings_bind_with_mapping (MainSettings, "id3v2-encoding-option",
535                                   priv->id3_v2_ignore_radio, "active",
536                                   G_SETTINGS_BIND_DEFAULT,
537                                   et_settings_enum_radio_get,
538                                   et_settings_enum_radio_set,
539                                   priv->id3_v2_ignore_radio, NULL);
540 
541     /* Write ID3v1 tag */
542     g_settings_bind (MainSettings, "id3v1-enabled", priv->id3_v1_check,
543                      "active", G_SETTINGS_BIND_DEFAULT);
544     g_signal_connect (priv->id3_v1_check, "notify::active",
545                       G_CALLBACK (notify_id3_settings_active), self);
546 
547     /* Id3V1 writing character set */
548     Charset_Populate_Combobox (GTK_COMBO_BOX (priv->id3_v1_encoding_combo),
549                                g_settings_get_enum (MainSettings,
550                                                     "id3v1-charset"));
551     g_settings_bind_with_mapping (MainSettings, "id3v1-charset",
552                                   priv->id3_v1_encoding_combo,
553                                   "active", G_SETTINGS_BIND_DEFAULT,
554                                   et_settings_enum_get, et_settings_enum_set,
555                                   GSIZE_TO_POINTER (ET_TYPE_CHARSET), NULL);
556 
557     /* ID3V1 Additional iconv() options*/
558     g_settings_bind_with_mapping (MainSettings, "id3v1-encoding-option",
559                                   priv->id3_v1_none_radio, "active",
560                                   G_SETTINGS_BIND_DEFAULT,
561                                   et_settings_enum_radio_get,
562                                   et_settings_enum_radio_set,
563                                   priv->id3_v1_none_radio, NULL);
564     g_settings_bind_with_mapping (MainSettings, "id3v1-encoding-option",
565                                   priv->id3_v1_transliterate_radio,
566                                   "active", G_SETTINGS_BIND_DEFAULT,
567                                   et_settings_enum_radio_get,
568                                   et_settings_enum_radio_set,
569                                   priv->id3_v1_transliterate_radio, NULL);
570     g_settings_bind_with_mapping (MainSettings, "id3v1-encoding-option",
571                                   priv->id3_v1_ignore_radio, "active",
572                                   G_SETTINGS_BIND_DEFAULT,
573                                   et_settings_enum_radio_get,
574                                   et_settings_enum_radio_set,
575                                   priv->id3_v1_ignore_radio, NULL);
576 
577     /* Character Set for reading tag */
578     /* "File Reading Charset" Check Button + Combo. */
579     g_settings_bind (MainSettings, "id3-override-read-encoding",
580                      priv->id3_read_encoding_check, "active",
581                      G_SETTINGS_BIND_DEFAULT);
582 
583     Charset_Populate_Combobox (GTK_COMBO_BOX (priv->id3_read_encoding_combo),
584                                g_settings_get_enum (MainSettings,
585                                                     "id3v1v2-charset"));
586     g_settings_bind_with_mapping (MainSettings, "id3v1v2-charset",
587                                   priv->id3_read_encoding_combo,
588                                   "active", G_SETTINGS_BIND_DEFAULT,
589                                   et_settings_enum_get, et_settings_enum_set,
590                                   GSIZE_TO_POINTER (ET_TYPE_CHARSET), NULL);
591     g_settings_bind (MainSettings, "id3-override-read-encoding",
592                      priv->id3_read_encoding_combo, "sensitive",
593                      G_SETTINGS_BIND_GET);
594     notify_id3_settings_active (NULL, NULL, self);
595 
596     /*
597      * Scanner
598      */
599     /* Save the number of the page. Asked in Scanner window */
600     priv->options_notebook_scanner = gtk_notebook_page_num (GTK_NOTEBOOK (priv->preferences_notebook),
601                                                             priv->scanner_grid);
602 
603     /* Character conversion for the 'Fill Tag' scanner (=> FTS...) */
604     g_settings_bind_with_mapping (MainSettings, "fill-convert-spaces",
605                                   priv->fts_underscore_p20_radio,
606                                   "active", G_SETTINGS_BIND_DEFAULT,
607                                   et_settings_enum_radio_get,
608                                   et_settings_enum_radio_set,
609                                   priv->fts_underscore_p20_radio, NULL);
610     g_settings_bind_with_mapping (MainSettings, "fill-convert-spaces",
611                                   priv->fts_spaces_radio, "active",
612                                   G_SETTINGS_BIND_DEFAULT,
613                                   et_settings_enum_radio_get,
614                                   et_settings_enum_radio_set,
615                                   priv->fts_spaces_radio, NULL);
616     g_settings_bind_with_mapping (MainSettings, "fill-convert-spaces",
617                                   priv->fts_none_radio, "active",
618                                   G_SETTINGS_BIND_DEFAULT,
619                                   et_settings_enum_radio_get,
620                                   et_settings_enum_radio_set,
621                                   priv->fts_none_radio, NULL);
622     /* TODO: No change tooltip. */
623 
624     /* Character conversion for the 'Rename File' scanner (=> RFS...) */
625     g_settings_bind_with_mapping (MainSettings, "rename-convert-spaces",
626                                   priv->rfs_underscore_p20_radio,
627                                   "active", G_SETTINGS_BIND_DEFAULT,
628                                   et_settings_enum_radio_get,
629                                   et_settings_enum_radio_set,
630                                   priv->rfs_underscore_p20_radio, NULL);
631     g_settings_bind_with_mapping (MainSettings, "rename-convert-spaces",
632                                   priv->rfs_spaces_radio, "active",
633                                   G_SETTINGS_BIND_DEFAULT,
634                                   et_settings_enum_radio_get,
635                                   et_settings_enum_radio_set,
636                                   priv->rfs_spaces_radio, NULL);
637     g_settings_bind_with_mapping (MainSettings, "rename-convert-spaces",
638                                   priv->rfs_remove_radio, "active",
639                                   G_SETTINGS_BIND_DEFAULT,
640                                   et_settings_enum_radio_get,
641                                   et_settings_enum_radio_set,
642                                   priv->rfs_remove_radio,
643                                   NULL);
644 
645     /* Character conversion for the 'Process Fields' scanner (=> PFS...) */
646     g_settings_bind (MainSettings, "process-uppercase-prepositions",
647                      priv->pfs_uppercase_prep_check, "active",
648                      G_SETTINGS_BIND_DEFAULT);
649 
650     /* Other options */
651     g_settings_bind (MainSettings, "fill-overwrite-tag-fields",
652                      priv->overwrite_fields_check, "active",
653                      G_SETTINGS_BIND_DEFAULT);
654 
655     /* Set a default comment text or CRC-32 checksum. */
656     g_settings_bind (MainSettings, "fill-set-default-comment",
657                      priv->default_comment_check, "active",
658                      G_SETTINGS_BIND_DEFAULT);
659     g_settings_bind (MainSettings, "fill-set-default-comment",
660                      priv->default_comment_entry, "sensitive",
661                      G_SETTINGS_BIND_GET);
662     g_settings_bind (MainSettings, "fill-default-comment",
663                      priv->default_comment_entry, "text",
664                      G_SETTINGS_BIND_DEFAULT);
665 
666     /* CRC32 comment. */
667     g_settings_bind (MainSettings, "fill-crc32-comment",
668                      priv->crc32_default_check, "active",
669                      G_SETTINGS_BIND_DEFAULT);
670 
671     /* CDDB */
672     /* 1st automatic search server. */
673     g_settings_bind (MainSettings, "cddb-automatic-search-hostname",
674                      gtk_bin_get_child (GTK_BIN (priv->cddb_automatic_host1_combo)),
675                      "text", G_SETTINGS_BIND_DEFAULT);
676     g_settings_bind (MainSettings, "cddb-automatic-search-port",
677                      priv->cddb_automatic_port1_button, "value",
678                      G_SETTINGS_BIND_DEFAULT);
679     g_settings_bind (MainSettings, "cddb-automatic-search-path",
680                      priv->cddb_automatic_path1_entry, "text",
681                      G_SETTINGS_BIND_DEFAULT);
682 
683     /* 2nd automatic search server. */
684     g_settings_bind (MainSettings, "cddb-automatic-search-hostname2",
685                      gtk_bin_get_child (GTK_BIN (priv->cddb_automatic_host2_combo)),
686                      "text", G_SETTINGS_BIND_DEFAULT);
687     g_settings_bind (MainSettings, "cddb-automatic-search-port2",
688                      priv->cddb_automatic_port2_button, "value",
689                      G_SETTINGS_BIND_DEFAULT);
690     g_settings_bind (MainSettings, "cddb-automatic-search-path2",
691                      priv->cddb_automatic_path2_entry, "text",
692                      G_SETTINGS_BIND_DEFAULT);
693 
694     /* CDDB Server Settings (Manual Search). */
695     g_settings_bind (MainSettings, "cddb-manual-search-hostname",
696                      gtk_bin_get_child (GTK_BIN (priv->cddb_manual_host_combo)),
697                      "text", G_SETTINGS_BIND_DEFAULT);
698     g_settings_bind (MainSettings, "cddb-manual-search-port",
699                      priv->cddb_manual_port_button, "value",
700                      G_SETTINGS_BIND_DEFAULT);
701     g_settings_bind (MainSettings, "cddb-manual-search-path",
702                      priv->cddb_manual_path_entry, "text",
703                      G_SETTINGS_BIND_DEFAULT);
704 
705     /* CDDB Proxy Settings. */
706     g_settings_bind (MainSettings, "cddb-proxy-enabled",
707                      priv->cddb_proxy_check, "active",
708                      G_SETTINGS_BIND_DEFAULT);
709     g_settings_bind (MainSettings, "cddb-proxy-hostname",
710                      priv->cddb_host_entry, "text", G_SETTINGS_BIND_DEFAULT);
711     g_settings_bind (MainSettings, "cddb-proxy-enabled", priv->cddb_host_entry,
712                      "sensitive", G_SETTINGS_BIND_GET);
713     g_settings_bind (MainSettings, "cddb-proxy-port", priv->cddb_port_button,
714                      "value", G_SETTINGS_BIND_DEFAULT);
715     g_settings_bind (MainSettings, "cddb-proxy-enabled",
716                      priv->cddb_port_button, "sensitive", G_SETTINGS_BIND_GET);
717     g_settings_bind (MainSettings, "cddb-proxy-username",
718                      priv->cddb_user_entry, "text", G_SETTINGS_BIND_DEFAULT);
719     g_settings_bind (MainSettings, "cddb-proxy-enabled", priv->cddb_user_entry,
720                      "sensitive", G_SETTINGS_BIND_GET);
721     g_settings_bind (MainSettings, "cddb-proxy-password",
722                      priv->cddb_password_entry, "text",
723                      G_SETTINGS_BIND_DEFAULT);
724     g_settings_bind (MainSettings, "cddb-proxy-enabled",
725                      priv->cddb_password_entry, "sensitive",
726                      G_SETTINGS_BIND_GET);
727 
728     /* Track Name list (CDDB results). */
729     g_settings_bind (MainSettings, "cddb-follow-file", priv->cddb_follow_check,
730                      "active", G_SETTINGS_BIND_DEFAULT);
731 
732     /* Check box to use DLM. */
733     g_settings_bind (MainSettings, "cddb-dlm-enabled", priv->cddb_dlm_check,
734                      "active", G_SETTINGS_BIND_DEFAULT);
735 
736     /* Confirmation */
737     g_settings_bind (MainSettings, "confirm-write-tags",
738                      priv->confirm_write_check, "active",
739                      G_SETTINGS_BIND_DEFAULT);
740     g_settings_bind (MainSettings, "confirm-rename-file",
741                      priv->confirm_rename_check, "active",
742                      G_SETTINGS_BIND_DEFAULT);
743     g_settings_bind (MainSettings, "confirm-delete-file",
744                      priv->confirm_delete_check, "active",
745                      G_SETTINGS_BIND_DEFAULT);
746     g_settings_bind (MainSettings, "confirm-write-playlist",
747                      priv->confirm_write_playlist_check, "active",
748                      G_SETTINGS_BIND_DEFAULT);
749     g_settings_bind (MainSettings, "confirm-when-unsaved-files",
750                      priv->confirm_unsaved_files_check, "active",
751                      G_SETTINGS_BIND_DEFAULT);
752 
753     /* Properties of the scanner window */
754     g_settings_bind (MainSettings, "scan-startup",
755                      priv->scanner_dialog_startup_check, "active",
756                      G_SETTINGS_BIND_DEFAULT);
757 
758     /* Load the default page */
759     g_settings_bind (MainSettings, "preferences-page",
760                      priv->preferences_notebook, "page",
761                      G_SETTINGS_BIND_DEFAULT);
762 }
763 
764 static void
notify_id3_settings_active(GObject * object,GParamSpec * pspec,EtPreferencesDialog * self)765 notify_id3_settings_active (GObject *object,
766                             GParamSpec *pspec,
767                             EtPreferencesDialog *self)
768 {
769     EtPreferencesDialogPrivate *priv;
770     gboolean active;
771 
772     priv = et_preferences_dialog_get_instance_private (self);
773 
774     active = g_settings_get_boolean (MainSettings, "id3v2-enable-unicode");
775 
776     if (g_settings_get_boolean (MainSettings, "id3v2-enabled"))
777     {
778         gtk_widget_set_sensitive (priv->id3_v2_encoding_label, TRUE);
779 
780 #ifdef ENABLE_ID3LIB
781         gtk_widget_set_sensitive (priv->id3_v2_version_label, TRUE);
782         gtk_widget_set_sensitive (priv->id3_v2_version_combo, TRUE);
783 
784         if (!g_settings_get_boolean (MainSettings, "id3v2-version-4"))
785         {
786             /* When "ID3v2.3" is selected. */
787             gtk_combo_box_set_active (GTK_COMBO_BOX (priv->id3_v2_unicode_encoding_combo), 1);
788             gtk_widget_set_sensitive (priv->id3_v2_unicode_encoding_combo,
789                                       FALSE);
790         }
791         else
792         {
793             /* When "ID3v2.4" is selected, set "UTF-8" as default value. */
794             gtk_combo_box_set_active (GTK_COMBO_BOX (priv->id3_v2_unicode_encoding_combo),
795                                       0);
796             gtk_widget_set_sensitive (priv->id3_v2_unicode_encoding_combo,
797                                       active);
798         }
799 #else
800         gtk_widget_set_sensitive (priv->id3_v2_unicode_encoding_combo,
801                                   active);
802 #endif
803         gtk_widget_set_sensitive(priv->id3_v2_unicode_radio, TRUE);
804         gtk_widget_set_sensitive(priv->id3_v2_other_radio, TRUE);
805         gtk_widget_set_sensitive (priv->id3_v2_override_encoding_combo,
806                                   !active);
807         gtk_widget_set_sensitive (priv->id3_v2_iconv_label, !active);
808         gtk_widget_set_sensitive (priv->id3_v2_none_radio, !active);
809         gtk_widget_set_sensitive (priv->id3_v2_transliterate_radio, !active);
810         gtk_widget_set_sensitive (priv->id3_v2_ignore_radio, !active);
811         gtk_widget_set_sensitive (priv->id3_v2_crc32_check, TRUE);
812         gtk_widget_set_sensitive (priv->id3_v2_compression_check, TRUE);
813         gtk_widget_set_sensitive (priv->id3_v2_genre_check, TRUE);
814         gtk_widget_set_sensitive (priv->id3_v2_convert_check, TRUE);
815 
816     }else
817     {
818         gtk_widget_set_sensitive (priv->id3_v2_encoding_label, FALSE);
819 #ifdef ENABLE_ID3LIB
820         gtk_widget_set_sensitive (priv->id3_v2_version_label, FALSE);
821         gtk_widget_set_sensitive (priv->id3_v2_version_combo, FALSE);
822 #endif
823         gtk_widget_set_sensitive (priv->id3_v2_unicode_radio, FALSE);
824         gtk_widget_set_sensitive (priv->id3_v2_other_radio, FALSE);
825         gtk_widget_set_sensitive (priv->id3_v2_unicode_encoding_combo, FALSE);
826         gtk_widget_set_sensitive (priv->id3_v2_override_encoding_combo, FALSE);
827         gtk_widget_set_sensitive (priv->id3_v2_iconv_label, FALSE);
828         gtk_widget_set_sensitive (priv->id3_v2_none_radio, FALSE);
829         gtk_widget_set_sensitive (priv->id3_v2_transliterate_radio, FALSE);
830         gtk_widget_set_sensitive (priv->id3_v2_ignore_radio, FALSE);
831         gtk_widget_set_sensitive (priv->id3_v2_crc32_check, FALSE);
832         gtk_widget_set_sensitive (priv->id3_v2_compression_check, FALSE);
833         gtk_widget_set_sensitive (priv->id3_v2_genre_check, FALSE);
834         gtk_widget_set_sensitive (priv->id3_v2_convert_check, FALSE);
835     }
836 
837     active = g_settings_get_boolean (MainSettings, "id3v1-enabled");
838 
839     gtk_widget_set_sensitive (priv->id3_v1_encoding_grid, active);
840 }
841 
842 /*
843  * Check_Config: Check if config information are correct
844  *
845  * Problem noted : if a character is escaped (like : 'C\351line DION') in
846  *                 gtk_file_chooser it will converted to UTF-8. So after, there
847  *                 is a problem to convert it in the right system encoding to be
848  *                 passed to stat(), and it can find the directory.
849  * exemple :
850  *  - initial file on system                        : C\351line DION - D'eux (1995)
851  *  - converted to UTF-8 (path_utf8)                : Céline DION - D'eux (1995)
852  *  - try to convert to system encoding (path_real) : ?????
853  */
854 static gboolean
Check_DefaultPathToMp3(EtPreferencesDialog * self)855 Check_DefaultPathToMp3 (EtPreferencesDialog *self)
856 {
857     GVariant *default_path;
858     const gchar *path_real;
859     GFile *file;
860     GFileInfo *fileinfo;
861 
862     default_path = g_settings_get_value (MainSettings, "default-path");
863     path_real = g_variant_get_bytestring (default_path);
864 
865     if (!*path_real)
866     {
867         g_variant_unref (default_path);
868         return TRUE;
869     }
870 
871     file = g_file_new_for_path (path_real);
872     fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE ","
873                                   G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
874                                   G_FILE_QUERY_INFO_NONE, NULL, NULL);
875     g_variant_unref (default_path);
876     g_object_unref (file);
877 
878     if (fileinfo)
879     {
880         if (g_file_info_get_file_type (fileinfo) == G_FILE_TYPE_DIRECTORY)
881         {
882             g_object_unref (fileinfo);
883             return TRUE; /* Path is good */
884         }
885         else
886         {
887             GtkWidget *msgdialog;
888             const gchar *path_utf8;
889 
890             path_utf8 = g_file_info_get_display_name (fileinfo);
891             msgdialog = gtk_message_dialog_new (GTK_WINDOW (self),
892                                                 GTK_DIALOG_MODAL
893                                                 | GTK_DIALOG_DESTROY_WITH_PARENT,
894                                                 GTK_MESSAGE_ERROR,
895                                                 GTK_BUTTONS_CLOSE,
896                                                 "%s",
897                                                 _("The selected default path is invalid"));
898             gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (msgdialog),
899                                                       _("Path: ‘%s’\nError: %s"),
900                                                       path_utf8,
901                                                       g_strerror (errno));
902             gtk_window_set_title (GTK_WINDOW (msgdialog),
903                                   _("Invalid Path Error"));
904 
905             gtk_dialog_run (GTK_DIALOG (msgdialog));
906             gtk_widget_destroy (msgdialog);
907         }
908 
909         g_object_unref (fileinfo);
910     }
911 
912     return FALSE;
913 }
914 
915 static gboolean
Check_Config(EtPreferencesDialog * self)916 Check_Config (EtPreferencesDialog *self)
917 {
918     if (Check_DefaultPathToMp3 (self))
919         return TRUE; /* No problem detected */
920     else
921         return FALSE; /* Oops! */
922 }
923 
924 /* Callback from et_preferences_dialog_on_response. */
925 static void
OptionsWindow_Save_Button(EtPreferencesDialog * self)926 OptionsWindow_Save_Button (EtPreferencesDialog *self)
927 {
928     if (!Check_Config (self)) return;
929 
930     gtk_widget_hide (GTK_WIDGET (self));
931 }
932 
933 void
et_preferences_dialog_show_scanner(EtPreferencesDialog * self)934 et_preferences_dialog_show_scanner (EtPreferencesDialog *self)
935 {
936     EtPreferencesDialogPrivate *priv;
937 
938     g_return_if_fail (ET_PREFERENCES_DIALOG (self));
939 
940     priv = et_preferences_dialog_get_instance_private (self);
941 
942     gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->preferences_notebook),
943                                    priv->options_notebook_scanner);
944     gtk_window_present (GTK_WINDOW (self));
945 }
946 
947 /*
948  * et_preferences_on_response:
949  * @dialog: the dialog which trigerred the response signal
950  * @response_id: the response which was triggered
951  * @user_data: user data set when the signal was connected
952  *
953  * Signal handler for the response signal, to check whether the OK or cancel
954  * button was clicked, or if a delete event was received.
955  */
956 static void
et_preferences_on_response(GtkDialog * dialog,gint response_id,gpointer user_data)957 et_preferences_on_response (GtkDialog *dialog, gint response_id,
958                             gpointer user_data)
959 {
960     switch (response_id)
961     {
962         case GTK_RESPONSE_CLOSE:
963             OptionsWindow_Save_Button (ET_PREFERENCES_DIALOG (dialog));
964             break;
965         case GTK_RESPONSE_DELETE_EVENT:
966             break;
967         default:
968             g_assert_not_reached ();
969     }
970 }
971 
972 static void
et_preferences_dialog_init(EtPreferencesDialog * self)973 et_preferences_dialog_init (EtPreferencesDialog *self)
974 {
975     gtk_widget_init_template (GTK_WIDGET (self));
976     create_preferences_dialog (self);
977 }
978 
979 static void
et_preferences_dialog_class_init(EtPreferencesDialogClass * klass)980 et_preferences_dialog_class_init (EtPreferencesDialogClass *klass)
981 {
982     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
983 
984     gtk_widget_class_set_template_from_resource (widget_class,
985                                                  "/org/gnome/EasyTAG/preferences_dialog.ui");
986     gtk_widget_class_bind_template_child_private (widget_class,
987                                                   EtPreferencesDialog,
988                                                   default_path_button);
989     gtk_widget_class_bind_template_child_private (widget_class,
990                                                   EtPreferencesDialog,
991                                                   browser_startup_check);
992     gtk_widget_class_bind_template_child_private (widget_class,
993                                                   EtPreferencesDialog,
994                                                   browser_subdirs_check);
995     gtk_widget_class_bind_template_child_private (widget_class,
996                                                   EtPreferencesDialog,
997                                                   browser_expand_subdirs_check);
998     gtk_widget_class_bind_template_child_private (widget_class,
999                                                   EtPreferencesDialog,
1000                                                   browser_hidden_check);
1001     gtk_widget_class_bind_template_child_private (widget_class,
1002                                                   EtPreferencesDialog,
1003                                                   browser_case_check);
1004     gtk_widget_class_bind_template_child_private (widget_class,
1005                                                   EtPreferencesDialog,
1006                                                   log_show_check);
1007     gtk_widget_class_bind_template_child_private (widget_class,
1008                                                   EtPreferencesDialog,
1009                                                   header_show_check);
1010     gtk_widget_class_bind_template_child_private (widget_class,
1011                                                   EtPreferencesDialog,
1012                                                   list_bold_radio);
1013     gtk_widget_class_bind_template_child_private (widget_class,
1014                                                   EtPreferencesDialog,
1015                                                   file_name_replace_check);
1016     gtk_widget_class_bind_template_child_private (widget_class,
1017                                                   EtPreferencesDialog,
1018                                                   name_lower_radio);
1019     gtk_widget_class_bind_template_child_private (widget_class,
1020                                                   EtPreferencesDialog,
1021                                                   name_upper_radio);
1022     gtk_widget_class_bind_template_child_private (widget_class,
1023                                                   EtPreferencesDialog,
1024                                                   name_no_change_radio);
1025     gtk_widget_class_bind_template_child_private (widget_class,
1026                                                   EtPreferencesDialog,
1027                                                   file_preserve_check);
1028     gtk_widget_class_bind_template_child_private (widget_class,
1029                                                   EtPreferencesDialog,
1030                                                   file_parent_check);
1031     gtk_widget_class_bind_template_child_private (widget_class,
1032                                                   EtPreferencesDialog,
1033                                                   file_encoding_try_alternative_radio);
1034     gtk_widget_class_bind_template_child_private (widget_class,
1035                                                   EtPreferencesDialog,
1036                                                   file_encoding_transliterate_radio);
1037     gtk_widget_class_bind_template_child_private (widget_class,
1038                                                   EtPreferencesDialog,
1039                                                   file_encoding_ignore_radio);
1040     gtk_widget_class_bind_template_child_private (widget_class,
1041                                                   EtPreferencesDialog,
1042                                                   tags_auto_date_check);
1043     gtk_widget_class_bind_template_child_private (widget_class,
1044                                                   EtPreferencesDialog,
1045                                                   tags_auto_image_type_check);
1046     gtk_widget_class_bind_template_child_private (widget_class,
1047                                                   EtPreferencesDialog,
1048                                                   tags_track_check);
1049     gtk_widget_class_bind_template_child_private (widget_class,
1050                                                   EtPreferencesDialog,
1051                                                   tags_track_button);
1052     gtk_widget_class_bind_template_child_private (widget_class,
1053                                                   EtPreferencesDialog,
1054                                                   tags_disc_check);
1055     gtk_widget_class_bind_template_child_private (widget_class,
1056                                                   EtPreferencesDialog,
1057                                                   tags_disc_button);
1058     gtk_widget_class_bind_template_child_private (widget_class,
1059                                                   EtPreferencesDialog,
1060                                                   tags_preserve_focus_check);
1061     gtk_widget_class_bind_template_child_private (widget_class,
1062                                                   EtPreferencesDialog,
1063                                                   split_title_check);
1064     gtk_widget_class_bind_template_child_private (widget_class,
1065                                                   EtPreferencesDialog,
1066                                                   split_artist_check);
1067     gtk_widget_class_bind_template_child_private (widget_class,
1068                                                   EtPreferencesDialog,
1069                                                   split_album_check);
1070     gtk_widget_class_bind_template_child_private (widget_class,
1071                                                   EtPreferencesDialog,
1072                                                   split_genre_check);
1073     gtk_widget_class_bind_template_child_private (widget_class,
1074                                                   EtPreferencesDialog,
1075                                                   split_comment_check);
1076     gtk_widget_class_bind_template_child_private (widget_class,
1077                                                   EtPreferencesDialog,
1078                                                   split_composer_check);
1079     gtk_widget_class_bind_template_child_private (widget_class,
1080                                                   EtPreferencesDialog,
1081                                                   split_orig_artist_check);
1082     gtk_widget_class_bind_template_child_private (widget_class,
1083                                                   EtPreferencesDialog,
1084                                                   id3_strip_check);
1085     gtk_widget_class_bind_template_child_private (widget_class,
1086                                                   EtPreferencesDialog,
1087                                                   id3_v2_convert_check);
1088     gtk_widget_class_bind_template_child_private (widget_class,
1089                                                   EtPreferencesDialog,
1090                                                   id3_v2_crc32_check);
1091     gtk_widget_class_bind_template_child_private (widget_class,
1092                                                   EtPreferencesDialog,
1093                                                   id3_v2_compression_check);
1094     gtk_widget_class_bind_template_child_private (widget_class,
1095                                                   EtPreferencesDialog,
1096                                                   id3_v2_genre_check);
1097     gtk_widget_class_bind_template_child_private (widget_class,
1098                                                   EtPreferencesDialog,
1099                                                   id3_v2_check);
1100     gtk_widget_class_bind_template_child_private (widget_class,
1101                                                   EtPreferencesDialog,
1102                                                   id3_v2_version_label);
1103     gtk_widget_class_bind_template_child_private (widget_class,
1104                                                   EtPreferencesDialog,
1105                                                   id3_v2_version_combo);
1106     gtk_widget_class_bind_template_child_private (widget_class,
1107                                                   EtPreferencesDialog,
1108                                                   id3_v2_encoding_label);
1109     gtk_widget_class_bind_template_child_private (widget_class,
1110                                                   EtPreferencesDialog,
1111                                                   id3_v2_unicode_radio);
1112     gtk_widget_class_bind_template_child_private (widget_class,
1113                                                   EtPreferencesDialog,
1114                                                   id3_v2_unicode_encoding_combo);
1115     gtk_widget_class_bind_template_child_private (widget_class,
1116                                                   EtPreferencesDialog,
1117                                                   id3_v2_other_radio);
1118     gtk_widget_class_bind_template_child_private (widget_class,
1119                                                   EtPreferencesDialog,
1120                                                   id3_v2_override_encoding_combo);
1121     gtk_widget_class_bind_template_child_private (widget_class,
1122                                                   EtPreferencesDialog,
1123                                                   id3_v2_iconv_label);
1124     gtk_widget_class_bind_template_child_private (widget_class,
1125                                                   EtPreferencesDialog,
1126                                                   id3_v2_none_radio);
1127     gtk_widget_class_bind_template_child_private (widget_class,
1128                                                   EtPreferencesDialog,
1129                                                   id3_v2_transliterate_radio);
1130     gtk_widget_class_bind_template_child_private (widget_class,
1131                                                   EtPreferencesDialog,
1132                                                   id3_v2_ignore_radio);
1133     gtk_widget_class_bind_template_child_private (widget_class,
1134                                                   EtPreferencesDialog,
1135                                                   id3_v1_check);
1136     gtk_widget_class_bind_template_child_private (widget_class,
1137                                                   EtPreferencesDialog,
1138                                                   id3_v1_encoding_grid);
1139     gtk_widget_class_bind_template_child_private (widget_class,
1140                                                   EtPreferencesDialog,
1141                                                   id3_v1_encoding_combo);
1142     gtk_widget_class_bind_template_child_private (widget_class,
1143                                                   EtPreferencesDialog,
1144                                                   id3_v1_none_radio);
1145     gtk_widget_class_bind_template_child_private (widget_class,
1146                                                   EtPreferencesDialog,
1147                                                   id3_v1_transliterate_radio);
1148     gtk_widget_class_bind_template_child_private (widget_class,
1149                                                   EtPreferencesDialog,
1150                                                   id3_v1_ignore_radio);
1151     gtk_widget_class_bind_template_child_private (widget_class,
1152                                                   EtPreferencesDialog,
1153                                                   id3_read_encoding_check);
1154     gtk_widget_class_bind_template_child_private (widget_class,
1155                                                   EtPreferencesDialog,
1156                                                   id3_read_encoding_combo);
1157     gtk_widget_class_bind_template_child_private (widget_class,
1158                                                   EtPreferencesDialog,
1159                                                   preferences_notebook);
1160     gtk_widget_class_bind_template_child_private (widget_class,
1161                                                   EtPreferencesDialog,
1162                                                   scanner_grid);
1163     gtk_widget_class_bind_template_child_private (widget_class,
1164                                                   EtPreferencesDialog,
1165                                                   fts_underscore_p20_radio);
1166     gtk_widget_class_bind_template_child_private (widget_class,
1167                                                   EtPreferencesDialog,
1168                                                   fts_spaces_radio);
1169     gtk_widget_class_bind_template_child_private (widget_class,
1170                                                   EtPreferencesDialog,
1171                                                   fts_none_radio);
1172     gtk_widget_class_bind_template_child_private (widget_class,
1173                                                   EtPreferencesDialog,
1174                                                   rfs_underscore_p20_radio);
1175     gtk_widget_class_bind_template_child_private (widget_class,
1176                                                   EtPreferencesDialog,
1177                                                   rfs_spaces_radio);
1178     gtk_widget_class_bind_template_child_private (widget_class,
1179                                                   EtPreferencesDialog,
1180                                                   rfs_remove_radio);
1181     gtk_widget_class_bind_template_child_private (widget_class,
1182                                                   EtPreferencesDialog,
1183                                                   pfs_uppercase_prep_check);
1184     gtk_widget_class_bind_template_child_private (widget_class,
1185                                                   EtPreferencesDialog,
1186                                                   overwrite_fields_check);
1187     gtk_widget_class_bind_template_child_private (widget_class,
1188                                                   EtPreferencesDialog,
1189                                                   default_comment_check);
1190     gtk_widget_class_bind_template_child_private (widget_class,
1191                                                   EtPreferencesDialog,
1192                                                   default_comment_entry);
1193     gtk_widget_class_bind_template_child_private (widget_class,
1194                                                   EtPreferencesDialog,
1195                                                   crc32_default_check);
1196     gtk_widget_class_bind_template_child_private (widget_class,
1197                                                   EtPreferencesDialog,
1198                                                   cddb_automatic_host1_combo);
1199     gtk_widget_class_bind_template_child_private (widget_class,
1200                                                   EtPreferencesDialog,
1201                                                   cddb_automatic_port1_button);
1202     gtk_widget_class_bind_template_child_private (widget_class,
1203                                                   EtPreferencesDialog,
1204                                                   cddb_automatic_path1_entry);
1205     gtk_widget_class_bind_template_child_private (widget_class,
1206                                                   EtPreferencesDialog,
1207                                                   cddb_automatic_host2_combo);
1208     gtk_widget_class_bind_template_child_private (widget_class,
1209                                                   EtPreferencesDialog,
1210                                                   cddb_automatic_port2_button);
1211     gtk_widget_class_bind_template_child_private (widget_class,
1212                                                   EtPreferencesDialog,
1213                                                   cddb_automatic_path2_entry);
1214     gtk_widget_class_bind_template_child_private (widget_class,
1215                                                   EtPreferencesDialog,
1216                                                   cddb_manual_host_combo);
1217     gtk_widget_class_bind_template_child_private (widget_class,
1218                                                   EtPreferencesDialog,
1219                                                   cddb_manual_port_button);
1220     gtk_widget_class_bind_template_child_private (widget_class,
1221                                                   EtPreferencesDialog,
1222                                                   cddb_manual_path_entry);
1223     gtk_widget_class_bind_template_child_private (widget_class,
1224                                                   EtPreferencesDialog,
1225                                                   cddb_proxy_check);
1226     gtk_widget_class_bind_template_child_private (widget_class,
1227                                                   EtPreferencesDialog,
1228                                                   cddb_host_entry);
1229     gtk_widget_class_bind_template_child_private (widget_class,
1230                                                   EtPreferencesDialog,
1231                                                   cddb_port_button);
1232     gtk_widget_class_bind_template_child_private (widget_class,
1233                                                   EtPreferencesDialog,
1234                                                   cddb_user_entry);
1235     gtk_widget_class_bind_template_child_private (widget_class,
1236                                                   EtPreferencesDialog,
1237                                                   cddb_password_entry);
1238     gtk_widget_class_bind_template_child_private (widget_class,
1239                                                   EtPreferencesDialog,
1240                                                   cddb_follow_check);
1241     gtk_widget_class_bind_template_child_private (widget_class,
1242                                                   EtPreferencesDialog,
1243                                                   cddb_dlm_check);
1244     gtk_widget_class_bind_template_child_private (widget_class,
1245                                                   EtPreferencesDialog,
1246                                                   confirm_write_check);
1247     gtk_widget_class_bind_template_child_private (widget_class,
1248                                                   EtPreferencesDialog,
1249                                                   confirm_rename_check);
1250     gtk_widget_class_bind_template_child_private (widget_class,
1251                                                   EtPreferencesDialog,
1252                                                   confirm_delete_check);
1253     gtk_widget_class_bind_template_child_private (widget_class,
1254                                                   EtPreferencesDialog,
1255                                                   confirm_write_playlist_check);
1256     gtk_widget_class_bind_template_child_private (widget_class,
1257                                                   EtPreferencesDialog,
1258                                                   confirm_unsaved_files_check);
1259     gtk_widget_class_bind_template_child_private (widget_class,
1260                                                   EtPreferencesDialog,
1261                                                   scanner_dialog_startup_check);
1262     gtk_widget_class_bind_template_callback (widget_class,
1263                                              et_preferences_on_response);
1264     gtk_widget_class_bind_template_callback (widget_class,
1265                                              et_prefs_current_folder_changed);
1266 }
1267 
1268 /*
1269  * et_preferences_dialog_new:
1270  *
1271  * Create a new EtPreferencesDialog instance.
1272  *
1273  * Returns: a new #EtPreferencesDialog
1274  */
1275 EtPreferencesDialog *
et_preferences_dialog_new(GtkWindow * parent)1276 et_preferences_dialog_new (GtkWindow *parent)
1277 {
1278     g_return_val_if_fail (GTK_WINDOW (parent), NULL);
1279 
1280     return g_object_new (ET_TYPE_PREFERENCES_DIALOG, "transient-for", parent,
1281                          NULL);
1282 }
1283