Skip to content

Commit 84abfc9

Browse files
committed
v5: Fix to avoid affecting other UI styles for GNOME 3.38
Remove unwanted style if the IBus related style classes (.candidate-*) style block is shared with other styles that has nothing to do with IBus style Signed-off-by: Hollow Man <hollowman@hollowman.ml>
1 parent d0aa63c commit 84abfc9

5 files changed

Lines changed: 41 additions & 19 deletions

File tree

customize-ibus@hollowman.ml/extension.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,11 @@ const IBusThemeManager = GObject.registerClass(
300300
}
301301

302302
for (var index in matchedContent) {
303-
newFileContent +=
303+
newFileContent += this._rmUnrelatedStyleClass(
304304
matchedContent[index]
305305
.replace(/assets\//g, stylesheet + "/../assets/")
306-
.replace(/.button/g, ".candidate-page-button") + "\n";
306+
.replace(/.button/g, ".candidate-page-button") + "\n"
307+
);
307308
}
308309
regStr = /\n.candidate-[\s\S]*?}/gi;
309310
matchedContent = ByteArray.toString(contents).match(regStr);
@@ -341,29 +342,32 @@ const IBusThemeManager = GObject.registerClass(
341342
) {
342343
newContent = newContent.replace(/}/g, " border-image: none;\n}");
343344
}
344-
newFileContent +=
345+
newFileContent += this._rmUnrelatedStyleClass(
345346
newContent
346347
.replace(/assets\//g, stylesheet + "/../assets/")
347-
.replace(/}/g, addedGlobalColor) + "\n";
348+
.replace(/}/g, addedGlobalColor) + "\n"
349+
);
348350
}
349351
regStr = /.horizontal .candidate-[\s\S]*?}/gi;
350352
matchedContent = ByteArray.toString(contents).match(regStr);
351353
for (var index in matchedContent) {
352-
newFileContent +=
354+
newFileContent += this._rmUnrelatedStyleClass(
353355
matchedContent[index].replace(
354356
// Set assert file relative path to absolute path
355357
/assets\//g,
356358
stylesheet + "/../assets/"
357-
) + "\n";
359+
) + "\n"
360+
);
358361
}
359362
regStr = /.vertical .candidate-[\s\S]*?}/gi;
360363
matchedContent = ByteArray.toString(contents).match(regStr);
361364
for (var index in matchedContent) {
362-
newFileContent +=
365+
newFileContent += this._rmUnrelatedStyleClass(
363366
matchedContent[index].replace(
364367
/assets\//g,
365368
stylesheet + "/../assets/"
366-
) + "\n";
369+
) + "\n"
370+
);
367371
}
368372
this._prevCssStylesheet = stylesheet;
369373
} else {
@@ -397,6 +401,24 @@ const IBusThemeManager = GObject.registerClass(
397401
if (notFirstStart) this.restart();
398402
}
399403

404+
// Fix to avoid affecting other UI styles
405+
406+
/* Remove unwanted style if the IBus related style classes (.candidate-*) style
407+
block is shared with other styles that has nothing to do with IBus style
408+
*/
409+
410+
_rmUnrelatedStyleClass(str) {
411+
let splitedContent = str.split("{");
412+
if (splitedContent.length != 2) return splitedContent.join("{");
413+
let classList = splitedContent[0].split(",");
414+
let contentPart = splitedContent[1];
415+
let newClassList = [];
416+
for (var index in classList)
417+
if (classList[index].indexOf(".candidate-") != -1)
418+
newClassList.push(classList[index]);
419+
return newClassList.join(",") + "{" + contentPart;
420+
}
421+
400422
restart() {
401423
Meta.restart(_("Restarting..."));
402424
}

customize-ibus@hollowman.ml/locale/customize-ibus.pot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#, fuzzy
77
msgid ""
88
msgstr ""
9-
"Project-Id-Version: Customize Ibus \n"
9+
"Project-Id-Version: Customize Ibus 5\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-03-28 23:01+0800\n"
11+
"POT-Creation-Date: 2021-04-05 17:10+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -21,11 +21,11 @@ msgstr ""
2121
msgid "loading user theme for IBus:"
2222
msgstr ""
2323

24-
#: extension.js:370
24+
#: extension.js:374
2525
msgid "loading default theme for IBus"
2626
msgstr ""
2727

28-
#: extension.js:401
28+
#: extension.js:423
2929
msgid "Restarting..."
3030
msgstr ""
3131

@@ -69,6 +69,6 @@ msgstr ""
6969
msgid "Customize IBus"
7070
msgstr ""
7171

72-
#: prefs.js:353
72+
#: prefs.js:357
7373
msgid "Follow User Theme"
7474
msgstr ""

customize-ibus@hollowman.ml/locale/zh_CN/LC_MESSAGES/customize-ibus.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: customize-ibus 1\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2021-03-28 23:01+0800\n"
11+
"POT-Creation-Date: 2021-04-05 17:10+0800\n"
1212
"PO-Revision-Date: 2021-03-27 16:22+0800\n"
1313
"Last-Translator: Hollow Man <hollowman@hollowman.ml>\n"
1414
"Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
@@ -21,11 +21,11 @@ msgstr ""
2121
msgid "loading user theme for IBus:"
2222
msgstr "正在为IBus加载用户主题:"
2323

24-
#: extension.js:370
24+
#: extension.js:374
2525
msgid "loading default theme for IBus"
2626
msgstr "正在为IBus加载当前系统主题"
2727

28-
#: extension.js:401
28+
#: extension.js:423
2929
msgid "Restarting..."
3030
msgstr "正在重新启动⋯⋯"
3131

@@ -69,6 +69,6 @@ msgstr "默认"
6969
msgid "Customize IBus"
7070
msgstr "自定义IBus"
7171

72-
#: prefs.js:353
72+
#: prefs.js:357
7373
msgid "Follow User Theme"
7474
msgstr "跟随系统主题"

customize-ibus@hollowman.ml/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"original-authors": ["hollowman@hollowman.ml"],
99
"uuid": "customize-ibus@hollowman.ml",
1010
"extension-id": "customize-ibus",
11-
"version": 3
11+
"version": 5
1212
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "customize-ibus",
3-
"version": "3.0.0",
3+
"version": "5.0.0",
44
"description": "Customize IBus for orientation, theme, font and ascii mode auto-switch.",
55
"dependencies": {
66
"eslint": "^7.21.0",

0 commit comments

Comments
 (0)