Commit e9b570c5 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Search Provider: don't pass an icon name for system icons

Passing an icon name might result in showing a different icon if the user has a different theme
parent 724b2dc9
Pipeline #113605 failed with stages
in 1 minute and 21 seconds
......@@ -19,5 +19,5 @@ serde_json = "1.0"
serde_derive = "1.0"
pretty_env_logger = "0.3"
dbus = "0.6"
search-provider = { git = "https://gitlab.gnome.org/bilelmoussaoui/search-provider.git", branch = "bilelmoussaoui/update" }
search-provider = { git = "https://gitlab.gnome.org/World/Rust/search-provider.git" }
......@@ -14,7 +14,7 @@ dependency('libhandy-0.0', version: '>= 0.0.10')
find_program('cargo', required: false)
find_program('glib-compile-resources', required: true)
find_program('cargo-vendor', required: false)
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
desktop_file_validate = find_program('desktop-file-validate', required: false)
appstream_util = find_program('appstream-util', required: false)
......
......@@ -71,22 +71,20 @@ impl SearchProvider {
hashmap.insert("id".to_string(), arg::Variant(Box::new(sp_id.to_string())));
hashmap.insert("name".to_string(), arg::Variant(Box::new(icon_name.to_string())));
hashmap.insert("description".to_string(), arg::Variant(Box::new("".to_string())));
if !icon.is_system {
let gfile = gio::File::new_for_path(icon_path);
let (gbytes, _) = gfile.load_bytes(gio::NONE_CANCELLABLE).expect("Failed to read icon bytes");
let gicon = gio::BytesIcon::new(&gbytes);
let variant = gicon.serialize().unwrap();
let gbytes = unsafe {
let bytes_variant = glib_sys::g_variant_get_child_value(variant.to_glib_none().0, 1);
let bytes: glib::Bytes = from_glib_full(glib_sys::g_variant_get_data_as_bytes(bytes_variant));
bytes
};
let bytes: Vec<u8> = gbytes.to_vec();
hashmap.insert("icon".to_string(), arg::Variant(Box::new(("bytes".to_string(), arg::Variant(Box::new(bytes))))));
} else {
hashmap.insert("icon".to_string(), arg::Variant(Box::new(icon_name.to_string())));
}
let gfile = gio::File::new_for_path(icon_path);
let (gbytes, _) = gfile.load_bytes(gio::NONE_CANCELLABLE).expect("Failed to read icon bytes");
let gicon = gio::BytesIcon::new(&gbytes);
let variant = gicon.serialize().unwrap();
let gbytes = unsafe {
let bytes_variant = glib_sys::g_variant_get_child_value(variant.to_glib_none().0, 1);
let bytes: glib::Bytes = from_glib_full(glib_sys::g_variant_get_data_as_bytes(bytes_variant));
bytes
};
let bytes: Vec<u8> = gbytes.to_vec();
hashmap.insert("icon".to_string(), arg::Variant(Box::new(("bytes".to_string(), arg::Variant(Box::new(bytes))))));
let meta = ResultMetadata { hashmap };
metas.insert(0, meta);
}
......
......@@ -85,6 +85,7 @@ impl IconsViewContext {
fn init(&self) {
self.icons_container.set_row_spacing(12);
self.icons_container.set_column_spacing(12);
self.icons_container.set_homogeneous(false);
self.icons_container.set_max_children_per_line(14);
self.icons_container.set_min_children_per_line(6);
self.icons_container.set_selection_mode(gtk::SelectionMode::None);
......@@ -148,6 +149,10 @@ impl IconView {
let icon_name = icon.name.as_str();
let widget = gtk::FlowBoxChild::new();
widget.set_halign(gtk::Align::Center);
widget.set_valign(gtk::Align::Center);
let icon_img = gtk::Image::new_from_icon_name(Some(icon_name), gtk::IconSize::Dnd);
widget.set_tooltip_text(Some(icon_name));
widget.add(&icon_img);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment