From 58c31ef6f3dbd77c367724f8ac557f5ffb400be6 Mon Sep 17 00:00:00 2001 From: JiaminWang Date: Mon, 19 Aug 2024 10:13:24 -0400 Subject: [PATCH] scale not finished --- customize-ibus@hollowman.ml/extension.js | 96 +- customize-ibus@hollowman.ml/lib/API.js | 0 customize-ibus@hollowman.ml/lib/Manager.js | 443 ++++ .../lib/Prefs/Prefs.js | 590 +++++ .../lib/Prefs/PrefsKeys.js | 776 ++++++ customize-ibus@hollowman.ml/metadata.json | 17 +- customize-ibus@hollowman.ml/prefs.js | 2074 +---------------- .../schemas/gschemas.compiled | Bin 0 -> 4532 bytes ...hell.extensions.customize-ibus.gschema.xml | 6 +- customize-ibus@hollowman.ml/ui/adw/about.ui | 121 + .../ui/adw/background.ui | 171 ++ customize-ibus@hollowman.ml/ui/adw/general.ui | 372 +++ .../ui/adw/indicator.ui | 361 +++ .../ui/adw/settings.ui | 134 ++ customize-ibus@hollowman.ml/ui/adw/theme.ui | 142 ++ customize-ibus@hollowman.ml/ui/adw/tray.ui | 153 ++ 16 files changed, 3373 insertions(+), 2083 deletions(-) create mode 100644 customize-ibus@hollowman.ml/lib/API.js create mode 100644 customize-ibus@hollowman.ml/lib/Manager.js create mode 100644 customize-ibus@hollowman.ml/lib/Prefs/Prefs.js create mode 100644 customize-ibus@hollowman.ml/lib/Prefs/PrefsKeys.js create mode 100644 customize-ibus@hollowman.ml/schemas/gschemas.compiled create mode 100755 customize-ibus@hollowman.ml/ui/adw/about.ui create mode 100755 customize-ibus@hollowman.ml/ui/adw/background.ui create mode 100755 customize-ibus@hollowman.ml/ui/adw/general.ui create mode 100644 customize-ibus@hollowman.ml/ui/adw/indicator.ui create mode 100644 customize-ibus@hollowman.ml/ui/adw/settings.ui create mode 100755 customize-ibus@hollowman.ml/ui/adw/theme.ui create mode 100755 customize-ibus@hollowman.ml/ui/adw/tray.ui diff --git a/customize-ibus@hollowman.ml/extension.js b/customize-ibus@hollowman.ml/extension.js index 8dfc884..588964b 100644 --- a/customize-ibus@hollowman.ml/extension.js +++ b/customize-ibus@hollowman.ml/extension.js @@ -48,6 +48,7 @@ let CandidateDummyCursor = null; let gsettings = null; import { Fields } from "./fields.js"; +import { PrefsKeys } from "./lib/Prefs/PrefsKeys.js"; const IBUS_SYSTEMD_SERVICE = "org.freedesktop.IBus.session.GNOME.service"; const UNKNOWN = { ON: 0, OFF: 1, DEFAULT: 2 }; const ASCIIMODES = ["en", "A", "英"]; @@ -91,7 +92,7 @@ const IBusOrientation = GObject.registerClass( CandidateArea.setOrientation.bind(CandidateArea); CandidateArea.setOrientation = () => {}; gsettings.bind( - Fields.ORIENTATION, + PrefsKeys.keys['candidate_orientation'].name, this, "orientation", Gio.SettingsBindFlags.GET, @@ -100,7 +101,7 @@ const IBusOrientation = GObject.registerClass( `changed::lookup-table-orientation`, () => { let value = IBusSettings.get_int("lookup-table-orientation"); - gsettings.set_uint(Fields.ORIENTATION, 1 - value); + gsettings.set_uint(PrefsKeys.keys['candidate_orientation'].name, 1 - value); }, ); } @@ -140,7 +141,7 @@ const IBusAnimation = GObject.registerClass( super(); this._openOrig = CandidatePopup.open; gsettings.bind( - Fields.CANDANIMATION, + PrefsKeys.keys['candidate_popup_animation'].name, this, "animation", Gio.SettingsBindFlags.GET, @@ -189,7 +190,7 @@ const IBusClickSwitch = GObject.registerClass( constructor() { super(); gsettings.bind( - Fields.CANDRIGHTFUNC, + PrefsKeys.keys['candidate-box-right-click-func'].name, this, "switchfunction", Gio.SettingsBindFlags.GET, @@ -300,7 +301,7 @@ const IBusScroll = GObject.registerClass( super(); gsettings.bind( - Fields.SCROLLMODE, + PrefsKeys.keys['candidate-scroll-mode'].name, this, "scrollmode", Gio.SettingsBindFlags.GET, @@ -372,13 +373,13 @@ const IBusNotFollowCaret = GObject.registerClass( CandidatePopup.setPosition(CandidateDummyCursor, 0); }; gsettings.bind( - Fields.CANDSTILLPOS, + PrefsKeys.keys['candidate-still-position'].name, this, "position", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.REMCANDPOS, + PrefsKeys.keys['remember-candidate-position'].name, this, "remember", Gio.SettingsBindFlags.GET, @@ -401,7 +402,7 @@ const IBusNotFollowCaret = GObject.registerClass( successGetRem = false; if (this._remember && !this._hasSetRember) { let state = new Map( - Object.entries(gsettings.get_value(Fields.CANDBOXPOS).deep_unpack()), + Object.entries(gsettings.get_value(PrefsKeys.keys['candidate-box-position'].name).deep_unpack()), ); if (state.has("x") && state.has("y")) { x = state.get("x"); @@ -480,22 +481,22 @@ const IBusFontSetting = GObject.registerClass( constructor() { super(); gsettings.bind( - Fields.CUSTOMFONT, + PrefsKeys.keys['custom-font'].name, this, "fontname", Gio.SettingsBindFlags.GET, ); this._fontChangeID = IBusSettings.connect( - `changed::${Fields.CUSTOMFONT}`, + `changed::${PrefsKeys.keys['custom-font'].name}`, () => { - let value = IBusSettings.get_string(Fields.CUSTOMFONT); - gsettings.set_string(Fields.CUSTOMFONT, value); + let value = IBusSettings.get_string(PrefsKeys.keys['custom-font'].name); + gsettings.set_string(PrefsKeys.keys['custom-font'].name, value); }, ); } set fontname(fontname) { - IBusSettings.set_string(Fields.CUSTOMFONT, fontname); + IBusSettings.set_string(PrefsKeys.keys['custom-font'].name, fontname); let scale = 15 / 16; // the fonts-size difference between index and candidate let desc = Pango.FontDescription.from_string(fontname); let get_weight = () => { @@ -688,7 +689,7 @@ const IBusOpacity = GObject.registerClass( this._child_opacity.push(candidate_child[i].get_opacity()); } gsettings.bind( - Fields.CANDOPACITY, + PrefsKeys.keys['candidate-opacity'].name, this, "opacity", Gio.SettingsBindFlags.GET, @@ -1090,13 +1091,13 @@ const IBusReposition = GObject.registerClass( this._location_handler = null; global.display.set_cursor(Meta.Cursor.DEFAULT); let state = new Map( - Object.entries(gsettings.get_value(Fields.CANDBOXPOS).deep_unpack()), + Object.entries(gsettings.get_value(PrefsKeys.keys['candidate-box-position'].name).deep_unpack()), ); let [boxX, boxY] = CandidateDummyCursor.get_position(); state.set("x", boxX); state.set("y", boxY); gsettings.set_value( - Fields.CANDBOXPOS, + PrefsKeys.keys['candidate-box-position'].name, new GLib.Variant("a{su}", Object.fromEntries(state)), ); return GLib.SOURCE_REMOVE; @@ -1145,7 +1146,7 @@ const IBusTrayClickSwitch = GObject.registerClass( constructor() { super(); gsettings.bind( - Fields.TRAYSSWITCHKEY, + PrefsKeys.keys['tray-source-switch-click-key'].name, this, "traysswitchkey", Gio.SettingsBindFlags.GET, @@ -1788,102 +1789,103 @@ const IBusInputSourceIndicator = GObject.registerClass( _bindSettings() { gsettings.bind( - Fields.INPUTINDTOG, + PrefsKeys.keys['input-indicator-only-on-toggle'].name, this, "inputindtog", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDASCII, + PrefsKeys.keys['input-indicator-only-use-ascii'].name, this, "inputindASCII", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDSINGLE, + PrefsKeys.keys['input-indicator-not-on-single-ime'].name, this, "inputindsingle", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDRIGC, + PrefsKeys.keys['input-indicator-right-close'].name, this, "inputindrigc", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDSCROLL, + PrefsKeys.keys['input-indicator-use-scroll'].name, this, "inputindscroll", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDANIM, + PrefsKeys.keys['input-indicator-animation'].name, this, "inputindanim", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDUSEF, + PrefsKeys.keys['use-indicator-custom-font'].name, this, "inputindusef", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDCUSTOMFONT, + PrefsKeys.keys['indicator-custom-font'].name, this, "fontname", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEINPUTINDLCLK, + PrefsKeys.keys['use-indicator-left-click'].name, this, "useinputindlclk", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDLCLICK, + PrefsKeys.keys['indicator-left-click-func'].name, this, "inputindlclick", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEINDOPACITY, + PrefsKeys.keys['use-indicator-auto-hide'].name, this, "useindopacity", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INDOPACITY, + PrefsKeys.keys['input-indicator-hide-time'].name, this, "indopacity", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEINDSHOWD, + PrefsKeys.keys['use-indicator-show-delay'].name, this, "useindshowd", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDSHOW, + PrefsKeys.keys['input-indicator-show-time'].name, this, "inputindshow", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEINDAUTOHID, + PrefsKeys.keys['use-indicator-auto-hide'].name, this, "useindautohid", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.INPUTINDHID, + PrefsKeys.keys['input-indicator-hide-time'].name, this, "inputindhid", Gio.SettingsBindFlags.GET, ); } + _destroy_indicator() { this.close(BoxPointer.PopupAnimation[this.animation]); @@ -2535,49 +2537,49 @@ const Extensions = GObject.registerClass( Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUIBUSEMOJI, + PrefsKeys.keys['menu-ibus-emoji'].name, this, "menuibusemoji", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUEXTPREF, + PrefsKeys.keys['menu-extensions-preference'].name, this, "menuextpref", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUIBUSPREF, + PrefsKeys.keys['menu-ibus-preference'].name, this, "menuibuspref", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUIBUSVER, + PrefsKeys.keys['menu-ibus-version'].name, this, "menuibusver", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUIBUSREST, + PrefsKeys.keys['menu-ibus-restart'].name, this, "menuibusrest", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.MENUIBUSEXIT, + PrefsKeys.keys['menu-ibus-exit'].name, this, "menuibusexit", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.IBUSRESTTIME, + PrefsKeys.keys['ibus-restart-time'].name, this, "ibusresttime", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEINPUTIND, + PrefsKeys.keys['use-input-indicator'].name, this, "useinputind", Gio.SettingsBindFlags.GET, @@ -2589,25 +2591,25 @@ const Extensions = GObject.registerClass( Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEREPOSITION, + PrefsKeys.keys['use-candidate-reposition'].name, this, "reposition", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.FIXIMELIST, + PrefsKeys.keys['fix-ime-list'].name, this, "fiximelist", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USETRAY, + PrefsKeys.keys['use-tray'].name, this, "usetray", Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USETRAYSSWITCH, + PrefsKeys.keys['use-tray-click-source-switch'].name, this, "usetraysswitch", Gio.SettingsBindFlags.GET, @@ -2625,7 +2627,7 @@ const Extensions = GObject.registerClass( Gio.SettingsBindFlags.GET, ); gsettings.bind( - Fields.USEBUTTONS, + PrefsKeys.keys['use-candidate-buttons'].name, this, "usebuttons", Gio.SettingsBindFlags.GET, @@ -2647,7 +2649,7 @@ const Extensions = GObject.registerClass( `changed::show-icon-on-systray`, () => { let value = IBusSettings.get_boolean("show-icon-on-systray"); - gsettings.set_boolean(Fields.USETRAY, value); + gsettings.set_boolean(PrefsKeys.keys['use-tray'].name, value); }, ); } diff --git a/customize-ibus@hollowman.ml/lib/API.js b/customize-ibus@hollowman.ml/lib/API.js new file mode 100644 index 0000000..e69de29 diff --git a/customize-ibus@hollowman.ml/lib/Manager.js b/customize-ibus@hollowman.ml/lib/Manager.js new file mode 100644 index 0000000..cad4710 --- /dev/null +++ b/customize-ibus@hollowman.ml/lib/Manager.js @@ -0,0 +1,443 @@ +/** + * Manager Library + */ + +/** + * Apply settings to the GNOME Shell + */ +export class Manager { + /** + * Current shell version + * + * @type {number|null} + */ + #shellVersion = null; + + /** + * Instance of Gio.Settings + * + * @type {Settings|null} + */ + #settings = null; + + /** + * Instance of IBusOrientation + * + * @type {IBusOrientation|null} + */ + #ibusOrientation = null; + + /** + * Class Constructor + * + * @param {Object} dependencies + * 'Settings' instance of Gio::Settings + * @param {number} shellVersion float in major.minor format + */ + constructor(dependencies, shellVersion) { + this.#settings = dependencies['Settings'] || null; + this.#shellVersion = shellVersion; + this.#ibusOrientation = new IBusOrientation(); + } + + /** + * register all signals for settings + * + * @returns {void} + */ + registerSettingsSignals() { + // this.#settings.connect('changed::candidate-orientation', () => { + // this.#applyCandidateOrientation(); + // }); + // this.#applyAutoSwitch(); + // }); + + // this.#settings.connect('changed::enable-custom-theme', () => { + // this.#applyCustomTheme(); + // }); + + // this.#settings.connect('changed::enable-custom-theme-dark', () => { + // this.#applyCustomThemeDark(); + // }); + + // this.#settings.connect('changed::use-candidate-opacity', () => { + // this.#applyCandidateOpacity(); + // }); + + // this.#settings.connect('changed::use-indicator-opacity', () => { + // this.#applyIndicatorOpacity(); + // }); + + // this.#settings.connect('changed::use-custom-bg', () => { + // this.#applyCustomBg(); + // }); + + // this.#settings.connect('changed::use-custom-bg-dark', () => { + // this.#applyCustomBgDark(); + // }); + + // this.#settings.connect('changed::enable-orientation', () => { + // this.#applyOrientation(); + // }); + + // this.#settings.connect('changed::custom-font', () => { + // this.#applyCustomFont(); + // }); + + // this.#settings.connect('changed::ascii-mode', () => { + // this.#applyAsciiMode(); + // }); + + // this.#settings.connect('changed::unkown-ascii-state', () => { + // this.#applyUnknownAsciiState(); + // }); + + // this.#settings.connect('changed::input-mode-list', () => { + // this.#applyInputModeList(); + // }); + + // this.#settings.connect('changed::custom-theme', () => { + // this.#applyCustomThemePath(); + // }); + + // this.#settings.connect('changed::custom-theme-dark', () => { + // this.#applyCustomThemeDarkPath(); + // }); + + // this.#settings.connect('changed::custom-bg', () => { + // this.#applyCustomBgPath(); + // }); + + // this.#settings.connect('changed::custom-bg-dark', () => { + // this.#applyCustomBgDarkPath(); + // }); + + // this.#settings.connect('changed::input-mode-remember', () => { + // this.#applyInputModeRemember(); + // }); + + // this.#settings.connect('changed::candidate-scroll-mode', () => { + // this.#applyCandidateScrollMode(); + // }); + + // this.#settings.connect('changed::menu-ibus-emoji', () => { + // this.#applyMenuIbusEmoji(); + // }); + + // this.#settings.connect('changed::menu-extension-preference', () => { + // this.#applyMenuExtensionPreference(); + // }); + + // this.#settings.connect('changed::menu-ibus-preference', () => { + // this.#applyMenuIbusPreference(); + // }); + + // this.#settings.connect('changed::menu-ibus-version', () => { + // this.#applyMenuIbusVersion(); + // }); + + // this.#settings.connect('changed::menu-ibus-restart', () => { + // this.#applyMenuIbusRestart(); + // }); + + // this.#settings.connect('changed::menu-ibus-exit', () => { + // this.#applyMenuIbusExit(); + // }); + + // this.#settings.connect('changed::use-input-indicator', () => { + // this.#applyInputIndicator(); + // }); + + // this.#settings.connect('changed::input-indicator-only-on-toggle', () => { + // this.#applyInputIndicatorOnlyOnToggle(); + // }); + + // this.#settings.connect('changed::input-indicator-only-use-ascii', () => { + // this.#applyInputIndicatorOnlyUseAscii(); + // }); + + // this.#settings.connect('changed::input-indicator-not-on-single-ime', () => { + // this.#applyInputIndicatorNotOnSingleIme(); + // }); + + // this.#settings.connect('changed::input-indicator-use-scroll', () => { + // this.#applyInputIndicatorUseScroll(); + // }); + + // this.#settings.connect('changed::input-indicator-animation', () => { + // this.#applyInputIndicatorAnimation(); + // }); + + // this.#settings.connect('changed::use-indicator-show-delay', () => { + // this.#applyIndicatorShowDelay(); + // }); + + // this.#settings.connect('changed::input-indicator-show-time', () => { + // this.#applyInputIndicatorShowTime(); + // }); + + // this.#settings.connect('changed::use-indicator-auto-hide', () => { + // this.#applyIndicatorAutoHide(); + // }); + + // this.#settings.connect('changed::input-indicator-hide-time', () => { + // this.#applyInputIndicatorHideTime(); + // }); + + // this.#settings.connect('changed::use-popup-animation', () => { + // this.#applyPopupAnimation(); + // }); + + // this.#settings.connect('changed::candidate-popup-animation', () => { + // this.#applyCandidatePopupAnimation(); + // }); + + // this.#settings.connect('changed::use-candidate-reposition', () => { + // this.#applyCandidateReposition(); + // }); + + // this.#settings.connect('changed::fix-ime-list', () => { + // this.#applyFixImeList(); + // }); + + // this.#settings.connect('changed::use-indicator-left-click', () => { + // this.#applyIndicatorLeftClick(); + // }); + + // this.#settings.connect('changed::indicator-left-click-func', () => { + // this.#applyIndicatorLeftClickFunc(); + // }); + + // this.#settings.connect('changed::input-indicator-right-close', () => { + // this.#applyIndicatorRightClickClose(); + // }); + + // this.#settings.connect('changed::use-indicator-custom-font', () => { + // this.#applyIndicatorCustomFont(); + // }); + + // this.#settings.connect('changed::indicator-custom-font', () => { + // this.#applyIndicatorCustomFontValue(); + // }); + + // this.#settings.connect('changed::use-tray', () => { + // this.#applyTrayIcon(); + // }); + + // this.#settings.connect('changed::use-tray-click-source-switch', () => { + // this.#applyTrayClickSourceSwitch(); + // }); + + // this.#settings.connect('changed::tray-source-switch-click-key', () => { + // this.#applyTraySourceSwitchClickKey(); + // }); + + // this.#settings.connect('changed::use-candidate-box-right-click', () => { + // this.#applyCandidateBoxRightClick(); + // }); + + // this.#settings.connect('changed::candidate-box-right-click-func', () => { + // this.#applyCandidateBoxRightClickFunc(); + // }); + + // this.#settings.connect('changed::use-candidate-still', () => { + // this.#applyCandidateStill(); + // }); + + // this.#settings.connect('changed::candidate-still-position', () => { + // this.#applyCandidateStillPosition(); + // }); + + // this.#settings.connect('changed::remember-candidate-position', () => { + // this.#applyRememberCandidatePosition(); + // }); + + // this.#settings.connect('changed::candidate-box-position', () => { + // this.#applyCandidateBoxPosition(); + // }); + } + + /** + * apply everything to the GNOME Shell + * + * @returns {void} + */ + applyAll() { + // this.#applyCandidateOrientation(); + } + // this.#applyAutoSwitch(false); + // this.#applyCustomTheme(false); + // this.#applyCustomThemeDark(false); + // this.#applyCandidateOpacity(false); + // this.#applyIndicatorOpacity(false); + // this.#applyCustomBg(false); + // this.#applyCustomBgDark(false); + // this.#applyOrientation(false); + // this.#applyCustomFont(false); + // this.#applyAsciiMode(false); + // this.#applyUnknownAsciiState(false); + // this.#applyInputModeList(false); + // this.#applyCustomThemePath(false); + // this.#applyCustomThemeDarkPath(false); + // this.#applyCustomBgPath(false); + // this.#applyCustomBgDarkPath(false); + // this.#applyInputModeRemember(false); + // this.#applyCandidateScrollMode(false); + // this.#applyMenuIbusEmoji(false); + // this.#applyMenuExtensionPreference(false); + // this.#applyMenuIbusPreference(false); + // this.#applyMenuIbusVersion(false); + // this.#applyMenuIbusRestart(false); + // this.#applyMenuIbusExit(false); + // this.#applyInputIndicator(false); + // this.#applyInputIndicatorOnlyOnToggle(false); + // this.#applyInputIndicatorOnlyUseAscii(false); + // this.#applyInputIndicatorNotOnSingleIme(false); + // this.#applyInputIndicatorUseScroll(false); + // this.#applyInputIndicatorAnimation(false); + // this.#applyIndicatorShowDelay(false); + // this.#applyInputIndicatorShowTime(false); + // this.#applyIndicatorAutoHide(false); + // this.#applyInputIndicatorHideTime(false); + // this.#applyPopupAnimation(false); + // this.#applyCandidatePopupAnimation(false); + // this.#applyCandidateReposition(false); + // this.#applyFixImeList(false); + // this.#applyIndicatorLeftClick(false); + // this.#applyIndicatorLeftClickFunc(false); + // this.#applyIndicatorRightClickClose(false); + // this.#applyIndicatorCustomFont(false); + // this.#applyIndicatorCustomFontValue(false); + // this.#applyTrayIcon(false); + // this.#applyTrayClickSourceSwitch(false); + // this.#applyTraySourceSwitchClickKey(false); + // this.#applyCandidateBoxRightClick(false); + // this.#applyCandidateBoxRightClickFunc(false); + // this.#applyCandidateStill(false); + // this.#applyCandidateStillPosition(false); + // this.#applyRememberCandidatePosition(false); + // this.#applyCandidateBoxPosition(false); + + + /** + * revert everything done by this class to the GNOME Shell + * + * @returns {void} + */ + revertAll() { + // this.#applyCandidateOrientation(true); + } + // this.#applyAutoSwitch(true); + // this.#applyCustomTheme(true); + // this.#applyCustomThemeDark(true); + // this.#applyCandidateOpacity(true); + // this.#applyIndicatorOpacity(true); + // this.#applyCustomBg(true); + // this.#applyCustomBgDark(true); + // this.#applyOrientation(true); + // this.#applyCustomFont(true); + // this.#applyAsciiMode(true); + // this.#applyUnknownAsciiState(true); + // this.#applyInputModeList(true); + // this.#applyCustomThemePath(true); + // this.#applyCustomThemeDarkPath(true); + // this.#applyCustomBgPath(true); + // this.#applyCustomBgDarkPath(true); + // this.#applyInputModeRemember(true); + // this.#applyCandidateScrollMode(true); + // this.#applyMenuIbusEmoji(true); + // this.#applyMenuExtensionPreference(true); + // this.#applyMenuIbusPreference(true); + // this.#applyMenuIbusVersion(true); + // this.#applyMenuIbusRestart(true); + // this.#applyMenuIbusExit(true); + // this.#applyInputIndicator(true); + // this.#applyInputIndicatorOnlyOnToggle(true); + // this.#applyInputIndicatorOnlyUseAscii(true); + // this.#applyInputIndicatorNotOnSingleIme(true); + // this.#applyInputIndicatorUseScroll(true); + // this.#applyInputIndicatorAnimation(true); + // this.#applyIndicatorShowDelay(true); + // this.#applyInputIndicatorShowTime(true); + // this.#applyIndicatorAutoHide(true); + // this.#applyInputIndicatorHideTime(true); + // this.#applyPopupAnimation(true); + // this.#applyCandidatePopupAnimation(true); + // this.#applyCandidateReposition(true); + // this.#applyFixImeList(true); + // this.#applyIndicatorLeftClick(true); + // this.#applyIndicatorLeftClickFunc(true); + // this.#applyIndicatorRightClickClose(true); + // this.#applyIndicatorCustomFont(true); + // this.#applyIndicatorCustomFontValue(true); + // this.#applyTrayIcon(true); + // this.#applyTrayClickSourceSwitch(true); + // this.#applyTraySourceSwitchClickKey(true); + // this.#applyCandidateBoxRightClick(true); + // this.#applyCandidateBoxRightClickFunc(true); + // this.#applyCandidateStill(true); + // this.#applyCandidateStillPosition(true); + // this.#applyRememberCandidatePosition(true); + // this.#applyCandidateBoxPosition(true); + +// /** +// * apply candidate orientation settings +// * +// * @param {boolean} forceOriginal force original shell setting +// * +// * @returns {void} +// */ +// #applyCandidateOrientation(forceOriginal = false) { +// let orientation = this.#settings.get_int('candidate-orientation'); +// if (forceOriginal) { +// this.#ibusOrientation.orientation = 1 - orientation; +// } else { +// this.#ibusOrientation.orientation = orientation; +// } +// } + /** + * Export current settings to a file + * + * @returns {void} + */ + exportCurrentSettings() { + const SCHEMA_PATH = "your.schema.path"; // replace with your actual schema path + + const fileChooser = new Gtk.FileChooserDialog({ + title: _("Export Current Settings"), + action: Gtk.FileChooserAction.SAVE, + }); + fileChooser.add_button(_("Cancel"), Gtk.ResponseType.CANCEL); + fileChooser.add_button(_("Save"), Gtk.ResponseType.OK); + + fileChooser.set_current_name("settings.ini"); + fileChooser.set_do_overwrite_confirmation(true); + + const filter = new Gtk.FileFilter(); + filter.add_pattern("*.ini"); + filter.set_name("INI files"); + fileChooser.add_filter(filter); + + fileChooser.connect("response", (dialog, response) => { + if (response === Gtk.ResponseType.OK) { + let filename = dialog.get_filename(); + if (!filename.ends_with(".ini")) { + filename += ".ini"; + } + let file = Gio.file_new_for_path(filename); + let raw = file.replace(null, false, Gio.FileCreateFlags.NONE, null); + let out = Gio.BufferedOutputStream.new_sized(raw, 4096); + + out.write_all( + GLib.spawn_command_line_sync(`dconf dump ${SCHEMA_PATH}`)[1], + null + ); + out.close(null); + } + dialog.destroy(); + }); + + fileChooser.show(); + } +} + diff --git a/customize-ibus@hollowman.ml/lib/Prefs/Prefs.js b/customize-ibus@hollowman.ml/lib/Prefs/Prefs.js new file mode 100644 index 0000000..b65ab12 --- /dev/null +++ b/customize-ibus@hollowman.ml/lib/Prefs/Prefs.js @@ -0,0 +1,590 @@ +/** + * Prefs Library + * + * @author Hollowman + * @copyright 2020-2024 + */ + +const { Gio, GLib } = imports.gi; +import Gtk from 'gi://Gtk?version=4.0'; +import GObject from "gi://GObject"; +import { PrefsKeys } from "./PrefsKeys.js"; +import { Fields } from "../../fields.js"; +const { _ } = imports.gettext; + + + +export class Prefs { + #shellVersion = null; + #prefsKeys = null; + #builder = null; + #settings = null; + #gdk = null; + #dependencies = null; + #profiles = [ + 'default', + 'minimal', + 'superminimal', + ]; + + constructor(dependencies, prefsKeys, shellVersion) { + this.#settings = dependencies['Settings'] || null; + this.#builder = dependencies['Builder'] || null; + this.#gdk = dependencies['Gdk'] || null; + this.#prefsKeys = prefsKeys; + this.#shellVersion = shellVersion; + this.#dependencies = dependencies; + } + + fillPrefsWindow(window, UIFolderPath, gettextDomain) { + let uiFilenames = [ + 'general', + 'tray', + 'indicator', + 'theme', + 'background', + 'settings', + 'about' + ]; + + this.#builder.set_translation_domain(gettextDomain); + for (let uiFilename of uiFilenames) { + try { + console.debug(`Loading UI file: ${UIFolderPath}/adw/${uiFilename}.ui`); + this.#builder.add_from_file(`${UIFolderPath}/adw/${uiFilename}.ui`); + } catch (error) { + console.error(`Failed to load UI file: ${UIFolderPath}/adw/${uiFilename}.ui`, error); + } + } + + for (let uiFilename of uiFilenames) { + try { + let page = this.#builder.get_object(uiFilename); + if (page) { + window.add(page); + } else { + console.error(`UI object for ${uiFilename} not found in the loaded builder.`); + } + } catch (error) { + console.error(`Failed to get UI object for: ${uiFilename}`, error); + } + } + + this.#setValues(); + this.#guessProfile(); + // this.#onlyShowSupportedRows(); + this.#registerAllSignals(window); + + this.#setWindowSize(window); + this.#updateIBusVersion(); + + window.search_enabled = true; + } + + #setWindowSize(window) { + let [pmWidth, pmHeight, pmScale] = this.#getPrimaryMonitorInfo(); + let sizeTolerance = 50; + let width = 800; + let height = 800; + + if ((pmWidth / pmScale) - sizeTolerance >= width && + (pmHeight / pmScale) - sizeTolerance >= height) { + window.set_default_size(width, height); + } + } + + #getPrimaryMonitorInfo() { + let display = this.#gdk.Display.get_default(); + let pm = display.get_monitors().get_item(0); + + if (!pm) { + return [700, 500, 1]; + } + + let geo = pm.get_geometry(); + let scale = pm.get_scale_factor(); + + return [geo.width, geo.height, scale]; + } + + #registerAllSignals(window) { + this.#registerKeySignals(); + this.#registerProfileSignals(); + } + + #registerKeySignals() { + for (let [_, key] of Object.entries(this.#prefsKeys.keys)) { + let widgetId = key.widgetId; + let widget = this.#builder.get_object(widgetId); + + if (!widget) { + console.error(`Widget with ID ${widgetId} not found for widgetType ${key.widgetType}.`); + continue; + } + + switch (key.widgetType) { + case 'AdwComboRow': + widget.connect('notify::selected', (w) => { + let val = w.get_selected(); + this.#settings.set_int(key.name, val); + this.#guessProfile(); + }); + break; + case 'AdwSwitchRow': + widget.connect('notify::active', (w) => { + try { + this.#settings.set_boolean(key.name, w.get_active()); + } catch (error) { + console.error(`Error setting boolean for ${key.name}:`, error); + } + this.#handleSwitchRow(widget, key.widgetId); + }); + break; + case 'AdwSlider': + widget.connect('notify::value', (w) => { + this.#settings.set_int(key.name, w.get_value()); + this.#guessProfile(); + }); + break; + case 'GtkAdjustment': + widget.connect('value-changed', (w) => { + this.#settings.set_int(key.name, w.get_value()); + this.#guessProfile(); + }); + break; + case 'GtkFileChooserButton': + widget.connect('file-set', (w) => { + this.#settings.set_string(key.name, w.get_filename()); + this.#guessProfile(); + }); + break; + case 'AdwPreferencesRow': + let fontButton = this.#builder.get_object('custom_font_button'); + if (fontButton) { + fontButton.connect('font-set', (w) => { + this.#settings.set_string(key.name, w.get_font()); + }); + } else { + console.error('Font button with ID custom_font_button not found.'); + } + break; + case 'AdwActionRow': + let scale = this.#builder.get_object('candidate_box_opacity_scale'); + if (scale) { + scale.connect('value-changed', (w) => { + this.#settings.set_int(key.name, w.get_value()); + }); + } else { + console.error('Scale with ID candidate_box_opacity_scale not found.'); + } + break; + case 'GtkButton': + widget.connect('clicked', (w) => { + this.#handleButtonClicked(widget, key.widgetId); + }); + break; + case 'GtkCheckButton': + widget.connect('toggled', (w) => { + let target = this.#builder.get_object('candidate_box_opacity_label'); + target.set_sensitive(false); + }); + break; + default: + console.error(`Unhandled widgetType ${key.widgetType} for widgetId ${widgetId}.`); + break; + } + } + } + + #registerProfileSignals() { + for (let profile of this.#profiles) { + let widget = this.#builder.get_object(`profile_${profile}`); + if (!widget) { + break; + } + widget.connect('clicked', (w) => { + this.#setValues(profile); + }); + } + } + + #guessProfile() { + let totalCount = 0; + let matchCount = {}; + + for (let profile of this.#profiles) { + matchCount[profile] = 0; + } + + for (let [_, key] of Object.entries(this.#prefsKeys.keys)) { + if (!key.supported) { + continue; + } + + let value; + + try { + switch (key.widgetType) { + case 'AdwSwitchRow': + value = this.#builder.get_object(key.widgetId)?.get_active(); + break; + case 'AdwComboRow': + value = this.#builder.get_object(key.widgetId)?.get_selected(); + break; + case 'GtkButton': + value = this.#builder.get_object(key.widgetId)?.get_label(); + break; + case 'AdwSlider': + value = this.#builder.get_object(key.widgetId)?.get_value(); + break; + case 'GtkCheckButton': + value = this.#builder.get_object(key.widgetId)?.get_active(); + break; + case 'GtkScale': + value = this.#builder.get_object(key.widgetId)?.get_value(); + break; + case 'GtkAdjustment': + value = this.#builder.get_object(key.widgetId)?.get_value(); + break; + case 'AdwPreferencesRow': + value = this.#builder.get_object(key.widgetId)?.get_font(); + break; + case 'GtkFontButton': + value = this.#builder.get_object(key.widgetId)?.get_font(); + break; + case 'GtkFileChooserButton': + value = this.#builder.get_object(key.widgetId)?.get_filename(); + break; + default: + value = ''; + continue; + } + } catch (error) { + console.error(`Error getting object for widget ID ${key.widgetId}:`, error); + value = ''; + } + + for (let profile of this.#profiles) { + if (key.profiles[profile] === value) { + matchCount[profile]++; + } + } + + totalCount++; + } + + // Additional logging to verify matchCount + console.debug(`Match count:`, matchCount); + + let currentProfile = 'custom'; + for (let profile of this.#profiles) { + if (matchCount[profile] === totalCount) { + currentProfile = profile; + break; + } + } + + let widget = this.#builder.get_object(`profile_${currentProfile}`); + if (widget) { + widget.set_active(true); + } else { + console.error(`Profile widget for ${currentProfile} not found.`); + } + } + + #setValues(profile) { + for (let [, key] of Object.entries(this.#prefsKeys.keys)) { + let widget = this.#builder.get_object(key.widgetId); + if (!widget) { + console.error(`Widget with ID ${key.widgetId} not found`); + continue; + } + + switch (key.widgetType) { + case 'AdwSwitchRow': + try { + this.#settings.bind( + key.name, + widget, + 'active', + Gio.SettingsBindFlags.DEFAULT + ); + } catch (error) { + console.error(`Error binding boolean for ${key.name}:`, error); + } + break; + + case 'AdwComboRow': + this.#settings.bind( + key.name, + widget, + 'selected', + Gio.SettingsBindFlags.DEFAULT + ); + break; + + // case 'AdwPreferencesRow': + // this.#settings.bind( + // key.name, + // widget, + // '', + // Gio.SettingsBindFlags.DEFAULT, + // ); + // break; + + case 'GtkFontButton': + this.#settings.bind( + key.name, + widget, + 'font', + Gio.SettingsBindFlags.DEFAULT, + ); + break; + + case 'GtkAdjustment': + this.#settings.bind( + key.name, + widget, + 'value', + Gio.SettingsBindFlags.DEFAULT, + ); + break; + + case 'GtkCheckButton': + try{ + let checkValue = (profile) ? key.profiles[profile] : this.#settings.get_boolean(key.name); + widget.set_active(checkValue); + } catch (error) { + console.error(`Error getting boolean for ${key.name}:`, error); + } + let targetWidget = this.#builder.get_object(key.widgetId).get_parent(); + if (targetWidget) { + targetWidget.set_visible(widget.get_active()); + targetWidget.set_sensitive(widget.get_active()); + } + break; + + case 'GtkComboBoxText': + let comboValue = (profile) ? key.profiles[profile] : this.#settings.get_string(key.name); + widget.set_active_id(comboValue); + break; + + case 'GtkButton': + break; + } + } + } + + #onlyShowActiveRows() { + + } + + #handleSwitchRow(widget, Id) { + switch (Id.toString()) { + case 'candidate_box_opacity_switch_row': + let target = this.#builder.get_object('candidate_box_opacity_row'); + target.set_visible(widget.get_active()); + break; + default: + break; + } + } + + #handleButtonClicked(widget, Id) { + switch (Id) { + case 'custom_theme_dark_button': + this.#selectFile(widget); + break; + case 'gnome_settings_button': + this.#applySettings(widget); + break; + case 'ibus_preferences_button': + this.#openIBusPreferences(); + break + case 'start_restart_button': + this.#restartIbus(); + break; + case 'import_settings_from_file_button': + this.#importSettings(widget); + break; + case 'export_current_settings_button': + this.#exportSettings(widget); + break; + case 'restore_default_settings_button': + this.#resetSettings(); + default: + widget.set_label('Not Implemented'); + break; + } + } + + #showFileChooser(title, action, acceptBtn, acceptHandler, setDefaultName, widget) { + let iniFilter = new Gtk.FileFilter(); + iniFilter.set_name("INI files"); + iniFilter.add_mime_type("application/x-ini"); + iniFilter.add_pattern("*.ini"); + + let dialog = new Gtk.FileChooserNative({ + title: title, + action: action, + transient_for: this.#builder.get_object('window'), + accept_label: acceptBtn, + cancel_label: "Cancel" + }); + + if (setDefaultName) + dialog.set_current_name( + "Customize_IBus_Settings_" + new Date().getTime().toString() + ".ini", + ); + + dialog.add_filter(iniFilter); + + dialog.connect("response", (d, id) => { + if (id !== Gtk.ResponseType.ACCEPT) { + d.destroy(); + return; + } + acceptHandler.call(this, d.get_file().get_path()); + d.destroy(); + }); + + dialog.show(); + + + } + + #exportSettings(widget) { + this.#showFileChooser( + "Export Current Settings", + Gtk.FileChooserAction.SAVE, + "Save", + (filename) => { + if (!filename.endsWith(".ini")) filename += ".ini"; + let file = Gio.file_new_for_path(filename); + let raw = file.replace(null, false, Gio.FileCreateFlags.NONE, null); + let out = Gio.BufferedOutputStream.new_sized(raw, 4096); + + out.write_all( + GLib.spawn_command_line_sync("dconf dump " + SCHEMA_PATH)[1], + null, + ); + out.close(null); + }, + true, + widget, + ); + } + + #importSettings(widget) { + + this.#showFileChooser( + "Import Settings from File", + Gtk.FileChooserAction.OPEN, + "Open", + (filename) => { + if (filename && GLib.file_test(filename, GLib.FileTest.EXISTS)) { + let settingsFile = Gio.File.new_for_path(filename); + let [, , stdin, stdout, stderr] = GLib.spawn_async_with_pipes( + null, + ["dconf", "load", SCHEMA_PATH], + null, + GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, + null, + ); + + stdin = new Gio.UnixOutputStream({ fd: stdin, close_fd: true }); + GLib.close(stdout); + GLib.close(stderr); + + stdin.splice( + settingsFile.read(null), + Gio.OutputStreamSpliceFlags.CLOSE_SOURCE | + Gio.OutputStreamSpliceFlags.CLOSE_TARGET, + null, + ); + } + }, + false, + widget, + ); + } + + #applySettings(widget) { + GLib.spawn_command_line_async("gnome-control-center keyboard"); + } + + #resetSettings() { + this.#setValues(); + this.#resetExtension(); + } + + #resetExtension() { + let dialog = new Gtk.MessageDialog({ + title: "Reset to Default", + text: "Reset all settings to default?", + buttons: Gtk.ButtonsType.OK_CANCEL, + transient_for: this.#builder.get_object('window'), + }); + + dialog.connect("response", (d, id) => { + if (id === Gtk.ResponseType.OK) { + this.#setValues(); + } + d.destroy(); + } + ); + dialog.show(); + } + + #restartIbus() { + this.gsettings.set_string( + PrefsKeys.keys["ibus-restart-time"].name, + new Date().getTime().toString(), + ); + this.#updateIBusVersion(); + } + + #updateIBusVersion() { + let widget = this.#builder.get_object("tray_group"); + let result = GLib.spawn_command_line_sync("ibus version"); + let version = result[1].toString().trim(); + widget.set_title(`IBus version: ${version}`); + } + + + #selectFile(widget) { + widget.set_label('File selected23'); + + let dialog; + try { + dialog = new Gtk.FileChooserDialog({ + title: 'Select a file', + action: Gtk.FileChooserAction.OPEN, + transient_for: widget.get_toplevel(), + modal: true, + buttons: [ + { label: 'Cancel', action: Gtk.ResponseType.CANCEL }, + { label: 'Open', action: Gtk.ResponseType.OK }, + ], + }); + widget.set_label('File selected20'); + } catch (e) { + widget.set_label('File selected1'); + console.error('Error creating dialog:', e); + return; + } + + + widget.set_label('File selected29'); + + dialog.set_transient_for(widget.get_toplevel()); + + console.log('Step 3: Running dialog'); + dialog.run(); + } + + #openIBusPreferences() { + GLib.spawn_command_line_async("ibus-setup"); + } + +} \ No newline at end of file diff --git a/customize-ibus@hollowman.ml/lib/Prefs/PrefsKeys.js b/customize-ibus@hollowman.ml/lib/Prefs/PrefsKeys.js new file mode 100644 index 0000000..1e176bf --- /dev/null +++ b/customize-ibus@hollowman.ml/lib/Prefs/PrefsKeys.js @@ -0,0 +1,776 @@ +/** + * PrefsKeys Library + * + * @author Hollowman + * @copyright 2020-2024 + */ + +/** + * prefs keys + */ +export class PrefsKeys { + /** + * Current shell version + * + * @type {number|null} + */ + #shellVersion = null; + + constructor(shellVersion) { + this.#shellVersion = shellVersion; + + /** + * holds all keys generated by this.#setKey() + * + * @member {Object} + */ + this.keys = {}; + + this.#setDefaults(); + } + + #setDefaults() { + // General Settings + this.#setKey( + 'general', + 'candidate-orientation', + 'AdwComboRow', + true, + { + default: 0, + minimal: 1, + superminimal: 1 + }, + { + 0: 'vertical', + 1: 'horizontal' + } + ); + + + + this.#setKey( + 'general', + 'candidate-popup-animation', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + { + 0: 'none', + 1: 'slide', + 2: 'fade', + 3: 'all' + } + ); + + this.#setKey( + 'general', + 'candidate-box-right-click-func', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + { + 0: 'open-menu', + 1: 'switch-source' + } + ); + + this.#setKey( + 'general', + 'candidate-scroll-mode', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + { + 0: 'change-page', + 1: 'change-candidate' + } + ); + + this.#setKey( + 'general', + 'remember-candidate-position', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + { + 0: 'remember-last-position', + 1: 'dont-remember-position' + } + ); + + this.#setKey( + 'general', + 'candidate-still-position', + 'AdwComboRow', + true, + { + default: this._position, + minimal: 0, + superminimal: 0 + }, + { + 0: 'center', + 1: 'center-left', + 2: 'top-left', + 3: 'top-center', + 4: 'top-right', + 5: 'center-right', + 6: 'bottom-right', + 7: 'bottom-center', + 8: 'bottom-left' + } + ); + + this.#setKey( + 'general', + 'use-custom-font', + 'AdwPreferencesRow', + true, + { + default: 'Sans Regular 16', + minimal: 'Sans Regular 16', + superminimal: 'Sans Regular 16' + } + ); + + this.#setKey( + 'general', + 'ascii-mode', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off', + } + ); + + this.#setKey( + 'general', + 'candidate-opacity', + 'GtkAdjustment', + true, + { + default: 120, + minimal: 1, + superminimal: 1 + }, + { + lower: 1, + upper: 255, + step_increment: 1, + value: 120 + } + ); + + this.#setKey( + 'general', + 'fix-ime-list', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off' + } + ); + + this.#setKey( + 'general', + 'use-candidate-reposition', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off' + } + ); + + this.#setKey( + 'general', + 'use-candidate-buttons', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off' + } + ); + + // Indicator Settings + this.#setKey( + 'indicator', + 'use-input-indicator', + 'AdwSwitchRow', + true, + { + default: true, + minimal: false, + superminimal: false + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-only-on-toggle', + 'AdwSwitchRow', + true, + { + default: true, + minimal: false, + superminimal: false + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-only-use-ascii', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: true + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-not-on-single-ime', + 'AdwSwitchRow', + true, + { + default: true, + minimal: false, + superminimal: true + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-right-close', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: true + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-use-scroll', + 'AdwSwitchRow', + true, + { + default: false, + minimal: true, + superminimal: false + } + ); + + this.#setKey( + 'indicator', + 'input-indicator-animation', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + { + 0: 'none', + 1: 'slide', + 2: 'fade', + 3: 'all' + } + ); + +// this.#setKey( +// 'indicator', +// 'use-indicator-custom-font', +// 'AdwPreferencesRow', +// true, +// { +// default: 0, +// minimal: 0, +// superminimal: 0 +// }, +// { +// 0: 'Sans Regular 16', +// 1: 'Sans Bold 18', +// 2: 'Sans Italic 14' +// } +// ); + +// this.#setKey( +// 'indicator', +// 'use-indicator-left-click', +// 'AdwComboRow', +// true, +// { +// default: 0, +// minimal: 0, +// superminimal: 0 +// }, +// { +// 0: 'drag-to-move', +// 1: 'switch-source' +// } +// ); + +// this.#setKey( +// 'indicator', +// 'indicator-opacity', +// 'GtkScale', +// true, +// { +// default: 255, +// minimal: 200, +// superminimal: 150 +// } +// ); + +// this.#setKey( +// 'indicator', +// 'use-indicator-show-delay', +// 'GtkScale', +// true, +// { +// default: false, +// minimal: true, +// superminimal: false +// } +// ); + +// this.#setKey( +// 'indicator', +// 'input-indicator-show-time', +// 'AdwSlider', +// true, +// { +// default: 1, +// minimal: 2, +// superminimal: 3 +// } +// ); + +// // this.#setKey( +// // 'indicator', +// // 'use-indicator-auto-hide', +// // 'AdwSwitchRow', +// // true, +// // { +// // default: true, +// // minimal: false, +// // superminimal: true +// // } +// // ); + +// // this.#setKey( +// // 'indicator', +// // 'input-indicator-hide-time', +// // 'AdwSlider', +// // true, +// // { +// // default: 1, +// // minimal: 2, +// // superminimal: 3 +// // } +// // ); + + // Tray Settings + this.#setKey( + 'tray', + 'use-tray', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off' + } + ); + + this.#setKey( + 'tray', + 'use-tray-click-source-switch', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + }, + { + true: 'on', + false: 'off' + } + ); + + this.#setKey( + 'tray', + 'tray-source-switch-click-key', + 'AdwComboRow', + true, + { + default: 0, + minimal: 0, + superminimal: 0 + }, + ); + + + this.#setKey( + 'tray', + 'menu-ibus-emoji', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + } + ); + + this.#setKey( + 'tray', + 'menu-extension-preference', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + } + ); + + this.#setKey( + 'tray', + 'menu-ibus-preference', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + } + ); + + this.#setKey( + 'tray', + 'menu-ibus-version', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + } + ); + + // this.#setKey( + // 'tray', + // 'start-restart', + // 'GtkButton', + // true, + // { + // default: false, + // minimal: false, + // superminimal: false + // } + // ); + + this.#setKey( + 'tray', + 'menu-ibus-exit', + 'AdwSwitchRow', + true, + { + default: false, + minimal: false, + superminimal: false + } + ); + +// // Theme Settings +// this.#setKey( +// 'theme', +// 'custom-theme', +// 'GtkCheckButton', +// true, +// { +// default: false, +// minimal: false, +// superminimal: false +// } +// ); + +// this.#setKey( +// 'theme', +// 'custom-theme-dark', +// 'GtkCheckButton', +// true, +// { +// default: false, +// minimal: false, +// superminimal: false +// } +// ); + +// // Background Settings +// this.#setKey( +// 'background', +// 'custom-bg', +// 'GtkCheckButton', +// true, +// { +// default: false, +// minimal: false, +// superminimal: false +// } +// ); + +// this.#setKey( +// 'background', +// 'custom-bg-f', +// 'AdwPreferencesRow', +// true, +// { +// default: false, +// minimal: false, +// superminimal: false +// } +// ); + + // Settings + this.#setKey( + 'settings', + 'restore-default-settings', + 'GtkButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'settings', + 'export-current-settings', + 'GtkButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'settings', + 'import-settings-from-file', + 'GtkButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'settings', + 'gnome-settings', + 'GtkButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'settings', + 'ibus-preferences', + 'GtkButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'candidate-box-opacity-switch', + 'AdwSwitchRow', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'candidate-box-opacity', + 'AdwPreferencesRow', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'candidate-box-opacity', + 'GtkCheckButton', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'container-box-opacity', + 'GtkBox', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'candidate-box-opacity', + 'GtkScale', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + + this.#setKey( + 'general', + 'candidate-box-opacity', + 'GtkLabel', + true, + { + default: '', + minimal: '', + superminimal: '' + } + ); + +// this.#setKey( +// 'settings', +// 'menu-ibus-preference', +// 'AdwActionRow', +// true, +// { +// default: '', +// minimal: '', +// superminimal: '' +// } +// ); + this.#setKey( + 'theme', + 'custom-theme-dark', + 'GtkButton', + true, + { + default: 'None', + minimal: 'None', + superminimal: 'None' + } + ); + } + + #setKey(category, name, widgetType, supported, profiles, maps = {}) { + let id = name.replace(/-/g, '_'); + let widgetName = widgetType.toLowerCase().replace('adw', '').replace('gtk', ''); + let widgetId = `${id}_${widgetName}`; + + if (widgetType === 'AdwActionRow' || widgetType === 'AdwComboRow' || widgetType === 'AdwPreferencesRow' || widgetType === 'AdwSwitchRow') { + widgetId = `${id}_row`; + } + + console.log(`生成的widgetId: ${widgetId}, 对应的name: ${name}, widgetType: ${widgetType}`); + + this.keys[id] = { + category, + widgetType, + name, + id, + widgetId, + supported, + profiles, + maps + }; + + return this.keys[id]; + } + + deleteKey(id) { + delete this.keys[id]; + } +} + +export function getPrefsKeys(shellVersion) { + return new PrefsKeys(shellVersion); +} diff --git a/customize-ibus@hollowman.ml/metadata.json b/customize-ibus@hollowman.ml/metadata.json index eaef434..37eb7a7 100644 --- a/customize-ibus@hollowman.ml/metadata.json +++ b/customize-ibus@hollowman.ml/metadata.json @@ -1,15 +1,20 @@ { + "_generated": "Generated by SweetTooth, do not edit", "description": "Full customization of appearance, behavior, system tray and input source indicator for IBus\n\nSupport Customization of:\n* Candidate Box Orientation\n* Candidate Box Animation\n* Right-click Candidate Box to Switch the Input Mode or Open the Tray Menu\n* Scroll on Candidate Box to Switch among Pages or Candidates\n* Fix Candidate Box to Not Follow the Caret and Set Fixed Position\n* Candidate Box Font\n* Input Mode Remember and Auto-switch by APP\n* Change Candidate Box Opacity\n* Fix IME List Order\n* Drag Candidate Box to Reposition\n* Show or Hide Candidate Box Page Buttons\n* System Tray Menus and Interaction Settings\n* * Show or Hide Tray Icon\n* * Directly Click Tray Icon to Switch Input Mode\n* * Add Additional Menu\n* Input Source Indicator Appearance and Interaction Settings\n* * Enable Indicator\n* * Only Indicate when Switching Input Mode\n* * Only Indicate when Using ASCII Input Mode\n* * Not Indicate when Using Single Mode IME\n* * Right-click Indicator to Hide\n* * Scroll on Indicator to Switch Input Mode\n* * Indicator Animation\n* * Customize Font\n* * Left-click Indicator to Drag to Move Indicator or Switch Input Mode\n* * Change Opacity\n* * Enable Indicator Show Delay and Configure Showing Timeout\n* * Enable Auto-hide Indicator and Configure Auto-hide Timeout\n* Theme (Stylesheet Provided or Extracted from GNOME Shell Themes, Refer to Help Instructions in Extension for More)\n* Candidate Box Background and its Displaying Style\n* Theme and Background Picture Follow GNOME Night Light Mode\n\nUser Guide: https://hollowmansblog.wordpress.com/2021/08/21/customize-ibus-user-guide/\n\n\u6df1\u5ea6\u5b9a\u5236 IBus \u7684\u5916\u89c2\u3001\u884c\u4e3a\u3001\u7cfb\u7edf\u6258\u76d8\u4ee5\u53ca\u8f93\u5165\u6307\u793a\n\n\u652f\u6301\u81ea\u5b9a\u4e49\uff1a\n* \u5019\u9009\u6846\u65b9\u5411\n* \u5019\u9009\u6846\u52a8\u753b\n* \u53f3\u952e\u5355\u51fb\u5019\u9009\u6846\u4ee5\u5207\u6362\u8f93\u5165\u6e90\u6216\u6253\u5f00\u4efb\u52a1\u680f\u83dc\u5355\n* \u5019\u9009\u6846\u4e0a\u6eda\u52a8\u4ee5\u5207\u6362\u9875\u9762\u6216\u5019\u9009\u8bcd\n* \u56fa\u5b9a\u5019\u9009\u6846\u4f7f\u5176\u4e0d\u8ddf\u968f\u5149\u6807\u4ee5\u53ca\u8bbe\u5b9a\u56fa\u5b9a\u4f4d\u7f6e\n* \u5019\u9009\u6846\u5b57\u4f53\n* \u8f93\u5165\u6a21\u5f0f\u6839\u636e\u5e94\u7528\u8bb0\u5fc6\u5e76\u81ea\u52a8\u5207\u6362\n* \u66f4\u6539\u5019\u9009\u6846\u900f\u660e\u5ea6\n* \u56fa\u5b9a\u8f93\u5165\u6cd5\u5217\u8868\u987a\u5e8f\n* \u62d6\u62fd\u79fb\u52a8\u5019\u9009\u6846\n* \u663e\u793a\u6216\u9690\u85cf\u5019\u9009\u6846\u8c03\u9875\u6309\u94ae\n* \u7cfb\u7edf\u4efb\u52a1\u680f\u6258\u76d8\u663e\u793a\u548c\u4ea4\u4e92\u8bbe\u7f6e\n* * \u663e\u793a\u6216\u9690\u85cf\u6258\u76d8\u56fe\u6807\n* * \u76f4\u63a5\u70b9\u51fb\u6258\u76d8\u56fe\u6807\u5207\u6362\u8f93\u5165\u6e90\n* * \u6dfb\u52a0\u989d\u5916\u83dc\u5355\n* \u8f93\u5165\u6e90\u6307\u793a\u5668\u53ca\u5176\u663e\u793a\u548c\u4ea4\u4e92\u8bbe\u7f6e\n* * \u542f\u7528\u6307\u793a\u5668\n* * \u4ec5\u5728\u5207\u6362\u8f93\u5165\u6cd5\u65f6\u6307\u793a\n* * \u4ec5\u5728\u82f1\u6587\u8f93\u5165\u65f6\u6307\u793a\n* * \u4f7f\u7528\u5355\u6a21\u5f0f\u8f93\u5165\u6cd5\u65f6\u4e0d\u6307\u793a\n* * \u53f3\u51fb\u6307\u793a\u5668\u6765\u5c06\u5176\u9690\u85cf\n* * \u6307\u793a\u5668\u4e0a\u6eda\u52a8\u6765\u5207\u6362\u8f93\u5165\u6e90\n* * \u6307\u793a\u5668\u663e\u793a\u52a8\u753b\n* * \u81ea\u5b9a\u4e49\u5b57\u4f53\n* * \u5de6\u51fb\u6307\u793a\u5668\u4ee5\u62d6\u62fd\u79fb\u52a8\u6216\u8005\u5207\u6362\u8f93\u5165\u6e90\n* * \u66f4\u6539\u900f\u660e\u5ea6\n* * \u542f\u7528\u5ef6\u65f6\u663e\u793a\u4ee5\u53ca\u914d\u7f6e\u663e\u793a\u65f6\u5ef6\n* * \u542f\u7528\u81ea\u52a8\u9690\u85cf\u4ee5\u53ca\u914d\u7f6e\u81ea\u52a8\u9690\u85cf\u65f6\u5ef6\n* \u76ae\u80a4\u6837\u5f0f\u4e3b\u9898\uff08\u63d0\u4f9b\u7684\u6216\u8005\u4eceGNOME Shell\u4e3b\u9898\u4e2d\u63d0\u53d6\u7684\u6837\u5f0f\u8868\uff0c\u53c2\u89c1\u6269\u5c55\u7684\u5e2e\u52a9\u90e8\u5206\u6765\u83b7\u53d6\u66f4\u591a\u6307\u5bfc\uff09\n* \u5019\u9009\u6846\u80cc\u666f\u56fe\u7247\u53ca\u5176\u663e\u793a\u6837\u5f0f\n* \u4e3b\u9898\u548c\u80cc\u666f\u56fe\u7247\u8ddf\u968fGNOME\u591c\u706f\n\n\u4f7f\u7528\u6307\u5357\uff1ahttps://blog.csdn.net/qq_18572023/article/details/116331601", + "donations": { + "github": "HollowMan6" + }, "extension-id": "customize-ibus", "gettext-domain": "customize-ibus", "name": "Customize IBus", - "original-authors": ["hollowman@opensuse.org"], + "original-authors": [ + "hollowman@opensuse.org" + ], "settings-schema": "org.gnome.shell.extensions.customize-ibus", - "shell-version": ["46"], - "donations": { - "github": "HollowMan6" - }, + "shell-version": [ + "46" + ], "url": "https://github.com/openSUSE/Customize-IBus", "uuid": "customize-ibus@hollowman.ml", "version": 89 -} +} \ No newline at end of file diff --git a/customize-ibus@hollowman.ml/prefs.js b/customize-ibus@hollowman.ml/prefs.js index afd4d86..4cb759b 100644 --- a/customize-ibus@hollowman.ml/prefs.js +++ b/customize-ibus@hollowman.ml/prefs.js @@ -1,2027 +1,47 @@ -// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- -// vim:fdm=syntax -// by:hollowman6@github tuberry@github - -"use strict"; - -import Adw from "gi://Adw"; -import Gio from "gi://Gio"; -import Gtk from "gi://Gtk"; -import GObject from "gi://GObject"; -import GLib from "gi://GLib"; -import IBus from "gi://IBus"; -import GdkPixbuf from "gi://GdkPixbuf"; - -import { - ExtensionPreferences, - gettext as _, -} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js"; -import { Fields } from "./fields.js"; - -const SessionType = - GLib.getenv("XDG_SESSION_TYPE") === "wayland" ? "Wayland" : "Xorg"; -const SCHEMA_PATH = "/org/gnome/shell/extensions/customize-ibus/"; - -const BoxSettings = { - margin_start: 10, - margin_end: 10, - margin_top: 10, - margin_bottom: 10, -}; - -function mergeObjects(main, bck) { - for (let prop in bck) { - if ( - Object.prototype.hasOwnProperty.call(main, prop) === false && - Object.prototype.hasOwnProperty.call(bck, prop) - ) { - main[prop] = bck[prop]; - } - } - - return main; -} - -const CustomizeIBus = GObject.registerClass( - class CustomizeIBus extends Gtk.ScrolledWindow { - constructor(gsettings, metadata, dir) { - super({ - hscrollbar_policy: Gtk.PolicyType.NEVER, - vscrollbar_policy: Gtk.PolicyType.NEVER, - }); - this.gsettings = gsettings; - this.metadata = metadata; - this.dir = dir; - - this._bulidWidget(); - this._bulidUI(); - this._bindValues(); - this._syncStatus(); - } - - _bulidWidget() { - this.ibus_settings = new Gio.Settings({ - schema_id: "org.freedesktop.ibus.panel", - }); - - this._field_enable_custom_theme = this._checkMaker( - _("Custom IME light theme"), - ); - this._field_enable_custom_theme_dark = this._checkMaker( - _("Custom IME dark theme"), - ); - this._field_use_custom_font = this._checkMaker(_("Use custom font")); - this._field_use_custom_bg = this._checkMaker( - _("Use custom light background"), - ); - this._field_use_custom_bg_dark = this._checkMaker( - _("Use custom dark background"), - ); - this._field_use_candidate_scroll = this._checkMaker( - _("Candidates scroll"), - ); - this._field_enable_ASCII = this._checkMaker(_("Auto switch ASCII mode")); - this._field_enable_orien = this._checkMaker(_("Candidates orientation")); - this._field_use_candidate_animation = this._checkMaker( - _("Candidates popup animation"), - ); - this._field_use_candidate_still = this._checkMaker( - _("Fix candidate box"), - ); - - this._field_use_tray_source_switch_key = this._checkMaker( - _("Directly switch source with click"), - ); - - this._field_use_candidate_right_click = this._checkMaker( - _("Candidate box right click"), - ); - - this._field_indicator_use_custom_font = this._checkMaker( - _("Use custom font"), - ); - - let adjustment = this._createAdjustment(Fields.CANDOPACITY, 1); - this._field_use_candidate_opacity = this._checkMaker( - _("Candidate box opacity"), - ); - this._field_candidate_opacity = new Gtk.Scale({ - adjustment, - digits: 0, - draw_value: true, - hexpand: true, - }); - - this._restart_ibus = new Gtk.Button({ - label: _("Start / Restart IBus"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._reset_extension = new Gtk.Button({ - label: _("Restore Default Settings"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._export_settings = new Gtk.Button({ - label: _("Export Current Settings"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._import_settings = new Gtk.Button({ - label: _("Import Settings from File"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._field_orientation = this._comboMaker([ - _("Vertical"), - _("Horizontal"), - ]); - - this._field_candidate_remember_position = this._comboMaker([ - _("Don't Remember Position"), - _("Remember Last Position"), - ]); - - this._field_remember_input = this._comboMaker([ - _("Don't Remember State"), - _("Remember Input State"), - ]); - - this._field_candidate_scroll_mode = this._comboMaker([ - _("Change Page"), - _("Change Candidate"), - ]); - - this._field_unkown_state = this._comboMaker([ - _("On"), - _("Off"), - _("Keep"), - ]); - - this._field_tray_source_switch_key = this._comboMaker([ - _("Left"), - _("Right"), - ]); - - this._field_indicator_left_click = this._comboMaker([ - _("Drag to Move"), - _("Switch Source"), - ]); - - this._field_candidate_right_click = this._comboMaker([ - _("Open Menu"), - _("Switch Source"), - ]); - - this._field_candidate_still_position = this._comboMaker([ - _("Center"), - _("Center-Left"), - _("Top-Left"), - _("Top-Center"), - _("Top-Right"), - _("Center-Right"), - _("Bottom-Right"), - _("Bottom-Center"), - _("Bottom-Left"), - ]); - - this._field_bg_mode = this._comboMaker([ - _("Centered"), - _("Full"), - _("Zoom"), - ]); - - this._field_bg_dark_mode = this._comboMaker([ - _("Centered"), - _("Full"), - _("Zoom"), - ]); - - this._field_bg_repeat_mode = this._comboMaker([ - _("No repeat"), - _("Repeat"), - ]); - - this._field_bg_dark_repeat_mode = this._comboMaker([ - _("No repeat"), - _("Repeat"), - ]); - - this._field_indicator_animation = this._comboMaker([ - _("None"), - _("Slide"), - _("Fade"), - _("All"), - ]); - - this._field_candidate_animation = this._comboMaker([ - _("None"), - _("Slide"), - _("Fade"), - _("All"), - ]); - - this._ibus_version = new Gtk.Label({ - use_markup: true, - hexpand: true, - halign: Gtk.Align.CENTER, - label: - "" + _("IBus Version: ") + "" + _("unknown (installed ?)"), - }); - this._field_candidate_buttons = new Gtk.Switch(); - this._field_candidate_reposition = new Gtk.Switch(); - this._field_fix_ime_list = new Gtk.Switch(); - this._field_use_tray = new Gtk.Switch(); - this._field_ibus_emoji = new Gtk.Switch(); - this._field_extension_entry = new Gtk.Switch(); - this._field_ibus_preference = new Gtk.Switch(); - this._field_ibus_version = new Gtk.Switch(); - this._field_ibus_restart = new Gtk.Switch(); - this._field_ibus_exit = new Gtk.Switch(); - this._field_use_indicator = new Gtk.Switch(); - this._field_indicator_only_toggle = new Gtk.Switch(); - this._field_indicator_only_in_ASCII = new Gtk.Switch(); - this._field_indicator_not_single_IME = new Gtk.Switch(); - this._field_indicator_right_close = new Gtk.Switch(); - this._field_indicator_scroll = new Gtk.Switch(); - - this._field_indicator_enable_left_click = this._checkMaker( - _("Enable indicator left click"), - ); - adjustment = this._createAdjustment(Fields.INDOPACITY, 1); - this._field_indicator_use_opacity = this._checkMaker( - _("Indicator opacity"), - ); - this._field_indicator_opacity = new Gtk.Scale({ - adjustment, - digits: 0, - draw_value: true, - hexpand: true, - }); - adjustment = this._createAdjustment(Fields.INPUTINDSHOW, 1); - this._field_indicator_enable_show_delay = this._checkMaker( - _("Enable indicator show delay (unit: seconds)"), - ); - this._field_indicator_show_time = new Gtk.Scale({ - adjustment, - digits: 0, - draw_value: true, - hexpand: true, - }); - adjustment = this._createAdjustment(Fields.INPUTINDHID, 1); - this._field_indicator_enable_autohide = this._checkMaker( - _("Enable indicator auto-hide timeout (unit: seconds)"), - ); - this._field_indicator_hide_time = new Gtk.Scale({ - adjustment, - digits: 0, - draw_value: true, - hexpand: true, - }); - - this._field_open_system_settings = new Gtk.Button({ - label: _("GNOME Settings"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._field_open_ibus_pref = new Gtk.Button({ - label: _("IBus Preferences"), - hexpand: true, - halign: Gtk.Align.CENTER, - }); - - this._field_custom_font = new Gtk.FontButton({ - font: this.gsettings.get_string(Fields.CUSTOMFONT), - }); - - this._field_indicator_custom_font = new Gtk.FontButton({ - font: this.gsettings.get_string(Fields.INPUTINDCUSTOMFONT), - }); - - const filter = new Gtk.FileFilter(); - filter.add_pixbuf_formats(); - - this._fileChooser = new Gtk.FileChooserNative({ - title: _("Select an Image"), - filter, - modal: true, - }); - this._logoPicker = new Gtk.Button({ - label: _("(None)"), - }); - this._reset_logo_button = this._iconButtonMaker("edit-clear"); - this._reset_logo_button.visible = false; - this._open_logo_button = this._iconLinkButtonMaker("", "document-open"); - this._open_logo_button.visible = false; - - this._fileDarkChooser = new Gtk.FileChooserNative({ - title: _("Select an Image"), - filter, - modal: true, - }); - this._logoDarkPicker = new Gtk.Button({ - label: _("(None)"), - }); - this._reset_logoDark_button = this._iconButtonMaker("edit-clear"); - this._reset_logoDark_button.visible = false; - this._open_logoDark_button = this._iconLinkButtonMaker( - "", - "document-open", - ); - this._open_logoDark_button.visible = false; - - const cssFilter = new Gtk.FileFilter(); - cssFilter.add_pattern("*.css"); - - this._cssFileChooser = new Gtk.FileChooserNative({ - title: _("Select an IBus Stylesheet"), - filter: cssFilter, - modal: true, - }); - this._cssPicker = new Gtk.Button({ - label: _("(None)"), - }); - this._reset_css_button = this._iconButtonMaker("edit-clear"); - this._reset_css_button.visible = false; - this._open_css_button = this._iconLinkButtonMaker("", "document-open"); - this._open_css_button.visible = false; - - this._cssDarkFileChooser = new Gtk.FileChooserNative({ - title: _("Select an IBus Stylesheet"), - filter: cssFilter, - modal: true, - }); - this._cssDarkPicker = new Gtk.Button({ - label: _("(None)"), - }); - this._reset_cssDark_button = this._iconButtonMaker("edit-clear"); - this._reset_cssDark_button.visible = false; - this._open_cssDark_button = this._iconLinkButtonMaker( - "", - "document-open", - ); - this._open_cssDark_button.visible = false; - } - - _updateLogoPicker() { - const filename = this.gsettings.get_string(Fields.CUSTOMBG); - if (!GLib.basename(filename)) { - this._logoPicker.label = _("(None)"); - this._open_logo_button.uri = ""; - this._open_logo_button.visible = false; - this._reset_logo_button.visible = false; - } else { - this._logoPicker.label = GLib.basename(filename); - this._open_logo_button.uri = "file://" + filename; - this._open_logo_button.visible = true; - this._reset_logo_button.visible = true; - } - } - - _updateLogoDarkPicker() { - const filename = this.gsettings.get_string(Fields.CUSTOMBGDARK); - if (!GLib.basename(filename)) { - this._logoDarkPicker.label = _("(None)"); - this._open_logoDark_button.uri = ""; - this._open_logoDark_button.visible = false; - this._reset_logoDark_button.visible = false; - } else { - this._logoDarkPicker.label = GLib.basename(filename); - this._open_logoDark_button.uri = "file://" + filename; - this._open_logoDark_button.visible = true; - this._reset_logoDark_button.visible = true; - } - } - - _updateCssPicker() { - const filename = this.gsettings.get_string(Fields.CUSTOMTHEME); - if (!GLib.basename(filename)) { - this._cssPicker.label = _("(None)"); - this._open_css_button.uri = ""; - this._open_css_button.visible = false; - this._reset_css_button.visible = false; - } else { - this._cssPicker.label = GLib.basename(filename); - this._open_css_button.uri = "file://" + filename; - this._open_css_button.visible = true; - this._reset_css_button.visible = true; - } - } - - _updateCssDarkPicker() { - const filename = this.gsettings.get_string(Fields.CUSTOMTHEMENIGHT); - if (!GLib.basename(filename)) { - this._cssDarkPicker.label = _("(None)"); - this._open_cssDark_button.uri = ""; - this._open_cssDark_button.visible = false; - this._reset_cssDark_button.visible = false; - } else { - this._cssDarkPicker.label = GLib.basename(filename); - this._open_cssDark_button.uri = "file://" + filename; - this._open_cssDark_button.visible = true; - this._reset_cssDark_button.visible = true; - } - } - - _updateIBusVersion() { - let IBusVersion = _("unknown (installed ?)"); - if (IBus.MAJOR_VERSION) - IBusVersion = - "v" + - IBus.MAJOR_VERSION + - "." + - IBus.MINOR_VERSION + - "." + - IBus.MICRO_VERSION; - this._ibus_version.label = - "" + _("IBus Version: ") + "" + IBusVersion; - } - - _bulidUI() { - this._notebook = new Gtk.Notebook({ - enable_popup: true, - }); - this.set_child(this._notebook); - - this._ibus_basic = this._listFrameMaker(_("General")); - this._ibus_basic._add(this._field_enable_orien, this._field_orientation); - this._ibus_basic._add( - this._field_use_candidate_animation, - this._field_candidate_animation, - ); - this._ibus_basic._add( - this._field_use_candidate_right_click, - this._field_candidate_right_click, - ); - this._ibus_basic._add( - this._field_use_candidate_scroll, - this._field_candidate_scroll_mode, - ); - this._ibus_basic._add( - this._field_use_candidate_still, - this._field_candidate_remember_position, - this._field_candidate_still_position, - ); - this._ibus_basic._add( - this._field_use_custom_font, - this._field_custom_font, - ); - this._ibus_basic._add( - this._field_enable_ASCII, - this._field_remember_input, - this._field_unkown_state, - ); - this._ibus_basic._add( - this._field_use_candidate_opacity, - this._field_candidate_opacity, - ); - this._ibus_basic._add( - this._switchLabelMaker(_("Fix IME list order")), - this._field_fix_ime_list, - ); - this._ibus_basic._add( - this._switchLabelMaker(_("Enable drag to reposition candidate box")), - this._field_candidate_reposition, - ); - this._ibus_basic._add( - this._switchLabelMaker(_("Candidate box page buttons")), - this._field_candidate_buttons, - ); - this._basicHelpPage(this._ibus_basic); - - this._ibus_tray = this._listFrameMaker(_("Tray")); - this._ibus_tray._add(this._ibus_version); - this._ibus_tray._add(this._restart_ibus); - this._ibus_tray._add( - this._switchLabelMaker(_("Show IBus tray icon")), - this._field_use_tray, - ); - this._ibus_tray._add( - this._field_use_tray_source_switch_key, - this._field_tray_source_switch_key, - ); - this._ibus_tray._add( - new Gtk.Label({ - use_markup: true, - hexpand: true, - halign: Gtk.Align.CENTER, - label: "" + _("Add Additional Menu Entries") + "", - }), - ); - this._ibus_tray._add( - this._switchLabelMaker(_("Copying Emoji")), - this._field_ibus_emoji, - ); - this._ibus_tray._add( - this._switchLabelMaker(_("This Extension's Preferences")), - this._field_extension_entry, - ); - this._ibus_tray._add( - this._switchLabelMaker(_("IBus Preferences")), - this._field_ibus_preference, - ); - this._ibus_tray._add( - this._switchLabelMaker(_("IBus Version")), - this._field_ibus_version, - ); - this._ibus_tray._add( - this._switchLabelMaker(_("Restarting IBus")), - this._field_ibus_restart, - ); - this._ibus_tray._add( - this._switchLabelMaker(_("Exiting IBus")), - this._field_ibus_exit, - ); - this._trayHelpPage(this._ibus_tray); - - this._ibus_indicator = this._listFrameMaker(_("Indicator")); - this._ibus_indicator._add( - this._switchLabelMaker(_("Use input source indicator")), - this._field_use_indicator, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Indicate only when switching input source")), - this._field_indicator_only_toggle, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Indicate only when using ASCII mode")), - this._field_indicator_only_in_ASCII, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Don't indicate when using single mode IME")), - this._field_indicator_not_single_IME, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Enable right click to close indicator")), - this._field_indicator_right_close, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Enable scroll to switch input source")), - this._field_indicator_scroll, - ); - this._ibus_indicator._add( - this._switchLabelMaker(_("Indicator popup animation")), - this._field_indicator_animation, - ); - this._ibus_indicator._add( - this._field_indicator_use_custom_font, - this._field_indicator_custom_font, - ); - this._ibus_indicator._add( - this._field_indicator_enable_left_click, - this._field_indicator_left_click, - ); - this._ibus_indicator._add( - this._field_indicator_use_opacity, - this._field_indicator_opacity, - ); - this._ibus_indicator._add( - this._field_indicator_enable_show_delay, - this._field_indicator_show_time, - ); - this._ibus_indicator._add( - this._field_indicator_enable_autohide, - this._field_indicator_hide_time, - ); - this._indicatorHelpPage(this._ibus_indicator); - - this._ibus_theme = this._listFrameMaker(_("Theme")); - this._ibus_theme._add( - this._field_enable_custom_theme, - this._cssPicker, - this._reset_css_button, - this._open_css_button, - ); - this._ibus_theme._add( - this._field_enable_custom_theme_dark, - this._cssDarkPicker, - this._reset_cssDark_button, - this._open_cssDark_button, - ); - this._themeHelpPage(this._ibus_theme); - - this._ibus_bg = this._listFrameMaker(_("Background")); - this._ibus_bg._add( - this._field_use_custom_bg, - this._field_bg_mode, - this._field_bg_repeat_mode, - this._logoPicker, - this._reset_logo_button, - this._open_logo_button, - ); - this._ibus_bg._add( - this._field_use_custom_bg_dark, - this._field_bg_dark_mode, - this._field_bg_dark_repeat_mode, - this._logoDarkPicker, - this._reset_logoDark_button, - this._open_logoDark_button, - ); - this._bgHelpPage(this._ibus_bg); - this._ibus_settings = this._listFrameMaker(_("Settings")); - this._ibus_settings._add( - new Gtk.Label({ - use_markup: true, - hexpand: true, - halign: Gtk.Align.CENTER, - label: "" + _("Settings for extension") + "", - }), - ); - this._ibus_settings._add( - this._reset_extension, - this._export_settings, - this._import_settings, - ); - this._ibus_settings._add( - new Gtk.Label({ - use_markup: true, - hexpand: true, - halign: Gtk.Align.CENTER, - label: - "" + _("Other official IBus customization settings") + "", - }), - ); - this._ibus_settings._add( - this._field_open_system_settings, - this._field_open_ibus_pref, - ); - this._settingsHelpPage(this._ibus_settings); - this._aboutPage(); - } - - _syncStatus() { - this._field_enable_ASCII.connect("notify::active", (widget) => { - this._field_remember_input.set_sensitive(widget.active); - this._field_unkown_state.set_sensitive(widget.active); - }); - this._field_enable_orien.connect("notify::active", (widget) => { - this._field_orientation.set_sensitive(widget.active); - }); - this._field_use_candidate_animation.connect( - "notify::active", - (widget) => { - this._field_candidate_animation.set_sensitive(widget.active); - }, - ); - this._field_use_candidate_scroll.connect("notify::active", (widget) => { - this._field_candidate_scroll_mode.set_sensitive(widget.active); - }); - this._field_use_candidate_right_click.connect( - "notify::active", - (widget) => { - this._field_candidate_right_click.set_sensitive(widget.active); - }, - ); - this._field_use_candidate_still.connect("notify::active", (widget) => { - this._field_candidate_remember_position.set_sensitive(widget.active); - this._field_candidate_still_position.set_sensitive(widget.active); - }); - this._field_use_tray_source_switch_key.connect( - "notify::active", - (widget) => { - this._field_tray_source_switch_key.set_sensitive(widget.active); - }, - ); - this._field_use_tray.connect("notify::active", (widget) => { - this._field_tray_source_switch_key.set_sensitive( - this._field_use_tray_source_switch_key && widget.active, - ); - this._field_use_tray_source_switch_key.set_sensitive(widget.active); - this._field_ibus_emoji.set_sensitive(widget.active); - this._field_extension_entry.set_sensitive(widget.active); - this._field_ibus_preference.set_sensitive(widget.active); - this._field_ibus_version.set_sensitive(widget.active); - this._field_ibus_restart.set_sensitive(widget.active); - this._field_ibus_exit.set_sensitive(widget.active); - this.ibus_settings.set_boolean("show-icon-on-systray", widget.active); - }); - this._field_use_indicator.connect("notify::active", (widget) => { - this._field_indicator_only_toggle.set_sensitive(widget.active); - this._field_indicator_only_in_ASCII.set_sensitive(widget.active); - this._field_indicator_not_single_IME.set_sensitive(widget.active); - this._field_indicator_right_close.set_sensitive(widget.active); - this._field_indicator_scroll.set_sensitive(widget.active); - this._field_indicator_animation.set_sensitive(widget.active); - this._field_indicator_left_click.set_sensitive( - this._field_indicator_enable_left_click.active && widget.active, - ); - this._field_indicator_opacity.set_sensitive( - this._field_indicator_use_opacity.active && widget.active, - ); - this._field_indicator_show_time.set_sensitive( - this._field_indicator_enable_show_delay.active && widget.active, - ); - this._field_indicator_hide_time.set_sensitive( - this._field_indicator_enable_autohide.active && widget.active, - ); - this._field_indicator_custom_font.set_sensitive( - this._field_indicator_use_custom_font.active && widget.active, - ); - this._field_indicator_use_custom_font.set_sensitive(widget.active); - this._field_indicator_enable_left_click.set_sensitive(widget.active); - this._field_indicator_use_opacity.set_sensitive(widget.active); - this._field_indicator_enable_show_delay.set_sensitive(widget.active); - this._field_indicator_enable_autohide.set_sensitive(widget.active); - }); - this._field_indicator_enable_left_click.connect( - "notify::active", - (widget) => { - this._field_indicator_left_click.set_sensitive(widget.active); - }, - ); - this._field_indicator_use_opacity.connect("notify::active", (widget) => { - this._field_indicator_opacity.set_sensitive(widget.active); - }); - this._field_indicator_enable_show_delay.connect( - "notify::active", - (widget) => { - this._field_indicator_show_time.set_sensitive(widget.active); - }, - ); - this._field_indicator_enable_autohide.connect( - "notify::active", - (widget) => { - this._field_indicator_hide_time.set_sensitive(widget.active); - }, - ); - this._field_indicator_use_custom_font.connect( - "notify::active", - (widget) => { - this._field_indicator_custom_font.set_sensitive(widget.active); - }, - ); - this._field_use_custom_font.connect("notify::active", (widget) => { - this._field_custom_font.set_sensitive(widget.active); - this.ibus_settings.set_boolean(Fields.USECUSTOMFONT, widget.active); - this.ibus_settings.set_string( - Fields.CUSTOMFONT, - this.gsettings.get_string(Fields.CUSTOMFONT), - ); - }); - this._field_use_candidate_opacity.connect("notify::active", (widget) => { - this._field_candidate_opacity.set_sensitive(widget.active); - }); - this._field_use_custom_bg.connect("notify::active", (widget) => { - this._logoPicker.set_sensitive(widget.active); - this._field_bg_mode.set_sensitive(widget.active); - this._field_bg_repeat_mode.set_sensitive(widget.active); - this._reset_logo_button.set_sensitive(widget.active); - this._open_logo_button.set_sensitive(widget.active); - }); - this._field_use_custom_bg_dark.connect("notify::active", (widget) => { - this._logoDarkPicker.set_sensitive(widget.active); - this._field_bg_dark_mode.set_sensitive(widget.active); - this._field_bg_dark_repeat_mode.set_sensitive(widget.active); - this._reset_logoDark_button.set_sensitive(widget.active); - this._open_logoDark_button.set_sensitive(widget.active); - }); - this._field_enable_custom_theme.connect("notify::active", (widget) => { - this._cssPicker.set_sensitive(widget.active); - this._reset_css_button.set_sensitive(widget.active); - this._open_css_button.set_sensitive(widget.active); - }); - this._field_enable_custom_theme_dark.connect( - "notify::active", - (widget) => { - this._cssDarkPicker.set_sensitive(widget.active); - this._reset_cssDark_button.set_sensitive(widget.active); - this._open_cssDark_button.set_sensitive(widget.active); - }, - ); - this._fileChooser.connect("response", (dlg, response) => { - if (response !== Gtk.ResponseType.ACCEPT) return; - this.gsettings.set_string(Fields.CUSTOMBG, dlg.get_file().get_path()); - }); - this._logoPicker.connect("clicked", () => { - this._fileChooser.transient_for = this.get_root(); - let path = Gio.File.new_for_path( - this.gsettings.get_string(Fields.CUSTOMBG), - ).get_parent(); - if (path) { - this._fileChooser.set_current_folder(path); - } - this._fileChooser.show(); - }); - this._restart_ibus.connect("clicked", () => { - this.gsettings.set_string( - Fields.IBUSRESTTIME, - new Date().getTime().toString(), - ); - this._updateIBusVersion(); - }); - this._reset_extension.connect("clicked", () => { - this._resetExtension(); - }); - const dconfFilter = new Gtk.FileFilter(); - dconfFilter.add_pattern("*.ini"); - /* Settings */ - // Export Current Settings - this._export_settings.connect("clicked", () => { - this._showFileChooser( - _("Export Current Settings"), - { - action: Gtk.FileChooserAction.SAVE, - filter: dconfFilter, - }, - _("Save"), - (filename) => { - if (!filename.endsWith(".ini")) filename += ".ini"; - let file = Gio.file_new_for_path(filename); - let raw = file.replace(null, false, Gio.FileCreateFlags.NONE, null); - let out = Gio.BufferedOutputStream.new_sized(raw, 4096); - - out.write_all( - GLib.spawn_command_line_sync("dconf dump " + SCHEMA_PATH)[1], - null, - ); - out.close(null); - }, - true, - ); - }); - // Import Settings from file - this._import_settings.connect("clicked", () => { - this._showFileChooser( - _("Import Settings from File"), - { - action: Gtk.FileChooserAction.OPEN, - filter: dconfFilter, - }, - _("Open"), - (filename) => { - if (filename && GLib.file_test(filename, GLib.FileTest.EXISTS)) { - let settingsFile = Gio.File.new_for_path(filename); - let [, , stdin, stdout, stderr] = GLib.spawn_async_with_pipes( - null, - ["dconf", "load", SCHEMA_PATH], - null, - GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, - null, - ); - - stdin = new Gio.UnixOutputStream({ fd: stdin, close_fd: true }); - GLib.close(stdout); - GLib.close(stderr); - - // // Disable and then re-enable extension - // let [ , , , retCode] = GLib.spawn_command_line_sync('gnome-extensions disable ' + this.uuid); - // if (retCode == 0) { - // GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, () => GLib.spawn_command_line_sync('gnome-extensions disable ' + this.uuid)); - // } - - stdin.splice( - settingsFile.read(null), - Gio.OutputStreamSpliceFlags.CLOSE_SOURCE | - Gio.OutputStreamSpliceFlags.CLOSE_TARGET, - null, - ); - } - }, - ); - }); - // GNOME Settings - this._field_open_system_settings.connect("clicked", () => { - GLib.spawn_command_line_async("gnome-control-center keyboard"); - }); - // IBus Preferences - this._field_open_ibus_pref.connect("clicked", () => { - GLib.spawn_command_line_async("ibus-setup"); - }); - this._fileDarkChooser.connect("response", (dlg, response) => { - if (response !== Gtk.ResponseType.ACCEPT) return; - this.gsettings.set_string( - Fields.CUSTOMBGDARK, - dlg.get_file().get_path(), - ); - }); - this._logoDarkPicker.connect("clicked", () => { - this._fileDarkChooser.transient_for = this.get_root(); - let path = Gio.File.new_for_path( - this.gsettings.get_string(Fields.CUSTOMBGDARK), - ).get_parent(); - if (path) { - this._fileDarkChooser.set_current_folder(path); - } - this._fileDarkChooser.show(); - }); - this._cssFileChooser.connect("response", (dlg, response) => { - if (response !== Gtk.ResponseType.ACCEPT) return; - this.gsettings.set_string( - Fields.CUSTOMTHEME, - dlg.get_file().get_path(), - ); - }); - this._cssPicker.connect("clicked", () => { - this._cssFileChooser.transient_for = this.get_root(); - let path = Gio.File.new_for_path( - this.gsettings.get_string(Fields.CUSTOMTHEME), - ).get_parent(); - if (path) { - this._cssFileChooser.set_current_folder(path); - } - this._cssFileChooser.show(); - }); - this._cssDarkFileChooser.connect("response", (dlg, response) => { - if (response !== Gtk.ResponseType.ACCEPT) return; - this.gsettings.set_string( - Fields.CUSTOMTHEMENIGHT, - dlg.get_file().get_path(), - ); - }); - this._cssDarkPicker.connect("clicked", () => { - this._cssDarkFileChooser.transient_for = this.get_root(); - let path = Gio.File.new_for_path( - this.gsettings.get_string(Fields.CUSTOMTHEMENIGHT), - ).get_parent(); - if (path) { - this._cssDarkFileChooser.set_current_folder(path); - } - this._cssDarkFileChooser.show(); - }); - this._reset_logo_button.connect("clicked", () => { - this.gsettings.set_string(Fields.CUSTOMBG, ""); - }); - this._reset_logoDark_button.connect("clicked", () => { - this.gsettings.set_string(Fields.CUSTOMBGDARK, ""); - }); - this._reset_css_button.connect("clicked", () => { - this.gsettings.set_string(Fields.CUSTOMTHEME, ""); - }); - this._reset_cssDark_button.connect("clicked", () => { - this.gsettings.set_string(Fields.CUSTOMTHEMENIGHT, ""); - }); - - this._field_remember_input.set_sensitive(this._field_enable_ASCII.active); - this._field_unkown_state.set_sensitive(this._field_enable_ASCII.active); - this._field_orientation.set_sensitive(this._field_enable_orien.active); - this._field_candidate_animation.set_sensitive( - this._field_use_candidate_animation.active, - ); - this._field_candidate_scroll_mode.set_sensitive( - this._field_use_candidate_scroll.active, - ); - this._field_candidate_right_click.set_sensitive( - this._field_use_candidate_right_click.active, - ); - this._field_candidate_remember_position.set_sensitive( - this._field_use_candidate_still.active, - ); - this._field_candidate_still_position.set_sensitive( - this._field_use_candidate_still.active, - ); - this._field_use_tray_source_switch_key.set_sensitive( - this._field_use_tray.active, - ); - this._field_tray_source_switch_key.set_sensitive( - this._field_use_tray.active && - this._field_use_tray_source_switch_key.active, - ); - this._field_ibus_emoji.set_sensitive(this._field_use_tray.active); - this._field_extension_entry.set_sensitive(this._field_use_tray.active); - this._field_ibus_preference.set_sensitive(this._field_use_tray.active); - this._field_ibus_version.set_sensitive(this._field_use_tray.active); - this._field_ibus_restart.set_sensitive(this._field_use_tray.active); - this._field_ibus_exit.set_sensitive(this._field_use_tray.active); - this._field_indicator_only_toggle.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_only_in_ASCII.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_not_single_IME.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_right_close.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_scroll.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_animation.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_left_click.set_sensitive( - this._field_use_indicator.active && - this._field_indicator_enable_left_click.active, - ); - this._field_indicator_opacity.set_sensitive( - this._field_use_indicator.active && - this._field_indicator_use_opacity.active, - ); - this._field_indicator_show_time.set_sensitive( - this._field_use_indicator.active && - this._field_indicator_enable_show_delay.active, - ); - this._field_indicator_hide_time.set_sensitive( - this._field_use_indicator.active && - this._field_indicator_enable_autohide.active, - ); - this._field_indicator_enable_left_click.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_use_opacity.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_enable_show_delay.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_enable_autohide.set_sensitive( - this._field_use_indicator.active, - ); - this._field_indicator_custom_font.set_sensitive( - this._field_use_indicator.active && - this._field_indicator_use_custom_font.active, - ); - this._field_indicator_use_custom_font.set_sensitive( - this._field_use_indicator.active, - ); - this._field_custom_font.set_sensitive(this._field_use_custom_font.active); - this._field_candidate_opacity.set_sensitive( - this._field_use_candidate_opacity.active, - ); - this._field_bg_mode.set_sensitive(this._field_use_custom_bg.active); - this._field_bg_dark_mode.set_sensitive( - this._field_use_custom_bg_dark.active, - ); - this._field_bg_repeat_mode.set_sensitive( - this._field_use_custom_bg.active, - ); - this._field_bg_dark_repeat_mode.set_sensitive( - this._field_use_custom_bg_dark.active, - ); - this._logoPicker.set_sensitive(this._field_use_custom_bg.active); - this._reset_logo_button.set_sensitive(this._field_use_custom_bg.active); - this._open_logo_button.set_sensitive(this._field_use_custom_bg.active); - this._logoDarkPicker.set_sensitive(this._field_use_custom_bg_dark.active); - this._reset_logoDark_button.set_sensitive( - this._field_use_custom_bg_dark.active, - ); - this._open_logoDark_button.set_sensitive( - this._field_use_custom_bg_dark.active, - ); - this._cssPicker.set_sensitive(this._field_enable_custom_theme.active); - this._reset_css_button.set_sensitive( - this._field_enable_custom_theme.active, - ); - this._open_css_button.set_sensitive( - this._field_enable_custom_theme.active, - ); - this._cssDarkPicker.set_sensitive( - this._field_enable_custom_theme_dark.active, - ); - this._reset_cssDark_button.set_sensitive( - this._field_enable_custom_theme_dark.active, - ); - this._open_cssDark_button.set_sensitive( - this._field_enable_custom_theme_dark.active, - ); - } - - _bindValues() { - this.gsettings.bind( - Fields.AUTOSWITCH, - this._field_enable_ASCII, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.ENABLECUSTOMTHEME, - this._field_enable_custom_theme, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.ENABLECUSTOMTHEMENIGHT, - this._field_enable_custom_theme_dark, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.ENABLEORIEN, - this._field_enable_orien, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.ORIENTATION, - this._field_orientation, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECANDANIM, - this._field_use_candidate_animation, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.CANDANIMATION, - this._field_candidate_animation, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USESCROLL, - this._field_use_candidate_scroll, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.SCROLLMODE, - this._field_candidate_scroll_mode, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECANDRIGHTSWITCH, - this._field_use_candidate_right_click, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.CANDRIGHTFUNC, - this._field_candidate_right_click, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECANDSTILL, - this._field_use_candidate_still, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.CANDSTILLPOS, - this._field_candidate_still_position, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USETRAYSSWITCH, - this._field_use_tray_source_switch_key, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.TRAYSSWITCHKEY, - this._field_tray_source_switch_key, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.REMCANDPOS, - this._field_candidate_remember_position, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.REMEMBERINPUT, - this._field_remember_input, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.UNKNOWNSTATE, - this._field_unkown_state, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECANDOPACITY, - this._field_use_candidate_opacity, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.CANDOPACITY, - this._field_candidate_opacity, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECUSTOMFONT, - this._field_use_custom_font, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.CUSTOMFONT, - this._field_custom_font, - "font", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDUSEF, - this._field_indicator_use_custom_font, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDCUSTOMFONT, - this._field_indicator_custom_font, - "font", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECUSTOMBG, - this._field_use_custom_bg, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USECUSTOMBGDARK, - this._field_use_custom_bg_dark, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.BGMODE, - this._field_bg_mode, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.BGDARKMODE, - this._field_bg_dark_mode, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.BGREPEATMODE, - this._field_bg_repeat_mode, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.BGDARKREPEATMODE, - this._field_bg_dark_repeat_mode, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUIBUSEMOJI, - this._field_ibus_emoji, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEREPOSITION, - this._field_candidate_reposition, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEBUTTONS, - this._field_candidate_buttons, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.FIXIMELIST, - this._field_fix_ime_list, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USETRAY, - this._field_use_tray, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUEXTPREF, - this._field_extension_entry, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUIBUSPREF, - this._field_ibus_preference, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUIBUSVER, - this._field_ibus_version, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUIBUSREST, - this._field_ibus_restart, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.MENUIBUSEXIT, - this._field_ibus_exit, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEINPUTIND, - this._field_use_indicator, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDTOG, - this._field_indicator_only_toggle, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDASCII, - this._field_indicator_only_in_ASCII, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDSINGLE, - this._field_indicator_not_single_IME, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEINPUTINDLCLK, - this._field_indicator_enable_left_click, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDLCLICK, - this._field_indicator_left_click, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDRIGC, - this._field_indicator_right_close, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDSCROLL, - this._field_indicator_scroll, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDANIM, - this._field_indicator_animation, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEINDOPACITY, - this._field_indicator_use_opacity, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INDOPACITY, - this._field_indicator_opacity, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEINDSHOWD, - this._field_indicator_enable_show_delay, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDSHOW, - this._field_indicator_show_time, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.USEINDAUTOHID, - this._field_indicator_enable_autohide, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.bind( - Fields.INPUTINDHID, - this._field_indicator_hide_time, - "active", - Gio.SettingsBindFlags.DEFAULT, - ); - this.gsettings.connect( - `changed::${Fields.CUSTOMBG}`, - this._updateLogoPicker.bind(this), - ); - this._updateLogoPicker(); - this.gsettings.connect( - `changed::${Fields.CUSTOMBGDARK}`, - this._updateLogoDarkPicker.bind(this), - ); - this._updateLogoDarkPicker(); - this.gsettings.connect( - `changed::${Fields.CUSTOMTHEME}`, - this._updateCssPicker.bind(this), - ); - this._updateCssPicker(); - this.gsettings.connect( - `changed::${Fields.CUSTOMTHEMENIGHT}`, - this._updateCssDarkPicker.bind(this), - ); - this._updateCssDarkPicker(); - this._updateIBusVersion(); - } - - _createAdjustment(key, step_increment) { - let schemaKey = this.gsettings.settings_schema.get_key(key); - let [type, variant] = schemaKey.get_range().deep_unpack(); - if (type !== "range") - throw new Error('Invalid key type "%s" for adjustment'.format(type)); - let [lower, upper] = variant.deep_unpack(); - let adj = new Gtk.Adjustment({ - lower, - upper, - step_increment, - }); - this.gsettings.bind(key, adj, "value", Gio.SettingsBindFlags.DEFAULT); - return adj; - } - - _listFrameMaker(lbl) { - let box = new Gtk.Box(BoxSettings); - let frame = new Gtk.Frame({ - margin_top: 10, - }); - - box.append(frame); - this._notebook.append_page(box, new Gtk.Label({ label: lbl })); - - frame.grid = new Gtk.Grid({ - hexpand: true, - row_homogeneous: false, - column_homogeneous: false, - }); - - frame.grid._row = 0; - frame.set_child(frame.grid); - - frame._add = (x, y, z, a, b, c) => { - const boxrow = new Gtk.ListBoxRow({ - activatable: true, - selectable: false, - }); - const hbox = new Gtk.Box(BoxSettings); - boxrow.set_child(hbox); - let spacing = 4; - hbox.set_spacing(spacing); - hbox.append(x); - if (y) hbox.append(y); - if (z) hbox.append(z); - if (a) hbox.append(a); - if (b) hbox.append(b); - if (c) hbox.append(c); - frame.grid.attach(boxrow, 0, frame.grid._row++, 1, 1); - }; - return frame; - } - - _expanderFrame(frame) { - let expanderFrame = new Gtk.Frame({ - margin_top: 10, - }); - expanderFrame.grid = new Gtk.Grid({ - margin_start: 10, - margin_end: 10, - margin_top: 10, - margin_bottom: 10, - hexpand: true, - row_spacing: 12, - column_spacing: 18, - row_homogeneous: false, - column_homogeneous: false, - halign: Gtk.Align.CENTER, - }); - expanderFrame.grid._row = 0; - expanderFrame.set_child(expanderFrame.grid); - - let expander = new Gtk.Expander({ - use_markup: true, - child: expanderFrame, - expanded: true, - label: "💡" + _("Help") + "", - }); - frame.grid.attach(expander, 0, frame.grid._row++, 1, 1); - - expanderFrame._add = (x) => { - expanderFrame.grid.attach(x, 0, frame.grid._row++, 1, 1); - }; - return expanderFrame; - } - - _aboutPage() { - let box = new Gtk.Box(BoxSettings); - let frame = new Gtk.Frame({ - margin_top: 10, - }); - - box.append(frame); - this._notebook.append_page(box, new Gtk.Label({ label: _("About") })); - - frame.grid = new Gtk.Grid({ - margin_start: 10, - margin_end: 10, - margin_top: 10, - margin_bottom: 10, - hexpand: true, - row_spacing: 12, - column_spacing: 18, - row_homogeneous: false, - column_homogeneous: false, - halign: Gtk.Align.CENTER, - }); - - frame.grid._row = 0; - frame.set_child(frame.grid); - - let version = _("unknown (self-build ?)"); - if (this.metadata.version !== undefined) { - version = this.metadata.version.toString(); - } - let iconFile = GLib.build_filenamev([ - this.dir.get_path(), - "img", - "logo.png", - ]); - let logo = Gtk.Image.new_from_pixbuf( - GdkPixbuf.Pixbuf.new_from_file(iconFile), - ); - logo.set_pixel_size(80); - frame.grid.attach(logo, 0, frame.grid._row++, 1, 1); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: "" + _("Customize IBus") + "", - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ label: _("Version: ") + version }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - label: - "😎 " + - _( - "Full customization of appearance, behavior, system tray and input source indicator for IBus.", - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: " ", - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: _( - 'Copyright © 2021-2023 Hollow Man <hollowman@opensuse.org>', - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: _( - 'Source Code: https://github.com/openSUSE/Customize-IBus', - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: _( - 'Sponsored by Google Summer of Code 2021 @openSUSE.', - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: " ", - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - label: _("Current Session") + ": " + SessionType, - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: " ", - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: _( - 'This program comes with ABSOLUTELY NO WARRANTY.', - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - frame.grid.attach( - new Gtk.Label({ - use_markup: true, - label: _( - 'See the GNU General Public License, version 3 or later for details.', - ), - }), - 0, - frame.grid._row++, - 1, - 1, - ); - } - - _basicHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Here you can set the IBus input window orientation, animation, right click to open menu or switch source, scroll to switch among pages or candidates, fix candidate box to not follow caret position, font, ASCII mode auto-switch when windows are switched by users, candidate box opacity, fix IME list order when switching, reposition candidate box by dragging when input, and also show or hide candidate box page buttons.", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: If fix candidate box is enabled, you can set the candidate box position with 9 options. Recommend to enable drag to reposition candidate box at the same time so that you can rearrange the position at any time. Will remember candidate position forever after reposition if you set to remember last position, and restore at next login.', - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Note: If auto switch ASCII mode is enabled, and you have set to Remember Input State, every opened APP's input mode will be remembered if you have switched the input source manually in the APP's window, and the newly-opened APP will follow the configuration. APP's Input State will be remembered forever.", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: If you enable drag to reposition candidate box, and if fix candidate box is enabled, your rearranged position will last until the end of this session. If not the rearranged position will only last for the specific input.', - ), - }), - ); - } - - _trayHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Here you can set to show IBus tray icon, enable directly switch source with click, add additional menu entries to IBus input source indicator menu at system tray to restore the feelings on Non-GNOME desktop environment. You can also start or restart IBus by pressing the top button.", - ), - }), - ); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: If Directly switch source with click is enabled, when the left key is selected, if you click the tray icon with left key, you will have input source switched, and click right key will open the menu as normal, vice versa.', - ), - }), - ); - } - - _indicatorHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Here you can set to show input source indicator, default is to show indicator every time you type, move caret or switch input source. You can set to show indicator only when switching input source. You can also set to only notify in ASCII mode (for multi-mode IME), not notify when using single mode IME, mouse right click to close indicator, scroll to switch input source, popup animation, font, mouse left click to switch input source or drag to move indicator, indicator opacity, enable show delay and show timeout (in seconds), enable auto-hide and auto-hide timeout (in seconds).", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: If you choose to enable the show delay, there won\'t be a show delay when you switch input source or window.', - ), - }), - ); - } - - _themeHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Support importing stylesheet generated by IBus Theme Tools or provided by IBus Theme Hub.', - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "When light theme and dark theme are turned on at the same time, the IBus theme will automatically follow GNOME Night Light mode, use light theme when off, and use dark theme when on. When only the light theme or dark theme is turned on, the IBus theme will always use the theme that is turned on.", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Warning: If not for debugging, please DO NOT add any classes that\'s not started with .candidate-* into IBus stylesheet to prevent from corrupting system themes.', - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: Support stylesheets hot reload, CSS changes reflecting in real-time.', - ), - }), - ); - } - - _bgHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Support customizing your IBus Input window background with a picture. It has a higher priority than the theme-defined background.", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "When light background and dark background are turned on at the same time, the IBus background will automatically follow GNOME Night Light mode, use light background when off, and use dark background when on. When only the light background or dark background is turned on, the IBus background will always use the background that is turned on.", - ), - }), - ); - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - 'Note: Please make sure your background picture can always be visited. If your pictures are stored in the removable device and the system doesn\'t mount it by default, please disable and then enable the corresponding Use custom background again to make it effective after manually mounting.', - ), - }), - ); - } - - _settingsHelpPage(frame) { - let expanderFrame = this._expanderFrame(frame); - - expanderFrame._add( - new Gtk.Label({ - use_markup: true, - wrap: true, - label: _( - "Here you can reset the settings of this extension to default. You can also export current settings to an ini file for backup, and then import it when you need restore. For your information, you may also open the official IBus customization settings for customizations you can't find in this extension.", - ), - }), - ); - } - - _checkMaker(x) { - return new Gtk.CheckButton({ - label: x, - hexpand: true, - halign: Gtk.Align.START, - }); - } - - _switchLabelMaker(x) { - return new Gtk.Label({ - label: x, - hexpand: true, - use_markup: true, - halign: Gtk.Align.START, - }); - } - - _comboMaker(ops) { - let l = new Gtk.ListStore(); - l.set_column_types([GObject.TYPE_STRING]); - ops.forEach((op) => l.set(l.append(), [0], [op])); - let c = new Gtk.ComboBox({ model: l }); - let r = new Gtk.CellRendererText(); - c.pack_start(r, false); - c.add_attribute(r, "text", 0); - return c; - } - - _iconButtonMaker(icon_name) { - return new Gtk.Button({ - icon_name: icon_name, - visible: true, - }); - } - - _iconLinkButtonMaker(uri, icon_name) { - return new Gtk.LinkButton({ - uri, - icon_name: icon_name, - visible: true, - }); - } - - _showFileChooser(title, params, acceptBtn, acceptHandler, setDefaultName) { - let transient_for; - transient_for = this.get_root ? this.get_root() : this; - let dialog = new Gtk.FileChooserDialog( - mergeObjects({ title: title, transient_for: transient_for }, params), - ); - if (setDefaultName) - dialog.set_current_name( - "Customize_IBus_Settings_" + new Date().getTime().toString() + ".ini", - ); - dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL); - dialog.add_button(acceptBtn, Gtk.ResponseType.ACCEPT); - - dialog.show(); - - dialog.connect("response", (d, id) => { - if (id !== Gtk.ResponseType.ACCEPT) { - d.destroy(); - return; - } - acceptHandler.call(this, d.get_file().get_path()); - d.destroy(); - }); - } - - /* Settings */ - // Restore Default Settings - _resetExtension() { - let transient_for = this.get_root ? this.get_root() : this; - let dialog = new Gtk.MessageDialog({ - transient_for, - modal: true, - message_type: Gtk.MessageType.WARNING, - }); - dialog.set_default_response(Gtk.ResponseType.OK); - dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL); - dialog.add_button(_("OK"), Gtk.ResponseType.OK); - dialog.set_markup( - "" + _("Reset All Settings to Default?") + "", - ); - let message = new Gtk.Label({ - wrap: true, - justify: 3, - use_markup: true, - label: _("This will discard all the current configurations!"), - }); - dialog.get_message_area().append(message); - dialog.connect("response", (d, id) => { - if (id !== Gtk.ResponseType.OK) { - d.destroy(); - return; - } - for (let field in Fields) - if (field !== "IBUSRESTTIME") this.gsettings.reset(Fields[field]); - d.destroy(); - }); - dialog.show(); - } - - destroy() { - if (this._fileChooser) this._fileChooser.destroy(); - this._fileChooser = null; - if (this._fileDarkChooser) this._fileDarkChooser.destroy(); - this._fileDarkChooser = null; - if (this._cssFileChooser) this._cssFileChooser.destroy(); - this._cssFileChooser = null; - if (this._cssDarkFileChooser) this._cssDarkFileChooser.destroy(); - this._cssDarkFileChooser = null; - } - }, -); - -export default class Preferences extends ExtensionPreferences { - /** - * This class is constructed once when your extension preferences are - * about to be opened. This is a good time to setup translations or anything - * else you only do once. - * - * @param {ExtensionMeta} metadata - An extension meta object - */ - constructor(metadata) { - super(metadata); - } - - /** - * Fill the preferences window with preferences. - * - * If this method is overridden, `getPreferencesWidget()` will NOT be called. - * - * @param {Adw.PreferencesWindow} window - the preferences window - */ - fillPreferencesWindow(window) { - const widget = this.getPreferencesWidget(); - const page = new Adw.PreferencesPage(); - const group = new Adw.PreferencesGroup(); - group.add(widget); - page.add(group); - window.set_title(_("Customize IBus")); - window.add(page); - } - - /** - * This function is called when the preferences window is first created to - * build and return a GTK4 widget. - * - * The preferences window will be a `Adw.PreferencesWindow`, and the widget - * returned by this function will be added to an `Adw.PreferencesPage` or - * `Adw.PreferencesGroup` if necessary. - * - * @returns {Gtk.Widget} the preferences widget - */ - getPreferencesWidget() { - return new CustomizeIBus(this.getSettings(), this.metadata, this.dir); - } -} +/** + * Prefs Dialog + * + * @author Javad Rahmatzadeh + * @copyright 2020-2024 + * @license GPL-3.0-only + */ + +import Gtk from 'gi://Gtk'; +import Gdk from 'gi://Gdk'; + +import {ExtensionPreferences} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'; +import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js'; + +import {Prefs} from './lib/Prefs/Prefs.js'; +import {PrefsKeys} from './lib/Prefs/PrefsKeys.js'; + +/** + * Preferences window entry point + */ +export default class customizeIBusPrefs extends ExtensionPreferences +{ + /** + * fill preferences window + * + * @returns {void} + */ + fillPreferencesWindow(window) { + const shellVersion = parseFloat(Config.PACKAGE_VERSION); + const gettextDomain = this.metadata['gettext-domain']; + + let UIFolderPath = this.dir.get_child('ui').get_path(); + let prefsKeys = new PrefsKeys(shellVersion); + + let prefs = new Prefs( + { + Builder: new Gtk.Builder(), + Settings: this.getSettings(), + Gdk, + }, + prefsKeys, + shellVersion + ); + + prefs.fillPrefsWindow(window, UIFolderPath, gettextDomain); + } +} \ No newline at end of file diff --git a/customize-ibus@hollowman.ml/schemas/gschemas.compiled b/customize-ibus@hollowman.ml/schemas/gschemas.compiled new file mode 100644 index 0000000000000000000000000000000000000000..733f1a8496332870e08c7f1a9288bf142e25c8ed GIT binary patch literal 4532 zcmai1Yitx%7`-A$0SlBC1OzPBob>PvHk#>5PbX~5+iCfXf0RovwCoSwOJ@15^{ z_cd>+YU!%s2>&-4yv);ye!h1RxapIH6Uls*6!XP;aOXfF28@NsNl&GW^eP8v~5>F&=ycPz_9opayypa20S(3`zVy*~hiu017mb z0&0C+5557I4$J^%0yhFT0k;6Nf!iXegI?a&qD%!dwxh)g(F6VpSnx~5GWyix;GY3k zmI<-9d&?d4sVm?ozzVS8zP45LsmH>f4^9K0KVi?KPhAPW0NxC&npnAqKJ_s8o#4Gd z@0x*s(Wf2^zZ-lQ_+j1oS@fw#!2be#9BArz^)dR??9WN?Y2fdk{%!QBFNI%*0WAlr z&+U4aKK14B6X4r{@28&|OP_iO{JX#p03Q{eI7pv*4EzFkGtlv}_9A_1epe@WFYwW+ z<0<;om%;xKd<6Jl!%geyQ!~ydz&`_BZ}dM+pL!(xG9+3JQFCq!eQK7k1J4B>fB&am z`qZP~KLXAGZSHOv2Ws}S4ZI0BU;prCmZxUiI>5Vut`)-u(Whql9`IMdq2!n4^r`t> zC&5F82vL9cylM2Q*`EYh0lrR z8-T91mHX&Zm&4x*-VV$gxO^sk>MP*)fDZ$|zrN;a`qYeDFZe9bv--&)Tpy?hz{lW= z6wvSN8&g@Hn%_GgoCbcHe{eW`YUWP?yc&3D;6C|X)NHo{yc@XpR`XYur)K}V!TW)V zNjqgeQ!~y-!N-7~mwi~z^3=??li<_9(bu}l=u?k}Ke`+Yj2yRUEq!Xnc@}s!Ft`1s zQ}n4B=exj5fCXpEWIw6dZU(##*xIkWo#m++pRM5SKz`bu@90xA4&C7WK>ePjXX#VZ z{{s9Quy**nE%d2neqs?U2d4ZX7SpHZ{H+EjfHA##6@6;Prw%+982afwi|A9co=3o0 zU}y5j=jc<@Zv$@vf_0vn>wG(S<1oZ<&Bj)ir)K$1@F8Hwp_~7tPhAH8DEJulxNj!X zr{?&c0AD;@hPIzpeC{%G)c;H}p71@x&o?see%f%+ZW574Ksf}aPwK<2$ytgf=%)v>Pob$KE4stNjEnl17A`@|*M?~7%3igEP9&rd`ScmsRE z?<|e39IQqyt9o-qerF^z3wn?_{(W}lbQK|ADFK8I2Br=si_$2(q~{5}RrPIRvr%l%6R%DDNyoCw|u=got7y_Vjb z;Z!hf1kE3>a2%MkK?y96ezSecVY!Pex_sUzSNSd`zH79YD-G`}uwG-;mX-d;dRLki z4X)$hmL%u1j9hU*l)R-iX_jWBQJs7qt_9&-SDIWS?R`VgUToY;+cWcOT6d7-#qp3c zrnoe6{x$^jw`4t&jl}xVXJSX!LpB_Cx!ADRS+);#2`~cSeTjFc>jB>9u>Hy(?@ZSK zyccr5&jNUl!|_to0laJR{x%W7wpqM8a&JTi%lq2RVBWv31b7!42TTBX=fm+&+zKeb zC}1+ceCFMe_qS?*`xTDia?MPDuL9Wj>wv2P-tluse custom font - false + true use custom candidate box opacity @@ -255,7 +255,7 @@ candidate popup box right click function - false + true use candidate popup box not follow caret @@ -273,4 +273,4 @@ last remembered candidate box position - + \ No newline at end of file diff --git a/customize-ibus@hollowman.ml/ui/adw/about.ui b/customize-ibus@hollowman.ml/ui/adw/about.ui new file mode 100755 index 0000000..1894254 --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/about.ui @@ -0,0 +1,121 @@ + + + + about + About + help-about-symbolic + + + + + + vertical + 20 + 20 + 20 + 20 + 20 + + + /home/jas/.local/share/gnome-shell/extensions/customize-ibus@hollowman.ml/img/logo.png + 128 + + + + + Customize IBus + center + + + + + + Version: 89 + center + + + + + Full customization of appearance, behavior, system tray and input source indicator for IBus. + center + True + 50 + + + + + horizontal + center + + + Copyright © 2021-2023 + + + + + Hollow Man + https://github.com/HollowMan6 + + + + + <hollowman@opensuse.org> + + + + + + + Source Code + https://github.com/openSUSE/Customize-IBus + + + + + + + + Current Session: Wayland + center + + + + + This program comes with ABSOLUTELY NO WARRANTY. + center + + + + + horizontal + center + 5 + + + See the + + + + + GNU General Public License, version 3 or later + https://www.gnu.org/licenses/gpl-3.0.html + + + + + for details. + + + + + + + + + + diff --git a/customize-ibus@hollowman.ml/ui/adw/background.ui b/customize-ibus@hollowman.ml/ui/adw/background.ui new file mode 100755 index 0000000..5bc8c2a --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/background.ui @@ -0,0 +1,171 @@ + + + + background + Background + preferences-desktop-wallpaper-symbolic + + + + Background Settings + + + + + + + horizontal + 10 + + + false + start + + + + + Use custom light background + start + false + + + + + + Zoom + Centered + Full + + end + + + + + + Repeat + No Repeat + + end + + + + + + (None) + + + end + + + + + + + + + + + + + horizontal + 10 + + + false + start + + + + + Use custom dark background + start + false + + + + + + Zoom + Centered + Full + + end + + + + + + Repeat + No Repeat + + end + + + + + + (None) + + + end + + + + + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Support customizing your IBus Input window background with a picture. It has a higher priority than the theme-defined background. + true + 0 + + + + + + When light background and dark background are turned on at the same time, the IBus background will automatically follow GNOME Night Light mode, use light background when off, and use dark background when on. When only the light background or dark background is turned on, the IBus background will always use the background that is turned on. + true + 0 + + + + + + <span size="small"><b>Note:</b> Please make sure your background picture can always be visited. If your pictures are stored in the removable device and the system doesn't mount it by default, please disable and then enable the corresponding <b>Use custom background</b> again to make it effective after manually mounting.</span> + true + true + 0 + + + + + + + + + + + + + + + diff --git a/customize-ibus@hollowman.ml/ui/adw/general.ui b/customize-ibus@hollowman.ml/ui/adw/general.ui new file mode 100755 index 0000000..447741c --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/general.ui @@ -0,0 +1,372 @@ + + + + general + General + preferences-desktop-symbolic + + + + General Settings + true + + + + + 50 + + + horizontal + 10 + 12 + 12 + 6 + 6 + + + true + center + + + + + Candidates Orientation + start + false + center + + + + + + + + Vertical + Horizontal + + + + 0 + true + + + + + + + + + + + 50 + Candidates Popup Animation + + + + None + Slide + Fade + All + + + + 0 + + + + + + + 50 + Candidate Box Right Click + + + + Open Menu + Switch Source + + + + 0 + + + + + + + 50 + Candidates Scroll + + + + Change Page + Change Candidate + + + + 0 + + + + + + + 50 + Fix Candidate Box + + + + Remember Last Position + Don't Remember Position + + + + 0 + + + + + + + 50 + Candidate Box Position + + + + Center + Center-Left + Top-Left + Top-Center + Top-Right + Center-Right + Bottom-Right + Bottom-Center + Bottom-Left + + + + 0 + + + + + + + 50 + + + horizontal + 310 + 12 + 12 + 6 + 6 + + + horizontal + + + Use custom font + start + false + center + + + + + + + false + false + end + center + 16 + 80 + Sans Regular 16 + + + + + + + + + + + 50 + Auto Switch ASCII Mode + false + + + + + + + 50 + Candidate Box Opacity + false + + + + + + + false + 50 + + + horizontal + 15 + true + true + 12 + 12 + 6 + 6 + + + Candidate Box Opacity + false + true + true + center + + + + + horizontal + 5 + true + + + horizontal + true + true + false + + + 0 + 255 + 255 + 1 + + + + + + + + 255 + true + true + 3 + 1 + + + + + + + + + + + + + + + + + 50 + Fix IME List Order + false + + + + + + + 50 + Enable Drag to Reposition Candidate Box + false + + + + + + + 50 + Candidate Box Page Buttons + false + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Here you can set the IBus input window orientation, animation, right click to open menu or switch source, scroll to switch among pages or candidates, fix candidate box to not follow caret position, font, ASCII mode auto-switch when windows are switched by users, candidate box opacity, fix IME list order when switching, reposition candidate box by dragging when input, and also show or hide candidate box page buttons. + true + 0 + + + + + + <span size="small"><b>Note:</b> If <b>fix candidate box</b> is enabled, you can set the candidate box position with 9 options. Recommend to <b>enable drag to reposition candidate box</b> at the same time so that you can rearrange the position at any time. Will remember candidate position forever after reposition if you set to <b>remember last position</b>, and restore at next login.</span> + true + true + 0 + + + + + + <span size="small"><b>Note:</b> If <b>auto switch ASCII mode</b> is enabled, and you have set to <b>Remember Input State</b>, every opened APP's input mode will be remembered if you have switched the input source manually in the APP's window, and the newly-opened APP will follow the configuration. APP's Input State will be remembered forever.</span> + true + true + 0 + + + + + + <span size="small"><b>Note:</b> If you <b>enable drag to reposition candidate box</b>, and if <b>fix candidate box</b> is enabled, your rearranged position will last until the end of this session. If not the rearranged position will only last for the specific input.</span> + true + true + 0 + + + + + + + + + + + + + + + diff --git a/customize-ibus@hollowman.ml/ui/adw/indicator.ui b/customize-ibus@hollowman.ml/ui/adw/indicator.ui new file mode 100644 index 0000000..6f32437 --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/indicator.ui @@ -0,0 +1,361 @@ + + + + indicator + Indicator + input-keyboard-symbolic + + + + Indicator Settings + + + + + Use input source indicator + true + + + + + + + Indicate only when switching input source + true + + + + + + + Indicate only when using ASCII mode + false + + + + + + + Don’t indicate when using single mode IME + true + + + + + + + Enable right click to close indicator + false + + + + + + + Enable scroll to switch input source + false + + + + + + + Indicator popup animation + + + + None + Slide + Fade + All + + + + 0 + + + + + + + + + horizontal + 310 + + + horizontal + + + Use custom font + start + false + 12 + + + + + + + false + false + end + center + 16 + 80 + Sans Regular 16 + + + + + + + + + + + Enable indicator left click + + + + Drag to Move + Switch Source + + + + 0 + + + + + + + + false + + + horizontal + 15 + true + true + + + Indicator Opacity + false + 12 + true + true + + + + + horizontal + 5 + true + + + horizontal + true + true + false + + + 0 + 255 + 255 + 1 + + + + + + + + 255 + true + true + 3 + 1 + + + + + + + + + + + + + + + + + + + + + horizontal + 10 + + + true + + + + + Enable indicator show delay (unit: seconds) + start + false + + + + + 0.0 + + + + + horizontal + true + + + 0 + 10 + 1 + 0.1 + + + + + + + 10.0 + + + + + 1.0 + 3 + + + + + + + + + + + + + horizontal + 10 + + + true + + + + + Enable indicator auto-hide timeout (unit: seconds) + start + false + + + + + 0.0 + + + + + horizontal + true + + + 0 + 10 + 1 + 0.1 + + + + + + + 10.0 + + + + + 1.0 + 3 + + + + + + + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Here you can set to show input source indicator, default is to show indicator every time you type, move caret or switch input source. You can set to show indicator only when switching input source. You can also set to only notify in ASCII mode (for multi-mode IME), not notify when using single mode IME, mouse right click to close indicator, scroll to switch input source, popup animation, font, mouse left click to switch input source or drag to move indicator, indicator opacity, enable show delay and show timeout (in seconds), enable auto-hide and auto-hide timeout (in seconds). + true + 0 + + + + + + <span size="small"><b>Note:</b> If you choose to enable the show delay, there won't be a show delay when you switch input source or window.</span> + true + true + 0 + + + + + + + + + + + + + + + + + + + + + + diff --git a/customize-ibus@hollowman.ml/ui/adw/settings.ui b/customize-ibus@hollowman.ml/ui/adw/settings.ui new file mode 100644 index 0000000..e616fcf --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/settings.ui @@ -0,0 +1,134 @@ + + + + settings + Settings + preferences-desktop-symbolic + + + + + + vertical + 12 + + + horizontal + center + + + Settings for extension + + + + + + + + horizontal + 12 + center + + + Restore Default Settings + + + + + Export Current Settings + + + + + Import Settings from File + + + + + + + + + + + + + + vertical + 12 + + + horizontal + center + + + Other official IBus customization settings + + + + + + + + horizontal + 12 + center + + + GNOME Settings + + + + + IBus Preferences + + + + + + + + + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Here you can reset the settings of this extension to default. You can also export current settings to an ini file for backup, and then import it when you need restore. For your information, you may also open the official IBus customization settings for customizations you can't find in this extension. + true + 0 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/customize-ibus@hollowman.ml/ui/adw/theme.ui b/customize-ibus@hollowman.ml/ui/adw/theme.ui new file mode 100755 index 0000000..d37ea60 --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/theme.ui @@ -0,0 +1,142 @@ + + + + theme + Theme + preferences-desktop-theme-symbolic + + + Theme Settings + + + + + + + horizontal + 10 + + + false + start + + + + + Custom IME light theme + start + true + + + + + end + + (None) + + + + + + + + + + + + + + + horizontal + 10 + + + false + start + + + + + Custom IME dark theme + start + true + + + + + end + + (None) + + + + + + + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Support importing stylesheet generated by <a href="https://github.com/openSUSE/IBus-Theme-Tools">IBus Theme Tools</a> or provided by <a href="https://github.com/openSUSE/IBus-Theme-Hub">IBus Theme Hub</a>. + true + true + 0 + + + + + + When light theme and dark theme are turned on at the same time, the IBus theme will automatically follow GNOME Night Light mode, use light theme when off, and use dark theme when on. When only the light theme or dark theme is turned on, the IBus theme will always use the theme that is turned on. + true + 0 + + + + + + <span size="small"><b><i>Warning:</i> If not for debugging, please DO NOT add any classes that's not started with <i>.candidate-* </i> into IBus stylesheet to prevent from corrupting system themes.</b></span> + true + true + 0 + + + + + + <span size="small"><b>Note:</b> Support stylesheets hot reload, CSS changes reflecting in real-time.</span> + true + true + 0 + + + + + + + + + + + + + + + diff --git a/customize-ibus@hollowman.ml/ui/adw/tray.ui b/customize-ibus@hollowman.ml/ui/adw/tray.ui new file mode 100755 index 0000000..b9e4a74 --- /dev/null +++ b/customize-ibus@hollowman.ml/ui/adw/tray.ui @@ -0,0 +1,153 @@ + + + + tray + Tray + utilities-terminal-symbolic + + + + IBus Version: + + + + Start / Restart IBus + + + Start / Restart IBus + false + false + end + center + 16 + 80 + + + + + + + + Show IBus tray icon + false + + + + + + Use tray icon click source + false + + + + + + Tray icon click source key + + + + Left + Right + + + + 0 + + + + + + + + + Add Additional Menu Entries + + + + Copying Emoji + false + + + + + + This Extension's Preferences + false + + + + + + IBus Preferences + false + + + + + + IBus Version + false + + + + + + Restarting IBus + false + + + + + + Exiting IBus + false + + + + + + + Help + Click to expand for more information + + + + + + vertical + 12 + 12 + 12 + 12 + 12 + + + + Here you can set to show IBus tray icon, enable directly switch source with click, add additional menu entries to IBus input source indicator menu at system tray to restore the feelings on Non-GNOME desktop environment. You can also start or restart IBus by pressing the top button. + true + 0 + + + + + + <span size="small"><b>Note:</b> If <b>Directly switch source with click</b> is enabled, when the left key is selected, if you click the tray icon with left key, you will have input source switched, and click right key will open the menu as normal, vice versa.</span> + true + true + 0 + + + + + + + + + + + + + + + + \ No newline at end of file