# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Auto-Generated by cargo-ebuild 0.5.4

EAPI=8

CRATES="
    addr2line@0.19.0
    adler@1.0.2
    aho-corasick@0.7.20
    aho-corasick@1.0.1
    android_system_properties@0.1.5
    anes@0.1.6
    anstyle@0.3.4
    anyhow@1.0.69
    anyhow@1.0.71
    approx@0.5.1
    arc-swap@1.6.0
    ashpd@0.4.0
    assert_cmd@2.0.10
    async-broadcast@0.5.1
    async-channel@1.8.0
    async-executor@1.5.1
    async-fs@1.6.0
    async-global-executor@2.3.1
    async-io@1.13.0
    async-lock@2.7.0
    async-recursion@1.0.4
    async-std@1.12.0
    async-task@4.4.0
    async-trait@0.1.68
    atomic-waker@1.1.1
    atty@0.2.14
    autocfg@1.1.0
    backtrace@0.3.67
    base-x@0.2.11
    bit-set@0.5.3
    bit-vec@0.6.3
    bit_field@0.10.2
    bitflags@1.3.2
    block-buffer@0.10.4
    block@0.1.6
    blocking@1.3.1
    bstr@1.3.0
    bumpalo@3.12.0
    bumpalo@3.12.2
    bytemuck@1.13.1
    byteorder@1.4.3
    cairo-rs@0.17.0
    cairo-sys-rs@0.17.0
    cast@0.3.0
    cc@1.0.79
    cfg-expr@0.11.0
    cfg-expr@0.15.1
    cfg-if@1.0.0
    chrono@0.4.24
    ciborium-io@0.2.0
    ciborium-ll@0.2.0
    ciborium@0.2.0
    clap@3.2.23
    clap@4.1.9
    clap_complete@4.1.5
    clap_derive@4.1.9
    clap_lex@0.2.4
    clap_lex@0.3.3
    codespan-reporting@0.11.1
    color_quant@1.1.0
    concurrent-queue@2.2.0
    const-cstr@0.3.0
    const_fn@0.4.9
    convert_case@0.4.0
    core-foundation-sys@0.8.3
    cpufeatures@0.2.7
    crc32fast@1.3.2
    criterion-plot@0.5.0
    criterion@0.4.0
    crossbeam-channel@0.5.7
    crossbeam-channel@0.5.8
    crossbeam-deque@0.8.3
    crossbeam-epoch@0.9.14
    crossbeam-utils@0.8.15
    crunchy@0.2.2
    crypto-common@0.1.6
    cssparser-macros@0.6.0
    cssparser@0.29.6
    ctor@0.1.26
    cxx-build@1.0.92
    cxx@1.0.92
    cxxbridge-flags@1.0.92
    cxxbridge-macro@1.0.92
    data-url@0.2.0
    derivative@2.2.0
    derive_more@0.99.17
    difflib@0.4.0
    digest@0.10.6
    discard@1.0.4
    dlib@0.5.0
    doc-comment@0.3.3
    dtoa-short@0.3.3
    dtoa@0.4.8
    dunce@1.0.4
    either@1.8.1
    encoding-index-japanese@1.20141219.5
    encoding-index-korean@1.20141219.5
    encoding-index-simpchinese@1.20141219.5
    encoding-index-singlebyte@1.20141219.5
    encoding-index-tradchinese@1.20141219.5
    encoding@0.2.33
    encoding_index_tests@0.1.4
    encoding_rs@0.8.32
    enumflags2@0.7.7
    enumflags2_derive@0.7.7
    enumn@0.1.8
    env_logger@0.10.0
    errno-dragonfly@0.1.2
    errno@0.2.8
    errno@0.3.1
    event-listener@2.5.3
    exr@1.6.3
    fastrand@1.9.0
    fdeflate@0.3.0
    field-offset@0.3.5
    flate2@1.0.25
    flate2@1.0.26
    float-cmp@0.9.0
    flume@0.10.14
    fnv@1.0.7
    foreign-types-macros@0.2.3
    foreign-types-shared@0.3.1
    foreign-types@0.5.0
    form_urlencoded@1.1.0
    four-cc@0.2.0
    futf@0.1.5
    futures-channel@0.3.27
    futures-channel@0.3.28
    futures-core@0.3.27
    futures-core@0.3.28
    futures-executor@0.3.27
    futures-executor@0.3.28
    futures-io@0.3.27
    futures-io@0.3.28
    futures-lite@1.13.0
    futures-macro@0.3.27
    futures-macro@0.3.28
    futures-sink@0.3.28
    futures-task@0.3.27
    futures-task@0.3.28
    futures-util@0.3.27
    futures-util@0.3.28
    futures@0.3.28
    fxhash@0.2.1
    gdk-pixbuf-sys@0.17.0
    gdk-pixbuf@0.17.0
    gdk4-sys@0.6.3
    gdk4-wayland-sys@0.6.3
    gdk4-wayland@0.6.3
    gdk4-x11-sys@0.6.3
    gdk4-x11@0.6.3
    gdk4@0.6.3
    generic-array@0.14.7
    getrandom@0.1.16
    getrandom@0.2.8
    getrandom@0.2.9
    gettext-rs@0.7.0
    gettext-sys@0.21.3
    gif@0.12.0
    gimli@0.27.2
    gio-sys@0.17.4
    gio@0.17.4
    gio@0.17.9
    glib-macros@0.17.5
    glib-macros@0.17.9
    glib-sys@0.17.4
    glib@0.17.5
    glib@0.17.9
    gloo-timers@0.2.6
    gobject-sys@0.17.4
    graphene-rs@0.17.1
    graphene-sys@0.17.0
    gsk4-sys@0.6.3
    gsk4@0.6.3
    gtk4-macros@0.6.6
    gtk4-sys@0.6.3
    gtk4@0.6.6
    gvdb-macros@0.1.6
    gvdb@0.4.0
    gweather-sys@4.2.0
    half@1.8.2
    half@2.2.1
    hashbrown@0.12.3
    heck@0.4.1
    hermit-abi@0.1.19
    hermit-abi@0.2.6
    hermit-abi@0.3.1
    hex@0.4.3
    humantime@2.1.0
    iana-time-zone-haiku@0.1.1
    iana-time-zone@0.1.53
    idna@0.3.0
    image@0.24.6
    indexmap@1.9.2
    indexmap@1.9.3
    instant@0.1.12
    io-lifetimes@1.0.10
    io-lifetimes@1.0.7
    is-terminal@0.4.4
    is-terminal@0.4.7
    itertools@0.10.5
    itoa@1.0.6
    jobserver@0.1.26
    jpeg-decoder@0.3.0
    js-sys@0.3.61
    js-sys@0.3.62
    kamadak-exif@0.5.5
    kv-log-macro@1.0.7
    language-tags@0.3.2
    lazy_static@1.4.0
    lcms2-sys@4.0.1
    lcms2@5.6.0
    lebe@0.5.2
    libadwaita-sys@0.4.1
    libadwaita@0.4.1
    libc@0.2.140
    libc@0.2.144
    libgweather@4.2.0
    libheif-rs@0.19.2
    libheif-sys@1.14.2
    libloading@0.7.4
    libm@0.2.6
    librsvg@2.56.0
    link-cplusplus@1.0.8
    linked-hash-map@0.5.6
    linux-raw-sys@0.1.4
    linux-raw-sys@0.3.7
    litrs@0.4.0
    locale_config@0.3.0
    lock_api@0.4.9
    log@0.4.17
    lopdf@0.29.0
    loupe@0.1.0
    mac@0.1.1
    malloc_buf@0.0.6
    markup5ever@0.11.0
    matches@0.1.10
    matrixmultiply@0.3.2
    matrixmultiply@0.3.7
    memchr@2.5.0
    memmap2@0.5.10
    memoffset@0.7.1
    memoffset@0.8.0
    miniz_oxide@0.6.2
    miniz_oxide@0.7.1
    mutate_once@0.1.1
    nalgebra-macros@0.2.0
    nalgebra@0.32.2
    nanorand@0.7.0
    new_debug_unreachable@1.0.4
    nix@0.26.2
    nodrop@0.1.14
    normalize-line-endings@0.3.0
    num-complex@0.4.3
    num-integer@0.1.45
    num-rational@0.4.1
    num-traits@0.2.15
    num_cpus@1.15.0
    objc-foundation@0.1.1
    objc@0.2.7
    objc_id@0.1.1
    object@0.30.3
    once_cell@1.17.1
    oorandom@11.1.3
    ordered-stream@0.2.0
    os_str_bytes@6.4.1
    pango-sys@0.17.0
    pango@0.17.4
    pangocairo-sys@0.17.3
    pangocairo@0.17.0
    parking@2.1.0
    parking_lot@0.12.1
    parking_lot_core@0.9.7
    paste@1.0.12
    percent-encoding@2.2.0
    phf@0.10.1
    phf@0.8.0
    phf_codegen@0.10.0
    phf_codegen@0.8.0
    phf_generator@0.10.0
    phf_generator@0.8.0
    phf_macros@0.10.0
    phf_shared@0.10.0
    phf_shared@0.8.0
    pin-project-internal@1.0.12
    pin-project-lite@0.2.9
    pin-project@1.0.12
    pin-utils@0.1.0
    pkg-config@0.3.26
    pkg-config@0.3.27
    plotters-backend@0.3.4
    plotters-svg@0.3.3
    plotters@0.3.4
    png@0.17.7
    png@0.17.8
    polling@2.8.0
    pom@3.2.0
    ppv-lite86@0.2.17
    precomputed-hash@0.1.1
    predicates-core@1.0.6
    predicates-tree@1.0.9
    predicates@2.1.5
    predicates@3.0.1
    proc-macro-crate@1.3.1
    proc-macro-error-attr@1.0.4
    proc-macro-error@1.0.4
    proc-macro-hack@0.5.20+deprecated
    proc-macro2@1.0.52
    proc-macro2@1.0.56
    proptest@1.1.0
    qoi@0.4.1
    quick-error@1.2.3
    quick-error@2.0.1
    quick-xml@0.27.1
    quote@1.0.26
    quote@1.0.27
    rand@0.7.3
    rand@0.8.5
    rand_chacha@0.2.2
    rand_chacha@0.3.1
    rand_core@0.5.1
    rand_core@0.6.4
    rand_hc@0.2.0
    rand_pcg@0.2.1
    rand_xorshift@0.3.0
    rawpointer@0.2.1
    rayon-core@1.11.0
    rayon@1.7.0
    rctree@0.5.0
    redox_syscall@0.2.16
    redox_syscall@0.3.5
    regex-automata@0.1.10
    regex-syntax@0.6.28
    regex-syntax@0.7.1
    regex@1.7.1
    regex@1.8.1
    rgb@0.8.36
    rustc-demangle@0.1.23
    rustc_version@0.2.3
    rustc_version@0.4.0
    rustix@0.36.9
    rustix@0.37.19
    rusty-fork@0.3.0
    ryu@1.0.13
    safe-transmute@0.11.2
    safe_arch@0.6.0
    same-file@1.0.6
    scopeguard@1.1.0
    scratch@1.0.5
    selectors@0.24.0
    semver-parser@0.7.0
    semver@0.9.0
    semver@1.0.17
    serde@1.0.156
    serde@1.0.162
    serde_derive@1.0.156
    serde_derive@1.0.162
    serde_json@1.0.94
    serde_json@1.0.96
    serde_repr@0.1.12
    serde_spanned@0.6.1
    servo_arc@0.2.0
    sha1@0.10.5
    sha1@0.6.1
    sha1_smol@1.0.0
    simba@0.8.0
    simba@0.8.1
    simd-adler32@0.3.5
    siphasher@0.3.10
    slab@0.4.8
    smallvec@1.10.0
    socket2@0.4.9
    spin@0.9.8
    stable_deref_trait@1.2.0
    standback@0.2.17
    static_assertions@1.1.0
    stdweb-derive@0.5.3
    stdweb-internal-macros@0.2.9
    stdweb-internal-runtime@0.1.5
    stdweb@0.4.20
    string_cache@0.8.7
    string_cache_codegen@0.5.2
    strsim@0.10.0
    syn@1.0.109
    syn@2.0.15
    system-deps@6.0.3
    system-deps@6.1.0
    target-lexicon@0.12.7
    temp-dir@0.1.11
    tempfile@3.4.0
    tempfile@3.5.0
    tendril@0.4.3
    termcolor@1.2.0
    termtree@0.4.1
    textwrap@0.16.0
    thiserror-impl@1.0.39
    thiserror-impl@1.0.40
    thiserror@1.0.39
    thiserror@1.0.40
    tiff@0.8.1
    time-macros-impl@0.1.2
    time-macros@0.1.1
    time@0.2.27
    tinytemplate@1.2.1
    tinyvec@1.6.0
    tinyvec_macros@0.1.1
    toml@0.5.11
    toml@0.7.3
    toml_datetime@0.6.1
    toml_edit@0.19.7
    toml_edit@0.19.8
    tracing-attributes@0.1.24
    tracing-core@0.1.30
    tracing@0.1.37
    typenum@1.16.0
    uds_windows@1.0.2
    unarray@0.1.4
    unicode-bidi@0.3.11
    unicode-bidi@0.3.13
    unicode-ident@1.0.8
    unicode-normalization@0.1.22
    unicode-width@0.1.10
    url@2.3.1
    utf-8@0.7.6
    value-bag@1.0.0-alpha.9
    version-compare@0.1.1
    version_check@0.9.4
    wait-timeout@0.2.0
    waker-fn@1.1.0
    walkdir@2.3.3
    wasi@0.11.0+wasi-snapshot-preview1
    wasi@0.9.0+wasi-snapshot-preview1
    wasm-bindgen-backend@0.2.84
    wasm-bindgen-backend@0.2.85
    wasm-bindgen-futures@0.4.35
    wasm-bindgen-macro-support@0.2.84
    wasm-bindgen-macro-support@0.2.85
    wasm-bindgen-macro@0.2.84
    wasm-bindgen-macro@0.2.85
    wasm-bindgen-shared@0.2.84
    wasm-bindgen-shared@0.2.85
    wasm-bindgen@0.2.84
    wasm-bindgen@0.2.85
    web-sys@0.3.61
    web-sys@0.3.62
    weezl@0.1.7
    wide@0.7.8
    winapi-i686-pc-windows-gnu@0.4.0
    winapi-util@0.1.5
    winapi-x86_64-pc-windows-gnu@0.4.0
    winapi@0.3.9
    windows-sys@0.42.0
    windows-sys@0.45.0
    windows-sys@0.48.0
    windows-targets@0.42.2
    windows-targets@0.48.0
    windows_aarch64_gnullvm@0.42.2
    windows_aarch64_gnullvm@0.48.0
    windows_aarch64_msvc@0.42.2
    windows_aarch64_msvc@0.48.0
    windows_i686_gnu@0.42.2
    windows_i686_gnu@0.48.0
    windows_i686_msvc@0.42.2
    windows_i686_msvc@0.48.0
    windows_x86_64_gnu@0.42.2
    windows_x86_64_gnu@0.48.0
    windows_x86_64_gnullvm@0.42.2
    windows_x86_64_gnullvm@0.48.0
    windows_x86_64_msvc@0.42.2
    windows_x86_64_msvc@0.48.0
    winnow@0.3.6
    winnow@0.4.6
    xdg-home@1.0.0
    xml5ever@0.17.0
    yeslogic-fontconfig-sys@4.0.1
    zbus@3.12.0
    zbus_macros@3.12.0
    zbus_names@2.5.0
    zune-inflate@0.2.54
    zvariant@3.12.0
    zvariant_derive@3.12.0
    zvariant_utils@1.0.0
