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

Wrong icon name #13

Closed
lessneek opened this issue Apr 1, 2024 · 12 comments · May be fixed by #29
Closed

Wrong icon name #13

lessneek opened this issue Apr 1, 2024 · 12 comments · May be fixed by #29

Comments

@lessneek
Copy link

lessneek commented Apr 1, 2024

I have "network-workgroup" in the icons.toml file and use it in code:

gtk::Image {
    set_icon_name: Some(icon_names::NETWORK_WORKGROUP),
},

the generated file icon_names.rs contains these lines:

/// Icon name of the icon `network-workgroup`, found at `"icons/icon-development-kit/network-workgroup-symbolic.svg"`.
pub const NETWORK_WORKGROUP: &str = "network-workgroup";

the problem is the icon shown is not network-workgroup-symbolic but simple network-workgroup with colors.
If I set_icon_name: Some("network-workgroup-symbolic") I get a symbolic icon as expected.

@nazar-pc
Copy link
Contributor

the problem is the icon shown is not network-workgroup-symbolic but simple network-workgroup with colors.

What do you mean by this, what colors if the icon itself is monochrome?

@lessneek
Copy link
Author

network-workgroup is color, the network-workgroup-symbolic is monochrome.

@nazar-pc
Copy link
Contributor

nazar-pc commented Jan 1, 2025

icon-development-kit only has one icon, where is the second one with colors coming from?

@lessneek
Copy link
Author

lessneek commented Jan 1, 2025

From system resources, i guess. I don't even need the icons crate btw for both icons. I have the latest Fedora Workstation installed.

icons_test

use gtk::prelude::{BoxExt, GtkWindowExt};
use relm4::{gtk, ComponentParts, ComponentSender, RelmApp, RelmWidgetExt, SimpleComponent};

struct AppModel {}

struct AppWidgets {
    image1: gtk::Image,
    image2: gtk::Image,
}

impl SimpleComponent for AppModel {
    type Input = ();
    type Output = ();
    type Init = ();
    type Root = gtk::Window;
    type Widgets = AppWidgets;

    fn init_root() -> Self::Root {
        gtk::Window::builder().title("Icons test").build()
    }

    /// Initialize the UI and model.
    fn init(
        _: Self::Init,
        window: Self::Root,
        _: ComponentSender<Self>,
    ) -> relm4::ComponentParts<Self> {
        let model = AppModel {};

        let vbox = gtk::Box::builder()
            .orientation(gtk::Orientation::Vertical)
            .spacing(5)
            .build();

        let image1 = gtk::Image::new();
        image1.set_margin_all(5);
        image1.set_icon_name(Some("network-workgroup"));

        let image2 = gtk::Image::new();
        image2.set_margin_all(5);
        image2.set_icon_name(Some("network-workgroup-symbolic"));

        window.set_child(Some(&vbox));
        vbox.set_margin_all(5);
        vbox.append(&image1);
        vbox.append(&image2);

        let widgets = AppWidgets { image1, image2 };

        ComponentParts { model, widgets }
    }
}

fn main() {
    let app = RelmApp::new("relm4.test.icons");
    app.run::<AppModel>(());
}
[package]
name = "test_gtk_icons"
version = "0.1.0"
edition = "2021"

[dependencies]
relm4 = "0.9.1"

@nazar-pc
Copy link
Contributor

nazar-pc commented Jan 1, 2025

Hm... I think that might be a system theme that you have installed, interesting.
Depending on use case you may or may not actually want that behavior 🤔

@lessneek
Copy link
Author

lessneek commented Jan 1, 2025

I haven't installed any theme, just default Fedora installation. Or what could I have installed?

Screenshot From 2025-01-01 17-04-31

@nazar-pc
Copy link
Contributor

nazar-pc commented Jan 1, 2025

Are you sure network-workgroup-symbolic comes from relm4-icons at all? There is a chance it comes from system icons instead and network-workgroup is what comes from an app, but some of its icons are overridden by one of the system themes. I use Ubuntu and there are some non-symbolic icons installed via dependencies like Humanity. Check in debugger what it loads and from where (Ctrl+Shift+d).

@lessneek
Copy link
Author

lessneek commented Jan 1, 2025

I have all these icons already installed in my system, they come with Fedora distribution. But in case I want my app icons look the same on other systems I need to override these icons resources with relm4-icons. And since the crate has only symbolic versions of icons, I need to have all icons names with the -symbolic suffix.

@lessneek lessneek closed this as completed Jan 1, 2025
@nazar-pc
Copy link
Contributor

nazar-pc commented Jan 1, 2025

I see. Don't get me wrong, I do think it is a fair request, I'm not 100% sure why removing -symbolic was necessary in the first place, maybe it should be reversed. I also noticed some icons being re-styled on my systems, likely those that matched icons installed on the system.

@lessneek
Copy link
Author

lessneek commented Jan 1, 2025

What do you think is it a good idea to have only own icons resources and never allow use of system icons?

@nazar-pc
Copy link
Contributor

nazar-pc commented Jan 2, 2025

Hard to say. On one hand I'd like to control the way application looks, on the other hand I'm glad I'm able to install Numix icons pack and many of the apps I use look better. I guess it needs to be configurable 🤔

@lessneek
Copy link
Author

lessneek commented Jan 3, 2025

Also there could be a problem when there is no particular icon in a system.

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

Successfully merging a pull request may close this issue.

2 participants