diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 495053b..cfac1de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,39 +13,10 @@ jobs: - ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setting up cLaTeXMath cache πŸ—‚ - id: cache-clatexmath - uses: actions/cache@v2 - with: - path: ~/cLaTeXMath/ - key: ${{ runner.os }}-clatexmath - name: Downloading dependencies πŸ“₯ - run: sudo apt-get install build-essential libfontconfig1-dev zlib1g-dev libjsoncpp-dev libgtksourceviewmm-3.0-dev libgtkmm-3.0-dev libtinyxml2-dev python3 python3-pip python3-setuptools - - name: Download the latest version of Meson 🧰 - run: | - sudo pip3 install meson ninja - - name: Build cLaTeXMath from cache ✏ - id: build-clatexmath_cache - if: steps.cache-clatexmath.outputs.cache-hit == 'true' - run: | - pushd ~/cLaTeXMath/ - git pull - meson _build --reconfigure - ninja -C _build - sudo meson install -C _build - popd - - name: Build cLaTeXMath from source πŸ–‹ - if: steps.cache-clatexmath.outputs.cache-hit != 'true' || steps.build-clatexmath_cache == 'failure' - run: | - rm -rf ~/cLaTeXMath/ - git clone https://github.com/NanoMichael/cLaTexMath ~/cLaTeXMath/ - pushd ~/cLaTeXMath/ - meson _build - ninja -C _build - sudo meson install -C _build - popd + run: sudo apt-get install build-essential meson libfontconfig1-dev zlib1g-dev libgtksourceviewmm-3.0-dev libgtkmm-3.0-dev libtinyxml2-dev - name: Configure πŸ”§ - run: meson _build + run: meson _build --default-library static - name: Compile 🎲 run: ninja -C _build - name: Compress build artifacts πŸ“¦ @@ -71,7 +42,7 @@ jobs: dnf install -y gcc-c++ meson dnf install -y mingw64-filesystem mingw64-gcc-c++ dnf install -y mingw64-winpthreads-static - dnf install -y mingw64-gtkmm30 mingw64-gtksourceviewmm3 mingw64-jsoncpp mingw64-zlib mingw64-fontconfig mingw64-librsvg2 + dnf install -y mingw64-gtkmm30 mingw64-gtksourceviewmm3 mingw64-zlib mingw64-fontconfig mingw64-librsvg2 - name: Install cLaTeXMath πŸ–‹ run: | dnf config-manager --add-repo https://download.opensuse.org/repositories/home:sp1rit:mingw/Fedora_33/home:sp1rit:mingw.repo @@ -80,8 +51,8 @@ jobs: run: patch -p1 < windows.patch - name: Configure πŸ”§ run: | - export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mwindows" \ - LDFLAGS="-fstack-protector -lssp -mwindows -Wl,--subsystem,windows" + export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" \ + LDFLAGS="-fstack-protector -lssp" export CXXFLAGS="$CFLAGS" meson --prefix=/ --cross-file=/usr/share/mingw/toolchain-mingw64.meson --default-library shared x86_64-w64-mingw32 - name: Compile 🎲 @@ -114,7 +85,7 @@ jobs: - name: Download dependencies πŸ“₯ run: | brew install meson ninja pkg-config - brew install fontconfig gtkmm3 gtksourceviewmm3 jsoncpp librsvg sp1ritCS/tap/clatexmath zlib + brew install fontconfig gtkmm3 gtksourceviewmm3 librsvg sp1ritCS/tap/clatexmath zlib - name: Patch NoteKit 🩹 run: patch -p1 < Apple/llvm.patch - name: Configure πŸ”§ diff --git a/.github/workflows/latest-release.yml b/.github/workflows/latest-release.yml deleted file mode 100644 index ddf806c..0000000 --- a/.github/workflows/latest-release.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: automated build - -on: - push: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: setting the dependencies up - run: sudo apt install libfontconfig1-dev zlib1g-dev libjsoncpp-dev libgtksourceviewmm-3.0-dev libtinyxml2-dev libgtkmm-3.0-dev cmake ninja-build - - name: installing cLaTeXMath - run: ./install-clatexmath.sh - - name: configure - run: cmake -G "Ninja" -DHAVE_CLATEXMATH=ON . - - name: ninja - run: ninja - - name: compress header files - run: 7z a -r linux-latest.zip . - - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: true - title: "Development Build" - files: linux-latest.zip - - - uses: actions/upload-artifact@v1 - if: always() - with: - name: build-artifact-ubuntu-latest - path: . diff --git a/.github/workflows/package-deb.yml b/.github/workflows/package-deb.yml index 56f0dc5..2319175 100644 --- a/.github/workflows/package-deb.yml +++ b/.github/workflows/package-deb.yml @@ -16,7 +16,7 @@ jobs: - name: removing gcc10 run: sudo apt remove libgcc-10-dev - name: setting the dependencies up - run: sudo apt install libfontconfig1-dev zlib1g-dev libjsoncpp-dev libgtksourceviewmm-3.0-dev libgtkmm-3.0-dev libtinyxml2-dev cmake debhelper=12.1.1ubuntu1~ubuntu18.04.1 dpkg-dev + run: sudo apt install libfontconfig1-dev zlib1g-dev libgtksourceviewmm-3.0-dev libgtkmm-3.0-dev libtinyxml2-dev cmake debhelper=12.1.1ubuntu1~ubuntu18.04.1 dpkg-dev - name: running debhelper run: dpkg-buildpackage -b -uc - uses: "marvinpinto/action-automatic-releases@latest" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 86e4194..61b1593 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,7 +19,7 @@ jobs: dnf install -y gcc-c++ meson dnf install -y mingw64-filesystem mingw64-gcc-c++ dnf install -y mingw64-winpthreads-static - dnf install -y mingw64-gtkmm30 mingw64-gtksourceviewmm3 mingw64-jsoncpp mingw64-zlib mingw64-fontconfig mingw64-librsvg2 + dnf install -y mingw64-gtkmm30 mingw64-gtksourceviewmm3 mingw64-zlib mingw64-fontconfig mingw64-librsvg2 dnf install -y adwaita-icon-theme gtk-update-icon-cache - name: Install Rust πŸ¦€ run: | @@ -72,6 +72,8 @@ jobs: cp -r /usr/share/icons/Adwaita/ dist/bin/data/icons/ # generate icon cache for notekit icons gtk-update-icon-cache dist/bin/data/icons/hicolor/ + # recompile gsettings schema cache + glib-compile-schemas dist/bin/share/glib-2.0/schemas/gnome # add rust uutils coreutils cp coreutils/target/x86_64-pc-windows-gnu/release/{mkdir,touch,mv,rm}.exe dist/bin/ # add notesbase folder and put README.md into it diff --git a/.gitignore b/.gitignore index 82f44e4..288410e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ config.h # protection against over-aggresive fontconfig data/fonts/.uuid + +# compile gsettings schemas +gnome/gschemas.compiled diff --git a/Apple/llvm.patch b/Apple/llvm.patch index e606e1f..1c64018 100644 --- a/Apple/llvm.patch +++ b/Apple/llvm.patch @@ -1,16 +1,16 @@ -From e93560b8fe25d16836230eb78d037f52b577ab5d Mon Sep 17 00:00:00 2001 +From 908df6ddfa9dcb9bb8093c91d3759d1bdbec19b2 Mon Sep 17 00:00:00 2001 From: sp1rit -Date: Tue, 27 Apr 2021 09:31:41 +0200 +Date: Sun, 23 May 2021 18:55:26 +0200 Subject: [PATCH] tweaks to llvm clang build Signed-off-by: sp1rit --- main.cpp | 4 ++-- - meson.build | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) + meson.build | 3 +-- + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp -index 1fc7c32..9f1077c 100644 +index 61d25dd..aada02f 100644 --- a/main.cpp +++ b/main.cpp @@ -9,8 +9,8 @@ int main (int argc, char *argv[]) @@ -25,16 +25,22 @@ index 1fc7c32..9f1077c 100644 } ); diff --git a/meson.build b/meson.build -index 5a9f407..e55b597 100644 +index 34bba29..a9553f3 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('notekit', 'cpp', - version : '0.1', + version : '0.1.0', - default_options : ['warning_level=3', 'cpp_std=c++14'] + default_options : ['warning_level=3', 'cpp_std=c++17'] ) conf_data = configuration_data() +@@ -52,4 +52,3 @@ executable('notekit', + install : true + ) + +-meson.add_install_script('build-aux/postinstall.py') -- 2.31.1 + diff --git a/README.md b/README.md index fe04725..b5af8cc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # NoteKit This program is a structured notetaking application based on GTK+ 3. Write your notes in instantly-formatted Markdown, organise them in a tree of folders that can be instantly navigated from within the program, and add hand-drawn notes by mouse, touchscreen or digitiser. -![Screenshot](/screenshots/notekit-example.png?raw=true) +![Screenshot](/screenshots/notekit.png?raw=true) -We have a [Discord server](https://discord.gg/WVas9aX6Ee) for questions and discussing the project's development. +We have a [Discord server](https://discord.gg/WVas9aX6Ee) and a bridged [Matrix space](https://matrix.to/#/!qrAsPfOWegCOsSGhWc:tchncs.de?via=tchncs.de&via=matrix.org&via=t2bot.io) for questions and discussing the project's development. ## Why? @@ -33,7 +33,24 @@ Moreover, there is also To run the binary, you will in addition require at least the following packages: `libgtkmm-3.0-1v5 libgtksourceviewmm-3.0-0v5 libjsoncpp1 zlib1g libxml2`, where the version of `libgtkmm-3.0-1v5` is at least 3.20. (In particular, this means that Ubuntu 16.04 LTS (xenial) and derived distributions are too old.) If the binary does not work for you, it is recommended that you build from source, as described below. -## How to build +## How to build from source + +### Building with meson + +Invoke `meson _build` followed by `ninja -C _build` to compile NoteKit. You can then install NoteKit by invoking `meson install -C _build` (If you don't have polkit running, you'll need to execute it as uid 0). + +Required dependencies (pkg-config names): + +* `gtkmm-3.0` +* `gtksourceview-3.0` +* `zlib` +* `fontconfig` +* `clatexmath`* + +\* If clatexmath is not installed, meson will automatically build it too (you'll need the additional `tinyxml2` dependency). If you do not want cLaTeXMath, you can give meson the `-Dclatexmath=false` option. + +### Building with cmake + Either invoke `cmake .` followed by `make` (which will build a binary at `cmake-build-Release/output/notekit`), or get [CodeLite](https://codelite.org/), open and build the workspace. Required libraries: @@ -41,7 +58,6 @@ Required libraries: * `cmake`. * `libgtkmm-3.0-dev`>=3.20 (UI stuff) * `libgtksourceviewmm-3.0-dev`>=3.18 (more UI stuff) -* `libjsoncpp-dev` ~ 1.7.4 (config files; older versions may work) * `zlib1g-dev` * `libfontconfig1-dev` ~ 2.13 (to use custom fonts) @@ -50,6 +66,7 @@ If you want to enable LaTeX math rendering support, you moreover need: * Set the CMAKE variable `HAVE_CLATEXMATH` to ON. * Run `install-clatexmath.sh` to clone [cLaTeXMath](https://github.com/NanoMichael/cLaTeXMath) into a subfolder and build it as a static library. * If you observe linker errors, make sure your `gcc` is sufficiently new. +* `libtinyxml2-dev` >= 7.0.1 For older LaTeX math support using [lasem](https://github.com/GNOME/lasem), you can proceed as follows: @@ -59,8 +76,17 @@ For older LaTeX math support using [lasem](https://github.com/GNOME/lasem), you Development and testing was exclusively conducted on X11-based Linux. The one tested way of building on Windows involves [MSYS2](https://www.msys2.org/)'s mingw-w64 package family (following the `cmake` route outlined above). Since MSYS2's `coreutils` depend on its Cygwin fork, the released Windows binary packages instead include a subset of coreutils from [GnuWin32](http://gnuwin32.sourceforge.net/). +### Development environment with meson + +NoteKit provides a virtual environment that sets everything up for you. + +If you have bash or zsh (other shells *may* work too, but havn't been tested) you can run `source devel/bin/active` to turn it on. Then you can then simply run `configure _build` followed by `ninja -C _build` (you might also need to regenerate the gsettings cache by running `glib-compile-schemas devel/gnome/`). Running NoteKit should be as easy as executing the `notekit` binary within `_build`. + +To deactivate the environment, simply invoke `deactivate`. + ## Installation notes -* By default, configuration is saved in `$HOME/.config/notekit`, and notes are in `$HOME/.local/share/notekit`. This may depend on your `$XDG_` environmental variables, and the notes base path can be changed in the `config.json` file in the configuration folder. +* The settings are handled by GSettings. This means NoteKit will store it's preferences in an "OS native" way (dconf on Linux, registry on Windows and plist files on OS X). However if you dont want this, you can set the `GSETTINGS_BACKEND` environment variable to `keyfile`, to store all gsettings in an ini file. +* By default, the notes are stored in `$HOME/.local/share/notekit`. This may depend on your `$XDG_` environmental variables, and the notes base path can be set in the preferences. * Resources (`data/` and `sourceview/`) are searched in `/notekit/` under `$XDG_DATA_DIRS` (default: `/usr/local/share:/usr/share`), followed by the current working directory `.`. If packaging Notekit or otherwise preparing it for system-wide installation, these two folders should probably be copied into `/usr/share/notekit/data` and `/usr/share/notekit/sourceview` respectively. ## Usage notes @@ -88,7 +114,7 @@ Development and testing was exclusively conducted on X11-based Linux. The one te ### Syntax highlighting -![Screenshot](/screenshots/syntax-highlighting.png?raw=true) +![Screenshot](/screenshots/notekit-syntax_highlighting.png?raw=true) ### Misc diff --git a/about.cpp b/about.cpp new file mode 100644 index 0000000..d7a3170 --- /dev/null +++ b/about.cpp @@ -0,0 +1,16 @@ +#include "about.h" +#include + +AboutDiag::AboutDiag() { + set_program_name("NoteKit"); + set_logo_icon_name("com.github.blackhole89.notekit"); + set_comments("A GTK3 hierarchical markdown notetaking\napplication with tablet support."); + set_version(NK_VERSION); + set_website("https://github.com/blackhole89/notekit"); + set_website_label("GitHub: @blackhole89/notekit"); + set_copyright("Almighty Archjanitor: Matvey Soloviev"); + set_license_type(Gtk::LICENSE_GPL_3_0); + + set_authors(contributers); + set_artists(artists); +} diff --git a/about.h b/about.h new file mode 100644 index 0000000..4a1b3be --- /dev/null +++ b/about.h @@ -0,0 +1,29 @@ +#include + +class AboutDiag : public Gtk::AboutDialog { + public: + AboutDiag(); + protected: + /* modified version of + * ```sh + * echo "std::vector contributers {" && \ + * git shortlog -sn | awk '{$1 = ""; print "\t\""substr($0, 2)"\"," }' && \ + * echo "};" + * ``` + * Modifications: + * - Merged my (sp1rit) names into one + */ + std::vector contributers { + "Matvey Soloviev", + "Florian \"sp1rit\"", + "noasakurajin", + "Bilal Elmoussaoui", + "Lyes Saadi", + "proxi", + "倧黄老鼠", + }; + std::vector artists { + "Thomas Kole", + "James & Orman Clark @ iconic.app http://iconic.app" + }; +}; diff --git a/build-aux/postinstall.py b/build-aux/postinstall.py new file mode 100644 index 0000000..44d05fc --- /dev/null +++ b/build-aux/postinstall.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 + +from os import environ, path +from subprocess import call + +prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') +datadir = path.join(prefix, 'share') +destdir = environ.get('DESTDIR', '') + +# Package managers set this so we don't need to run +if not destdir: + print('Updating icon cache...') + call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')]) + + print('Updating desktop database...') + call(['update-desktop-database', '-q', path.join(datadir, 'applications')]) + + print('Compiling GSettings schemas...') + call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')]) diff --git a/config.h.in b/config.h.in index 8208e03..2b68cd9 100644 --- a/config.h.in +++ b/config.h.in @@ -1,4 +1,5 @@ // global config +#define NK_VERSION "0.1.0" #cmakedefine HAVE_LASEM #cmakedefine HAVE_CLATEXMATH diff --git a/config.h.meson.in b/config.h.meson.in index 952932d..d64700c 100644 --- a/config.h.meson.in +++ b/config.h.meson.in @@ -1,3 +1,4 @@ // global config +#define NK_VERSION "@version@" #mesondefine HAVE_CLATEXMATH diff --git a/data/icons/hicolor/scalable/emblems/maximize-symbolic.svg b/data/icons/hicolor/scalable/emblems/maximize-symbolic.svg new file mode 100644 index 0000000..ea10544 --- /dev/null +++ b/data/icons/hicolor/scalable/emblems/maximize-symbolic.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/icons/hicolor/scalable/emblems/maximize.svg b/data/icons/hicolor/scalable/emblems/maximize.svg new file mode 100644 index 0000000..8c079ff --- /dev/null +++ b/data/icons/hicolor/scalable/emblems/maximize.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/icons/hicolor/scalable/emblems/minimize-symbolic.svg b/data/icons/hicolor/scalable/emblems/minimize-symbolic.svg new file mode 100644 index 0000000..3d43a5f --- /dev/null +++ b/data/icons/hicolor/scalable/emblems/minimize-symbolic.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/icons/hicolor/scalable/emblems/minimize.svg b/data/icons/hicolor/scalable/emblems/minimize.svg new file mode 100644 index 0000000..f43a970 --- /dev/null +++ b/data/icons/hicolor/scalable/emblems/minimize.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/preferences.glade b/data/preferences.glade index 47fdca2..85580a8 100644 --- a/data/preferences.glade +++ b/data/preferences.glade @@ -1,35 +1,33 @@ - + - False + False + Preferences - NoteKit False True - True - dialog - - - + True + com.github.blackhole89.notekit + dialog - False - 10 - 10 - 10 - 10 + False + 10 + 10 vertical - False - end + False + 12 + end - - gtk-ok + + gtk-close True - True - True - True + True + True + True True @@ -37,20 +35,6 @@ 0 - - - gtk-cancel - True - True - True - True - - - True - True - 1 - - False @@ -59,71 +43,106 @@ - + + True - False - vertical + False + 12 + 12 + 12 + 12 + 12 + 12 + + + True + False + start + Base Directory + 1 + + + 0 + 0 + + + + + True + False + start + Use headerbar + 1 + + + 0 + 1 + + + + + True + False + start + Syntax highlighting + 1 + + + 0 + 2 + + True - False - 5 + False + vertical - + True - False - Base Directory + True + select-folder + - False + True True 0 - + True - False - select-folder - + False + <small><span foreground="grey">The directory in which the tree of notes is stored.</span></small> + True + True + 48 + 0 - True + False True 1 - False - True - 0 - - - - - True - False - start - 10 - <small><span foreground="grey">The directory in which the tree of notes is stored.</span></small> - True - True - - - False - True - 1 + 1 + 0 True - False + False + vertical - + True - False + True + False + True False @@ -132,12 +151,15 @@ - - Use headerbar + True - True - False - True + False + <small><span foreground="grey">Display a GNOME 3 style CSD title bar instead of deferring to the window manager. +</span></small> + True + True + 48 + 0 False @@ -147,35 +169,21 @@ - False - True - 2 - - - - - True - False - start - 10 - <small><span foreground="grey">Display a GNOME 3 style CSD title bar instead of deferring to the window manager.</span></small> - True - True - - - False - True - 3 + 1 + 1 True - False + False + vertical - + True - False + True + False + True False @@ -184,12 +192,16 @@ - - Enable syntax highlighting + True - True - False - True + False + <small><span foreground="grey">Enable syntax highlighting in three-backtick code spans, using the languages supported by your system's GtkSourceView (gedit, pluma etc.) setup. +This increases startup time and may result in markdown rendering failing if <i>any</i> installed language specification is buggy. +</span></small> + True + True + 48 + 0 False @@ -199,48 +211,13 @@ - False - True - 4 - - - - - True - False - start - 10 - <small><span foreground="grey">Enable syntax highlighting in three-backtick code spans, using the languages supported by your system's GtkSourceView (gedit, pluma etc.) setup. -This increases startup time and may result in markdown rendering failing if <i>any</i> installed language specification is buggy. -</span></small> - True - True - 70 - - - False - True - 5 - - - - - True - False - end - end - True - Preference changes only take effect after restarting NoteKit. - - - False - True - 6 + 1 + 2 - True + False True 1 @@ -248,15 +225,28 @@ This increases startup time and may result in markdown rendering failing if < - button1 - button2 + button - + + vertical + + + + + + + vertical + + + + + + + vertical - - - + + diff --git a/data/stylesheet.css b/data/stylesheet.css index e8223d6..278a4ce 100644 --- a/data/stylesheet.css +++ b/data/stylesheet.css @@ -62,7 +62,8 @@ #mainView { - font: 16px Charter; + font-size: 16px; + font-family: Charter, serif; padding-top: 16px; padding-right: 16px; padding-bottom: 16px; diff --git a/debian/control b/debian/control index 42aaac6..e26a129 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: notekit Section: text Priority: optional Maintainer: Matvey Soloviev -Build-Depends: cmake, libfontconfig1-dev, zlib1g-dev, libjsoncpp-dev, libgtksourceviewmm-3.0-dev, libgtkmm-3.0-dev, debhelper-compat (= 12) +Build-Depends: cmake, libfontconfig1-dev, zlib1g-dev, libgtksourceviewmm-3.0-dev, libgtkmm-3.0-dev, debhelper-compat (= 12) Standards-Version: 4.5.1 Homepage: https://github.com/blackhole89/notekit #Vcs-Browser: https://salsa.debian.org/debian/notekit diff --git a/devel/.gitignore b/devel/.gitignore new file mode 100644 index 0000000..fad85b7 --- /dev/null +++ b/devel/.gitignore @@ -0,0 +1,3 @@ +share/ +bin/notekit +config/* diff --git a/devel/bin/activate b/devel/bin/activate new file mode 100644 index 0000000..87166cb --- /dev/null +++ b/devel/bin/activate @@ -0,0 +1,166 @@ +# Modified version of python3's venv +# Copyright (c) 2021 Florian "sp1rit". +# Copyright Β© 2001-2021 Python Software Foundation. All rights reserved. +# +# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +# -------------------------------------------- +# +# 1. This LICENSE AGREEMENT is between the Python Software Foundation +# ("PSF"), and the Individual or Organization ("Licensee") accessing and +# otherwise using this software ("Python") in source or binary form and +# its associated documentation. +# +# 2. Subject to the terms and conditions of this License Agreement, PSF hereby +# grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +# analyze, test, perform and/or display publicly, prepare derivative works, +# distribute, and otherwise use Python alone or in any derivative version, +# provided, however, that PSF's License Agreement and PSF's notice of copyright, +# i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Python Software Foundation; +# All Rights Reserved" are retained in Python alone or in any derivative version +# prepared by Licensee. +# +# 3. In the event Licensee prepares a derivative work that is based on +# or incorporates Python or any part thereof, and wants to make +# the derivative work available to others as provided herein, then +# Licensee hereby agrees to include in any such work a brief summary of +# the changes made to Python. +# +# 4. PSF is making Python available to Licensee on an "AS IS" +# basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +# IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +# DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +# FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +# INFRINGE ANY THIRD PARTY RIGHTS. +# +# 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +# FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +# A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +# OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. +# +# 6. This License Agreement will automatically terminate upon a material +# breach of its terms and conditions. +# +# 7. Nothing in this License Agreement shall be deemed to create any +# relationship of agency, partnership, or joint venture between PSF and +# Licensee. This License Agreement does not grant permission to use PSF +# trademarks or trade name in a trademark sense to endorse or promote +# products or services of Licensee, or any third party. +# +# 8. By copying, installing or otherwise using Python, Licensee +# agrees to be bound by the terms and conditions of this License +# Agreement. + +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +configure() { + meson --prefix $VIRTUAL_ENV $@ +} + +deactivate () { + # reset old environment variables + if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then + PATH="${_OLD_VIRTUAL_PATH:-}" + export PATH + unset _OLD_VIRTUAL_PATH + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r + fi + + if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then + PS1="${_OLD_VIRTUAL_PS1:-}" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + unset VIRTUAL_ENV_LANG + + unset -f configure + + if [ ! "${1:-}" = "nondestructive" ]; then + unset XDG_CONFIG_HOME + if [[ -n "${_OLD_VIRTUAL_XDG_CONFIG_HOME:-}" ]]; then + echo "Setting config home" + XDG_CONFIG_HOME="${_OLD_VIRTUAL_XDG_CONFIG_HOME:-}" + export XDG_CONFIG_HOME + unset _OLD_VIRTUAL_XDG_CONFIG_HOME + fi + + unset GSETTINGS_BACKEND + if [[ -n "${_OLD_VIRTUAL_GSETTINGS_BACKEND}" ]]; then + GSETTINGS_BACKEND="${_OLD_VIRTUAL_GSETTINGS_BACKEND}" + export GSETTINGS_BACKEND + unset _OLD_VIRTUAL_GSETTINGS_BACKEND + fi + + unset GSETTINGS_SCHEMA_DIR + if [[ -n "${_OLD_VIRTUAL_GSETTINGS_SCHEMA_DIR}" ]]; then + GSETTINGS_SCHEMA_DIR="${_OLD_VIRTUAL_GSETTINGS_SCHEMA_DIR}" + export GSETTINGS_SCHEMA_DIR + unset _OLD_VIRTUAL_GSETTINGS_SCHEMA_DIR + fi + + unset NK_DEVEL + if [[ -n "${_OLD_VIRTUAL_NK_DEVEL}" ]]; then + NK_DEVEL="${_OLD_VIRTUAL_NK_DEVEL}" + export NK_DEVEL + unset _OLD_VIRTUAL_NK_DEVEL + fi + + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="$(git rev-parse --show-toplevel)/devel" +VIRTUAL_ENV_LANG="c++" +export VIRTUAL_ENV VIRTUAL_ENV_LANG + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then + _OLD_VIRTUAL_PS1="${PS1:-}" + if [ "x(NoteKit Development) " != x ] ; then + PS1="(NoteKit Development) ${PS1:-}" + else + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then + # special case for Aspen magic directories + # see https://aspen.io/ + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" + else + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" + fi + fi + export PS1 +fi + +# NoteKit specific env vars +_OLD_VIRTUAL_XDG_CONFIG_HOME="$XDG_CONFIG_HOME" +XDG_CONFIG_HOME="$VIRTUAL_ENV/config" +_OLD_VIRTUAL_GSETTINGS_BACKEND="$GSETTINGS_BACKEND" +GSETTINGS_BACKEND=keyfile +_OLD_VIRTUAL_GSETTINGS_SCHEMA_DIR="$GSETTINGS_SCHEMA_DIR" +GSETTINGS_SCHEMA_DIR="$VIRTUAL_ENV/gnome" +_OLD_VIRTUAL_NK_DEVEL="$NK_DEVEL" +NK_DEVEL="$VIRTUAL_ENV" +export XDG_CONFIG_HOME GSETTINGS_BACKEND GSETTINGS_SCHEMA_DIR NK_DEVEL +export _OLD_VIRTUAL_XDG_CONFIG_HOME _OLD_VIRTUAL_GSETTINGS_BACKEND _OLD_VIRTUAL_GSETTINGS_SCHEMA_DIR _OLD_VIRTUAL_NK_DEVEL + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then + hash -r +fi diff --git a/devel/data b/devel/data new file mode 120000 index 0000000..eed2d0b --- /dev/null +++ b/devel/data @@ -0,0 +1 @@ +../data/ \ No newline at end of file diff --git a/devel/gnome b/devel/gnome new file mode 120000 index 0000000..1e74db9 --- /dev/null +++ b/devel/gnome @@ -0,0 +1 @@ +../gnome/ \ No newline at end of file diff --git a/devel/notesbase b/devel/notesbase new file mode 120000 index 0000000..841f0ab --- /dev/null +++ b/devel/notesbase @@ -0,0 +1 @@ +../notesbase/ \ No newline at end of file diff --git a/devel/sourceview b/devel/sourceview new file mode 120000 index 0000000..e7229a9 --- /dev/null +++ b/devel/sourceview @@ -0,0 +1 @@ +../sourceview/ \ No newline at end of file diff --git a/drawing.cpp b/drawing.cpp index c4ee9f1..c67acee 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -277,10 +277,14 @@ std::string CBoundDrawing::Serialize() raw_data.push_back(h); raw_data.push_back(strokes.size()); for(auto &s : strokes) { - raw_data.push_back(*(unsigned int*)&s.r); - raw_data.push_back(*(unsigned int*)&s.g); - raw_data.push_back(*(unsigned int*)&s.b); - raw_data.push_back(*(unsigned int*)&s.a); + float r = (float)s.r; + float g = (float)s.g; + float b = (float)s.b; + float a = (float)s.a; + raw_data.push_back(*(unsigned int*)&r); + raw_data.push_back(*(unsigned int*)&g); + raw_data.push_back(*(unsigned int*)&b); + raw_data.push_back(*(unsigned int*)&a); raw_data.push_back(s.xcoords.size()); int pos = raw_data.size(), len=s.xcoords.size(); raw_data.resize( raw_data.size()+3*len ); @@ -326,10 +330,10 @@ void CBoundDrawing::Deserialize(std::string input) int pos=3; for(unsigned int nstrokes = 0; nstrokes xcoords; std::vector ycoords; std::vector pcoords; @@ -81,4 +81,4 @@ class CBoundDrawing : public Gtk::DrawingArea void DumpForDebugging(); }; -#endif \ No newline at end of file +#endif diff --git a/freedesktop/com.github.blackhole89.notekit.metainfo.xml b/freedesktop/com.github.blackhole89.notekit.metainfo.xml index bb71b75..cb248b8 100644 --- a/freedesktop/com.github.blackhole89.notekit.metainfo.xml +++ b/freedesktop/com.github.blackhole89.notekit.metainfo.xml @@ -86,7 +86,16 @@ - https://raw.githubusercontent.com/blackhole89/notekit/master/screenshots/notekit-example.png + https://raw.githubusercontent.com/blackhole89/notekit/master/screenshots/notekit.png + + + https://raw.githubusercontent.com/blackhole89/notekit/master/screenshots/notekit-syntax_highlighting.png + + + https://raw.githubusercontent.com/blackhole89/notekit/master/screenshots/notekit_dark.png + + + https://raw.githubusercontent.com/blackhole89/notekit/master/screenshots/notekit_dark-syntax_highlighting.png https://github.com/blackhole89/notekit diff --git a/gnome/com.github.blackhole89.notekit.gschema.xml b/gnome/com.github.blackhole89.notekit.gschema.xml new file mode 100644 index 0000000..c460f39 --- /dev/null +++ b/gnome/com.github.blackhole89.notekit.gschema.xml @@ -0,0 +1,41 @@ + + + + + "Β΅{default}" + The directory in which the tree of notes is stored. + + + "" + The currently active document + + + true + Display a GNOME style CSD title bar instead of deferring to the window manager / gtk fallback. + + + false + Enable syntax highlighting in three-backtick code spans, using the languages supported by your system's GtkSourceView (gedit, pluma etc.) setup. + + + true + Enables Zen / hide-everything mode + + + false + Enables Zen / hide-everything mode + + + [ + (0.0,0.0,0.0,1.0), + (0.62745100259780884,0.65882354974746704,0.75294119119644165,1.0), + (0.97647058963775635,0.12156862765550613,0.21568627655506134,1.0), + (0.61568629741668701,0.7607843279838562,0.3960784375667572,1.0), + (0.21176470816135406,0.47058823704719543,0.73725491762161255,1.0), + (1.0,0.64313727617263794,0.0,1.0), + (0.76862746477127075,0.26666668057441711,0.49019607901573181,1.0) + ] + An array of selected colors specified as a tuple of four doubles, specifying RGBA values between 0 and 1. Each item represents one button within the toolbar. + + + diff --git a/main.cpp b/main.cpp index 1fc7c32..61d25dd 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,8 @@ int main (int argc, char *argv[]) app->set_accel_for_action("notebook.next-note", "Tab"); app->set_accel_for_action("notebook.prev-note", "Tab"); + app->set_accel_for_action("win.sidebar", "F9"); + app->set_accel_for_action("win.zen", "F11"); auto ret = app->run(); diff --git a/mainwindow.cpp b/mainwindow.cpp index d1bb33b..62cf979 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2,28 +2,37 @@ #include "navigation.h" #include #include +#include + +#include #ifdef HAVE_CLATEXMATH #define __OS_Linux__ #include "latex.h" #endif +#ifdef GDK_WINDOWING_X11 +#include +#endif +#ifdef GDK_WINDOWING_WAYLAND +#include +#endif + CMainWindow::CMainWindow(const Glib::RefPtr& app) : Gtk::ApplicationWindow(app), nav_model(), sview() { // Determine paths to operate on. CalculatePaths(); - // Load config. - LoadConfig(); - printf("== This is notekit, built at " __TIMESTAMP__ ". ==\n"); printf("Detected paths:\n"); - printf("Config: %s\n",config_path.c_str()); - printf("Active notes path: %s\n",config["base_path"].asString().c_str()); + //printf("Config: %s\n",config_path.c_str()); + printf("Active notes path: %s\n",settings->get_string("base-path").c_str()); printf("Default notes path: %s\n",default_base_path.c_str()); printf("Resource path: %s\n",data_path.c_str()); printf("\n"); + settings->signal_changed().connect(sigc::mem_fun(this,&CMainWindow::SettingChange)); + #ifdef HAVE_CLATEXMATH tex::LaTeX::init((data_path+"/data/latex").c_str()); /* allow \newcommand to override quietly, since we will be rerendering \newcommands unpredictably */ @@ -31,12 +40,17 @@ CMainWindow::CMainWindow(const Glib::RefPtr& app) : Gtk::Appli if(r) delete r; #endif - sview.Init(data_path, config["use_highlight_proxy"].asBool()); - nav_model.SetBasePath(config["base_path"].asString()); + sview.Init(data_path, settings->get_boolean("syntax-highlighting")); // make sure document is in place for tree expansion so we can set the selection - selected_document = config["active_document"].asString(); + selected_document = settings->get_string("active-document"); + if (settings->get_string("base-path") == "Β΅{default}") { + settings->set_string("base-path", default_base_path); + } else { + SettingChange("base-path"); + } + // set up window set_border_width(0); set_default_size(900,600); @@ -51,36 +65,33 @@ CMainWindow::CMainWindow(const Glib::RefPtr& app) : Gtk::Appli get_style_context()->add_class("notekit"); override_background_color(Gdk::RGBA("rgba(0,0,0,0)")); - /* set up menu */ - am.prefs.set_label("Preferences"); - am.prefs.signal_activate().connect( sigc::mem_fun(this,&CMainWindow::RunConfigWindow) ); - appmenu.append(am.prefs); - am.exprt.set_label("Export current"); - am.exprt.signal_activate().connect( sigc::mem_fun(this,&CMainWindow::FetchAndExport) ); - appmenu.append(am.exprt); - appmenu.append(am.sep); - am.hide_sidebar.set_label("Hide sidebar"); - // this should probably use Gio::Menu actions instead...? documentation is an unholy mess on this - am.hide_sidebar.signal_activate().connect( sigc::bind( sigc::mem_fun(this,&CMainWindow::on_action), "toggle-sidebar", WND_ACTION_TOGGLE_SIDEBAR, 1)); - appmenu.append(am.hide_sidebar); - appmenu.show_all(); - - /* set up header bar */ - use_hbar = config["use_headerbar"].asBool(); - - if(use_hbar) { - hbar.set_show_close_button(true); - hbar.set_title("NoteKit"); - appbutton.set_image_from_icon_name("accessories-text-editor", Gtk::ICON_SIZE_BUTTON, true); - appbutton.set_menu(appmenu); - set_icon_name("accessories-text-editor"); - - hbar.pack_start(appbutton); - set_titlebar(hbar); - } + /* + * set up menu + * I don't kow why every item is prefixed with _, + * but every other application I looked at did it + * so we are doing it too :D. + */ + menu->append("_Export Page", "win.export"); + menu->append("_Preferences", "win.pref"); + menu->append("_Toggle Sidebar", "win.sidebar"); + menu->append("_About", "win.about"); + + /* set up header bar */ + hbar.set_show_close_button(true); + hbar.set_title("NoteKit"); + appbutton.set_image_from_icon_name("accessories-text-editor", Gtk::ICON_SIZE_BUTTON, true); + appbutton.set_use_popover(true); + appbutton.set_menu_model(menu); + + zenbtn.set_image_from_icon_name("maximize-symbolic"); + zenbtn.signal_clicked().connect( sigc::bind( sigc::mem_fun(this,&CMainWindow::on_action), "toggle-zen", WND_ACTION_TOGGLE_ZEN, 1 )); + + hbar.pack_start(appbutton); + hbar.pack_end(zenbtn); + set_titlebar(hbar); + /* install tree view */ - nav_model.AttachView(this,&nav); nav.get_style_context()->add_class("sidebar"); nav_scroll.add(nav); @@ -115,40 +126,66 @@ CMainWindow::CMainWindow(const Glib::RefPtr& app) : Gtk::Appli insert_action_group("notebook",sview.actions); UpdateToolbarColors(); split.pack_start(*toolbar,Gtk::PACK_SHRINK); - on_action("color1",WND_ACTION_COLOR,1); + on_action("color0",WND_ACTION_COLOR,0); #define ACTION(name,param1,param2) sview.actions->add_action(name, sigc::bind( sigc::mem_fun(this,&CMainWindow::on_action), std::string(name), param1, param2 ) ) ACTION("next-note",WND_ACTION_NEXT_NOTE,1); ACTION("prev-note",WND_ACTION_PREV_NOTE,1); /* add the top-level layout */ - if(use_hbar) { - add(split); - } else { - /* without a headerbar, we also need to have a vbox for the classic menu here */ - cm.view.set_label("View"); - // TODO: this results in Gtk-CRITICALs on quit as appmenu elements are double freed. - // Is there any way we can set a submenu here without making free of cm.view recursively free appmenu? - cm.view.set_submenu(appmenu); - cm.mbar.append(cm.view); - cm.menu_box.pack_start(cm.mbar,Gtk::PACK_SHRINK); - cm.menu_box.pack_start(split); - add(cm.menu_box); - } + Glib::RefPtr legacy = Gio::Menu::create(); + legacy->append_submenu("View", menu); + cm.mbar = Gtk::MenuBar(legacy); + cm.menu_box.pack_start(cm.mbar,Gtk::PACK_SHRINK); + cm.menu_box.pack_start(split); + add(cm.menu_box); + + settings->bind("csd", hbar.property_visible()); + settings->bind("csd", cm.mbar.property_visible(), Gio::SettingsBindFlags::SETTINGS_BIND_INVERT_BOOLEAN); + settings->bind("csd", property_decorated()); + split.show_all(); + cm.menu_box.show(); + appbutton.show_all(); + zenbtn.show_all(); + show(); + /* + * Note to future developers: If you changed anything + * regarding window construction and NoteKit is now + * throwing an SEGV, make sure that the sview is actually + * shown. (NoteKit segfaults when trying to render any + * widget (LaTeX, drawing, etc.) onto an invisible view. + * If set your current document to "" (empty string) and + * start notekit (this empty page shouldn't have any widgets) + * you should be able to see a transparent area where the + * sview is supposed to be. Happy fixing :D + * + * We can't just call show_all(), as that would break the + * bound visibility state of the hbar &| mbar. + */ + + window = gtk_widget_get_window(GTK_WIDGET(this->gobj())); + + SettingCsdUpdate(); + SettingSidebarUpdate(); + SettingZenUpdate(); - show_all(); - /* workaround to make sure the right pen width is selected at start */ Gtk::RadioToolButton *b; toolbar_builder->get_widget("medium",b); b->set_active(false); b->set_active(true); - OpenDocument(selected_document); + //if (settings->get_string("active-document") == "") { + // settings->set_string("active-document", ""); + //} else { + SettingChange("active-document"); + //} close_handler = this->signal_delete_event().connect( sigc::mem_fun(this, &CMainWindow::on_close) ); signal_motion_notify_event().connect(sigc::mem_fun(this,&CMainWindow::on_motion_notify),false); idle_timer = Glib::signal_timeout().connect(sigc::mem_fun(this,&CMainWindow::on_idle),5000,Glib::PRIORITY_LOW); + + printf("Current document: %s\n", settings->get_string("active-document").c_str()); } int mkdirp(std::string dir) @@ -167,7 +204,6 @@ void CMainWindow::CalculatePaths() if(dbg != NULL) { fprintf(stderr,"INFO: Debug mode set! Will operate in %s.\n", dbg); data_path=dbg; - config_path= data_path + "/notesbase"; default_base_path= data_path + "/notesbase"; return; } @@ -175,20 +211,10 @@ void CMainWindow::CalculatePaths() char *home = getenv("HOME"); if(!home || !*home) { fprintf(stderr,"WARNING: Could not determine user's home directory! Will operate in current working directory.\n"); - config_path="notesbase"; default_base_path="notesbase"; data_path="."; return; - } - - char *config_home = getenv("XDG_CONFIG_HOME"); - if(!config_home || !*config_home) config_path=std::string(home)+"/.config/notekit"; - else config_path=std::string(config_home)+"/notekit"; - - if(mkdirp(config_path)) { - fprintf(stderr,"WARNING: Could not create config path '%s'. Falling back to current working directory.\n",config_path.c_str()); - config_path="notesbase"; - } + } char *data_home = getenv("XDG_DATA_HOME"); if(!data_home || !*data_home) default_base_path=std::string(home)+"/.local/share/notekit"; @@ -204,7 +230,7 @@ void CMainWindow::CalculatePaths() if(!data_dirs || !*data_dirs) data_dirs=strdup("/usr/local/share:/usr/share"); else - data_dirs=strdup(data_dirs); + data_dirs=strdup(data_dirs); char *next=data_dirs; strtok(data_dirs,":"); @@ -220,71 +246,34 @@ void CMainWindow::CalculatePaths() free(data_dirs); } -void CMainWindow::LoadConfig() -{ - char *buf; gsize length; - Glib::RefPtr file = Gio::File::create_for_path(config_path+"/config.json"); - - try { - file->load_contents(buf, length); - } catch(Gio::Error &e) { - file = Gio::File::create_for_path(data_path+"/data/default_config.json"); - - try { - file->load_contents(buf, length); - } catch(Gio::Error &e) { - fprintf(stderr,"FATAL: config.json not found in note tree, and default_config.json not found in data tree!\n"); - exit(-1); - } - } - - Json::CharReaderBuilder rbuilder; - std::istringstream i(buf); - std::string errs; - Json::parseFromStream(rbuilder, i, &config, &errs); - - /* set default base path if none has been explicitly set */ - if(!config["base_path"].isString() || config["base_path"].asString()=="") { - config["base_path"]=default_base_path; - } - - g_free(buf); -} - -void CMainWindow::SaveConfig() -{ - Json::StreamWriterBuilder wbuilder; - std::string str = Json::writeString(wbuilder, config); - - FILE *fl = fopen( (config_path+"/config.json").c_str(), "wb"); - fwrite(str.c_str(),str.length(),1,fl); - fclose(fl); +void CMainWindow::RunAboutDiag() { + about.run(); + about.hide(); } -void CMainWindow::RunConfigWindow() +void CMainWindow::RunPreferenceDiag() { Glib::RefPtr config_builder; config_builder = Gtk::Builder::create_from_file(data_path+"/data/preferences.glade"); Gtk::Dialog *dlg; config_builder->get_widget("preferences",dlg); - Gtk::FileChooserButton *dir; Gtk::CheckButton *use_headerbar, *use_highlight_proxy; config_builder->get_widget("base_path",dir); config_builder->get_widget("use_headerbar",use_headerbar); config_builder->get_widget("use_highlight_proxy",use_highlight_proxy); - dir->set_current_folder(config["base_path"].asString()); - use_headerbar->set_active(config["use_headerbar"].asBool()); - use_highlight_proxy->set_active(config["use_highlight_proxy"].asBool()); - if(dlg->run() == Gtk::RESPONSE_OK) { - config["base_path"]=dir->get_current_folder(); - config["use_highlight_proxy"]=use_highlight_proxy->get_active(); - config["use_headerbar"]=use_headerbar->get_active(); - SaveConfig(); - } + dir->set_filename(settings->get_string("base-path")); + dir->signal_file_set().connect(sigc::mem_fun(this,&CMainWindow::UpdateBasePath)); + settings->bind("csd", use_headerbar->property_active()); + settings->bind("syntax-highlighting", use_highlight_proxy->property_active()); + dlg->run(); dlg->hide(); } +void CMainWindow::UpdateBasePath() { + settings->set_string("base-path", dir->get_filename()); +} + void CMainWindow::InitToolbar() { toolbar_builder = Gtk::Builder::create_from_file(data_path+"/data/toolbar.glade"); @@ -298,7 +287,9 @@ void CMainWindow::InitToolbar() /* generate colour buttons */ Gtk::RadioToolButton *b0 = nullptr; - for(unsigned int i=1;i<=config["colors"].size();++i) { + Glib::Variant> colors; + settings->get_value("colors", colors); + for(unsigned int i=0;i<=colors.get_n_children()-1;++i) { char buf[255]; //Gtk::Widget *sdfg; @@ -308,7 +299,7 @@ void CMainWindow::InitToolbar() ACTION(buf,WND_ACTION_COLOR,i); Gtk::RadioToolButton *b = nullptr; - if(i == 1) { + if(i == active_color) { b = b0 = new Gtk::RadioToolButton(buf); } else { Gtk::RadioToolButton::Group g = b0->get_group(); // because for some reason, the group argument is & @@ -326,34 +317,20 @@ void CMainWindow::InitToolbar() } } -void CMainWindow::GetColor(int id, float &r, float &g, float &b) -{ - Json::Value def; - def["r"]=def["g"]=def["b"]=0; - r=config["colors"].get(id-1,def)["r"].asFloat(); - g=config["colors"].get(id-1,def)["g"].asFloat(); - b=config["colors"].get(id-1,def)["b"].asFloat(); -} - -void CMainWindow::SetColor(int id, float r, float g, float b) -{ - Json::Value def; - def["r"]=def["g"]=def["b"]=0; - config["colors"][id-1]["r"]=r; - config["colors"][id-1]["g"]=g; - config["colors"][id-1]["b"]=b; -} - - void CMainWindow::UpdateToolbarColors() { std::string colorcss; - int i=1; + int i=0; char buf[255]; - for(auto a : config["colors"]) { - sprintf(buf,"#color%d { -gtk-icon-palette: warning rgb(%d,%d,%d); }\n", i, (int)(255*a["r"].asDouble()), (int)(255*a["g"].asDouble()), (int)(255*a["b"].asDouble()) ); + Glib::Variant> gcolors; + settings->get_value("colors", gcolors); + + + for(color_t color : gcolors.get()) { + setlocale(LC_NUMERIC, "C"); + sprintf(buf,"#color%d { -gtk-icon-palette: warning rgba(%d,%d,%d,%f); }\n", i, (int)(255*std::get<0>(color)), (int)(255*std::get<1>(color)), (int)(255*std::get<2>(color)), std::get<3>(color)); colorcss += buf; ++i; } @@ -405,23 +382,23 @@ void CMainWindow::FetchAndSave() void CMainWindow::FetchAndExport() { if(active_document=="") return; - + Gtk::FileChooserDialog d("Export current note", Gtk::FILE_CHOOSER_ACTION_SAVE); d.set_transient_for(*this); d.add_button("_Cancel", Gtk::RESPONSE_CANCEL); d.add_button("_Export", Gtk::RESPONSE_OK); - + auto filter_md = Gtk::FileFilter::create(); filter_md->set_name("Portable markdown"); filter_md->add_mime_type("text/plain"); filter_md->add_mime_type("text/markdown"); d.add_filter(filter_md); - + auto filter_pdf = Gtk::FileFilter::create(); filter_pdf->set_name("Pandoc to PDF (requires pandoc)"); filter_pdf->add_mime_type("application/pdf"); d.add_filter(filter_pdf); - + switch(d.run()) { case Gtk::RESPONSE_OK: { gsize len; @@ -429,43 +406,126 @@ void CMainWindow::FetchAndExport() buf = sbuffer->serialize(sbuffer,"text/plain",sbuffer->begin(),sbuffer->end(),len); std::string str((const char*)buf,len); g_free(buf); - + if(d.get_filter() == filter_md) { FILE *fl = fopen(d.get_filename().c_str(), "wb"); fwrite(str.c_str(),str.length(),1,fl); fclose(fl); } else if(d.get_filter() == filter_pdf) { - char *tempmd = tempnam(NULL,"nkexport"); - FILE *fl = fopen(tempmd, "wb"); + #ifdef _WIN32 + char* filename = std::getenv("TMP"); + strcat(filename, "/nkexportXXXXXX"); + #elif __APPLE__ + char* filename = std::getenv("TMPDIR"); + strcat(filename, "/nkexportXXXXXX"); + #else + char filename[] = "/tmp/nkexportXXXXXX"; + #endif + int fd = mkstemp(filename); + printf("Export: %s, Desciptor: %d\n", filename, fd); + FILE *fl = fdopen(fd, "w"); fwrite(str.c_str(),str.length(),1,fl); fclose(fl); - + char cmdbuf[1024]; - snprintf(cmdbuf,1024,"pandoc -f markdown+hard_line_breaks+compact_definition_lists -t latex -o \"%s\" \"%s\"",d.get_filename().c_str(),tempmd); + snprintf(cmdbuf,1024,"pandoc -f markdown -t latex -o \"%s\" \"%s\"",d.get_filename().c_str(),filename); int retval; - if(retval=system(cmdbuf)) { - printf("Exporting to PDF (temporary file: %s): failure (%d). Temporary file not deleted.\n",tempmd,retval); + if((retval=system(cmdbuf))) { + printf("Exporting to PDF (temporary file: %s): failure (%d). Temporary file not deleted.\n",filename,retval); } else { - printf("Exporting to PDF (temporary file: %s): success.\n",tempmd); - ::remove(tempmd); + printf("Exporting to PDF (temporary file: %s): success.\n",filename); + ::remove(filename); } } - + break; } default:; } } -void CMainWindow::OpenDocument(std::string filename) +void CMainWindow::OpenDocument(std::string filename) { + FetchAndSave(); + settings->set_string("active-document", filename); +} + +/* set apparent opened document filename without actually loading/unload anything */ +void CMainWindow::SetupDocumentWindow(Glib::ustring filename) { + active_document = filename; + selected_document = filename; + set_title(active_document + " - NoteKit"); + hbar.set_title("NoteKit"); + hbar.set_subtitle(active_document); +} + +CMainWindow::~CMainWindow() +{ +} + +bool CMainWindow::on_close(GdkEventAny* any_event) { + + if(active_document=="") return false; + FetchAndSave(); - if(filename=="") { + return false; +} + +void CMainWindow::on_action(std::string name, int type, int param) +{ + printf("Action triggered: %s\n",name.c_str()); + switch(type) { + case WND_ACTION_COLOR: { /* for some reason, this has to live in it's own seperate block */ + GVariant* colors = g_settings_get_value(settings->gobj(), "colors"); + g_variant_get_child(colors, param, "(dddd)", &sview.active.r, &sview.active.g, &sview.active.b, &sview.active.a); + active_color = param; + } break; + case WND_ACTION_NEXT_NOTE: + nav_model.NextDoc(); + break; + case WND_ACTION_PREV_NOTE: + nav_model.PrevDoc(); + break; + case WND_ACTION_TOGGLE_ZEN: + settings->set_boolean("zen", !settings->get_boolean("zen")); + break; + case WND_ACTION_TOGGLE_SIDEBAR: + settings->set_boolean("sidebar", !settings->get_boolean("sidebar")); + break; + } +} + +void CMainWindow::SettingChange(const Glib::ustring& key) { + printf("Setting changed: %s\n", key.c_str()); + settingmap_t::iterator setting = settingmap.find(key); + if (setting != settingmap.end()) { + setting->second(); + } +} + +void CMainWindow::SettingBasepathUpdate() { + printf("Basepath update: %s\n", settings->get_string("base-path").c_str()); + /* + * This is a somewhat ugly cheat: + * binit is set to true in mainwindow.h by default. After launch notekit shound set the currently active document to whatever is set in gsettings. + * After changing base_dir within the preferences notekit should not drop any active document. + */ + if (!binit) { + settings->set_string("active-document", ""); + } else { + binit = false; + } + nav_model.SetBasePath(settings->get_string("base-path")); + nav_model.AttachView(this,&nav); +} + +void CMainWindow::SettingDocumentUpdate() { + Glib::ustring filename = settings->get_string("active-document"); + printf("Active document: %s\n", filename.c_str()); + if (filename == "") { sview.set_editable(false); sview.set_can_focus(false); - - SetActiveFilename(""); - + SetupDocumentWindow(""); sbuffer->begin_not_undoable_action(); sbuffer->set_text("( Nothing opened. Please create or open a file. ) "); sbuffer->end_not_undoable_action(); @@ -473,93 +533,117 @@ void CMainWindow::OpenDocument(std::string filename) } sview.set_editable(true); sview.set_can_focus(true); - + char *buf; gsize length; try { Glib::RefPtr file = Gio::File::create_for_path(nav_model.base + "/" + filename); - file->load_contents(buf, length); + file->load_contents(buf, length); } catch(Gio::Error &e) { sview.set_editable(false); sview.set_can_focus(false); - fprintf(stderr,"Error: Failed to load document %s!\n",filename.c_str()); - SetActiveFilename(""); - + SetupDocumentWindow(""); sbuffer->begin_not_undoable_action(); char error_msg[512]; sprintf(error_msg,"( Failed to open %s. Please create or open a file. ) ",filename.c_str()); sbuffer->set_text(error_msg); sbuffer->end_not_undoable_action(); - return; } - + sbuffer->begin_not_undoable_action(); sbuffer->set_text(""); Gtk::TextBuffer::iterator i = sbuffer->begin(); if(length) sbuffer->deserialize(sbuffer,"text/notekit-markdown",i,(guint8*)buf,length); - //sbuffer->set_text(buf); sbuffer->end_not_undoable_action(); - - SetActiveFilename(filename); - - /*Glib::RefPtr anch = sbuffer->create_child_anchor(sbuffer->begin()); - testbutton.set_text("hello world"); - sview.add_child_at_anchor(testbutton,anch); - testbutton.show();*/ - g_free(buf); -} -/* set apparent opened document filename without actually loading/unload anything */ -void CMainWindow::SetActiveFilename(std::string filename) -{ - active_document = filename; - selected_document = filename; - if(use_hbar) { - hbar.set_subtitle(active_document); - } else { - set_title(active_document + " - NoteKit"); - } - config["active_document"]=filename; -} + SetupDocumentWindow(filename); -CMainWindow::~CMainWindow() -{ + g_free(buf); } -bool CMainWindow::on_close(GdkEventAny* any_event) -{ - SaveConfig(); - - if(active_document=="") return false; - - FetchAndSave(); - - return false; +void CMainWindow::SettingCsdUpdate() { + /* + * Due to differences in windowing protocols, there + * is no standardized way in GTK to set if you want + * server-side decorations (SSD) or client-side (CSD) + * ones. + * Note to future developers: If you see NoteKit throwing + * a SEGV and gdb tells you it has something to do with + * this, it's likely that `window` has not been initialized + * yet. For debug purposes, you can wrap this whole block + * in an if(window != 0x0) statement to prevent this. To + * fix it properly, you'll have to move whatever you did + * in the CMainWindow constructor further down. + */ + bool state = settings->get_boolean("csd"); + /* + * X11: + * This checks if Gdk was build with X support and if so + * determines if the current window is using the X protocol. + * If this is the case, it adds sets the third [2] value of + * _MOTIF_WM_HINTS (decorations) to the inverse state of the + * current "csd" setting. + */ + #ifdef GDK_WINDOWING_X11 + // + if (GDK_IS_X11_DISPLAY (gdk_window_get_display(window))) { + GdkAtom atom = gdk_atom_intern("_MOTIF_WM_HINTS", false); + long hints[5] = { 2, 0, (int)!state, 0, 0}; + gdk_property_change(window, atom, atom, 32, GDK_PROP_MODE_REPLACE, (unsigned char *)hints, 5); + } + #endif + /* + * Wayland: + * Some Wayland compositors also allow outsourcing the drawing + * of decorations to itself. This is defined in the xdg-decoration + * spec, whose abstractions are part of Gdk. + * However the Wayland compositor I tested against (Wayfire) was + * unable to change the decorations after it's initial set, so + * NoteKit had to be restarted in order to have proper decorations. + */ + #ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (gdk_window_get_display(window))) { + if (state) { + gdk_wayland_window_announce_csd(window); + } else { + gdk_wayland_window_announce_ssd(window); + } + } + #endif + /* + * TODO: here is space for potential support of broadway, w32 & quartz: + * IMO broadway support for SSD irrelevant, as it doesn't make much sense. + * Both w32 & quartz appear unfeasible with gtk+3, as their integration is + * lacking the features required to change CSD/SSD. + * However gtk4 seems to have all required features. + * - w32: get_effective_window_decorations(GdkSurface*, GdkWMDecoration*) + * - osx: GdkMacosWindow -> setDecorated(bool) + */ + return; } -void CMainWindow::on_action(std::string name, int type, int param) -{ - printf("%s\n",name.c_str()); - switch(type) { - case WND_ACTION_COLOR: - GetColor(param, sview.active.r,sview.active.g, sview.active.b); - sview.active.a=1; - break; - case WND_ACTION_NEXT_NOTE: - nav_model.NextDoc(); - break; - case WND_ACTION_PREV_NOTE: - nav_model.PrevDoc(); - break; - case WND_ACTION_TOGGLE_SIDEBAR: - if(am.hide_sidebar.get_active()) { - nav_scroll.set_visible(false); - } else { - nav_scroll.set_visible(true); - } - break; +void CMainWindow::SettingZenUpdate() { + bool state = settings->get_boolean("zen"); + sidebar_action->set_enabled(!state); + if (state) { + nav_scroll.set_visible(false); + toolbar->hide(); + zenbtn.set_image_from_icon_name("minimize-symbolic"); + } else { + nav_scroll.set_visible(settings->get_boolean("sidebar")); + toolbar->show(); + zenbtn.set_image_from_icon_name("maximize-symbolic"); } + Glib::Variant mesh = Glib::Variant::create(state); + zen_action->set_state(mesh); +} + +void CMainWindow::SettingSidebarUpdate() { + bool state = settings->get_boolean("sidebar"); + if (!settings->get_boolean("zen")) nav_scroll.set_visible(state); + Glib::Variant mesh = Glib::Variant::create(state); + sidebar_action->set_state(mesh); } bool CMainWindow::on_idle() @@ -573,27 +657,52 @@ bool CMainWindow::on_idle() return true; } -bool CMainWindow::on_click_color(GdkEventButton* e, int number) +bool CMainWindow::on_click_color(GdkEventButton* e, unsigned int number) { if(e->button == 3) { // right click Gtk::ColorChooserDialog dialog("Select a color"); dialog.set_transient_for(*this); - char buf[32]; - float r,g,b; - GetColor(number,r,g,b); - sprintf(buf,"rgb(%d,%d,%d)",(int)(r*255),(int)(g*255),(int)(b*255)); - - dialog.set_rgba(Gdk::RGBA(buf)); - + Glib::Variant> colors; + settings->get_value("colors", colors); + try { + color_t color = colors.get_child(number); + Gdk::RGBA gcolor = Gdk::RGBA(); + gcolor.set_rgba(std::get<0>(color), std::get<1>(color), std::get<2>(color), std::get<3>(color)); + dialog.set_rgba(gcolor); + } catch (std::out_of_range const&) { + fprintf(stderr, "Color %d is not available in settings, if this persists try resetting com/github/blackhole89/NoteKit/colors\n", number); + } + const int result = dialog.run(); switch(result) { case Gtk::RESPONSE_OK: { - Gdk::RGBA col = dialog.get_rgba(); - SetColor(number,col.get_red(),col.get_green(),col.get_blue()); - UpdateToolbarColors(); + // I do not like this solution, however I'm unaware of a better one. + GVariant* colors = g_settings_get_value(settings->gobj(), "colors"); + GVariantBuilder builder; + g_variant_builder_init(&builder, G_VARIANT_TYPE ("a(dddd)")); + for(unsigned int i=0;i<=g_variant_n_children(colors)-1;++i) { + if (i == number) { + Gdk::RGBA ncolor = dialog.get_rgba(); + g_variant_builder_add(&builder, "(dddd)", ncolor.get_red(), ncolor.get_green(), ncolor.get_blue(), ncolor.get_alpha()); + /* + * If the color that gets currently edited (this) is the actuve color, it should update the colors of the sourceview too. + * Otherwise the color of the button will change, but the pen will continue to draw the old color until the (still active) button is pressed. + */ + if (number == active_color) { + sview.active.r = ncolor.get_red(); + sview.active.g = ncolor.get_green(); + sview.active.b = ncolor.get_blue(); + sview.active.a = ncolor.get_alpha(); + } + } else { + g_variant_builder_add_value(&builder, g_variant_get_child_value(colors, i)); + } + } + GVariant *variant = g_variant_builder_end (&builder); + g_settings_set_value (settings->gobj(), "colors", variant); break; } default:; diff --git a/mainwindow.h b/mainwindow.h index a3cab01..50a35ce 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -5,8 +5,7 @@ #include -#include - +#include "about.h" #include "notebook.h" #include "navigation.h" @@ -14,7 +13,8 @@ enum { WND_ACTION_COLOR, WND_ACTION_NEXT_NOTE, WND_ACTION_PREV_NOTE, - WND_ACTION_TOGGLE_SIDEBAR + WND_ACTION_TOGGLE_SIDEBAR, + WND_ACTION_TOGGLE_ZEN }; class CMainWindow : public Gtk::ApplicationWindow @@ -31,19 +31,21 @@ class CMainWindow : public Gtk::ApplicationWindow void HardClose(); void FetchAndSave(); void OpenDocument(std::string filename); - void SetActiveFilename(std::string filename); + void SetupDocumentWindow(Glib::ustring filename); void FetchAndExport(); - + void FocusDocument(); - - void GetColor(int id, float &r, float &g, float &b); - void SetColor(int id, float r, float g, float b); + + typedef std::tuple color_t; protected: + /* low level window for csd check */ + GdkWindow* window; + //Signal handlers: bool on_close(GdkEventAny* any_event); void on_action(std::string name,int type, int param); - bool on_click_color(GdkEventButton *btn, int num); + bool on_click_color(GdkEventButton *btn, unsigned int num); bool on_motion_notify(GdkEventMotion* event); sigc::connection idle_timer; @@ -53,14 +55,16 @@ class CMainWindow : public Gtk::ApplicationWindow //Gtk::Box filler; /* config */ - std::string config_path; std::string default_base_path; std::string data_path; void CalculatePaths(); - Json::Value config; - void LoadConfig(); - void SaveConfig(); - void RunConfigWindow(); + void RunPreferenceDiag(); + + /* settings */ + Glib::RefPtr settings = Gio::Settings::create("com.github.blackhole89.NoteKit"); + void SettingChange(const Glib::ustring& key); + bool binit = true; + void UpdateBasePath(); /* tree view on the left */ Gtk::ScrolledWindow nav_scroll; @@ -79,27 +83,50 @@ class CMainWindow : public Gtk::ApplicationWindow Gtk::Toolbar *toolbar; void InitToolbar(); void UpdateToolbarColors(); + unsigned int active_color = 0; /* header */ - bool use_hbar; Gtk::HeaderBar hbar; Gtk::MenuButton appbutton; + Gtk::Button zenbtn; + bool zen = false; + + AboutDiag about; + void RunAboutDiag(); /* menu */ + bool navigation = true; + Glib::RefPtr export_action = add_action("export", sigc::mem_fun(this,&CMainWindow::FetchAndExport)); + Glib::RefPtr pref_action = add_action("pref", sigc::mem_fun(this,&CMainWindow::RunPreferenceDiag)); + Glib::RefPtr about_action = add_action("about", sigc::mem_fun(this,&CMainWindow::RunAboutDiag)); + Glib::RefPtr sidebar_action = add_action_bool("sidebar", sigc::bind( sigc::mem_fun(this,&CMainWindow::on_action), "toggle-sidebar", WND_ACTION_TOGGLE_SIDEBAR, 1), &navigation); + Glib::RefPtr zen_action = add_action_bool("zen", sigc::bind( sigc::mem_fun(this,&CMainWindow::on_action), "toggle-zen", WND_ACTION_TOGGLE_ZEN, 1), zen); + Glib::RefPtr menu = Gio::Menu::create(); Gtk::Menu appmenu; - struct { - Gtk::MenuItem prefs; - Gtk::SeparatorMenuItem sep; - Gtk::CheckMenuItem hide_sidebar; - Gtk::MenuItem exprt; - } am; /* classic menu */ struct { Gtk::VBox menu_box; Gtk::MenuBar mbar; - Gtk::MenuItem view; } cm; + + Gtk::FileChooserButton *dir; + + void SettingBasepathUpdate(); + void SettingDocumentUpdate(); + void SettingCsdUpdate(); + void SettingZenUpdate(); + void SettingSidebarUpdate(); + + typedef std::map> settingmap_t; + settingmap_t settingmap { + {"base-path", sigc::mem_fun(this,&CMainWindow::SettingBasepathUpdate)}, + {"active-document", sigc::mem_fun(this,&CMainWindow::SettingDocumentUpdate)}, + {"colors", sigc::mem_fun(this,&CMainWindow::UpdateToolbarColors)}, + {"csd", sigc::mem_fun(this,&CMainWindow::SettingCsdUpdate)}, + {"zen", sigc::mem_fun(this,&CMainWindow::SettingZenUpdate)}, + {"sidebar", sigc::mem_fun(this,&CMainWindow::SettingSidebarUpdate)} + }; }; -#endif // MAINWINDOW_H \ No newline at end of file +#endif // MAINWINDOW_H diff --git a/meson.build b/meson.build index 5a9f407..84689ae 100644 --- a/meson.build +++ b/meson.build @@ -1,20 +1,25 @@ project('notekit', 'cpp', - version : '0.1', + version : '0.1.0', default_options : ['warning_level=3', 'cpp_std=c++14'] ) conf_data = configuration_data() +if get_option('version') != '' + conf_data.set('version', get_option('version')) +else + conf_data.set('version', meson.project_version()) +endif deps = [ dependency('gtkmm-3.0'), dependency('gtksourceviewmm-3.0'), - dependency('jsoncpp'), dependency('zlib'), - dependency('fontconfig') + dependency('fontconfig'), + dependency('gdk-x11-3.0', required : false) ] if get_option('clatexmath') - deps += dependency('clatexmath', version: '>=0.0.3') + deps += dependency('clatexmath', version: '>=0.0.3', fallback: ['clatexmath', 'clatexmath_dep']) conf_data.set('HAVE_CLATEXMATH', true) endif @@ -28,11 +33,16 @@ subdir('freedesktop') install_subdir('data/', install_dir: get_option('datadir')/'notekit') install_subdir('sourceview/', install_dir: get_option('datadir')/'notekit') +install_data('gnome/com.github.blackhole89.notekit.gschema.xml', + install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas') +) + #if get_option('clatexmath') # meson.add_install_script('symlink-clatexmath.sh') #endif executable('notekit', + 'about.cpp', 'drawing.cpp', 'imagewidgets.cpp', 'main.cpp', @@ -42,3 +52,5 @@ executable('notekit', dependencies: deps, install : true ) + +meson.add_install_script('build-aux/postinstall.py') diff --git a/meson_options.txt b/meson_options.txt index b3860a0..0827803 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('clatexmath', type : 'boolean', value : true, description : 'Use cLaTeXMath') +option('version', type: 'string', description: 'Sets a custom version string, you\'ll most likely not need to do this.') diff --git a/navigation.cpp b/navigation.cpp index 112500e..ecdb7cc 100644 --- a/navigation.cpp +++ b/navigation.cpp @@ -334,6 +334,7 @@ void CNavigationView::AttachView(CMainWindow *w, Gtk::TreeView *view) //conns[0] = store->signal_row_changed().connect(sigc::mem_fun(*this,&CNavigationView::on_row_edit)); /* set up the sole column of the treeview */ + v->remove_all_columns(); v->append_column("Name",cols.name); Gtk::CellRendererText *cr = (Gtk::CellRendererText*)v->get_column_cell_renderer(0); v->get_column(0)->set_cell_data_func(*cr, sigc::mem_fun(this,&CNavigationView::on_render_cell)); @@ -349,6 +350,7 @@ void CNavigationView::AttachView(CMainWindow *w, Gtk::TreeView *view) conns[6] = v->signal_button_press_event().connect_notify(sigc::mem_fun(this,&CNavigationView::on_button_press_event),false); + store->clear(); /* expand root directory */ ExpandDirectory("",NULL); for(auto r : store->children()) { @@ -546,7 +548,7 @@ void CNavigationView::HandleRename(std::string oldname, std::string newname) { //printf("handlerename %s->%s: %s\n",oldname.c_str(),newname.c_str(),mainwindow->active_document.c_str() ); if(mainwindow->active_document == oldname) - mainwindow->SetActiveFilename(newname); + mainwindow->SetupDocumentWindow(newname); } /* Recursively update the full_path entries for all of a tree node's children to react to a directory having been renamed. diff --git a/pkgs/flatpak/com.github.blackhole89.notekit.yaml b/pkgs/flatpak/com.github.blackhole89.notekit.yaml index 779418e..bced2b3 100644 --- a/pkgs/flatpak/com.github.blackhole89.notekit.yaml +++ b/pkgs/flatpak/com.github.blackhole89.notekit.yaml @@ -8,14 +8,14 @@ finish-args: - --socket=fallback-x11 - --device=dri modules: - - name: jsoncpp + - name: tinyxml2 buildsystem: meson config-opts: - "-Dtests=false" sources: - - type: archive - url: https://github.com/open-source-parsers/jsoncpp/archive/1.9.4.tar.gz - sha256: 'e34a628a8142643b976c7233ef381457efad79468c67cb1ae0b83a33d7493999' + - type: git + url: git://github.com/leethomason/tinyxml2.git + commit: 4c7cc9d6e4fbc2ec6edfba1887118960ca5c4940 - name: mm-common buildsystem: meson @@ -109,7 +109,7 @@ modules: sources: - type: git url: https://github.com/NanoMichael/cLaTeXMath - commit: 580809b4c5177fa59a8a645987bbba105361b4a2 + commit: e482066d9aca23be5f2c4fc1aeefe773f3b10aa2 - name: notekit buildsystem: meson diff --git a/screenshots/notekit-syntax_highlighting.png b/screenshots/notekit-syntax_highlighting.png new file mode 100644 index 0000000..0fb6a10 Binary files /dev/null and b/screenshots/notekit-syntax_highlighting.png differ diff --git a/screenshots/notekit.png b/screenshots/notekit.png new file mode 100644 index 0000000..06be84a Binary files /dev/null and b/screenshots/notekit.png differ diff --git a/screenshots/notekit_dark-syntax_highlighting.png b/screenshots/notekit_dark-syntax_highlighting.png new file mode 100644 index 0000000..ab10fac Binary files /dev/null and b/screenshots/notekit_dark-syntax_highlighting.png differ diff --git a/screenshots/notekit_dark.png b/screenshots/notekit_dark.png new file mode 100644 index 0000000..34e019f Binary files /dev/null and b/screenshots/notekit_dark.png differ diff --git a/subprojects/clatexmath.wrap b/subprojects/clatexmath.wrap new file mode 100644 index 0000000..8f3ab2d --- /dev/null +++ b/subprojects/clatexmath.wrap @@ -0,0 +1,6 @@ +[wrap-git] +url = https://github.com/NanoMichael/cLaTeXMath.git +revision = head + +[provide] +dependency_names = clatexmath diff --git a/utils/notekit-migrate-gsettings b/utils/notekit-migrate-gsettings new file mode 100755 index 0000000..e33c1c1 --- /dev/null +++ b/utils/notekit-migrate-gsettings @@ -0,0 +1,11 @@ +#!/bin/sh + +CONFIG="${@:-$HOME/.config/notekit/config.json}" +[[ -z ${GLIB_SCHEMA_DIRECTORY} ]] || _NK_MGS_SCHEMADIR="--schemadir ${GLIB_SCHEMA_DIRECTORY} " + +set +u +gsettings ${_NK_MGS_SCHEMADIR}set com.github.blackhole89.NoteKit base-path "$(jq -r .base_path $CONFIG)" +gsettings ${_NK_MGS_SCHEMADIR}set com.github.blackhole89.NoteKit active-document "$(jq -r .active_document $CONFIG)" +gsettings ${_NK_MGS_SCHEMADIR}set com.github.blackhole89.NoteKit csd "$(jq -r .use_headerbar $CONFIG)" +gsettings ${_NK_MGS_SCHEMADIR}set com.github.blackhole89.NoteKit syntax-highlighting "$(jq -r .use_highlight_proxy $CONFIG)" +gsettings ${_NK_MGS_SCHEMADIR}set com.github.blackhole89.NoteKit colors "$(jq -r '[.colors | .[] | "(\(.r), \(.g), \(.b), 1.0)"]' $CONFIG | sed 's/"//g')" diff --git a/windows.patch b/windows.patch index fbb11de..8db6e98 100644 --- a/windows.patch +++ b/windows.patch @@ -1,23 +1,23 @@ -From d2e775b07fe181905caa9af3c7a0ffb83b8c368c Mon Sep 17 00:00:00 2001 -From: sp1rit -Date: Tue, 4 May 2021 21:58:31 +0200 +From 180b03a31b2709c32b8c14ba881abbcf744158cc Mon Sep 17 00:00:00 2001 +From: "Florian \"sp1rit\"" +Date: Fri, 21 May 2021 16:32:47 +0200 Subject: [PATCH] various changes that are required to build notekit with mingw -Signed-off-by: sp1rit +Signed-off-by: Florian "sp1rit --- - drawing.cpp | 6 +++--- + drawing.cpp | 4 ++-- imagewidgets.cpp | 4 ++-- main.cpp | 5 +++-- mainwindow.cpp | 3 ++- notebook_highlight.hpp | 4 ++-- - 5 files changed, 12 insertions(+), 10 deletions(-) + 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drawing.cpp b/drawing.cpp -index c4ee9f1..663198d 100644 +index c67acee..18a7ec0 100644 --- a/drawing.cpp +++ b/drawing.cpp -@@ -392,13 +392,13 @@ void CBoundDrawing::Unselect() { +@@ -396,13 +396,13 @@ void CBoundDrawing::Unselect() { void CBoundDrawing::on_unrealize() { @@ -33,13 +33,6 @@ index c4ee9f1..663198d 100644 strokes.~vector(); } -@@ -516,4 +516,4 @@ bool CStroke::Select(float x0, float x1, float y0, float y1) - void CStroke::Unselect() - { - selected.clear(); --} -\ No newline at end of file -+} diff --git a/imagewidgets.cpp b/imagewidgets.cpp index 1c52a6b..45012af 100644 --- a/imagewidgets.cpp @@ -60,7 +53,7 @@ index 1c52a6b..45012af 100644 void CImageWidget::SetSize(int x, int y) diff --git a/main.cpp b/main.cpp -index 1fc7c32..9bbec94 100644 +index 61d25dd..3a46ad7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,13 +1,14 @@ @@ -81,18 +74,18 @@ index 1fc7c32..9bbec94 100644 app->signal_activate().connect( [app,&mainwindow]() { mainwindow=new CMainWindow(app); diff --git a/mainwindow.cpp b/mainwindow.cpp -index af65f5a..4e43c49 100644 +index 050cbc7..0829df8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp -@@ -2,6 +2,7 @@ - #include "navigation.h" - #include - #include +@@ -5,6 +5,7 @@ + #include + + #include +#include #ifdef HAVE_CLATEXMATH #define __OS_Linux__ -@@ -396,7 +397,7 @@ void CMainWindow::FetchAndSave() +@@ -362,7 +363,7 @@ void CMainWindow::FetchAndSave() fclose(fl); /* atomic replace */ @@ -100,7 +93,7 @@ index af65f5a..4e43c49 100644 + MoveFileExA(tmp_filename.c_str(), filename.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH); } - void CMainWindow::OpenDocument(std::string filename) + void CMainWindow::FetchAndExport() diff --git a/notebook_highlight.hpp b/notebook_highlight.hpp index cf8569c..f1e846e 100644 --- a/notebook_highlight.hpp