"

inherit cargo meson xdg-utils gnome2-utils

DESCRIPTION="A simple image viewer application written with GTK4 and Rust."
HOMEPAGE="https://gitlab.gnome.org/Incubator/loupe"
SRC_URI="https://gitlab.gnome.org/Incubator/loupe/-/archive/${PV}/loupe-${PV}.tar.gz
    $(cargo_crate_uris)
"

IUSE="$IUSE svg heif"

DEPEND="
    gui-libs/gtk
    gui-libs/libadwaita
    dev-libs/libgweather
    svg? ( gnome-base/librsvg )
    heif? ( media-libs/libheif )
    media-libs/lcms
"

RDEPEND="${DEPEND}"

LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 Boost-1.0 CC0-1.0 GPL-3+ LGPL-2.1+ MIT MIT-0 MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"
SLOT="0"
KEYWORDS="amd64"

# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare(){
    default

    # cargo.eclass works with gitlab uris and gitlab.gnome.org is not considered a gitlab uri :-(
    sed -i "s/gitlab.gnome.org/github.com/g" Cargo.{toml,lock} || die

    sed -i '/librsvg/s/.*/librsvg = "2.56.0"/' Cargo.toml
    sed -i "\|CARGO_HOME|s|.*|cargo_env = { 'CARGO_HOME': '${WORKDIR}/cargo_home' }|" src/meson.build

    if ! use heif; then
       sed -i "/dependency('libheif'/d" meson.build || die
	fi

	sed -i '/^gnome.post_install($/,/^)$/d' meson.build || die
}

src_compile() {
	meson_src_compile
}

pkg_preinst() {
   gnome2_schemas_savelist
}

pkg_postinst() {
   gnome2_schemas_update
   xdg_icon_cache_update
   xdg_desktop_database_update
}

pkg_postrm() {
   gnome2_schemas_update
   xdg_icon_cache_update
   xdg_desktop_database_update
}