Skip to content

Commit 223fd98

Browse files
committed
init
0 parents  commit 223fd98

File tree

108 files changed

+24117
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+24117
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/build
2+
/_build
3+
/.flatpak
4+
/.flatpak-builder
5+
/flatpak-repo
6+
/flatpak-app
7+
/target
8+
Cargo.lock
9+
/.editorconfig
10+
/.vscode
11+
src/config.rs

Cargo.toml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "rnote"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
9+
[dependencies]
10+
rand = "0.8"
11+
serde = {version = "1.0", features = ["derive", "rc"]}
12+
serde_json = { version="1.0" }
13+
gtk4 = {version = "0.2"}
14+
adw = {version = "0.1.0-alpha-3", package="libadwaita"}
15+
cairo-rs = {version = "0.14", features = ["png", "svg"]}
16+
lazy_static ="1.4"
17+
once_cell = "1"
18+
base64 = "0.13"
19+
image = "0.23"
20+
tera = "1.12"
21+
librsvg = { git="https://gitlab.gnome.org/GNOME/librsvg" }
22+
log = "0.4"
23+
pretty_env_logger = "0.3"
24+
regex = "1.5"
25+
nalgebra = { version = "0.29", features = ["serde-serialize"] }
26+
parry2d-f64 = { version = "0.7", features = ["serde-serialize"] }

LICENSE

+674
Large diffs are not rendered by default.

