0
Fork 0
mirror of https://codeberg.org/librewolf/source.git synced 2024-12-22 05:33:03 -05:00
LibreWolf/patches/fullpage-translations-customization.patch

165 lines
6.3 KiB
Diff
Raw Permalink Normal View History

2024-08-10 05:21:15 -05:00
diff --git a/browser/base/content/main-popupset.inc.xhtml b/browser/base/content/main-popupset.inc.xhtml
index 1fb595272a18..56c2c58e111c 100644
--- a/browser/base/content/main-popupset.inc.xhtml
+++ b/browser/base/content/main-popupset.inc.xhtml
2024-08-10 05:21:15 -05:00
@@ -607,6 +607,8 @@
checked="false"
autocheck="false"
2024-08-10 05:21:15 -05:00
id="translations-panel-settings-never-translate-site"/>
+ <menuitem data-l10n-id="translations-panel-disable-translations"
2024-08-10 05:21:15 -05:00
+ id="translations-panel-disable-translations"/>
<menuseparator/>
<menuitem class="manage-languages-menuitem"
data-l10n-id="translations-panel-settings-manage-languages"
2024-08-10 05:21:15 -05:00
diff --git a/browser/base/content/main-popupset.js b/browser/base/content/main-popupset.js
index c403c914f27c..6338cbd92621 100644
--- a/browser/base/content/main-popupset.js
+++ b/browser/base/content/main-popupset.js
@@ -251,6 +251,9 @@ document.addEventListener(
case "translations-panel-settings-never-translate-site":
FullPageTranslationsPanel.onNeverTranslateSite();
break;
+ case "translations-panel-disable-translations":
+ FullPageTranslationsPanel.openDisableTranslations();
+ break;
case "translations-panel-manage-languages":
FullPageTranslationsPanel.openManageLanguages();
break;
diff --git a/browser/components/preferences/main.inc.xhtml b/browser/components/preferences/main.inc.xhtml
index 4c2637db10b7..846a538036d7 100644
--- a/browser/components/preferences/main.inc.xhtml
+++ b/browser/components/preferences/main.inc.xhtml
2024-06-15 13:08:05 -05:00
@@ -389,8 +389,16 @@
preference="layout.spellcheckDefault"/>
<!-- Translations -->
- <vbox id="translationsGroup" hidden="true" data-subcategory="translations">
+ <vbox id="translationsGroup" data-subcategory="translations">
<label><html:h2 data-l10n-id="translations-manage-header"/></label>
+ <checkbox id="translations-manage-enable"
+ data-l10n-id="translations-manage-enable"
+ preference="browser.translations.enable"
+ data-subcategory="translations-enable" />
+ <vbox id="innerTranslationsGroup" hidden="true">
2024-06-15 13:08:05 -05:00
+ <checkbox id="translations-manage-autopopup"
+ data-l10n-id="translations-manage-autopopup"
+ preference="browser.translations.automaticallyPopup" />
<hbox id="translations-manage-description" align="center">
<description flex="1" data-l10n-id="translations-manage-intro-2"/>
<button id="translations-manage-settings-button"
2024-06-15 13:08:05 -05:00
@@ -412,6 +420,7 @@
<description id="translations-manage-error" hidden="true"></description>
</vbox>
</vbox>
+ </vbox>
</groupbox>
<!-- Files and Applications -->
2024-08-10 05:21:15 -05:00
diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
index fec5aa685ea7..92082d259903 100644
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
2024-08-10 05:21:15 -05:00
@@ -145,6 +145,10 @@ Preferences.addAll([
{ id: "dom.ipc.processCount.web", type: "int" },
{ id: "layers.acceleration.disabled", type: "bool", inverted: true },
+ /* Fullpage Translations */
+ { id: "browser.translations.enable", type: "bool" },
+ { id: "browser.translations.automaticallyPopup", type: "bool" },
+
// Files and Applications
{ id: "pref.downloads.disable_button.edit_actions", type: "bool" },
2024-08-10 05:21:15 -05:00
@@ -326,6 +330,22 @@ var gMainPane = {
gMainPane.initTranslations();
+ let inPrompt = false;
+ Preferences.get("browser.translations.enable").on("change", () => {
+ if(!Preferences.get("browser.translations.enable").value)
+ if(!inPrompt) {
+ inPrompt = true;
+ confirmRestartPrompt(false, 1, true, false).then(buttonIndex => {
+ inPrompt = false;
+ if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
+ Services.startup.quit(
+ Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart
+ );
+ }
+ });
+ }
+ });
+
if (
Services.prefs.getBoolPref(
"media.videocontrols.picture-in-picture.enabled"
2024-08-10 05:21:15 -05:00
@@ -793,6 +813,10 @@ var gMainPane = {
document.getElementById("checkSpelling"),
() => this.writeCheckSpelling()
);
+ Preferences.addSyncFromPrefListener(
+ document.getElementById("translations-manage-enable"),
+ () => this.readEnableTranslations()
+ );
Preferences.addSyncFromPrefListener(
document.getElementById("alwaysAsk"),
() => this.readUseDownloadDir()
2024-08-10 05:21:15 -05:00
@@ -1023,24 +1047,33 @@ var gMainPane = {
document.getElementById("zoomBox").hidden = false;
},
+ readEnableTranslations(skipInit = false) {
+ const translationsEnabled = Preferences.get("browser.translations.enable").value;
+ document.getElementById("innerTranslationsGroup").hidden = !translationsEnabled;
+ if (!this._translationsInitialized && !skipInit)
+ this.initTranslations();
+ },
+
+ _translationsInitialized: false,
+
/**
* Initialize the translations view.
*/
async initTranslations() {
+ this.readEnableTranslations(true);
+
if (!Services.prefs.getBoolPref("browser.translations.enable")) {
return;
}
+ this._translationsInitialized = true;
+
/**
* Which phase a language download is in.
*
* @typedef {"downloaded" | "loading" | "uninstalled"} DownloadPhase
*/
- // Immediately show the group so that the async load of the component does
- // not cause the layout to jump. The group will be empty initially.
- document.getElementById("translationsGroup").hidden = false;
-
class TranslationsState {
/**
* The fully initialized state.
2024-08-10 05:21:15 -05:00
diff --git a/browser/components/translations/content/fullPageTranslationsPanel.js b/browser/components/translations/content/fullPageTranslationsPanel.js
index 0c8288af9aca..05e49c06ff63 100644
--- a/browser/components/translations/content/fullPageTranslationsPanel.js
+++ b/browser/components/translations/content/fullPageTranslationsPanel.js
2024-08-10 05:21:15 -05:00
@@ -1220,6 +1220,15 @@ var FullPageTranslationsPanel = new (class {
);
}
+ openDisableTranslations() {
+ const window =
+ gBrowser.selectedBrowser.browsingContext.top.embedderElement.ownerGlobal;
+ window.openTrustedLinkIn(
+ "about:preferences#general-translations-enable",
+ "tab"
+ );
+ }
+
/**
* Redirect the user to about:preferences
*/