diff --git a/README.md b/README.md
index b38de8f..d7f540f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# 自定义IBus
+# 自定义 IBus
[![last-commit](https://img.shields.io/github/last-commit/HollowMan6/Customize-IBus)](https://github.com/HollowMan6/Customize-IBus/graphs/commit-activity)
[![release-date](https://img.shields.io/github/release-date/HollowMan6/Customize-IBus)](../../releases)
@@ -17,15 +17,17 @@
(English version is down below)
-在GNOME Shell中更改IBus的候选框方向、主题、字体和输入法默认语言。
+### 注意:如果后期无重大 BUG 的话,v8 将是支持 GNOME 3.38 的最后一个版本
+
+在 GNOME Shell 中更改 IBus 的候选框方向、shell 主题、背景图片、字体和输入法默认语言。
![demo](img/demo.png)
## 安装
-从GNOME扩展商店中获取:
+从 GNOME 扩展商店中获取:
-[][EGO]
+[][ego]
或者手动自行安装:
@@ -38,19 +40,36 @@ cd Customize-IBus && make install
![image](img/preference.png)
-## 使用用户主题来更改IBus皮肤的实现
+## 使用用户主题来更改 IBus 皮肤的实现
+
+当用户从主题列表中选中一个主题,本扩展会首先读取该主题的定义 CSS 文件,从中提取出定义 IBus 皮肤的类样式(`.candidate-*`),然后将其写入本扩展的`stylesheet.css`文件。最后重启 GNOME-shell。
+
+### _提示:_
-当用户从主题列表中选中一个主题,本扩展会首先读取该主题的定义CSS文件,从中提取出定义IBus皮肤的类样式(`.candidate-*`),然后将其写入本扩展的`stylesheet.css`文件。最后重启GNOME-shell。
+1. 推荐使用 X11。如果你在 Wayland 中更改 IBus 主题,你的当前所有工作都将会丢失,因为 Wayland 下只支持通过重新登陆来重启 GNOME-shell。
+2. 在 Fedora 33 和 Ubuntu 20.04, GNOME-shell 3.38 中(v3,v5,v8)通过了测试。
+3. 对于那些不使用 GNOME 而是使用如 KDE 等桌面环境的用户,更改 IBus 主题最简单的方法请参见[这里](https://github.com/qvshuo/Ibus-custom-theme),从而为 IBus 指定一个不同的 GTK 主题。
-### *提示:*
-1. 推荐使用X11。如果你在Wayland中更改IBus主题,你的当前所有工作都将会丢失,因为Wayland下只支持通过重新登陆来重启GNOME-shell。
-2. 在Fedora 33和Ubuntu 20.04, GNOME-shell 3.38中通过了测试。
+## 更改 IBus 背景图片的实现
+
+在[修复 Unity8-Wood 主题对 IBus 背景支持](https://github.com/openSUSE/mentoring/issues/158#issuecomment-813837436)时发现为`.candidate-popup-content`增加如下样式:
+
+```css
+background: url("assets/bg.png");
+background-repeat: no-repeat;
+background-size: cover;
+```
+
+即可实现对背景的修改。
+
+进一步结合[ibus-font-setting](https://extensions.gnome.org/extension/1121/ibus-font-setting/)和[background-logo](https://pagure.io/background-logo-extension),参考 GNOME-Shell 源代码中`candidate-popup-content`样式[对应组件](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/ibusCandidatePopup.js#L154),并对其修改样式实现不重启 GNOME-Shell 进行 IBus 背景图片的修改。
## 备忘
-- [X] 从[ibus-tweaker](https://github.com/tuberry/ibus-tweaker)中导入,去除与IBus无关功能。
-- [X] 从用户主题中读取IBus相关样式
-- [X] 将相关功能合并在一起。
+- [x] 从[ibus-tweaker](https://github.com/tuberry/ibus-tweaker)中导入,去除与 IBus 无关功能。
+- [x] 从用户主题中读取 IBus 相关样式
+- [x] 将相关功能合并在一起。
+- [x] V8: 增加更改 IBus 背景图片功能。
## 致谢
@@ -58,17 +77,21 @@ cd Customize-IBus && make install
2. [ibus-tweaker](https://github.com/tuberry/ibus-tweaker)
3. [user-theme](https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/tree/master/extensions/user-theme)
4. [shell-restarter](https://github.com/koolskateguy89/gnome-shell-extension-shell-restarter)
+5. [background-logo](https://pagure.io/background-logo-extension)
-*该项目是谷歌编程之夏 (GSoC) 2021于[OpenSUSE](https://github.com/openSUSE/mentoring/issues/158)社区成果的一部分。*
+_该项目是谷歌编程之夏 (GSoC) 2021 于[OpenSUSE](https://github.com/openSUSE/mentoring/issues/158)社区成果的一部分。_
# Customize IBus
-Customize IBus in GNOME Shell for orientation, theme, font and input mode auto-switch.
+### Note: If no severe bug was found later, v8 will be the last version that support GNOME 3.38.
+
+Customize IBus for orientation, shell theme, background picture, font and ascii mode auto-switch.
![demo](img/demo-en.png)
## Installation
-[][EGO]
+
+[][ego]
Or manually:
@@ -85,15 +108,18 @@ cd Customize-IBus && make install
When user chooses a theme from the list, this extension will first read the theme CSS file, extract the IBus related style classes (`.candidate-*`), then write it to extension's `stylesheet.css`. Finally restart the GNOME-shell.
-### *NOTE:*
+### _NOTE:_
+
1. Recommend to use X11. If you change IME theme under Wayland, all your current work may be lost (Since Wayland only support relogin to restart the GNOME-shell).
-2. Tested on Fedora 33 and Ubuntu 20.04, GNOME-shell 3.38.
+2. Tested on Fedora 33 and Ubuntu 20.04, GNOME-shell 3.38(v3, v5, v8).
+3. For users who don't use GNOME but other desktop environments like KDE, the easiest way to change the IBus theme is to act as described in [here](https://github.com/qvshuo/Ibus-custom-theme) to use a different GTK theme for IBus.
## To-do
-- [X] Import from [ibus-tweaker](https://github.com/tuberry/ibus-tweaker) and remove features unrelated to IBus.
-- [X] Read from user themes and apply only for ibus.
-- [X] Merge functions related together.
+- [x] Import from [ibus-tweaker](https://github.com/tuberry/ibus-tweaker) and remove features unrelated to IBus.
+- [x] Read from user themes and apply only for ibus.
+- [x] Merge functions related together.
+- [x] V8: Add functionality to modify IBus Background picture.
## Acknowledgements
@@ -101,7 +127,8 @@ When user chooses a theme from the list, this extension will first read the them
2. [ibus-tweaker](https://github.com/tuberry/ibus-tweaker)
3. [user-theme](https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/tree/master/extensions/user-theme)
4. [shell-restarter](https://github.com/koolskateguy89/gnome-shell-extension-shell-restarter)
+5. [background-logo](https://pagure.io/background-logo-extension)
-*This project is part of the achievement of the Google Summer of Code 2021 at [OpenSUSE](https://github.com/openSUSE/mentoring/issues/158).*
+_This project is part of the achievement of the Google Summer of Code 2021 at [OpenSUSE](https://github.com/openSUSE/mentoring/issues/158)._
-[EGO]:https://extensions.gnome.org/extension/4112/customize-ibus/
+[ego]: https://extensions.gnome.org/extension/4112/customize-ibus/
diff --git a/customize-ibus@hollowman.ml/extension.js b/customize-ibus@hollowman.ml/extension.js
index e11054b..e805319 100644
--- a/customize-ibus@hollowman.ml/extension.js
+++ b/customize-ibus@hollowman.ml/extension.js
@@ -192,6 +192,42 @@ const IBusFontSetting = GObject.registerClass(
}
);
+const IBusBGSetting = GObject.registerClass(
+ {
+ Properties: {
+ background: GObject.param_spec_string(
+ "bg",
+ "bg",
+ "background",
+ "",
+ GObject.ParamFlags.WRITABLE
+ ),
+ },
+ },
+ class IBusBGSetting extends GObject.Object {
+ _init() {
+ super._init();
+ gsettings.bind(Fields.CUSTOMBG, this, "bg", Gio.SettingsBindFlags.GET);
+ }
+
+ set bg(bg) {
+ global.log(_("loading background for IBus:") + bg);
+ let candidateBox = CandidatePopup.bin.get_children();
+ if (candidateBox)
+ candidateBox[0].set_style(
+ 'background: url("%s"); background-repeat:no-repeat; background-size:cover;'.format(
+ bg
+ )
+ );
+ }
+
+ destroy() {
+ let candidateBox = CandidatePopup.bin.get_children();
+ if (candidateBox) candidateBox[0].set_style("");
+ }
+ }
+);
+
const IBusOrientation = GObject.registerClass(
{
Properties: {
@@ -577,6 +613,13 @@ const Extensions = GObject.registerClass(
false,
GObject.ParamFlags.WRITABLE
),
+ bg: GObject.param_spec_boolean(
+ "bg",
+ "bg",
+ "bg",
+ false,
+ GObject.ParamFlags.WRITABLE
+ ),
input: GObject.param_spec_boolean(
"input",
"input",
@@ -626,6 +669,7 @@ const Extensions = GObject.registerClass(
"font",
Gio.SettingsBindFlags.GET
);
+ gsettings.bind(Fields.USECUSTOMBG, this, "bg", Gio.SettingsBindFlags.GET);
gsettings.bind(
Fields.ENABLEORIEN,
this,
@@ -668,6 +712,17 @@ const Extensions = GObject.registerClass(
}
}
+ set bg(bg) {
+ if (bg) {
+ if (this._bg) return;
+ this._bg = new IBusBGSetting();
+ } else {
+ if (!this._bg) return;
+ this._bg.destroy();
+ delete this._bg;
+ }
+ }
+
set orien(orien) {
if (orien) {
if (this._orien) return;
diff --git a/customize-ibus@hollowman.ml/locale/customize-ibus.pot b/customize-ibus@hollowman.ml/locale/customize-ibus.pot
index 70300c7..2a63422 100644
--- a/customize-ibus@hollowman.ml/locale/customize-ibus.pot
+++ b/customize-ibus@hollowman.ml/locale/customize-ibus.pot
@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: Customize Ibus 5\n"
+"Project-Id-Version: Customize Ibus 8\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-04-05 17:10+0800\n"
+"POT-Creation-Date: 2021-04-07 09:05+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
@@ -17,58 +17,70 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: extension.js:288
-msgid "loading user theme for IBus:"
+#: extension.js:214
+msgid "loading background for IBus:"
msgstr ""
-#: extension.js:374
+#: extension.js:410
msgid "loading default theme for IBus"
msgstr ""
-#: extension.js:423
+#: extension.js:459
msgid "Restarting..."
msgstr ""
-#: prefs.js:79
+#: prefs.js:81
msgid "Custom IME theme"
msgstr ""
-#: prefs.js:80
+#: prefs.js:82
msgid "Use custom font"
msgstr ""
-#: prefs.js:81
+#: prefs.js:83
+msgid "Use custom background"
+msgstr ""
+
+#: prefs.js:84
msgid "Auto switch ASCII mode"
msgstr ""
-#: prefs.js:82
+#: prefs.js:85
msgid "Candidates orientation"
msgstr ""
-#: prefs.js:85
+#: prefs.js:88
msgid "Vertical"
msgstr ""
-#: prefs.js:86
+#: prefs.js:89
msgid "Horizontal"
msgstr ""
-#: prefs.js:89
+#: prefs.js:92
msgid "On"
msgstr ""
-#: prefs.js:90
+#: prefs.js:93
msgid "Off"
msgstr ""
-#: prefs.js:91
+#: prefs.js:94
msgid "Default"
msgstr ""
-#: prefs.js:120
+#: prefs.js:102
+msgid "Select an Image"
+msgstr ""
+
+#: prefs.js:112
+msgid "(None)"
+msgstr ""
+
+#: prefs.js:152
msgid "Customize IBus"
msgstr ""
-#: prefs.js:357
+#: prefs.js:406
msgid "Follow User Theme"
msgstr ""
diff --git a/customize-ibus@hollowman.ml/locale/zh_CN/LC_MESSAGES/customize-ibus.po b/customize-ibus@hollowman.ml/locale/zh_CN/LC_MESSAGES/customize-ibus.po
index c564840..05a26ad 100644
--- a/customize-ibus@hollowman.ml/locale/zh_CN/LC_MESSAGES/customize-ibus.po
+++ b/customize-ibus@hollowman.ml/locale/zh_CN/LC_MESSAGES/customize-ibus.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: customize-ibus 1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-04-05 17:10+0800\n"
+"POT-Creation-Date: 2021-04-07 09:03+0800\n"
"PO-Revision-Date: 2021-03-27 16:22+0800\n"
"Last-Translator: Hollow Man \n"
"Language-Team: Chinese (simplified) \n"
@@ -17,58 +17,73 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: extension.js:288
-msgid "loading user theme for IBus:"
-msgstr "正在为IBus加载用户主题:"
+#: extension.js:214
+msgid "loading background for IBus:"
+msgstr "正在为IBus加载背景:"
-#: extension.js:374
+#: extension.js:410
msgid "loading default theme for IBus"
msgstr "正在为IBus加载当前系统主题"
-#: extension.js:423
+#: extension.js:459
msgid "Restarting..."
msgstr "正在重新启动⋯⋯"
-#: prefs.js:79
+#: prefs.js:81
msgid "Custom IME theme"
msgstr "自定义主题"
-#: prefs.js:80
+#: prefs.js:82
msgid "Use custom font"
msgstr "自定义字体"
-#: prefs.js:81
+#: prefs.js:83
+msgid "Use custom background"
+msgstr "自定义背景"
+
+#: prefs.js:84
msgid "Auto switch ASCII mode"
msgstr "默认中英文"
-#: prefs.js:82
+#: prefs.js:85
msgid "Candidates orientation"
msgstr "候选框方向"
-#: prefs.js:85
+#: prefs.js:88
msgid "Vertical"
msgstr "竖直"
-#: prefs.js:86
+#: prefs.js:89
msgid "Horizontal"
msgstr "水平"
-#: prefs.js:89
+#: prefs.js:92
msgid "On"
msgstr "英文"
-#: prefs.js:90
+#: prefs.js:93
msgid "Off"
msgstr "中文"
-#: prefs.js:91
+#: prefs.js:94
msgid "Default"
msgstr "默认"
-#: prefs.js:120
+#: prefs.js:102
+msgid "Select an Image"
+msgstr "选择一个图片"
+
+#: prefs.js:112
+msgid "(None)"
+msgstr "(无)"
+
+#: prefs.js:152
msgid "Customize IBus"
msgstr "自定义IBus"
-#: prefs.js:357
+#: prefs.js:406
msgid "Follow User Theme"
msgstr "跟随系统主题"
+
+#~ msgid "loading user theme for IBus:"
+#~ msgstr "正在为IBus加载用户主题:"
diff --git a/customize-ibus@hollowman.ml/metadata.json b/customize-ibus@hollowman.ml/metadata.json
index 178b719..b97342c 100644
--- a/customize-ibus@hollowman.ml/metadata.json
+++ b/customize-ibus@hollowman.ml/metadata.json
@@ -1,5 +1,5 @@
{
- "description": "Customize IBus for orientation, theme, font and ascii mode auto-switch",
+ "description": "Customize IBus for orientation, shell theme, background picture, font and ascii mode auto-switch",
"gettext-domain": "customize-ibus",
"name": "Customize IBus",
"settings-schema": "org.gnome.shell.extensions.customize-ibus",
@@ -8,5 +8,5 @@
"original-authors": ["hollowman@hollowman.ml"],
"uuid": "customize-ibus@hollowman.ml",
"extension-id": "customize-ibus",
- "version": 5
+ "version": 8
}
diff --git a/customize-ibus@hollowman.ml/prefs.js b/customize-ibus@hollowman.ml/prefs.js
index 54e88db..f258bec 100644
--- a/customize-ibus@hollowman.ml/prefs.js
+++ b/customize-ibus@hollowman.ml/prefs.js
@@ -38,6 +38,7 @@ const ibusGsettings = new Gio.Settings({
var Fields = {
ASCIIMODE: "ascii-mode",
CUSTOMFONT: "custom-font",
+ CUSTOMBG: "custom-bg",
UPDATESDIR: "updates-dir",
CHECKUPDATES: "check-updates",
INPUTONLIST: "input-on-list",
@@ -47,6 +48,7 @@ var Fields = {
ENABLECUSTOMTHEME: "enable-custom-theme",
INPUTLIST: "input-mode-list",
USECUSTOMFONT: "use-custom-font",
+ USECUSTOMBG: "use-custom-bg",
AUTOSWITCH: "enable-auto-switch",
ENABLEORIEN: "enable-orientation",
UNKNOWNSTATE: "unkown-ascii-state",
@@ -78,6 +80,7 @@ const CustomizeIBus = GObject.registerClass(
_bulidWidget() {
this._field_enable_custom_theme = this._checkMaker(_("Custom IME theme"));
this._field_use_custom_font = this._checkMaker(_("Use custom font"));
+ this._field_use_custom_bg = this._checkMaker(_("Use custom background"));
this._field_enable_ascii = this._checkMaker(_("Auto switch ASCII mode"));
this._field_enable_orien = this._checkMaker(_("Candidates orientation"));
@@ -93,6 +96,35 @@ const CustomizeIBus = GObject.registerClass(
this._field_custom_font = new Gtk.FontButton({
font_name: gsettings.get_string(Fields.CUSTOMFONT),
});
+ const filter = new Gtk.FileFilter();
+ filter.add_pixbuf_formats();
+ this._fileChooser = new Gtk.FileChooserNative({
+ title: _("Select an Image"),
+ filter,
+ modal: true,
+ });
+ this._fileChooser.connect("response", (dlg, response) => {
+ if (response !== Gtk.ResponseType.ACCEPT) return;
+ gsettings.set_string("custom-bg", dlg.get_file().get_path());
+ });
+
+ this._logoPicker = new Gtk.Button({
+ label: _("(None)"),
+ });
+ this._logoPicker.connect("clicked", () => {
+ this._fileChooser.transient_for = this.get_toplevel();
+ this._fileChooser.show();
+ });
+ gsettings.connect(
+ "changed::custom-bg",
+ this._updateLogoPicker.bind(this)
+ );
+ this._updateLogoPicker();
+ }
+
+ _updateLogoPicker() {
+ const filename = gsettings.get_string("custom-bg");
+ this._logoPicker.label = GLib.basename(filename);
}
_bulidUI() {
@@ -121,6 +153,7 @@ const CustomizeIBus = GObject.registerClass(
this._ibus._add(this._field_enable_orien, this._field_orientation);
this._ibus._add(this._field_use_custom_font, this._field_custom_font);
this._ibus._add(this._field_enable_ascii, this._field_unkown_state);
+ this._ibus._add(this._field_use_custom_bg, this._logoPicker);
this._ibus._add(this._field_enable_custom_theme);
this._box.add(this._field_theme_color);
}
@@ -136,6 +169,10 @@ const CustomizeIBus = GObject.registerClass(
this._field_custom_font.set_sensitive(widget.active);
ibusGsettings.set_boolean("use-custom-font", widget.active);
});
+ this._field_use_custom_bg.connect("notify::active", (widget) => {
+ this._logoPicker.set_sensitive(widget.active);
+ ibusGsettings.set_boolean("use-custom-bg", widget.active);
+ });
this._field_enable_custom_theme.connect("notify::active", (widget) => {
this._field_theme_color.set_sensitive(widget.active);
});
@@ -147,6 +184,7 @@ const CustomizeIBus = GObject.registerClass(
this._field_unkown_state.set_sensitive(this._field_enable_ascii.active);
this._field_orientation.set_sensitive(this._field_enable_orien.active);
this._field_custom_font.set_sensitive(this._field_use_custom_font.active);
+ this._logoPicker.set_sensitive(this._field_use_custom_bg.active);
this._field_theme_color.set_sensitive(
this._field_enable_custom_theme.active
);
@@ -189,6 +227,12 @@ const CustomizeIBus = GObject.registerClass(
"active",
Gio.SettingsBindFlags.DEFAULT
);
+ gsettings.bind(
+ Fields.USECUSTOMBG,
+ this._field_use_custom_bg,
+ "active",
+ Gio.SettingsBindFlags.DEFAULT
+ );
gsettings.bind(
Fields.USECUSTOMFONT,
this._field_use_custom_font,
@@ -333,6 +377,11 @@ const CustomizeIBus = GObject.registerClass(
if (!before || row.get_header()) return;
row.set_header(new Gtk.Separator());
}
+
+ on_destroy() {
+ if (this._fileChooser) this._fileChooser.destroy();
+ this._fileChooser = null;
+ }
}
);
diff --git a/customize-ibus@hollowman.ml/schemas/org.gnome.shell.extensions.customize-ibus.gschema.xml b/customize-ibus@hollowman.ml/schemas/org.gnome.shell.extensions.customize-ibus.gschema.xml
index ce09421..0a5cc51 100644
--- a/customize-ibus@hollowman.ml/schemas/org.gnome.shell.extensions.customize-ibus.gschema.xml
+++ b/customize-ibus@hollowman.ml/schemas/org.gnome.shell.extensions.customize-ibus.gschema.xml
@@ -9,6 +9,10 @@
false
use custom font
+
+ false
+ use custom background
+
false
enable custom theme
@@ -44,6 +48,10 @@
"Sans 16"
custom font
+
+ ""
+ custom background
+
false
enable updates indicator
diff --git a/img/demo-en.png b/img/demo-en.png
old mode 100644
new mode 100755
index 771ae04..529157f
Binary files a/img/demo-en.png and b/img/demo-en.png differ
diff --git a/img/demo.png b/img/demo.png
old mode 100644
new mode 100755
index 3fb98f5..ce5f131
Binary files a/img/demo.png and b/img/demo.png differ
diff --git a/img/preference-en.png b/img/preference-en.png
old mode 100644
new mode 100755
index e186914..357e230
Binary files a/img/preference-en.png and b/img/preference-en.png differ
diff --git a/img/preference.png b/img/preference.png
old mode 100644
new mode 100755
index 33e6fca..66328a2
Binary files a/img/preference.png and b/img/preference.png differ
diff --git a/package.json b/package.json
index 8238a9e..d9b961f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "customize-ibus",
- "version": "5.0.0",
- "description": "Customize IBus for orientation, theme, font and ascii mode auto-switch.",
+ "version": "8.0.0",
+ "description": "Customize IBus for orientation, shell theme, background picture, font and ascii mode auto-switch.",
"dependencies": {
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",