README.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
2+
<div align="center">
3+
<img src="resources/icons/scalable/apps/app.svg" width="256"></img>
4+
</div>
5+
6+
# Rnote
7+
A simple note taking application written in Rust and GTK4.
8+
9+
My motivation for this project is to create a simple but functional note taking application for freehand drawing or annotating pictures or documents. It eventually should be able to import / export various media file formats.
10+
One main consideration is that it is vector based, which should make it very flexible in editing and altering the contents.
11+
12+
**Disclaimer**
13+
This is my first Rust and GTK project and I am learning as I go along. Expect bugs and crashes. It also could blow up your computer. ;)
14+
15+
## Feature Ideas:
16+
* Stroke history list widget
17+
* with the ability to move them up and down the history / layers
18+
* Stroke trash restorer
19+
* with a preview of the deleted strokes ( as gtk4::Textures )
20+
* Dual sheets (e.g. one for imported pdfs and one for extra notes)
21+
22+
## To-Do
23+
- [x] Switch geometry to [nalgebra](https://crates.io/crates/nalgebra) wherever possible. It can operate on f64 and has much more features than graphene.
24+
- [ ] Template deduplication when loading in .rnote save files.
25+
- [ ] PDF Import, Export and printing option
26+
- [ ] PNG Import, Export
27+
- [ ] Implement bezier curve stroke with variable stroke width (see this paper: [Quadratic bezier offsetting with selective subdivision](https://microbians.com/math/Gabriel_Suchowolski_Quadratic_bezier_offsetting_with_selective_subdivision.pdf))
28+
29+
## Screenshots
30+
Rnote is a very early WIP project, so don't expect too much. :)
31+
32+
![2021-08-10-rnote.jpg](./resources/screenshots/main-window.png)
33+
34+
### Building with Flatpak
35+
There is a flatpak manifest in `build-aux/com.github.felixzwettler.rnote.json`.
36+
37+
First the Gnome 40 SDK is needed:
38+
```
39+
flatpak install org.gnome.Sdk//40 org.freedesktop.Sdk.Extension.rust-stable//21.08 org.gnome.Platform//40
40+
```
41+
42+
**Build**
43+
Building the app with flatpak is done with:
44+
```
45+
flatpak-builder --user flatpak-app build-aux/com.github.felixzwettler.rnote.json
46+
```
47+
48+
**Run**
49+
Then it can be run.
50+
From the build directory:
51+
```
52+
flatpak-builder --run flatpak-app build-aux/com.github.felixzwettler.rnote.json rnote
53+
```
54+
55+
Or if it is installed:
56+
```
57+
flatpak run com.github.felixzwettler.rnote
58+
```
59+
60+
**Install**
61+
And installed to the system with:
62+
```
63+
flatpak-builder --user --install flatpak-app build-aux/com.github.felixzwettler.rnote.json
64+
```
65+
66+
### Build it yourself with Meson
67+
Make sure `rustc` and `cargo` are installed. Then run:
68+
69+
```
70+
meson setup --prefix=/usr _build
71+
```
72+
Meson will ask for the user password when needed.
73+
74+
To enable the development profile, set `-Dprofile=devel` as a parameter. Else the `default` profile will be set. ( This can be reconfigured later )
75+
76+
**Compile**
77+
Once the project is configured, it can be compiled with:
78+
79+
```
80+
meson compile -C _build
81+
```
82+
83+
The compiled binary should now be here: `./build/target/release/rnote`.
84+
85+
**Install**
86+
Installing the binary into the system can be done with:
87+
88+
```
89+
meson install -C _build
90+
```
91+
92+
**Test**
93+
Meson has some tests to validate the desktop, gresources, ... files.
94+
```
95+
meson test -v -C _build
96+
```
97+
98+
This places the files in the specified prefix and their subpaths. The binary should now be in `/usr/bin` (and therefore in PATH)
99+
100+
**Reconfigure**
101+
reconfiguring the meson build files can be done with:
102+
103+
```
104+
meson configure -Dprofile=default _build
105+
```
106+
107+
For example if the profile needs to be changed.
108+
109+
110+
**Uninstall**
111+
If you don't like rnote, or decided that is not worth your precious disk space, you can always uninstall it with:
112+
113+
```
114+
sudo ninja uninstall -C _build
115+
```

build-aux/cargo.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
export MESON_BUILD_ROOT="$1"
4+
export MESON_SOURCE_ROOT="$2"
5+
export OUTPUT="$3"
6+
export PROFILE="$4"
7+
export APP_BIN="$5"
8+
export CARGO_TARGET_DIR="$MESON_BUILD_ROOT"/target
9+
export CARGO_HOME="$CARGO_TARGET_DIR"/cargo-home
10+
11+
if [[ $4 = "Devel" ]]
12+
then
13+
echo -e "\nDEVEL PROFILE\n"
14+
15+
cargo build --manifest-path \
16+
"$MESON_SOURCE_ROOT"/Cargo.toml && \
17+
cp "$CARGO_TARGET_DIR"/debug/"$APP_BIN" "$OUTPUT"
18+
else
19+
echo -e "\nDEFAULT PROFILE\n"
20+
cargo build --manifest-path \
21+
"$MESON_SOURCE_ROOT"/Cargo.toml --release && \
22+
cp "$CARGO_TARGET_DIR"/release/"$APP_BIN" "$OUTPUT"
23+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"app-id": "com.github.felixzwettler.rnote",
3+
"runtime": "org.gnome.Platform",
4+
"runtime-version": "40",
5+
"sdk": "org.gnome.Sdk",
6+
"sdk-extensions": [
7+
"org.freedesktop.Sdk.Extension.rust-stable"
8+
],
9+
"command": "rnote",
10+
"finish-args": [
11+
"--socket=wayland",
12+
"--socket=fallback-x11",
13+
"--device=dri",
14+
"--share=ipc",
15+
"--talk-name=org.a11y.Bus",
16+
"--filesystem=home",
17+
"--env=RUST_LOG=rnote=debug",
18+
"--env=G_MESSAGES_DEBUG=all",
19+
"--env=RUST_BACKTRACE=1"
20+
],
21+
"build-options": {
22+
"append-path": "/usr/lib/sdk/rust-stable/bin",
23+
"build-args": [
24+
"--share=network"
25+
],
26+
"test-args": [
27+
"--socket=x11",
28+
"--share=network"
29+
]
30+
},
31+
"modules": [
32+
{
33+
"name": "libadwaita",
34+
"buildsystem": "meson",
35+
"builddir": true,
36+
"sources": [
37+
{
38+
"type": "git",
39+
"url": "https://gitlab.gnome.org/GNOME/libadwaita.git",
40+
"branch": "main"
41+
}
42+
]
43+
},
44+
{
45+
"name": "rnote",
46+
"buildsystem": "meson",
47+
"run-tests": true,
48+
"config-opts": [
49+
"-Dprofile=default"
50+
],
51+
"sources": [
52+
{
53+
"type": "dir",
54+
"path": "../"
55+
}
56+
]
57+
}
58+
]
59+
}

build-aux/dist-vendor.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
export DIST="$1"
3+
export SOURCE_ROOT="$2"
4+
5+
cd "$SOURCE_ROOT"
6+
mkdir "$DIST"/.cargo
7+
cargo vendor | sed 's/^directory = ".*"/directory = "vendor"/g' > $DIST/.cargo/config
8+
# Move vendor into dist tarball directory
9+
mv vendor "$DIST"
10+

build-aux/meson_post_install.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
from os import environ, path
4+
from subprocess import call
5+
6+
if not environ.get('DESTDIR', ''):
7+
PREFIX = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
8+
DATA_DIR = path.join(PREFIX, 'share')
9+
print('Updating icon cache...')
10+
call(['gtk-update-icon-cache', '-qtf', path.join(DATA_DIR, 'icons/hicolor')])
11+
print("Compiling new schemas...")
12+
call(["glib-compile-schemas", path.join(DATA_DIR, 'glib-2.0/schemas')])
13+
print("Updating desktop database...")
14+
call(["update-desktop-database", path.join(DATA_DIR, 'applications')])

meson.build

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
project(
2+
'rnote',
3+
'rust',
4+
version: '0.1.0',
5+
meson_version: '>= 0.56',
6+
)
7+
i18n = import('i18n')
8+
gnome = import('gnome')
9+
fs = import('fs')
10+
11+
app_name = meson.project_name()
12+
base_id = 'com.github.felixzwettler.rnote'
13+
base_idpath = '/com/github/felixzwettler/rnote/'
14+
15+
if get_option('profile') == 'devel'
16+
profile = 'Devel'
17+
version_suffix = '-devel'
18+
app_id = base_id + '.' + profile
19+
app_idpath = base_idpath + profile + '/'
20+
else
21+
profile = ''
22+
version_suffix = ''
23+
app_id = base_id
24+
app_idpath = base_idpath
25+
endif
26+
27+
version = meson.project_version()
28+
version_array = version.split('.')
29+
version_major = version_array[0].to_int()
30+
version_minor = version_array[1].to_int()
31+
version_micro = version_array[2].to_int()
32+
33+
prefix = get_option('prefix')
34+
bindir = prefix / get_option('bindir')
35+
localedir = prefix / get_option('localedir')
36+
datadir = prefix / get_option('datadir')
37+
pkgdatadir = datadir / app_id
38+
iconsdir = datadir / 'icons'
39+
podir = meson.project_source_root() / 'po'
40+
gettext_package = app_name
41+
42+
user_home_dir = fs.expanduser('~')
43+
44+
dependency('glib-2.0', version: '>= 2.66')
45+
dependency('gio-2.0', version: '>= 2.66')
46+
dependency('gtk4', version: '>= 4.0.0')
47+
dependency('libadwaita-1', version: '>= 1.0.0-alpha.1')
48+
49+
cargo = find_program('cargo', required: true)
50+
cargo_script = find_program('build-aux/cargo.sh')
51+
glib_compile_resources = find_program('glib-compile-resources', required: true)
52+
glib_compile_schemas = find_program('glib-compile-schemas', required: true)
53+
desktop_file_validate = find_program('desktop-file-validate', required: false)
54+
appstream_util = find_program('appstream-util', required: false)
55+
56+
meson.add_dist_script(
57+
'build-aux/dist-vendor.sh',
58+
meson.project_build_root() / 'meson-dist' / app_name + '-' + version,
59+
meson.project_source_root()
60+
)
61+
62+
cargo_sources= files(
63+
meson.project_source_root() + '/' + 'Cargo.toml',
64+
meson.project_source_root() + '/' + 'Cargo.lock',
65+
)
66+
67+
subdir('resources')
68+
subdir('src')
69+
70+
meson.add_install_script('build-aux/meson_post_install.py')

meson_options.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
option(
2+
'profile',
3+
type: 'combo',
4+
choices: [
5+
'default',
6+
'devel'
7+
],
8+
value: 'default',
9+
description: 'The build profile for rnote. One of "default" or "devel".'
10+
)

resources/app.desktop.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Desktop Entry]
2+
Name=Rnote
3+
Comment=A simple note taking application
4+
Icon=@APP_ID@
5+
#DBusActivatable=true
6+
Exec=@APP_NAME@ %f
7+
Terminal=false
8+
MimeType=image/svg+xml;image/png;
9+
Type=Application
10+
Categories=GNOME;GTK;Graphics;
11+
Keywords=Gnome;GTK;Office;Graphics;Notes;
12+
StartupNotify=true

0 commit comments

Comments
 (0)