-
Notifications
You must be signed in to change notification settings - Fork 5
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
Refactor build script and expose build functions for crate dependents #19
Changes from 1 commit
07c9fb1
b175bdd
99c0c18
f24bb69
133b001
7d33e62
95bc7de
bfbd358
4120f43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,24 +24,17 @@ use gtk::{ | |
gio::{resources_register, Resource}, | ||
glib, | ||
}; | ||
use std::path::Path; | ||
|
||
/// Initialized the icons and registers them globally for your application. | ||
pub fn initialize_icons<P: AsRef<Path>>( | ||
gresource_bytes: &'static [u8], | ||
app_id: &str, | ||
base_resource_path: Option<P>, | ||
) { | ||
pub fn initialize_icons(gresource_bytes: &'static [u8]) { | ||
let bytes = glib::Bytes::from(gresource_bytes); | ||
let resource = Resource::from_data(&bytes).unwrap(); | ||
resources_register(&resource); | ||
|
||
gtk::init().unwrap(); | ||
dastansam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if base_resource_path.is_none() && app_id.is_empty() { | ||
let display = gdk::Display::default().unwrap(); | ||
let theme = gtk::IconTheme::for_display(&display); | ||
theme.add_resource_path("/org/gtkrs/icons/"); | ||
theme.add_resource_path("/org/gtkrs/icons/scalable/actions/"); | ||
} | ||
let display = gdk::Display::default().unwrap(); | ||
let theme = gtk::IconTheme::for_display(&display); | ||
theme.add_resource_path("/org/gtkrs/icons/"); | ||
theme.add_resource_path("/org/gtkrs/icons/scalable/actions/"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not look like an equivalent change. It only previously applied if app_id was not specified, but now it applies unconditionally despite the fact that app ID is required. Looking at generation code, I think you'll want to store There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the code in question is more a hack than an actual documented feature of GTK. It is not strictly harmful to call it unconditionally, but if the user has specified an app ID, the path of the icons can be adjusted such that it doesn't need this hack in the first place (that's why the |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work, but consider proper path handling, including when it has
"
:Storing
OsString
would be even more valid, but it requires platform-specific code to decode back on read, this way it will simply fail on non-utf8 characters at build time.