Commit d54557d9 authored by Albert Gräf's avatar Albert Gräf

Help browser: Make indexing start time configurable in the GUI prefs.

parent a46aad7e
......@@ -312,6 +312,11 @@
<input type="checkbox" id="browser_path" name="browser_path">
<span data-i18n="prefs.gui.browser.browser_path"></span>
</label>
<br/>
<label data-i18n="[title]prefs.gui.browser.browser_init_tt">
<input type="checkbox" id="browser_init" name="browser_init">
<span data-i18n="prefs.gui.browser.browser_init"></span>
</label>
</div>
</div>
......@@ -616,9 +621,10 @@ function apply(save_prefs) {
midi_use_alsa ? get_attr("midi-outdev-names", attrs).length : 0
);
// Send the gui prefs (currently just the name of the gui preset and the
// status of the save-zoom toggle) to Pd
pdgui.pdsend("pd gui-prefs", get_gui_preset(), get_bool_elem("save_zoom"), get_bool_elem("browser_doc"), get_bool_elem("browser_path"));
// Send the gui prefs (currently just the name of the gui preset, the
// status of the save-zoom toggle and various options related to the help
// browser) to Pd
pdgui.pdsend("pd gui-prefs", get_gui_preset(), get_bool_elem("save_zoom"), get_bool_elem("browser_doc"), get_bool_elem("browser_path"), get_bool_elem("browser_init"));
// Send the startup config data to Pd
pdgui.pdsend.apply(null, ["pd path-dialog", startup_use_stdpath, startup_verbose].concat(get_path_array()));
......@@ -857,7 +863,7 @@ function midi_prefs_callback(attrs) {
pdgui.resize_window(pd_object_callback);
}
function gui_prefs_callback(name, save_zoom, browser_doc, browser_path) {
function gui_prefs_callback(name, save_zoom, browser_doc, browser_path, browser_init) {
var s = document.getElementById("gui_preset"),
i;
for (i = 0; i < s.options.length; i++) {
......@@ -869,6 +875,7 @@ function gui_prefs_callback(name, save_zoom, browser_doc, browser_path) {
document.getElementById("save_zoom").checked = !!save_zoom;
document.getElementById("browser_doc").checked = !!browser_doc;
document.getElementById("browser_path").checked = !!browser_path;
document.getElementById("browser_init").checked = !!browser_init;
}
// startup settings
......
......@@ -412,7 +412,9 @@
"browser_doc": "Hilfe-Browser durchsucht nur den doc-Ordner",
"browser_doc_tt": "Der Hilfe-Browser durchkämmt nur Hilfe-Patches im doc-Ordner nach Suchbegriffen (schneller)",
"browser_path": "Hilfe-Browser durchsucht auch den Hilfe-Pfad",
"browser_path_tt": "Der Hilfe-Browser durchkämmt auch Hilfe-Patches im benutzerdefinierten Hilfe-Pfad nach Suchbegriffen (langsamer)"
"browser_path_tt": "Der Hilfe-Browser durchkämmt auch Hilfe-Patches im benutzerdefinierten Hilfe-Pfad nach Suchbegriffen (langsamer)",
"browser_init": "Erstelle den Hilfe-Index beim Programmstart",
"browser_init_tt": "Erstelle den Index für den Hilfe-Browser beim Programmstart (falls aktiviert), oder wenn der Browser zum ersten Mal ausgeführt wird (falls nicht aktiviert)"
}
},
"audio": {
......
......@@ -413,7 +413,9 @@
"browser_doc": "help browser only searches the doc folder",
"browser_doc_tt": "Only scan help patches in the doc folder for searchable keywords (faster)",
"browser_path": "help browser also searches the help path",
"browser_path_tt": "Also scan help patches in the user-defined help path for searchable keywords (slower)"
"browser_path_tt": "Also scan help patches in the user-defined help path for searchable keywords (slower)",
"browser_init": "prepare the help index at application start",
"browser_init_tt": "Prepare the index for the help browser when the application starts (if checked), or when the browser first launches (if unchecked)"
}
},
"audio": {
......
......@@ -2,7 +2,7 @@
var pwd;
var lib_dir;
var help_path, browser_doc, browser_path;
var help_path, browser_doc, browser_path, browser_init;
var pd_engine_id;
exports.set_pwd = function(pwd_string) {
......@@ -27,14 +27,17 @@ exports.set_pd_engine_id = function (id) {
exports.defunkify_windows_path = defunkify_windows_path;
function gui_set_browser_config(doc_flag, path_flag, helppath) {
function gui_set_browser_config(doc_flag, path_flag, init_flag, helppath) {
// post("gui_set_browser_config: " + helppath.join(":"));
browser_doc = doc_flag;
browser_path = path_flag;
browser_init = init_flag;
help_path = helppath;
// AG: Start building the keyword index for dialog_search.html. We do this
// here so that we can be sure that lib_dir and help_path are known already.
make_index();
// (This may also be deferred until the browser is launched for the first
// time, depending on the value of browser_init.)
if (browser_init == 1) make_index();
}
function gui_set_lib_dir(dir) {
......@@ -138,6 +141,7 @@ function read_file(err, filename, stat) {
}
var index_done = false;
var index_started = false;
function finish_index() {
index_done = true;
......@@ -177,21 +181,27 @@ function make_index() {
finish_index();
}
}
index_started = true;
post("building help index in " + doc_path);
dive(doc_path, read_file, browser_path?make_index_cont:finish_index);
}
// AG: This is called from dialog_search.html with a callback that expects to
// receive the finished index as its sole argument. Note that this doesn't
// really build the index (make_index does this), it simply waits for
// make_index to finish (if needed) and then invokes the callback on the
// resulting index.
// receive the finished index as its sole argument. We also build the index
// here if needed, using make_index, then simply wait until make_index
// finishes and finally invoke the callback on the resulting index.
function build_index(cb) {
if (index_done == true) {
cb(index);
} else {
setTimeout(function() { build_index(cb); }, 500);
function build_index_worker() {
if (index_done == true) {
cb(index);
} else {
setTimeout(build_index_worker, 500);
}
}
if (index_started == false) {
make_index();
}
build_index_worker();
}
exports.build_index = build_index;
......@@ -5098,9 +5108,9 @@ function gui_midi_properties(gfxstub, sys_indevs, sys_outdevs,
}
}
function gui_gui_properties(dummy, name, save_zoom, browser_doc, browser_path) {
function gui_gui_properties(dummy, name, save_zoom, browser_doc, browser_path, browser_init) {
if (dialogwin["prefs"] !== null) {
dialogwin["prefs"].window.gui_prefs_callback(name, save_zoom, browser_doc, browser_path);
dialogwin["prefs"].window.gui_prefs_callback(name, save_zoom, browser_doc, browser_path, browser_init);
}
}
......
......@@ -75,20 +75,21 @@ static void glob_perf(t_pd *dummy, float f)
sys_perf = (f != 0);
}
extern int sys_zoom, sys_browser_doc, sys_browser_path;
extern int sys_zoom, sys_browser_doc, sys_browser_path, sys_browser_init;
extern t_symbol *sys_gui_preset;
static void glob_gui_prefs(t_pd *dummy, t_symbol *s, float f, float f2, float f3)
static void glob_gui_prefs(t_pd *dummy, t_symbol *s, float f, float f2, float f3, float f4)
{
sys_gui_preset = s;
sys_zoom = !!(int)f;
sys_browser_doc = !!(int)f2;
sys_browser_path = !!(int)f3;
sys_browser_init = !!(int)f4;
}
/* just the gui-preset and the save-zoom toggle for now */
/* just the gui-preset, the save-zoom toggle and various help browser options for now */
static void glob_gui_properties(t_pd *dummy)
{
gui_vmess("gui_gui_properties", "xsiii", 0, sys_gui_preset->s_name, sys_zoom, sys_browser_doc, sys_browser_path);
gui_vmess("gui_gui_properties", "xsiiii", 0, sys_gui_preset->s_name, sys_zoom, sys_browser_doc, sys_browser_path, sys_browser_init);
}
// ths one lives inside g_editor so that it can access the clipboard
......@@ -174,7 +175,7 @@ void glob_init(void)
class_addmethod(glob_pdobject, (t_method)glob_clipboard_text,
gensym("clipboardtext"), A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_gui_prefs,
gensym("gui-prefs"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, 0);
gensym("gui-prefs"), A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(glob_pdobject, (t_method)glob_gui_properties,
gensym("gui-properties"), 0);
class_addmethod(glob_pdobject, (t_method)glob_recent_files,
......
......@@ -40,7 +40,7 @@
#define snprintf sprintf_s
#endif
int sys_defeatrt, sys_zoom, sys_browser_doc = 1, sys_browser_path;
int sys_defeatrt, sys_zoom, sys_browser_doc = 1, sys_browser_path, sys_browser_init;
t_symbol *sys_flags = &s_;
void sys_doflags( void);
......@@ -673,6 +673,8 @@ void sys_loadpreferences( void)
sscanf(prefbuf, "%d", &sys_browser_doc);
if (sys_getpreference("browser_path", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &sys_browser_path);
if (sys_getpreference("browser_init", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &sys_browser_init);
if (sys_getpreference("guipreset", prefbuf, MAXPDSTRING))
{
char preset_buf[MAXPDSTRING];
......@@ -816,6 +818,8 @@ void glob_savepreferences(t_pd *dummy)
sys_putpreference("browser_doc", buf1);
sprintf(buf1, "%d", sys_browser_path);
sys_putpreference("browser_path", buf1);
sprintf(buf1, "%d", sys_browser_init);
sys_putpreference("browser_init", buf1);
sys_putpreference("guipreset", sys_gui_preset->s_name);
sys_putpreference("flags",
(sys_flags ? sys_flags->s_name : ""));
......
......@@ -285,7 +285,7 @@ void glob_forward_files_from_secondary_instance(void)
}
extern void glob_recent_files(t_pd *dummy);
extern int sys_browser_doc, sys_browser_path;
extern int sys_browser_doc, sys_browser_path, sys_browser_init;
/* this is called from main() in s_entry.c */
int sys_main(int argc, char **argv)
......@@ -327,10 +327,10 @@ int sys_main(int argc, char **argv)
gui_vmess("gui_set_gui_preset", "s", sys_gui_preset->s_name);
/* send the recent files list */
glob_recent_files(0);
/* AG: send the help path; this must come *after* gui_set_lib_dir so
that the lib_dir is available when help indexing starts */
gui_start_vmess("gui_set_browser_config", "ii",
sys_browser_doc, sys_browser_path);
/* AG: send the browser config; this must come *after* gui_set_lib_dir
so that the lib_dir is available when help indexing starts */
gui_start_vmess("gui_set_browser_config", "iii",
sys_browser_doc, sys_browser_path, sys_browser_init);
gui_start_array();
for (nl = sys_helppath; nl; nl = nl->nl_next)
{
......
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