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

ibus customized pre-edit themes #158

Closed
qiangzhao opened this issue Feb 5, 2021 · 25 comments
Closed

ibus customized pre-edit themes #158

qiangzhao opened this issue Feb 5, 2021 · 25 comments
Labels

Comments

@qiangzhao
Copy link
Contributor

qiangzhao commented Feb 5, 2021

Project Title: ibus pre-edit window support customized theme

**Description: The original skin function of ibus in different desktop environments is based on GNOME-shell and GTK, we need to inherit and customize it, so that users can freely choose the style they need.

**Deliverable: the modification to different desktop components to accomplish the target.

Mentor: @epico @hillwoodroc @qiangzhao

Skills: C, C++, Python3

Skill Level: Medium

Get started:

IBus 1.5 API: https://github.com/ibus/ibus/wiki
GTK: https://gitlab.gnome.org/GNOME/gtk/
Gnome-shell: https://gitlab.gnome.org/GNOME/gnome-shell
Example of Gnome-shell theme: https://www.gnome-look.org/p/1291819/
@ddemaio ddemaio added the ibus label Feb 5, 2021
@HollowMan6
Copy link
Member

Hi, I'm a previous year GSoC applicant from #131, and I'm interested in this project.

After searching on the Google, I noticed that currently ibus's theme is determined by the desktop theme rime/ibus-rime#77, and we can't change it manually unless you use Gnome and change it with gnome-shell.

And another workaround to change the theme is to act in this way in Gnome: https://blog.csdn.net/weixin_30414245/article/details/96607094

So my question is, since this functionality hasn't been realized in ibus, do we just add an API for changing themes in ibus in this project? If so, currently I have no idea how to realize it, since the theme is directly determined by desktop theme. Can you give me more guidance?

@HollowMan6
Copy link
Member

I've got some ideas from IBus Tweaker: https://extensions.gnome.org/extension/2820/ibus-tweaker/
https://github.com/tuberry/ibus-tweaker

image

We can make a GNOME Shell Extension that reads from the skin files (it can be rime-like color schemes https://github.com/rime-aca/color_schemes) located in the specified folder (e.g. ~/ibus_themes), users can choose a theme from the list or just follow the original GNOME theme.

@epico
Copy link

epico commented Mar 22, 2021

I think we will use the current gtk3 theme and gnome-shell theme for this feature.

@HollowMan6
Copy link
Member

I think we will use the current gtk3 theme and gnome-shell theme for this feature.

OK, I see. So combining user-theme and ibus-tweaker will make a perfect demo. I'll try this.

@HollowMan6
Copy link
Member

HollowMan6 commented Mar 26, 2021

I have worked out a demo which successfully changes the IBus theme with user's current gnome-shell theme, it can also support additional functions such as customizing IBus for orientation, font and input mode auto-switch: https://github.com/HollowMan6/Customize-IBus

The extension has been sent to GNOME Shell Extension store for review (Currently it may not be available): https://extensions.gnome.org/extension/4112/customize-ibus/

Please suggest any changes if applicable @epico @hillwoodroc @qiangzhao

Cheers!

e.g.

Seen as the picture below for a example. User currently choose vim-light-doder for gnome-shell in User Themes, which is a light mode theme, while IBus uses vim-dark-doder theme chosen by user in Customize IBus, which is a dark mode theme. The pre-edit window of ibus-pinyin now uses the dark theme instead of light theme.
image

Realization

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:

  1. Recommend to use X11. If you change theme under Wayland, all your current work may be lost.
  2. Tested on Fedora 33, GNOME-shell 3.38.

To-do

  • Import from ibus-tweaker and remove features unrelated to IBus.
  • Read from user themes and apply only for ibus.
  • Merge the two functions.

@HollowMan6
Copy link
Member

Hi! I've had my proposal shared with https://drive.google.com/file/d/1a0vlrJAsqupYpBZtac9AYjAOspRQIYhw/view?usp=sharing, hope to get some feedback from the community and mentors @epico @hillwoodroc @qiangzhao

@epico
Copy link

epico commented Apr 6, 2021

@HollowMan6 Could you try some gnome-shell theme with customized background image?

@HollowMan6
Copy link
Member

@HollowMan6 Could you try some gnome-shell theme with customized background image?

hmm, I've never seen that kind of gnome-shell theme with background image for IBus candidate window before, can you provide some example?

@epico
Copy link

epico commented Apr 6, 2021

@HollowMan6
Copy link
Member

URL: https://www.gnome-look.org/p/1291819/

I knew this theme earlier since it's provided in the description part.

IBus 1.5 API: https://github.com/ibus/ibus/wiki
GTK: https://gitlab.gnome.org/GNOME/gtk/
Gnome-shell: https://gitlab.gnome.org/GNOME/gnome-shell
Example of Gnome-shell theme: https://www.gnome-look.org/p/1291819/

And I've tried this theme when I started to do this idea, it was problematic when I was trying on Fedora 33, GNOME 3.38. Now this gnome-shell theme seems to still be problematic with displaying IBus candidate window correctly and with no background image showing on Fedora rawhide, GNOME 40 changed using the official user theme extension.

图片

@epico Does this theme display IBus candidate window correctly on your computer, what version of GNOME-shell do you use?

@HollowMan6
Copy link
Member

I'm able to fix this theme by adding those style code to the gnome-shell.css

  background: url("assets/bg.png");
  background-repeat:no-repeat;
  background-size:cover;

pic

pic

So I can tell that my extension can fit such kind of themes since the extension just copies the whole IBus related style blocks to the stylesheet.css.

If we want to add a functionality to change background image to https://github.com/HollowMan6/Customize-IBus, just write the code to modify the .candidate-popup-content class in my extension's stylesheet.css and change the background url into user wanted image url, and everything will then works fine and it's easy to realize.

HollowMan6 added a commit to openSUSE/Customize-IBus that referenced this issue Apr 6, 2021
… Fix

During [fixing Unity8-Wood theme and add support for IBus Backgound](openSUSE/mentoring#158 (comment)), I found that if I add the following style for class `.candidate-popup-content`:

```css
  background: url("assets/bg.png");
  background-repeat:no-repeat;
  background-size:cover;
```

I can modify the background picture.

Further combining [ibus-font-setting](https://extensions.gnome.org/extension/1121/ibus-font-setting/) and [background-logo](https://pagure.io/background-logo-extension), referring to GNOME-Shell's source code, I found the [corresponding widget](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/ibusCandidatePopup.js#L154) for class `candidate-popup-content`, and modified the style to realize modifying IBus background picture without restarting GNOME-Shell.

Signed-off-by: Hollow Man <hollowman@hollowman.ml>
@HollowMan6
Copy link
Member

HollowMan6 commented Apr 6, 2021

The customizing IBus background picture functionality has been added into my extension for GNOME 40: openSUSE/Customize-IBus@1e00e3e

@epico
Copy link

epico commented Apr 7, 2021

@HollowMan6 Great, thanks! :)

HollowMan6 added a commit to openSUSE/Customize-IBus that referenced this issue Apr 7, 2021
During [fixing Unity8-Wood theme and add support for IBus Backgound](openSUSE/mentoring#158 (comment)), I found that if I add the following style for class `.candidate-popup-content`:

```css
  background: url("assets/bg.png");
  background-repeat:no-repeat;
  background-size:cover;
```

I can modify the background picture.

Further combining [ibus-font-setting](https://extensions.gnome.org/extension/1121/ibus-font-setting/) and [background-logo](https://pagure.io/background-logo-extension), referring to GNOME-Shell's source code, I found the [corresponding widget](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/master/js/ui/ibusCandidatePopup.js#L154) for class `candidate-popup-content`, and modified the style to realize modifying IBus background picture without restarting GNOME-Shell.

Signed-off-by: Hollow Man <hollowman@hollowman.ml>
@hillwoodroc
Copy link

Looks great!

@epico
Copy link

epico commented Apr 8, 2021

@HollowMan6 Could you consider to split this extension into theme conversion tool and import ibus theme extension?

@HollowMan6
Copy link
Member

@HollowMan6 Could you consider to split this extension into theme conversion tool and import ibus theme extension?

Do you mean by making a script in python or shell which allow users to select from the GNOME theme CSS file, then extract the IBus related style classes (.candidate-*), finally write it to another stylesheet?

And then modify the current extension to accept the user given stylesheet? @epico

@epico
Copy link

epico commented Apr 8, 2021

Do you mean by making a script in python or shell which allow users to select from the GNOME theme CSS file, then extract the IBus related style classes (.candidate-*), finally write it to another stylesheet?

Right, we can use Python or JavaScript to write the conversion tool, and maintain it in a separate repo.

And then modify the current extension to accept the user given stylesheet? @epico

Right, the import theme extension can import the modified theme file.

@HollowMan6
Copy link
Member

HollowMan6 commented Apr 8, 2021

OK, thanks! I'll do these jobs during GSoC coding period.

@HollowMan6
Copy link
Member

I’ve created a project for changing the IBus GTK theme in a non-GNOME Shell desktop environment using Python: https://github.com/HollowMan6/IBus-Theme , later during GSoC coding period I can merge the above theme conversion tool for GNOME into it to make a complete project.

Tested on XFCE:

image

@HollowMan6
Copy link
Member

Hi! Glad to hear that I'm accepted by GSoC 2021! I have made a lot of progress before the results are announced and have added quite a few features for my Customize IBus extension. Here's the repos collection: https://github.com/IBus-Customize . Hope to get some feedback. Issues are welcome!

And here's a guideline for using Customize IBus (in Chinese) : https://blog.csdn.net/qq_18572023/article/details/116331601

@epico
Copy link

epico commented May 18, 2021

Look forward to work on this feature with you during GSoC! 🙂

@AKACHI-4
Copy link

AKACHI-4 commented Feb 7, 2022

Hello people's i am a new comer can u explain me little bit more bcz now it is bit tough to me to understand it ....

.

@HollowMan6
Copy link
Member

@AKACHI-4 I guess you have to find another one as this is an idea for GSoC 2021, not for this year.

@AKACHI-4
Copy link

AKACHI-4 commented Feb 7, 2022

@HollowMan6 okay thanku

@qiangzhao
Copy link
Contributor Author

close for GSOC 2022 as offline discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants