name: cherrytree
version: 0.39.2
summary: Hierarchical note taking application
description: |
  A hierarchical note taking application, featuring rich text and syntax highlighting, storing data in a single XML or SQLite file. The project home page is giuspen.com/cherrytree.

grade: stable
confinement: strict
base: core18

slots:
  cherrytree:
    interface: dbus
    bus: session
    name: com.giuspen.CherryTreeService

plugs:
  gtk-2-engines:
    interface: content
    target: $SNAP/lib/gtk-2.0
    default-provider: gtk2-common-themes
  gtk-2-themes:
    interface: content
    target: $SNAP/share/themes
    default-provider: gtk2-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

apps:
  cherrytree:
    command: desktop-launch $SNAP/bin/cherrytree
    plugs:
      - home
      - unity7
      - wayland
      - x11
      - desktop
      - desktop-legacy
      - gsettings
    desktop: share/applications/cherrytree.desktop
    environment:
      PATH: $SNAP/usr/lib/p7zip:$PATH
      GTK_PATH: $SNAP/lib/gtk-2.0
      GTK_DATA_PREFIX: $SNAP
      XDG_DATA_DIRS: $SNAP/share:$XDG_DATA_DIRS

parts:
  desktop-gtk:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
    - libgtk2.0-dev
    - libgtk-3-dev
    stage-packages:
    - libxkbcommon0  # XKB_CONFIG_ROOT
    - ttf-ubuntu-font-family
    - dmz-cursor-theme
    - light-themes
    - adwaita-icon-theme
    - gnome-themes-standard
    - shared-mime-info
    - libgtk2.0-0
    - libgtk-3-0
    - libgdk-pixbuf2.0-0
    - libglib2.0-bin
    - libgtk2.0-bin
    - libgtk-3-bin
    - unity-gtk2-module
    - unity-gtk3-module
    - libappindicator3-1
    - locales-all
    - xdg-user-dirs
    - ibus-gtk
    - ibus-gtk3
    - libibus-1.0-5
    after: [desktop-patch]
    override-pull: |
      snapcraftctl pull
      patch -Np1 < $SNAPCRAFT_STAGE/desktop-launch.patch
    organize:
      usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gtk-2.0: usr/lib/gtk-2.0
      usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gtk-3.0: usr/lib/gtk-3.0

  desktop-patch:
    source: snap/local/patches
    source-type: local
    plugin: dump
    prime: [-* ]

  cherrytree:
    source: https://github.com/giuspen/cherrytree.git
    source-depth: 1
    plugin: python
    python-version: python2
    override-build: |
      sed -i 's|^Icon=.*|Icon=${SNAP}/meta/gui/cherrytree.png|' linux/cherrytree.desktop
      snapcraftctl build
      mkdir -p $SNAPCRAFT_PART_INSTALL/meta/gui/
      cp glade/cherrytree.png $SNAPCRAFT_PART_INSTALL/meta/gui/
    build-packages:
      - gettext
      - desktop-file-utils
    stage-packages:
      - python-gtk2
      - python-gtksourceview2
      - p7zip-full
      - python-dbus
      - python-enchant
      - python-chardet
    prime:
      - -usr/bin/7za
