Commit 53e73951 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

first draft of saving the preferences, including the gui preset (still won't...

first draft of saving the preferences, including the gui preset (still won't write to file for some reason)
parent 3552c248
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
<button type="button" onClick="ok()" data-i18n="[title]prefs.ok_tt"> <button type="button" onClick="ok()" data-i18n="[title]prefs.ok_tt">
<span data-i18n="prefs.ok"></span> <span data-i18n="prefs.ok"></span>
</button> </button>
<button type="button" onClick="apply()" data-i18n="[title]prefs.apply_tt"> <button type="button" onClick="apply(false)" data-i18n="[title]prefs.apply_tt">
<span data-i18n="prefs.apply"></span> <span data-i18n="prefs.apply"></span>
</button> </button>
<button type="button" onClick="cancel()" data-i18n="[title]prefs.close_tt"> <button type="button" onClick="cancel()" data-i18n="[title]prefs.close_tt">
...@@ -317,7 +317,7 @@ var pd_audio_attrs; ...@@ -317,7 +317,7 @@ var pd_audio_attrs;
var pd_midi_attrs; var pd_midi_attrs;
function ok() { function ok() {
apply(); apply(true);
cancel(); cancel();
} }
...@@ -325,6 +325,10 @@ function gui_preset_change(elem) { ...@@ -325,6 +325,10 @@ function gui_preset_change(elem) {
pdgui.skin.set(elem.value); pdgui.skin.set(elem.value);
} }
function get_gui_preset() {
return document.getElementById("gui_preset").selectedOptions[0].value;
}
// callbacks for devices and/or their number of channels // callbacks for devices and/or their number of channels
function dev_change(elem) { function dev_change(elem) {
var attrs, id, direction, index; var attrs, id, direction, index;
...@@ -407,7 +411,7 @@ function kludge_chans(type, attrs, index) { ...@@ -407,7 +411,7 @@ function kludge_chans(type, attrs, index) {
return chans; return chans;
} }
function apply() { function apply(save_prefs) {
var attrs = pd_audio_attrs, var attrs = pd_audio_attrs,
midi_use_alsa; midi_use_alsa;
pdgui.post("applying preferences"); pdgui.post("applying preferences");
...@@ -453,6 +457,14 @@ function apply() { ...@@ -453,6 +457,14 @@ function apply() {
midi_use_alsa ? get_attr("midi-indev-names", attrs).length : 0, midi_use_alsa ? get_attr("midi-indev-names", attrs).length : 0,
midi_use_alsa ? get_attr("midi-outdev-names", attrs).length : 0 midi_use_alsa ? get_attr("midi-outdev-names", attrs).length : 0
); );
// Send the name of the gui preset to Pd
pdgui.pdsend("pd gui-preset", get_gui_preset());
if (save_prefs) {
// save the prefs in Pd...
pdgui.pdsend("pd save-preferences");
}
} }
function cancel() { function cancel() {
...@@ -691,6 +703,16 @@ function midi_prefs_callback(attrs) { ...@@ -691,6 +703,16 @@ function midi_prefs_callback(attrs) {
pdgui.resize_window(pd_object_callback); pdgui.resize_window(pd_object_callback);
} }
function gui_prefs_callback(name) {
var s = document.getElementById("gui_preset"),
i;
for (i = 0; i < s.options.length; i++) {
if (s.options[i].value.toLowerCase() === name.toLowerCase()) {
s.selectedIndex = i;
break;
}
}
}
// This gets called from the nw_create_window function in index.html // This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side. Once we have it // It provides us with our window id from the C side. Once we have it
...@@ -709,6 +731,7 @@ function register_window_id(gfxstub, attr_arrays) { ...@@ -709,6 +731,7 @@ function register_window_id(gfxstub, attr_arrays) {
pdgui.pdsend("pd audio-properties"); // request audio pref attrs pdgui.pdsend("pd audio-properties"); // request audio pref attrs
pdgui.pdsend("pd midi-properties"); // request midi pref attrs pdgui.pdsend("pd midi-properties"); // request midi pref attrs
pdgui.pdsend("pd gui-properties"); // request saved gui properties
document.getElementsByClassName("container")[0].style.setProperty("display", "inline"); document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
} }
......
...@@ -48,6 +48,10 @@ exports.get_pd_opendir = function() { ...@@ -48,6 +48,10 @@ exports.get_pd_opendir = function() {
} }
} }
function gui_set_gui_preset(name) {
post("the gui preset is " + name);
}
exports.set_last_clipboard_data = function(data) { exports.set_last_clipboard_data = function(data) {
last_clipboard_data = data; last_clipboard_data = data;
} }
...@@ -3843,6 +3847,12 @@ function gui_midi_properties(gfxstub, sys_indevs, sys_outdevs, ...@@ -3843,6 +3847,12 @@ function gui_midi_properties(gfxstub, sys_indevs, sys_outdevs,
} }
} }
function gui_gui_properties(dummy, name) {
if (dialogwin["prefs"] !== null) {
dialogwin["prefs"].window.gui_prefs_callback(name);
}
}
// Let's try a closure for gui skins // Let's try a closure for gui skins
exports.skin = (function () { exports.skin = (function () {
var dir = "css/"; var dir = "css/";
......
...@@ -71,6 +71,18 @@ static void glob_perf(t_pd *dummy, float f) ...@@ -71,6 +71,18 @@ static void glob_perf(t_pd *dummy, float f)
sys_perf = (f != 0); sys_perf = (f != 0);
} }
extern char *sys_gui_preset;
static void glob_gui_preset(t_pd *dummy, t_symbol *s)
{
sys_gui_preset = s->s_name;
}
/* just the gui-preset for now */
static void glob_gui_properties(t_pd *dummy)
{
gui_vmess("gui_gui_properties", "xs", 0, sys_gui_preset);
}
// ths one lives inside g_editor so that it can access the clipboard // ths one lives inside g_editor so that it can access the clipboard
extern void glob_clipboard_text(t_pd *dummy, float f); extern void glob_clipboard_text(t_pd *dummy, float f);
...@@ -148,6 +160,10 @@ void glob_init(void) ...@@ -148,6 +160,10 @@ void glob_init(void)
gensym("perf"), A_FLOAT, 0); gensym("perf"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_clipboard_text, class_addmethod(glob_pdobject, (t_method)glob_clipboard_text,
gensym("clipboardtext"), A_FLOAT, 0); gensym("clipboardtext"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_gui_preset,
gensym("gui-preset"), A_SYMBOL, 0);
class_addmethod(glob_pdobject, (t_method)glob_gui_properties,
gensym("gui-properties"), 0);
#ifdef UNIX #ifdef UNIX
class_addmethod(glob_pdobject, (t_method)glob_watchdog, class_addmethod(glob_pdobject, (t_method)glob_watchdog,
gensym("watchdog"), 0); gensym("watchdog"), 0);
......
...@@ -437,6 +437,8 @@ void sys_loadpreferences( void) ...@@ -437,6 +437,8 @@ void sys_loadpreferences( void)
} }
if (sys_getpreference("defeatrt", prefbuf, MAXPDSTRING)) if (sys_getpreference("defeatrt", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &sys_defeatrt); sscanf(prefbuf, "%d", &sys_defeatrt);
if (sys_getpreference("guipreset", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%s", &sys_gui_preset);
if (sys_getpreference("flags", prefbuf, MAXPDSTRING)) if (sys_getpreference("flags", prefbuf, MAXPDSTRING))
{ {
if (strcmp(prefbuf, ".")) if (strcmp(prefbuf, "."))
...@@ -551,6 +553,7 @@ void glob_savepreferences(t_pd *dummy) ...@@ -551,6 +553,7 @@ void glob_savepreferences(t_pd *dummy)
sys_putpreference("nloadlib", buf1); sys_putpreference("nloadlib", buf1);
sprintf(buf1, "%d", sys_defeatrt); sprintf(buf1, "%d", sys_defeatrt);
sys_putpreference("defeatrt", buf1); sys_putpreference("defeatrt", buf1);
sys_putpreference("guipreset", sys_gui_preset);
sys_putpreference("flags", sys_putpreference("flags",
(sys_flags ? sys_flags->s_name : "")); (sys_flags ? sys_flags->s_name : ""));
sys_donesavepreferences(); sys_donesavepreferences();
......
...@@ -55,6 +55,7 @@ int sys_unique = 0; /* by default off, prevents multiple instances ...@@ -55,6 +55,7 @@ int sys_unique = 0; /* by default off, prevents multiple instances
int sys_legacy = 0; /* by default off, used to enable legacy features, int sys_legacy = 0; /* by default off, used to enable legacy features,
such as offsets in iemgui object positioning */ such as offsets in iemgui object positioning */
char *sys_guicmd; char *sys_guicmd;
char *sys_gui_preset = "default"; /* name of the gui theme to be used */
t_symbol *sys_libdir; t_symbol *sys_libdir;
t_symbol *sys_guidir; t_symbol *sys_guidir;
static t_namelist *sys_openlist; static t_namelist *sys_openlist;
...@@ -290,6 +291,8 @@ int sys_main(int argc, char **argv) ...@@ -290,6 +291,8 @@ int sys_main(int argc, char **argv)
return(1); return(1);
/* send the libdir to the GUI */ /* send the libdir to the GUI */
gui_vmess("gui_set_lib_dir", "s", sys_libdir->s_name); gui_vmess("gui_set_lib_dir", "s", sys_libdir->s_name);
/* send the name of the gui preset */
gui_vmess("gui_set_gui_preset", "s", sys_gui_preset);
if (sys_openlist) if (sys_openlist)
{ {
// send the files to be opened to the GUI. We send them one // send the files to be opened to the GUI. We send them one
......
...@@ -39,6 +39,7 @@ t_symbol *sys_decodedialog(t_symbol *s); ...@@ -39,6 +39,7 @@ t_symbol *sys_decodedialog(t_symbol *s);
void sys_loadpreferences( void); void sys_loadpreferences( void);
void sys_savepreferences( void); void sys_savepreferences( void);
extern int sys_defeatrt; extern int sys_defeatrt;
extern char *sys_gui_preset;
extern t_symbol *sys_flags; extern t_symbol *sys_flags;
/* s_main.c */ /* s_main.c */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment