Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Fix setting of browserPath when selection changes
Browse files Browse the repository at this point in the history
Change order of populating fields for system default and custom entries
  • Loading branch information
spikespaz committed Aug 20, 2019
1 parent ad54f98 commit f3eeb46
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/arsd
Submodule arsd updated from 576c88 to a28b47
22 changes: 16 additions & 6 deletions source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ void main(string[] args) {
int browserIndex = ["system_default", ""].canFind(settings.browserPath) ? 1 : -1;
int engineIndex = !browsers.values.canFind(settings.engineURL) ? 0 : -1;

if (engineIndex == 0)
engineUrl.setEnabled(true);

foreach (uint index, string browser; browsers.keys) {
browserSelect.addOption(browser);

Expand All @@ -92,18 +89,24 @@ void main(string[] args) {
browserSelect.setSelection(browserIndex);
engineSelect.setSelection(engineIndex);

if (browserSelect.currentText == "Custom")
engineUrl.setEnabled(true);

browserPath.content = browsers.get(browserSelect.currentText, "");
engineUrl.content = engines.get(engineSelect.currentText, settings.engineURL);

browserPathButton.setMaxWidth(30);
browserPathButton.addEventListener(EventType.triggered, {
getOpenFileName(&browserPath.content, browserPath.content, null);

settings.engineURL = engineUrl.content.strip();
settings.browserPath = browserPath.content.strip();
applyButton.setEnabled(true);
});

browserSelect.addEventListener(EventType.change, {
debug writeln(browserSelect.currentText);
debug writeln(browserPath.content);

if (browserSelect.currentText == "Custom") {
browserPath.setEnabled(true);
browserPathButton.show();
Expand All @@ -118,8 +121,6 @@ void main(string[] args) {

settings.browserPath = browserPath.content;
applyButton.setEnabled(true);

debug writeln(browserPath.content);
});

browserPath.addEventListener(EventType.keyup, {
Expand All @@ -128,6 +129,9 @@ void main(string[] args) {
});

engineSelect.addEventListener(EventType.change, {
debug writeln(engineSelect.currentText);
debug writeln(engineUrl.content);

if (engineSelect.currentText == "Custom") {
engineUrl.setEnabled(true);

Expand All @@ -150,20 +154,26 @@ void main(string[] args) {
});

applyButton.addEventListener(EventType.triggered, {
debug writeln("Valid Browser: ", validateExecutablePath(settings.browserPath));

if (browserSelect.currentText != "System Default" &&
!validateExecutablePath(settings.browserPath)) {
debug writeln(settings.browserPath);

createWarningDialog(
"Custom browser path is invalid.\nCheck the wiki for more information.",
window.hwnd);

return;
}

if (!validateEngineUrl(settings.engineURL)) {
debug writeln(settings.engineURL);

createWarningDialog(
"Custom search engine URL is invalid.\nCheck the wiki for more information.",
window.hwnd);

return;
}

Expand Down

0 comments on commit f3eeb46

Please sign in to comment.