src: style: fix build with newer gtk-rs

`gtk::Settings::property()` no longer returns a `Result` but instead
panics if the property doesn't exist. In order to work around this
change without affecting the surrounding code too much, this patch
modifies the `prop` function so we can avoid panics and wrap the
property value into a `Result` as was previously the case.

Part-of: <https://gitlab.gnome.org/World/Phosh/squeekboard/-/merge_requests/620>
This commit is contained in:
Arnaud Ferraris
2023-06-27 13:52:17 +02:00
committed by Marge Bot
parent 86674507e1
commit 078f58be26

View File

@ -99,7 +99,12 @@ fn get_theme_name(settings: &gtk::Settings) -> GtkTheme {
}).ok();
#[cfg(feature = "glib_v0_14")]
let prop = |s: &gtk::Settings, name| s.property(name);
let prop = |s: &gtk::Settings, name| {
if s.has_property(name, None) {
return Ok(s.property_value(name));
}
return Err("Key not found in settings");
};
#[cfg(not(feature = "glib_v0_14"))]
let prop = |s: &gtk::Settings, name| s.get_property(name);