1 
2 /*
3  * The Real SoundTracker - GUI configuration dialog
4  *
5  * Copyright (C) 1999-2019 Michael Krause
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #include <config.h>
23 
24 #include <glib/gi18n.h>
25 #include <gtk/gtk.h>
26 #include <string.h>
27 
28 #include "colors.h"
29 #include "extspinbutton.h"
30 #include "gui-settings.h"
31 #include "gui-subs.h"
32 #include "gui.h"
33 #include "instrument-editor.h"
34 #include "preferences.h"
35 #include "sample-editor.h"
36 #include "scope-group.h"
37 #include "track-editor.h"
38 #include "tracker-settings.h"
39 
40 #define SECTION "settings"
41 #define SECTION_ALWAYS "settings-always"
42 
43 gui_prefs gui_settings;
44 
45 extern ScopeGroup* scopegroup;
46 
47 static GtkWidget *vol_sym_check, *tone_porta_m_check, *vol_dec_check;
48 
49 static void
prefs_scopesfreq_changed(GtkSpinButton * spin)50 prefs_scopesfreq_changed(GtkSpinButton *spin)
51 {
52     gui_settings.scopes_update_freq = gtk_spin_button_get_value_as_int(spin);
53     scope_group_set_update_freq(scopegroup, gui_settings.scopes_update_freq);
54 }
55 
56 static void
prefs_trackerfreq_changed(GtkSpinButton * spin)57 prefs_trackerfreq_changed(GtkSpinButton *spin)
58 {
59     gui_settings.tracker_update_freq = gtk_spin_button_get_value_as_int(spin);
60     tracker_set_update_freq(gui_settings.tracker_update_freq);
61 }
62 
63 static void
gui_settings_double_changed(GtkSpinButton * spin,gdouble * val)64 gui_settings_double_changed(GtkSpinButton *spin, gdouble* val)
65 {
66     *val = gtk_spin_button_get_value(spin);
67 }
68 
69 static void
gui_settings_int_changed(GtkSpinButton * spin,gint * val)70 gui_settings_int_changed(GtkSpinButton *spin, gint* val)
71 {
72     *val = gtk_spin_button_get_value_as_int(spin);
73 }
74 
75 static void
gui_settings_asyncedit_toggled(GtkWidget * widget)76 gui_settings_asyncedit_toggled(GtkWidget* widget)
77 {
78     gui_play_stop();
79     gui_settings.asynchronous_editing = GTK_TOGGLE_BUTTON(widget)->active;
80 }
81 
82 static void
gui_settings_trypoly_toggled(GtkWidget * widget,GtkWidget * repeat)83 gui_settings_trypoly_toggled(GtkWidget* widget, GtkWidget* repeat)
84 {
85     gui_play_stop();
86     gui_settings.try_polyphony = GTK_TOGGLE_BUTTON(widget)->active;
87     gtk_widget_set_sensitive(repeat, gui_settings.try_polyphony);
88 }
89 
90 static void
gui_settings_misc_toggled(GtkWidget * widget,gboolean * var)91 gui_settings_misc_toggled(GtkWidget* widget, gboolean* var)
92 {
93     *var = GTK_TOGGLE_BUTTON(widget)->active;
94 }
95 
96 static void
gui_settings_redraw_toggled(GtkWidget * widget,gboolean * var)97 gui_settings_redraw_toggled(GtkWidget* widget, gboolean* var)
98 {
99     *var = GTK_TOGGLE_BUTTON(widget)->active;
100     tracker_redraw(tracker);
101 }
102 
103 static void
gui_settings_ft2vol_toggled(GtkWidget * widget,gboolean * var)104 gui_settings_ft2vol_toggled(GtkWidget* widget, gboolean* var)
105 {
106     gboolean is_active = GTK_TOGGLE_BUTTON(widget)->active;
107 
108     *var = is_active;
109     gtk_widget_set_sensitive(vol_sym_check, is_active);
110     gtk_widget_set_sensitive(tone_porta_m_check, is_active);
111     gtk_widget_set_sensitive(vol_dec_check, is_active);
112     tracker_redraw(tracker);
113 }
114 
115 static void
gui_settings_volsym_toggled(GtkWidget * widget,gboolean * var)116 gui_settings_volsym_toggled(GtkWidget* widget, gboolean* var)
117 {
118     gboolean is_active = GTK_TOGGLE_BUTTON(widget)->active;
119 
120     *var = is_active;
121     gtk_widget_set_sensitive(tone_porta_m_check, is_active);
122     tracker_redraw(tracker);
123 }
124 
125 static void
gui_settings_scopebufsize_changed(GtkSpinButton * spin)126 gui_settings_scopebufsize_changed(GtkSpinButton* spin)
127 {
128     double n = gtk_spin_button_get_value(spin);
129 
130     gui_settings.scopes_buffer_size = n * 1000000;
131 }
132 
133 static void
gui_settings_clavierfont_changed(GtkFontButton * fb)134 gui_settings_clavierfont_changed(GtkFontButton* fb)
135 {
136     gui_settings.clavier_font = gtk_font_button_get_font_name(fb);
137     instrument_editor_update_clavier(gui_settings.clavier_font);
138 }
139 
gui_settings_highlight_rows_changed(GtkSpinButton * spin)140 void gui_settings_highlight_rows_changed(GtkSpinButton* spin)
141 {
142     int n = gtk_spin_button_get_value_as_int(spin);
143 
144     gui_settings.highlight_rows_n = n;
145     if (gui_settings.highlight_rows)
146         tracker_redraw(tracker);
147 }
148 
gui_settings_highlight_rows_minor_changed(GtkSpinButton * spin)149 void gui_settings_highlight_rows_minor_changed(GtkSpinButton* spin)
150 {
151     int n = gtk_spin_button_get_value_as_int(spin);
152 
153     gui_settings.highlight_rows_minor_n = n;
154     if (gui_settings.highlight_rows)
155         tracker_redraw(tracker);
156 }
157 
158 static void
gui_settings_tracker_line_note_modified(GtkEntry * entry)159 gui_settings_tracker_line_note_modified(GtkEntry* entry)
160 {
161     gchar* text = g_strdup(gtk_entry_get_text(entry));
162     int i;
163 
164     for (i = 0; i < 3; i++) {
165         if (!text[i]) {
166             text[i] = ' ';
167             text[i + 1] = 0;
168         }
169     }
170     text[3] = 0;
171     if (strncmp(gui_settings.tracker_line_format, text, 3)) {
172         strncpy(gui_settings.tracker_line_format, text, 3);
173         tracker_redraw(tracker);
174     }
175     g_free(text);
176 }
177 
178 static void
gui_settings_tracker_line_ins_modified(GtkEntry * entry)179 gui_settings_tracker_line_ins_modified(GtkEntry* entry)
180 {
181     gchar* text = g_strdup(gtk_entry_get_text(entry));
182     int i;
183 
184     for (i = 0; i < 2; i++) {
185         if (!text[i]) {
186             text[i] = ' ';
187             text[i + 1] = 0;
188         }
189     }
190     text[2] = 0;
191     if (strncmp(gui_settings.tracker_line_format + 3, text, 2)) {
192         strncpy(gui_settings.tracker_line_format + 3, text, 2);
193         tracker_redraw(tracker);
194     }
195     g_free(text);
196 }
197 
198 static void
gui_settings_tracker_line_vol_modified(GtkEntry * entry)199 gui_settings_tracker_line_vol_modified(GtkEntry* entry)
200 {
201     gchar* text = g_strdup(gtk_entry_get_text(entry));
202     int i;
203 
204     for (i = 0; i < 2; i++) {
205         if (!text[i]) {
206             text[i] = ' ';
207             text[i + 1] = 0;
208         }
209     }
210     text[2] = 0;
211     if (strncmp(gui_settings.tracker_line_format + 5, text, 2)) {
212         strncpy(gui_settings.tracker_line_format + 5, text, 2);
213         tracker_redraw(tracker);
214     }
215     g_free(text);
216 }
217 
218 static void
gui_settings_tracker_line_effect_modified(GtkEntry * entry,GdkEventKey * event)219 gui_settings_tracker_line_effect_modified(GtkEntry* entry, GdkEventKey* event)
220 {
221     gchar* text = g_strdup(gtk_entry_get_text(entry));
222     int i;
223 
224     for (i = 0; i < 3; i++) {
225         if (!text[i]) {
226             text[i] = ' ';
227             text[i + 1] = 0;
228         }
229     }
230     text[3] = 0;
231     if (strncmp(gui_settings.tracker_line_format + 7, text, 3)) {
232         strncpy(gui_settings.tracker_line_format + 7, text, 3);
233         tracker_redraw(tracker);
234     }
235     g_free(text);
236 }
237 
238 static void
gui_settings_set_scopes_mode(GtkToggleButton * button,gpointer data)239 gui_settings_set_scopes_mode(GtkToggleButton* button, gpointer data)
240 {
241     if (gtk_toggle_button_get_active(button)) {
242         SampleDisplayMode i = GPOINTER_TO_INT(data);
243 
244         gui_settings.scopes_mode = i;
245         scope_group_set_mode(scopegroup, i);
246     }
247 }
248 
249 static void
gui_settings_set_selection_mode(GtkComboBox * combo)250 gui_settings_set_selection_mode(GtkComboBox* combo)
251 {
252     gui_settings.selection_mode = gtk_combo_box_get_active(combo);
253 }
254 
255 static void
gui_settings_set_editor_mode(GtkToggleButton * button,gpointer data)256 gui_settings_set_editor_mode(GtkToggleButton* button, gpointer data)
257 {
258     if (gtk_toggle_button_get_active(button)) {
259         SampleDisplayMode i = GPOINTER_TO_INT(data);
260 
261         gui_settings.editor_mode = i;
262         sample_editor_set_mode(SAMPLE_EDITOR_DISPLAY_EDITOR, i);
263     }
264 }
265 
266 static void
gui_settings_set_sampling_mode(GtkToggleButton * button,gpointer data)267 gui_settings_set_sampling_mode(GtkToggleButton* button, gpointer data)
268 {
269     if (gtk_toggle_button_get_active(button)) {
270         SampleDisplayMode i = GPOINTER_TO_INT(data);
271 
272         gui_settings.editor_mode = i;
273         sample_editor_set_mode(SAMPLE_EDITOR_DISPLAY_SAMPLING, i);
274     }
275 }
276 
277 static void
modes_radio_create(GtkWidget * table,GtkWidget ** array,const guint column,void (* sigfunc)(GtkToggleButton *,gpointer),SampleDisplayMode mode)278 modes_radio_create(GtkWidget* table,
279     GtkWidget** array,
280     const guint column,
281     void (*sigfunc)(GtkToggleButton*, gpointer),
282     SampleDisplayMode mode)
283 {
284     guint i;
285     GtkWidget* thing;
286 
287     for (i = 0; i < SAMPLE_DISPLAY_MODE_LAST; i++) {
288         GtkWidget* alignment;
289 
290         alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
291         thing = array[i] =
292             gtk_radio_button_new(i == 0 ? NULL : gtk_radio_button_get_group(GTK_RADIO_BUTTON(thing)));
293         gtk_container_add(GTK_CONTAINER(alignment), thing);
294         gtk_table_attach_defaults(GTK_TABLE(table), alignment, column, column + 1, i + 1, i + 2);
295         if (i == mode)
296             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), TRUE);
297         g_signal_connect(thing, "clicked", G_CALLBACK(sigfunc), GINT_TO_POINTER(i));
298     }
299 }
300 
301 static void
fonts_dialog(GtkWidget * window)302 fonts_dialog(GtkWidget* window)
303 {
304     static GtkWidget* dialog = NULL;
305     GtkWidget *mainbox, *thing;
306 
307     if (!dialog) {
308         gchar* buf;
309 
310         buf = g_strdup_printf(_("%s fonts configuration"), PACKAGE_NAME);
311         dialog = gtk_dialog_new_with_buttons(buf, GTK_WINDOW(window),
312             GTK_DIALOG_DESTROY_WITH_PARENT,
313             GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
314         g_free(buf);
315         gui_dialog_connect(dialog, NULL);
316         mainbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
317 
318         /* The tracker widget settings */
319         g_object_ref(G_OBJECT(trackersettings));
320         gtk_box_pack_start(GTK_BOX(mainbox), trackersettings, TRUE, TRUE, 0);
321 
322         thing = gtk_hseparator_new();
323         gtk_box_pack_start(GTK_BOX(mainbox), thing, FALSE, FALSE, 4);
324 
325         gtk_widget_show_all(dialog);
326     } else
327         gtk_window_present(GTK_WINDOW(dialog));
328 }
329 
gui_settings_dialog(void)330 void gui_settings_dialog(void)
331 {
332     static GtkWidget* configwindow = NULL;
333     static GtkWidget *scopes_radio[SAMPLE_DISPLAY_MODE_LAST],
334                      *editor_radio[SAMPLE_DISPLAY_MODE_LAST],
335                      *sampling_radio[SAMPLE_DISPLAY_MODE_LAST];
336 
337     static gchar *sel_mode[] = {N_("Classic ST"), N_("FT2"), N_("Mixed")};
338 
339     GtkWidget *mainbox, *sw, *thing, *thing1, *box1, *vbox1, *spin, *table;
340     GtkListStore* list_store;
341     GtkTreeIter iter;
342     GtkAllocation all;
343     PangoContext *context;
344     PangoLayout *layout;
345     gchar stmp[5], *buf;
346     gint wdth, hght;
347     guint i;
348 
349     if (configwindow != NULL) {
350         gtk_window_present(GTK_WINDOW(configwindow));
351         return;
352     }
353 
354     configwindow = gtk_dialog_new_with_buttons(_("GUI Configuration"), GTK_WINDOW(mainwindow), 0,
355         GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
356     gui_dialog_connect(configwindow, NULL);
357     gui_dialog_adjust(configwindow, GTK_RESPONSE_CLOSE);
358     mainbox = gtk_dialog_get_content_area(GTK_DIALOG(configwindow));
359 
360     sw = gtk_scrolled_window_new(NULL, NULL);
361     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
362     gtk_box_pack_start(GTK_BOX(mainbox), sw, TRUE, TRUE, 0);
363 
364     vbox1 = gtk_vbox_new(FALSE, 2);
365     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), vbox1);
366     gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(sw))), GTK_SHADOW_NONE);
367 
368     thing = gui_labelled_spin_button_new(_("Tracker Frequency"), 1, 80,
369         &spin, prefs_trackerfreq_changed, NULL, FALSE, NULL);
370     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
371     gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), gui_settings.tracker_update_freq);
372 
373     thing = gui_labelled_spin_button_new(_("Scopes Frequency"), 1, 80,
374         &spin, prefs_scopesfreq_changed, NULL, FALSE, NULL);
375     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
376     gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), gui_settings.scopes_update_freq);
377 
378     thing = gtk_label_new(_("Sample displays' mode"));
379     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
380     table = gtk_table_new(3, 4, TRUE);
381     thing = gtk_label_new(_("Scopes"));
382     gtk_table_attach_defaults(GTK_TABLE(table), thing, 1, 2, 0, 1);
383     thing = gtk_label_new(_("Smpl. Ed."));
384     gtk_table_attach_defaults(GTK_TABLE(table), thing, 2, 3, 0, 1);
385     thing = gtk_label_new(_("Sampling"));
386     gtk_table_attach_defaults(GTK_TABLE(table), thing, 3, 4, 0, 1);
387     thing = gtk_label_new(_("Strobo"));
388     gtk_widget_set_tooltip_text(thing,
389         _("Fast, but not so much accurate method for waveforms' drawing"));
390     gtk_table_attach_defaults(GTK_TABLE(table), thing, 0, 1, 1, 2);
391     thing = gtk_label_new(_("Minmax"));
392     gtk_widget_set_tooltip_text(thing,
393         _("More realistic waveform drawing method with higher CPU load"));
394     gtk_table_attach_defaults(GTK_TABLE(table), thing, 0, 1, 2, 3);
395 
396     modes_radio_create(table, scopes_radio, 1, gui_settings_set_scopes_mode, gui_settings.scopes_mode);
397     modes_radio_create(table, editor_radio, 2, gui_settings_set_editor_mode, gui_settings.editor_mode);
398     modes_radio_create(table, sampling_radio, 3, gui_settings_set_sampling_mode, gui_settings.sampling_mode);
399 
400     gtk_box_pack_start(GTK_BOX(vbox1), table, FALSE, TRUE, 0);
401 
402     box1 = gtk_hbox_new(FALSE, 4);
403     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, TRUE, 0);
404 
405     thing = gtk_label_new(_("Scopes buffer size [MB]"));
406     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, FALSE, 0);
407 
408     thing = extspinbutton_new(GTK_ADJUSTMENT(gtk_adjustment_new((double)gui_settings.scopes_buffer_size / 1000000, 0.5, 5.0, 0.1, 1.0, 0.0)), 0, 0, FALSE);
409     gtk_box_pack_end(GTK_BOX(box1), thing, FALSE, FALSE, 0);
410     gtk_spin_button_set_digits(GTK_SPIN_BUTTON(thing), 1);
411     g_signal_connect(thing, "value-changed",
412         G_CALLBACK(gui_settings_scopebufsize_changed), NULL);
413 
414     thing = gtk_hseparator_new();
415     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
416 
417     thing = gtk_check_button_new_with_label(_("Hexadecimal row numbers"));
418     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_hexmode);
419     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
420     g_signal_connect(thing, "toggled",
421         G_CALLBACK(gui_settings_redraw_toggled), &gui_settings.tracker_hexmode);
422 
423     thing = gtk_check_button_new_with_label(_("Use upper case letters for hex numbers"));
424     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_upcase);
425     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
426     g_signal_connect(thing, "toggled",
427         G_CALLBACK(gui_settings_redraw_toggled), &gui_settings.tracker_upcase);
428 
429     thing = gtk_check_button_new_with_label(_("Use note name B instead of H"));
430     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.bh);
431     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
432     g_signal_connect(thing, "toggled",
433         G_CALLBACK(gui_settings_redraw_toggled), &gui_settings.bh);
434 
435     thing = gtk_check_button_new_with_label(_("FT2-like volume column"));
436     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_ft2_volume);
437     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
438     g_signal_connect(thing, "toggled",
439         G_CALLBACK(gui_settings_ft2vol_toggled), &gui_settings.tracker_ft2_volume);
440 
441     vol_sym_check = thing = gtk_check_button_new_with_label(_("Use symbols in the volume column"));
442     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_ft2_wide);
443     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
444     g_signal_connect(thing, "toggled",
445         G_CALLBACK(gui_settings_volsym_toggled), &gui_settings.tracker_ft2_wide);
446 
447     tone_porta_m_check = thing = gtk_check_button_new_with_label(_("Leave Tone Porta as symbol \"m\""));
448     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_ft2_tpm);
449     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
450     g_signal_connect(thing, "toggled",
451         G_CALLBACK(gui_settings_redraw_toggled), &gui_settings.tracker_ft2_tpm);
452 
453     vol_dec_check = thing = gtk_check_button_new_with_label(_("Decimal volume representation"));
454     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tracker_vol_dec);
455     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
456     g_signal_connect(thing, "toggled",
457         G_CALLBACK(gui_settings_redraw_toggled), &gui_settings.tracker_vol_dec);
458 
459     thing = gtk_check_button_new_with_label(_("Asynchronous (IT-style) pattern editing"));
460     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.asynchronous_editing);
461     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
462     g_signal_connect(thing, "toggled",
463         G_CALLBACK(gui_settings_asyncedit_toggled), NULL);
464 
465     thing = gtk_check_button_new_with_label(_("Polyphonic try (non-editing) mode"));
466     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.try_polyphony);
467     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
468 
469     thing1 = gtk_check_button_new_with_label(_("Repeat same note on different channels"));
470     gtk_widget_set_sensitive(thing1, gui_settings.try_polyphony);
471     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing1), gui_settings.repeat_same_note);
472     gtk_box_pack_start(GTK_BOX(vbox1), thing1, FALSE, TRUE, 0);
473     g_signal_connect(thing1, "toggled",
474         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.repeat_same_note);
475     g_signal_connect(thing, "toggled",
476         G_CALLBACK(gui_settings_trypoly_toggled), thing1);
477 
478     thing = gtk_check_button_new_with_label(_("Record keyreleases"));
479     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.insert_noteoff);
480     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
481     g_signal_connect(thing, "toggled",
482         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.insert_noteoff);
483 
484     thing = gtk_check_button_new_with_label(_("Record precise timings"));
485     gtk_widget_set_tooltip_text(thing,
486         _("Use FX to record note press/release timings with tick accuracy"));
487     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.precise_timing);
488     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
489     g_signal_connect(thing, "toggled",
490         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.precise_timing);
491 
492     box1 = gtk_hbox_new(FALSE, 4);
493     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, TRUE, 0);
494 
495     thing = gtk_label_new(_("Human-made delay compensation [s]"));
496     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, FALSE, 0);
497 
498     thing = extspinbutton_new(GTK_ADJUSTMENT(gtk_adjustment_new(gui_settings.delay_comp,
499         0.0, 1.0, 0.01, 0.1, 0.0)), 0, 0, FALSE);
500     gtk_box_pack_end(GTK_BOX(box1), thing, FALSE, FALSE, 0);
501     gtk_spin_button_set_digits(GTK_SPIN_BUTTON(thing), 2);
502     g_signal_connect(thing, "value-changed",
503         G_CALLBACK(gui_settings_double_changed), &gui_settings.delay_comp);
504 
505     thing = gtk_check_button_new_with_label(_("Fxx command updates Tempo/BPM sliders"));
506     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.tempo_bpm_update);
507     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
508     g_signal_connect(thing, "toggled",
509         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.tempo_bpm_update);
510 
511     thing = gtk_check_button_new_with_label(_("Emulate FastTracker Rxx bug"));
512     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.rxx_bug_emu);
513     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
514     g_signal_connect(thing, "toggled",
515         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.rxx_bug_emu);
516 
517     thing = gtk_check_button_new_with_label(_("Use filter effect (Qxx/Zxx)"));
518     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.use_filter);
519     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
520     g_signal_connect(thing, "toggled",
521         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.use_filter);
522 
523     thing = gtk_check_button_new_with_label(_("Automatically add file extensions"));
524     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.add_extension);
525     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
526     g_signal_connect(thing, "toggled",
527         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.add_extension);
528 
529     thing = gtk_check_button_new_with_label(_("Switch to tracker after loading/saving"));
530     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.auto_switch);
531     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
532     g_signal_connect(thing, "toggled",
533         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.auto_switch);
534 
535     thing = gtk_check_button_new_with_label(_("Save window geometry on exit"));
536     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.save_geometry);
537     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
538     g_signal_connect(thing, "toggled",
539         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.save_geometry);
540 
541     thing = gtk_check_button_new_with_label(_("Save and restore permanent channels"));
542     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(thing), gui_settings.store_perm);
543     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
544     g_signal_connect(G_OBJECT(thing), "toggled",
545         G_CALLBACK(gui_settings_misc_toggled), &gui_settings.store_perm);
546 
547     box1 = gtk_hbox_new(FALSE, 4);
548     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, TRUE, 0);
549 
550     thing = gtk_label_new(_("* Undo pool size [MB]"));
551     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, FALSE, 0);
552 
553     thing = extspinbutton_new(GTK_ADJUSTMENT(gtk_adjustment_new(gui_settings.undo_size,
554         1.0, 100.0, 1.0, 10.0, 0.0)), 0, 0, FALSE);
555     gtk_box_pack_end(GTK_BOX(box1), thing, FALSE, FALSE, 0);
556     g_signal_connect(thing, "value-changed",
557         G_CALLBACK(gui_settings_int_changed), &gui_settings.undo_size);
558 
559     box1 = gtk_hbox_new(FALSE, 4);
560     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, FALSE, 0);
561     gtk_widget_set_tooltip_text(box1,
562         _("Classis ST: only Ctrl + B to start/stop marking a block;\n"
563           "FT2: marking by SHIFT + arrows;\n"
564           "Mixed: marking is started by SHIFT + arrows,\nstopped by Ctrl + B.\n"
565           "In the FT2 and Mixed modes Ctrl + B\ncan also be used to start marking."));
566 
567     thing = gtk_label_new(_("Selection mode"));
568     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, FALSE, 0);
569 
570     list_store = gtk_list_store_new(1, G_TYPE_STRING);
571     for (i = 0; i < SELECTION_LAST; i++) {
572         gtk_list_store_append(list_store, &iter);
573         gtk_list_store_set(list_store, &iter, 0, _(sel_mode[i]), -1);
574     }
575     thing = gui_combo_new(list_store);
576     gtk_combo_box_set_active(GTK_COMBO_BOX(thing), gui_settings.selection_mode);
577     gtk_box_pack_end(GTK_BOX(box1), thing, FALSE, FALSE, 0);
578     g_signal_connect(thing, "changed", G_CALLBACK(gui_settings_set_selection_mode), NULL);
579 
580     thing = gtk_hseparator_new();
581     gtk_box_pack_start(GTK_BOX(vbox1), thing, FALSE, TRUE, 0);
582 
583     /* Track line format */
584     box1 = gtk_hbox_new(FALSE, 4);
585     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, TRUE, 0);
586     thing = gtk_label_new(_("Track line format:"));
587     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0);
588 
589     thing = gtk_entry_new();
590 
591     context = gtk_widget_create_pango_context(thing);
592     layout = pango_layout_new(context);
593     pango_layout_set_font_description(layout, gtk_widget_get_style(thing)->font_desc);
594     /* With an extra symbol the width value becomes more appropriate */
595     pango_layout_set_text(layout, "----", -1);
596     pango_layout_get_pixel_size(layout, &wdth, &hght);
597     gtk_widget_set_size_request(thing, wdth, -1);
598 
599     gtk_entry_set_max_length((GtkEntry*)thing, 3);
600     strncpy(stmp, gui_settings.tracker_line_format, 3);
601     stmp[3] = 0;
602     gtk_entry_set_text((GtkEntry*)thing, stmp);
603     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0);
604     g_signal_connect(thing, "changed",
605         G_CALLBACK(gui_settings_tracker_line_note_modified), 0);
606 
607     thing = gtk_entry_new();
608     pango_layout_set_text(layout, "000", -1);
609     pango_layout_get_pixel_size(layout, &wdth, &hght);
610     gtk_widget_set_size_request(thing, wdth, -1);
611     gtk_entry_set_max_length((GtkEntry*)thing, 2);
612     strncpy(stmp, gui_settings.tracker_line_format + 3, 2);
613     stmp[2] = 0;
614     gtk_entry_set_text((GtkEntry*)thing, stmp);
615     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0);
616     g_signal_connect(thing, "changed",
617         G_CALLBACK(gui_settings_tracker_line_ins_modified), 0);
618 
619     thing = gtk_entry_new();
620     pango_layout_set_text(layout, "000", -1);
621     pango_layout_get_pixel_size(layout, &wdth, &hght);
622     gtk_widget_set_size_request(thing, wdth, -1);
623     gtk_entry_set_max_length((GtkEntry*)thing, 2);
624     strncpy(stmp, gui_settings.tracker_line_format + 5, 2);
625     stmp[2] = 0;
626     gtk_entry_set_text((GtkEntry*)thing, stmp);
627     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0);
628     g_signal_connect(thing, "changed",
629         G_CALLBACK(gui_settings_tracker_line_vol_modified), 0);
630 
631     thing = gtk_entry_new();
632     pango_layout_set_text(layout, "0000", -1);
633     pango_layout_get_pixel_size(layout, &wdth, &hght);
634     gtk_widget_set_size_request(thing, wdth, -1);
635     g_object_unref(layout);
636     g_object_unref(context);
637 
638     gtk_entry_set_max_length((GtkEntry*)thing, 3);
639     strncpy(stmp, gui_settings.tracker_line_format + 7, 3);
640     stmp[3] = 0;
641     gtk_entry_set_text((GtkEntry*)thing, stmp);
642     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, TRUE, 0);
643     g_signal_connect(thing, "changed",
644         G_CALLBACK(gui_settings_tracker_line_effect_modified), 0);
645 
646     thing1 = gtk_hbox_new(TRUE, 2);
647     gtk_box_pack_start(GTK_BOX(vbox1), thing1, FALSE, TRUE, 0);
648     /* Tracker colors configuration dialog */
649     thing = gtk_button_new_with_label(_("Color scheme"));
650     gtk_widget_set_tooltip_text(thing, _("Tracker colors configuration"));
651     gtk_box_pack_start(GTK_BOX(thing1), thing, TRUE, TRUE, 0);
652     g_signal_connect_swapped(thing, "clicked",
653         G_CALLBACK(colors_dialog), configwindow);
654 
655     /* Tracker fonts configuration dialog */
656     thing = gtk_button_new_with_label(_("Tracker fonts"));
657     gtk_widget_set_tooltip_text(thing, _("Tracker fonts configuration"));
658     gtk_box_pack_start(GTK_BOX(thing1), thing, TRUE, TRUE, 0);
659     g_signal_connect_swapped(thing, "clicked",
660         G_CALLBACK(fonts_dialog), configwindow);
661 
662     box1 = gtk_hbox_new(FALSE, 4);
663     gtk_box_pack_start(GTK_BOX(vbox1), box1, FALSE, TRUE, 0);
664 
665     thing = gtk_label_new(_("Clavier font"));
666     gtk_box_pack_start(GTK_BOX(box1), thing, FALSE, FALSE, 0);
667 
668     thing = gtk_font_button_new_with_font(gui_settings.clavier_font);
669     gtk_box_pack_end(GTK_BOX(box1), thing, FALSE, FALSE, 0);
670     g_signal_connect(thing, "font-set",
671         G_CALLBACK(gui_settings_clavierfont_changed), NULL);
672 
673     buf = g_strdup_printf(_("* Restart %s to actualize settings marked with asterisk"), PACKAGE_NAME);
674     thing = gtk_label_new(buf);
675     g_free(buf);
676     gtk_misc_set_alignment(GTK_MISC(thing), 0.0, 0.5);
677     gtk_box_pack_end(GTK_BOX(mainbox), thing, FALSE, TRUE, 0);
678 
679     thing = gtk_hseparator_new();
680     gtk_box_pack_start(GTK_BOX(mainbox), thing, FALSE, FALSE, 4);
681 
682     gtk_widget_show_all(configwindow);
683     /* Some compromise to find optimal settings window size */
684     gtk_widget_get_allocation(vbox1, &all);
685     hght = gdk_screen_get_height(gdk_screen_get_default());
686     gtk_widget_set_size_request(sw, -1,
687         MIN(all.height, hght - 100));
688     gtk_window_set_position(GTK_WINDOW(configwindow), GTK_WIN_POS_CENTER_ALWAYS);
689 }
690 
gui_settings_load_config(void)691 void gui_settings_load_config(void)
692 {
693     gui_settings.st_window_x = prefs_get_int(SECTION, "st-window-x", -666);
694     gui_settings.st_window_y = prefs_get_int(SECTION, "st-window-y", 0);
695     gui_settings.st_window_w = prefs_get_int(SECTION, "st-window-w", 0);
696     gui_settings.st_window_h = prefs_get_int(SECTION, "st-window-h", 0);
697 
698     gui_settings.tracker_hexmode = prefs_get_bool(SECTION, "gui-use-hexadecimal-numbers", TRUE);
699     gui_settings.tracker_upcase = prefs_get_bool(SECTION, "gui-use-upper-case", FALSE);
700     gui_settings.tracker_ft2_volume = prefs_get_bool(SECTION, "gui-ft2-volume", FALSE);
701     gui_settings.tracker_ft2_wide = prefs_get_bool(SECTION, "gui-ft2-wide", TRUE);
702     gui_settings.tracker_ft2_tpm = prefs_get_bool(SECTION, "gui-ft2-tone-porta-m", FALSE);
703     gui_settings.tracker_vol_dec = prefs_get_bool(SECTION, "gui-volume-decimal", FALSE);
704     gui_settings.advance_cursor_in_fx_columns = prefs_get_bool(SECTION, "gui-advance-cursor-in-fx-columns", FALSE);
705     gui_settings.asynchronous_editing = prefs_get_bool(SECTION, "gui-asynchronous-editing", FALSE);
706     gui_settings.try_polyphony = prefs_get_bool(SECTION, "gui-try-polyphony", TRUE);
707     gui_settings.repeat_same_note = prefs_get_bool(SECTION, "gui-repeat-same-note", FALSE);
708     gui_settings.insert_noteoff = prefs_get_bool(SECTION, "gui-insert-noteoff", TRUE);
709     gui_settings.precise_timing = prefs_get_bool(SECTION, "gui-precise-timing", FALSE);
710     gui_settings.delay_comp = prefs_get_double(SECTION, "gui-delay-compensation", 0.0);
711     gui_settings.looped = prefs_get_bool(SECTION, "gui-playback-looped", TRUE);
712     gui_settings.tracker_line_format = prefs_get_string(SECTION, "gui-tracker-line-format", "---0000000");
713     gui_settings.tracker_font = prefs_get_string(SECTION, "tracker-font", "");
714     gui_settings.tempo_bpm_update = prefs_get_bool(SECTION, "gui-tempo-bpm-update", TRUE);
715     gui_settings.rxx_bug_emu = prefs_get_bool(SECTION, "tracker-rxx-bug-emulate", FALSE);
716     gui_settings.use_filter = prefs_get_bool(SECTION, "player-use-filter", TRUE);
717     gui_settings.auto_switch = prefs_get_bool(SECTION, "gui-auto-switch", FALSE);
718     gui_settings.add_extension = prefs_get_bool(SECTION, "gui-add-extension", TRUE);
719     gui_settings.gui_display_scopes = prefs_get_bool(SECTION, "gui-display-scopes", TRUE);
720     gui_settings.gui_use_backing_store = prefs_get_bool(SECTION, "gui-use-backing-store", TRUE);
721     gui_settings.undo_size = prefs_get_int(SECTION, "gui-undo-size", 20);
722     gui_settings.highlight_rows = prefs_get_bool(SECTION, "tracker-highlight-rows", TRUE);
723     gui_settings.highlight_rows_n = prefs_get_int(SECTION, "tracker-highlight-rows-n", 16);
724     gui_settings.highlight_rows_minor_n = prefs_get_int(SECTION, "tracker-highlight-rows-minor-n", 8);
725     gui_settings.clavier_colors_gtk = prefs_get_bool(SECTION, "clavier-colors-gtk", TRUE);
726     gui_settings.clavier_font = prefs_get_string(SECTION, "clavier-font", "Monospace 8");
727 
728     gui_settings.save_geometry = prefs_get_bool(SECTION, "save-geometry", TRUE);
729     gui_settings.save_settings_on_exit = prefs_get_bool(SECTION, "save-settings-on-exit", TRUE);
730     gui_settings.tracker_update_freq = prefs_get_int(SECTION, "tracker-update-frequency", 50);
731     gui_settings.scopes_update_freq = prefs_get_int(SECTION, "scopes-update-frequency", 40);
732     gui_settings.scopes_buffer_size = prefs_get_int(SECTION, "scopes-buffer-size", 500000);
733     gui_settings.sharp = prefs_get_bool(SECTION, "sharp", TRUE);
734     gui_settings.bh = prefs_get_bool(SECTION, "bh", FALSE);
735     gui_settings.store_perm = prefs_get_bool(SECTION, "store-permanent", TRUE);
736     gui_settings.scopes_mode = prefs_get_int(SECTION, "sample-display-scopes-mode", SAMPLE_DISPLAY_MODE_STROBO);
737     gui_settings.editor_mode = prefs_get_int(SECTION, "sample-display-editor-mode", SAMPLE_DISPLAY_MODE_STROBO);
738     gui_settings.sampling_mode = prefs_get_int(SECTION, "sample-display-sampling-mode", SAMPLE_DISPLAY_MODE_STROBO);
739     gui_settings.selection_mode = prefs_get_int(SECTION, "selection-mode", SELECTION_CLASSIC);
740 
741     if (gui_settings.store_perm)
742         gui_settings.permanent_channels = prefs_get_int(SECTION, "permanent-channels", 0);
743 
744     gui_settings.file_out_channels = prefs_get_int(SECTION, "file-channels", 2);
745     gui_settings.file_out_mixfreq = prefs_get_int(SECTION, "file-mixfreq", 44100);
746     gui_settings.file_out_resolution = prefs_get_int(SECTION, "file-resolution", 16);
747 
748     gui_settings.loadmod_path = prefs_get_string(SECTION_ALWAYS, "loadmod-path", "~");
749     gui_settings.savemod_path = prefs_get_string(SECTION_ALWAYS, "savemod-path", "~");
750     gui_settings.savemodaswav_path = prefs_get_string(SECTION_ALWAYS, "savemodaswav-path", "~");
751     gui_settings.savesongasxm_path = prefs_get_string(SECTION_ALWAYS, "savesongasxm-path", "~");
752     gui_settings.loadsmpl_path = prefs_get_string(SECTION_ALWAYS, "loadsmpl-path", "~");
753     gui_settings.savesmpl_path = prefs_get_string(SECTION_ALWAYS, "savesmpl-path", "~");
754     gui_settings.loadinstr_path = prefs_get_string(SECTION_ALWAYS, "loadinstr-path", "~");
755     gui_settings.saveinstr_path = prefs_get_string(SECTION_ALWAYS, "saveinstr-path", "~");
756     gui_settings.loadpat_path = prefs_get_string(SECTION_ALWAYS, "loadpat-path", "~");
757     gui_settings.savepat_path = prefs_get_string(SECTION_ALWAYS, "savepat-path", "~");
758 
759     gui_settings.rm_path = prefs_get_string(SECTION_ALWAYS, "rm-path", "rm");
760     gui_settings.unzip_path = prefs_get_string(SECTION_ALWAYS, "unzip-path", "unzip");
761     gui_settings.lha_path = prefs_get_string(SECTION_ALWAYS, "lha-path", "lha");
762     gui_settings.gz_path = prefs_get_string(SECTION_ALWAYS, "gz-path", "zcat");
763     gui_settings.bz2_path = prefs_get_string(SECTION_ALWAYS, "bz2-path", "bunzip2");
764 
765     gui_settings.gui_disable_splash = prefs_get_bool(SECTION_ALWAYS, "gui-disable-splash", FALSE);
766 }
767 
gui_settings_save_config(void)768 void gui_settings_save_config(void)
769 {
770     if (gui_settings.save_geometry) {
771         GtkAllocation alloc;
772 
773         gtk_widget_get_allocation(mainwindow, &alloc);
774         gui_settings.st_window_w = alloc.width;
775         gui_settings.st_window_h = alloc.height;
776         gdk_window_get_root_origin(mainwindow->window,
777             &gui_settings.st_window_x,
778             &gui_settings.st_window_y);
779     }
780 
781     prefs_put_int(SECTION, "st-window-x", gui_settings.st_window_x);
782     prefs_put_int(SECTION, "st-window-y", gui_settings.st_window_y);
783     prefs_put_int(SECTION, "st-window-w", gui_settings.st_window_w);
784     prefs_put_int(SECTION, "st-window-h", gui_settings.st_window_h);
785 
786     prefs_put_bool(SECTION, "gui-use-hexadecimal-numbers", gui_settings.tracker_hexmode);
787     prefs_put_bool(SECTION, "gui-use-upper-case", gui_settings.tracker_upcase);
788     prefs_put_bool(SECTION, "gui-ft2-volume", gui_settings.tracker_ft2_volume);
789     prefs_put_bool(SECTION, "gui-ft2-wide", gui_settings.tracker_ft2_wide);
790     prefs_put_bool(SECTION, "gui-ft2-tone-porta-m", gui_settings.tracker_ft2_tpm);
791     prefs_put_bool(SECTION, "gui-volume-decimal", gui_settings.tracker_vol_dec);
792     prefs_put_bool(SECTION, "gui-advance-cursor-in-fx-columns", gui_settings.advance_cursor_in_fx_columns);
793     prefs_put_bool(SECTION, "gui-asynchronous-editing", gui_settings.asynchronous_editing);
794     prefs_put_bool(SECTION, "gui-try-polyphony", gui_settings.try_polyphony);
795     prefs_put_bool(SECTION, "gui-repeat-same-note", gui_settings.repeat_same_note);
796     prefs_put_bool(SECTION, "gui-insert-noteoff", gui_settings.insert_noteoff);
797     prefs_put_bool(SECTION, "gui-precise-timing", gui_settings.precise_timing);
798     prefs_put_double(SECTION, "gui-delay-compensation", gui_settings.delay_comp);
799     prefs_put_bool(SECTION, "gui-playback-looped", gui_settings.looped);
800     prefs_put_string(SECTION, "gui-tracker-line-format", gui_settings.tracker_line_format);
801     prefs_put_string(SECTION, "tracker-font", gui_settings.tracker_font);
802     prefs_put_bool(SECTION, "gui-tempo-bpm-update", gui_settings.tempo_bpm_update);
803     prefs_put_bool(SECTION, "tracker-rxx-bug-emulate", gui_settings.rxx_bug_emu);
804     prefs_put_bool(SECTION, "player-use-filter", gui_settings.use_filter);
805     prefs_put_bool(SECTION, "gui-auto-switch", gui_settings.auto_switch);
806     prefs_put_bool(SECTION, "gui-add-extension", gui_settings.add_extension);
807     prefs_put_bool(SECTION, "gui-display-scopes", gui_settings.gui_display_scopes);
808     prefs_put_bool(SECTION, "gui-use-backing-store", gui_settings.gui_use_backing_store);
809     prefs_put_int(SECTION, "gui-undo-size", gui_settings.undo_size);
810     prefs_put_bool(SECTION, "tracker-highlight-rows", gui_settings.highlight_rows);
811     prefs_put_int(SECTION, "tracker-highlight-rows-n", gui_settings.highlight_rows_n);
812     prefs_put_int(SECTION, "tracker-highlight-rows-minor-n", gui_settings.highlight_rows_minor_n);
813     prefs_put_bool(SECTION, "clavier-colors-gtk", gui_settings.clavier_colors_gtk);
814     prefs_put_string(SECTION, "clavier-font", gui_settings.clavier_font);
815     prefs_put_bool(SECTION, "save-geometry", gui_settings.save_geometry);
816     prefs_put_bool(SECTION, "save-settings-on-exit", gui_settings.save_settings_on_exit);
817     prefs_put_int(SECTION, "tracker-update-frequency", gui_settings.tracker_update_freq);
818     prefs_put_int(SECTION, "scopes-update-frequency", gui_settings.scopes_update_freq);
819     prefs_put_int(SECTION, "scopes-buffer-size", gui_settings.scopes_buffer_size);
820     prefs_put_bool(SECTION, "sharp", gui_settings.sharp);
821     prefs_put_bool(SECTION, "bh", gui_settings.bh);
822     prefs_put_bool(SECTION, "store-permanent", gui_settings.store_perm);
823     prefs_put_int(SECTION, "sample-display-scopes-mode", gui_settings.scopes_mode);
824     prefs_put_int(SECTION, "sample-display-editor-mode", gui_settings.editor_mode);
825     prefs_put_int(SECTION, "sample-display-sampling-mode", gui_settings.sampling_mode);
826     prefs_put_int(SECTION, "selection-mode", gui_settings.selection_mode);
827     colors_save(SECTION);
828 
829     if (gui_settings.store_perm)
830         prefs_put_int(SECTION, "permanent-channels", gui_settings.permanent_channels);
831 
832     prefs_put_int(SECTION, "file-channels", gui_settings.file_out_channels);
833     prefs_put_int(SECTION, "file-mixfreq", gui_settings.file_out_mixfreq);
834     prefs_put_int(SECTION, "file-resolution", gui_settings.file_out_resolution);
835 }
836 
gui_settings_save_config_always(void)837 void gui_settings_save_config_always(void)
838 {
839     prefs_put_string(SECTION_ALWAYS, "loadmod-path", gui_settings.loadmod_path);
840     prefs_put_string(SECTION_ALWAYS, "savemod-path", gui_settings.savemod_path);
841     prefs_put_string(SECTION_ALWAYS, "savemodaswav-path", gui_settings.savemodaswav_path);
842     prefs_put_string(SECTION_ALWAYS, "savesongasxm-path", gui_settings.savesongasxm_path);
843     prefs_put_string(SECTION_ALWAYS, "loadsmpl-path", gui_settings.loadsmpl_path);
844     prefs_put_string(SECTION_ALWAYS, "savesmpl-path", gui_settings.savesmpl_path);
845     prefs_put_string(SECTION_ALWAYS, "loadinstr-path", gui_settings.loadinstr_path);
846     prefs_put_string(SECTION_ALWAYS, "saveinstr-path", gui_settings.saveinstr_path);
847     prefs_put_string(SECTION_ALWAYS, "loadpat-path", gui_settings.loadpat_path);
848     prefs_put_string(SECTION_ALWAYS, "savepat-path", gui_settings.savepat_path);
849 
850     prefs_put_string(SECTION_ALWAYS, "rm-path", gui_settings.rm_path);
851     prefs_put_string(SECTION_ALWAYS, "unzip-path", gui_settings.unzip_path);
852     prefs_put_string(SECTION_ALWAYS, "lha-path", gui_settings.lha_path);
853     prefs_put_string(SECTION_ALWAYS, "gz-path", gui_settings.gz_path);
854     prefs_put_string(SECTION_ALWAYS, "bz2-path", gui_settings.bz2_path);
855 
856     prefs_put_bool(SECTION_ALWAYS, "gui-disable-splash", gui_settings.gui_disable_splash);
857 }
858 
gui_settings_make_path(const gchar * fn,gchar ** store)859 void gui_settings_make_path(const gchar* fn,
860     gchar** store)
861 {
862     gchar* dn = g_path_get_dirname(fn);
863 
864     if (*store)
865         g_free(*store);
866 
867     *store = g_strconcat(dn, "/", NULL);
868     g_free(dn);
869 }
870