Skip to content

Add a search provider

Bilal Elmoussaoui requested to merge search-provider into master

This refactors the code a bit to allow having a search provider easily.

Sadly, we can't show the nonsystem icons (the icon dev kit ones) as themed icons, so they are not recolored.

Per the GNOME Shell Provider API v2: the results could contain an icon https://gitlab.gnome.org/GNOME/gnome-shell/blob/master/js/ui/remoteSearch.js#L219-228. As those icons are not available in the user's system, we can't load them with an icon name.


    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 { // GVariant is not that supported with the current gtk-rs :/
        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))))));

Which gives such results

Screenshot_from_2019-08-26_06-05-01

Screenshot_from_2019-08-26_06-03-44

Screenshot_from_2019-08-26_06-05-20

Closes #6 (closed)

Edited by Bilal Elmoussaoui

Merge request reports