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

Use native theme in KDE #5

Open
RangerMauve opened this issue Jan 4, 2023 · 6 comments
Open

Use native theme in KDE #5

RangerMauve opened this issue Jan 4, 2023 · 6 comments

Comments

@RangerMauve
Copy link

Hey, is there a way to get the app to use the OS's theming in KDE (or even in GTK?).

It seems that out of the box it's using the default GTK theme rather than the one configured by the user. As a result any apps built with fltk will look off.

@MoAlyousef
Copy link
Contributor

Hi
You can try FLTK's app::get_system_colors() , which will attempt to get X11 colormap settings, usually set by the DE.
This will only affect the colors though.
The shape of widgets follows the app::scheme, or in fltk-theme, is custom drawn by overriding some drawing functions.

@RangerMauve
Copy link
Author

Hmm, it doesn't seem to have changed anything. I tried calling that API before creating any UI elements and just before calling app.run() and neither option had a visible effect. It just had the default grey theme.

@MoAlyousef
Copy link
Contributor

I’m interested to know what environment you’re using.
I tried it on a kubuntu machine on X11, the color becomes nearly white.
Are you perhaps using KDE on wayland?

@RangerMauve
Copy link
Author

RangerMauve commented Jan 8, 2023

This is with KDE Plasma 5.26.4 with X11 on Manjaro Linux.

It's on a 10th generation Intel core if that makes a difference. 🤔

use fltk_theme::{ColorTheme, color_themes};
use fltk::{app, button::Button, frame::Frame, prelude::*, window::Window};

fn main() -> Result<(), Box<dyn Error>> {
    let app = app::App::default();
    app::get_system_colors();

    let mut wind = Window::new(100, 100, 400, 300, "Hello from rust");
    let mut frame = Frame::new(0, 0, 400, 200, "");
    let mut but = Button::new(160, 210, 80, 40, "Click me!");
    wind.end();
    wind.show();

    println!("Wow OK we exited!");

    Ok(())
}

Screenshot_20230108_170251

@RangerMauve
Copy link
Author

This is what my GTK theme should look like according to the preview thingie in Plasma:

Screenshot_20230108_170507

@MoAlyousef
Copy link
Contributor

MoAlyousef commented Jan 9, 2023

It seems KDE plasma stores themes in $HOME/.local/share/plasma/desktoptheme//. The colors are in a colors subdirectory of the theme. I'm not sure where the current global theme is set in the system though. Maybe adding a light/dark Oxygen (or breeze) theme to this crate might give a less out of touch UI on KDE desktops. But I think adding logic to check system files to determine which is the current theme and the theme's details would be too much for this crate.

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

No branches or pull requests

2 participants