Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC Ibus Extension Refactor #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 49 additions & 47 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
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", "英"];
Expand Down Expand Up @@ -91,7 +92,7 @@
CandidateArea.setOrientation.bind(CandidateArea);
CandidateArea.setOrientation = () => {};
gsettings.bind(
Fields.ORIENTATION,
PrefsKeys.keys['candidate_orientation'].name,

Check failure on line 95 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'candidate_orientation'` with `"candidate_orientation"`
this,
"orientation",
Gio.SettingsBindFlags.GET,
Expand All @@ -100,7 +101,7 @@
`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);

Check failure on line 104 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `PrefsKeys.keys['candidate_orientation'].name,·1·-·value` with `⏎············PrefsKeys.keys["candidate_orientation"].name,⏎············1·-·value,⏎··········`
},
);
}
Expand Down Expand Up @@ -140,7 +141,7 @@
super();
this._openOrig = CandidatePopup.open;
gsettings.bind(
Fields.CANDANIMATION,
PrefsKeys.keys['candidate_popup_animation'].name,

Check failure on line 144 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'candidate_popup_animation'` with `"candidate_popup_animation"`
this,
"animation",
Gio.SettingsBindFlags.GET,
Expand Down Expand Up @@ -189,7 +190,7 @@
constructor() {
super();
gsettings.bind(
Fields.CANDRIGHTFUNC,
PrefsKeys.keys['candidate-box-right-click-func'].name,

Check failure on line 193 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'candidate-box-right-click-func'` with `"candidate-box-right-click-func"`
this,
"switchfunction",
Gio.SettingsBindFlags.GET,
Expand Down Expand Up @@ -300,7 +301,7 @@
super();

gsettings.bind(
Fields.SCROLLMODE,
PrefsKeys.keys['candidate-scroll-mode'].name,

Check failure on line 304 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'candidate-scroll-mode'` with `"candidate-scroll-mode"`
this,
"scrollmode",
Gio.SettingsBindFlags.GET,
Expand Down Expand Up @@ -372,13 +373,13 @@
CandidatePopup.setPosition(CandidateDummyCursor, 0);
};
gsettings.bind(
Fields.CANDSTILLPOS,
PrefsKeys.keys['candidate-still-position'].name,

Check failure on line 376 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'candidate-still-position'` with `"candidate-still-position"`
this,
"position",
Gio.SettingsBindFlags.GET,
);
gsettings.bind(
Fields.REMCANDPOS,
PrefsKeys.keys['remember-candidate-position'].name,

Check failure on line 382 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'remember-candidate-position'` with `"remember-candidate-position"`
this,
"remember",
Gio.SettingsBindFlags.GET,
Expand All @@ -401,7 +402,7 @@
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()),

Check failure on line 405 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `gsettings.get_value(PrefsKeys.keys['candidate-box-position'].name).deep_unpack()` with `⏎············gsettings⏎··············.get_value(PrefsKeys.keys["candidate-box-position"].name)⏎··············.deep_unpack(),⏎··········`
);
if (state.has("x") && state.has("y")) {
x = state.get("x");
Expand Down Expand Up @@ -480,22 +481,22 @@
constructor() {
super();
gsettings.bind(
Fields.CUSTOMFONT,
PrefsKeys.keys['custom-font'].name,

Check failure on line 484 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'custom-font'` with `"custom-font"`
this,
"fontname",
Gio.SettingsBindFlags.GET,
);
this._fontChangeID = IBusSettings.connect(
`changed::${Fields.CUSTOMFONT}`,
`changed::${PrefsKeys.keys['custom-font'].name}`,

Check failure on line 490 in [email protected]/extension.js

View workflow job for this annotation

GitHub Actions / lint

Replace `'custom-font'` with `"custom-font"`
() => {
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 = () => {
Expand Down Expand Up @@ -688,7 +689,7 @@
this._child_opacity.push(candidate_child[i].get_opacity());
}
gsettings.bind(
Fields.CANDOPACITY,
PrefsKeys.keys['candidate-opacity'].name,
this,
"opacity",
Gio.SettingsBindFlags.GET,
Expand Down Expand Up @@ -1090,13 +1091,13 @@
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;
Expand Down Expand Up @@ -1145,7 +1146,7 @@
constructor() {
super();
gsettings.bind(
Fields.TRAYSSWITCHKEY,
PrefsKeys.keys['tray-source-switch-click-key'].name,
this,
"traysswitchkey",
Gio.SettingsBindFlags.GET,
Expand Down Expand Up @@ -1788,102 +1789,103 @@

_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]);
Expand Down Expand Up @@ -2535,49 +2537,49 @@
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,
Expand All @@ -2589,25 +2591,25 @@
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,
Expand All @@ -2625,7 +2627,7 @@
Gio.SettingsBindFlags.GET,
);
gsettings.bind(
Fields.USEBUTTONS,
PrefsKeys.keys['use-candidate-buttons'].name,
this,
"usebuttons",
Gio.SettingsBindFlags.GET,
Expand All @@ -2647,7 +2649,7 @@
`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);
},
);
}
Expand Down
Empty file added [email protected]/lib/API.js
Empty file.
Loading
Loading