name: midori
version: git
version-script: |
  set -x
  VERSION=$(grep -r "^set(CORE_VERSION" CMakeLists.txt | sed -r "s@.+ ([0-9.]+)\)@\1@")
  echo $(git describe --tags || echo $VERSION)
summary: a lightweight, fast, and free web browser
description: |
  Midori is a lightweight yet powerful web browser which runs just as well on little embedded computers named for delicious pastries as it does on beefy machines with a core temperature exceeding that of planet earth. And it looks good doing that, too. Oh, and of course it's free software.

  Privacy out of the box:

      • Adblock filter list support.
      • Private browsing.
      • Manage cookies and scripts.

  Productivity features:

      • Open a 1000 tabs instantly.
      • Easy web apps creation.
      • Customizable side panels.
      • User scripts and styles a la Greasemonkey.
      • Web developer tools powered by WebKit.

grade: stable
confinement: strict
icon: icons/scalable/apps/org.midori_browser.Midori.svg

apps:
  midori:
    command: desktop-launch snapcraft-preload midori
    plugs:
      - home
      - pulseaudio
      - network
      - camera
      - removable-media
      - unity7
      - wayland
      - mir
      - screen-inhibit-control
      - password-manager-service
      - gsettings
      - network-bind
      - location-observe
      - network-status
    desktop: share/applications/org.midori_browser.Midori.desktop
    environment:
      LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/:$LD_LIBRARY_PATH
      # Work-around GPU crash https://bugs.webkit.org/show_bug.cgi?id=126122
      WEBKIT_DISABLE_COMPOSITING_MODE: 1
      # No Netscape plugins
      MOZ_PLUGIN_PATH: /
      PYTHONHOME: $SNAP/usr

slots:
  dbus:
    name: org.midori_browser.Midori
    bus: session

parts:
  midori:
    plugin: cmake
    configflags:
      - -DCMAKE_INSTALL_DATADIR=/usr/share
      - -DDESKTOP_ICON=/usr/share/icons/hicolor/scalable/apps/org.midori_browser.Midori.svg
    build-packages:
      - git
      - valac
      - libwebkit2gtk-4.0-dev
      - libsoup-gnome2.4-dev
      - libgcr-3-dev
      - libpeas-dev
      - libsqlite3-dev
      - libjson-glib-dev
      - libarchive-dev
      - intltool
      - ninja-build
      - libxml2-utils # xmllint
    stage-packages:
      - libjson-glib-1.0-0
      - libarchive13
      - libwebkit2gtk-4.0-37
      - libgcr-base-3-1
      - libgcr-ui-3-1
      - libgck-1-0
      - libgpm2
      - libdb5.3
      - libcanberra-gtk3-module
      - libpeas-1.0-0-python2loader
      - python-gi
      - gir1.2-webkit2-4.0
      - gir1.2-peas-1.0
      - myspell-en-us
      - gnome-icon-theme-symbolic
      - gstreamer1.0-x
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-pulseaudio
      - gstreamer1.0-libav
      - pulseaudio-module-x11
      - libmirclient9
    organize:
      lib/girepository-1.0/Midori-0.6.typelib: usr/lib/girepository-1.0/Midori-0.6.typelib
    stage:
      - -usr/share/gir-1.0/Midori-0.6.gir
      - -usr/lib/*/libcups.so.2
      - -usr/share/doc/libcups2/changelog.Debian.gz
      - -usr/lib/*/libsoup-2.4.so.1.7.0
      - -usr/lib/*/libsoup-gnome-2.4.so.1.7.0
      - -usr/lib/*/libjpeg.so.8.0.2
      - -usr/share/doc
      - -usr/lib/*/libX11-xcb.so.1.0.0
      - -usr/lib/*/libX11.so.6.3.0
      - -usr/share/X11/locale
    after:
      - desktop-gtk3
      - snapcraft-preload
  snapcraft-preload:
    source: https://github.com/kalikiana/snapcraft-preload.git
    source-branch: webkitgtk2
    plugin: cmake
    build-packages:
      - gcc-multilib
      - g++-multilib
