Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ jobs:
binary=$(find dist -maxdepth 1 -type f -name '*.bin' -print -quit)
test -n "${binary}"
test -x "${binary}"
version=$(sed -n '/^\[workspace\.package\]$/,/^\[/ { s/^version = "\([^"]*\)"/\1/p; }' Cargo.toml)
reported_source=$("${binary}" --source | head -n 1)
test "${reported_source}" = \
"OneNote Viewer ${version} source revision: ${GITHUB_SHA}"
G_DEBUG=fatal-warnings \
GTK_A11Y=none \
GSK_RENDERER=cairo \
Expand All @@ -73,8 +77,13 @@ jobs:
run: |
version=$(sed -n '/^\[workspace\.package\]$/,/^\[/ { s/^version = "\([^"]*\)"/\1/p; }' Cargo.toml)
test -n "${version}"
mkdir -p target/flatpak
ONENOTE_VIEWER_SOURCE_REVISION="${GITHUB_SHA}" \
./scripts/source-revision.sh > target/flatpak/source-revision
revision=$(cat target/flatpak/source-revision)
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "bundle=OneNoteViewer-${version}-linux-x86_64.flatpak" >> "${GITHUB_OUTPUT}"
echo "revision=${revision}" >> "${GITHUB_OUTPUT}"

- name: Build Flatpak bundle
uses: flatpak/flatpak-github-actions/flatpak-builder@401fe28a8384095fc1531b9d320b292f0ee45adb
Expand All @@ -88,6 +97,7 @@ jobs:
- name: Verify bundled application and extractor
env:
BUNDLE: ${{ steps.release.outputs.bundle }}
REVISION: ${{ steps.release.outputs.revision }}
VERSION: ${{ steps.release.outputs.version }}
run: |
flatpak install --noninteractive "./${BUNDLE}"
Expand All @@ -97,6 +107,10 @@ jobs:
reported_version=$(flatpak run io.github.emsi.OneNoteViewer --version |
head -n 1)
test "${reported_version}" = "OneNote Viewer ${VERSION}"
reported_source=$(flatpak run io.github.emsi.OneNoteViewer --source |
head -n 1)
test "${reported_source}" = \
"OneNote Viewer ${VERSION} source revision: ${REVISION}"
flatpak run --command=7zz io.github.emsi.OneNoteViewer i |
grep 'Cab' >/dev/null
xvfb-run -a \
Expand Down Expand Up @@ -154,6 +168,11 @@ jobs:
test -n "${appimage}"
test -x "${appimage}"
APPIMAGE_EXTRACT_AND_RUN=1 "${appimage}" --version
reported_source=$(APPIMAGE_EXTRACT_AND_RUN=1 "${appimage}" --source |
head -n 1)
version=$(sed -n '/^\[workspace\.package\]$/,/^\[/ { s/^version = "\([^"]*\)"/\1/p; }' Cargo.toml)
test "${reported_source}" = \
"OneNote Viewer ${version} source revision: ${GITHUB_SHA}"
APPIMAGE_EXTRACT_AND_RUN=1 \
G_DEBUG=fatal-warnings \
GTK_A11Y=none \
Expand Down
15 changes: 15 additions & 0 deletions crates/onenote-viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ impl Viewer {
let open_folder = gio::SimpleAction::new("open-folder", None);
let import_package = gio::SimpleAction::new("import-package", None);
let open_settings = gio::SimpleAction::new("settings", None);
let show_about = gio::SimpleAction::new("about", None);
let quit = gio::SimpleAction::new("quit", None);
let close_source = icon_button("onenote-close-symbolic", "Close selected notebook");
let spinner = gtk::Spinner::new();
Expand All @@ -362,6 +363,9 @@ impl Viewer {
let preferences_menu = gio::Menu::new();
preferences_menu.append(Some("Settings"), Some("win.settings"));
application_menu.append_section(None, &preferences_menu);
let information_menu = gio::Menu::new();
information_menu.append(Some("About OneNote Viewer"), Some("win.about"));
application_menu.append_section(None, &information_menu);
let quit_menu = gio::Menu::new();
quit_menu.append(Some("Quit OneNote Viewer"), Some("win.quit"));
application_menu.append_section(None, &quit_menu);
Expand Down Expand Up @@ -606,6 +610,7 @@ impl Viewer {
viewer.window.add_action(&open_folder);
viewer.window.add_action(&import_package);
viewer.window.add_action(&open_settings);
viewer.window.add_action(&show_about);
viewer.window.add_action(&quit);
application.set_accels_for_action("win.open-file", &["<Primary>o"]);
application.set_accels_for_action("win.open-folder", &["<Primary><Shift>o"]);
Expand All @@ -620,6 +625,7 @@ impl Viewer {
&quit,
&close_source,
);
viewer.connect_about(&show_about);
viewer.connect_system_theme();
viewer.connect_import_activity();
viewer.connect_zoom(&zoom_out, &zoom_in, &zoom_reset);
Expand Down Expand Up @@ -727,6 +733,15 @@ impl Viewer {
});
}

fn connect_about(self: &Rc<Self>, show_about: &gio::SimpleAction) {
let weak = Rc::downgrade(self);
show_about.connect_activate(move |_, _| {
if let Some(viewer) = weak.upgrade() {
crate::dialogs::present_about(&viewer.window);
}
});
}

fn connect_system_theme(self: &Rc<Self>) {
let Some(settings) = gtk::Settings::default() else {
return;
Expand Down
24 changes: 24 additions & 0 deletions crates/onenote-viewer/src/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ use std::rc::Rc;

type ErrorHandler = Rc<dyn Fn(&str, &str)>;

pub(crate) fn present_about(parent_window: &gtk::ApplicationWindow) {
let system_information = format!(
"Version: {}\nSource revision: {}\nApplication ID: io.github.emsi.OneNoteViewer",
env!("CARGO_PKG_VERSION"),
crate::SOURCE_REVISION,
);
let dialog = gtk::AboutDialog::builder()
.transient_for(parent_window)
.modal(true)
.program_name("OneNote Viewer")
.version(env!("CARGO_PKG_VERSION"))
.comments("A native Linux viewer for local Microsoft OneNote notebooks.")
.copyright("Copyright (c) 2026 Mariusz Woloszyn")
.authors(["Mariusz Woloszyn"])
.license_type(gtk::License::Gpl30)
.logo_icon_name("io.github.emsi.OneNoteViewer")
.website("https://github.com/emsi/OneNoteViewer")
.website_label("Project website")
.system_information(system_information)
.build();
dialog.add_css_class("settings-dialog");
dialog.present();
}

#[allow(clippy::too_many_lines)]
pub(crate) fn present_package_import<F, E>(
parent_window: &gtk::ApplicationWindow,
Expand Down
7 changes: 6 additions & 1 deletion packaging/flatpak/io.github.emsi.OneNoteViewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ modules:
CARGO_NET_OFFLINE: 'true'
build-commands:
- install -Dm0644 cargo/config .cargo/config.toml
- cargo build --offline --frozen --release -p onenote-viewer
- >-
ONENOTE_VIEWER_SOURCE_REVISION="$(cat onenote-viewer-source-revision)"
cargo build --offline --frozen --release -p onenote-viewer
- install -Dm0755 target/release/onenote-viewer /app/bin/onenote-viewer
- install -Dm0644 packaging/flatpak/io.github.emsi.OneNoteViewer.desktop /app/share/applications/io.github.emsi.OneNoteViewer.desktop
- install -Dm0644 packaging/flatpak/io.github.emsi.OneNoteViewer.metainfo.xml /app/share/metainfo/io.github.emsi.OneNoteViewer.metainfo.xml
Expand All @@ -62,4 +64,7 @@ modules:
- onepkg
- target
- test-corpus
- type: file
path: ../../target/flatpak/source-revision
dest-filename: onenote-viewer-source-revision
- cargo-sources.json
6 changes: 4 additions & 2 deletions scripts/build-appimage-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -eu

root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
cd "$root"

for command in cargo curl file glib-compile-schemas install pkg-config sha256sum; do
Expand Down Expand Up @@ -30,6 +30,7 @@ if [ -z "$version" ]; then
printf '%s\n' 'could not determine workspace version' >&2
exit 1
fi
revision=$(./scripts/source-revision.sh)

linuxdeploy_url=https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20251107-1/linuxdeploy-x86_64.AppImage
linuxdeploy_sha256=c20cd71e3a4e3b80c3483cef793cda3f4e990aca14014d23c544ca3ce1270b4d
Expand Down Expand Up @@ -73,7 +74,8 @@ download_verified "$sevenzip_source_url" "$sevenzip_source" "$sevenzip_source_sh
chmod +x "$linuxdeploy" "$appimagetool"

cargo fetch --locked
cargo build --offline --frozen --locked --release -p onenote-viewer
ONENOTE_VIEWER_SOURCE_REVISION="$revision" \
cargo build --offline --frozen --locked --release -p onenote-viewer

rm -rf "$appdir"
mkdir -p \
Expand Down
7 changes: 5 additions & 2 deletions scripts/build-flatpak-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -eu

root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
cd "$root"

for command in flatpak flatpak-builder; do
Expand Down Expand Up @@ -41,6 +41,10 @@ manifest=packaging/flatpak/io.github.emsi.OneNoteViewer.yml
build_dir=target/flatpak/build
repo_dir=target/flatpak/repo
bundle="dist/OneNoteViewer-${version}-linux-${arch}.flatpak"
revision_file=target/flatpak/source-revision

mkdir -p "$(dirname "$revision_file")" dist
./scripts/source-revision.sh >"$revision_file"

flatpak remote-add \
--user \
Expand All @@ -56,7 +60,6 @@ flatpak-builder \
--repo="$repo_dir" \
"$build_dir" \
"$manifest"
mkdir -p dist
flatpak build-bundle \
"$repo_dir" \
"$bundle" \
Expand Down
7 changes: 4 additions & 3 deletions scripts/package-native-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -eu

root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
cd "$root"

case "$(uname -m)" in
Expand All @@ -28,10 +28,11 @@ if ! git diff --quiet || ! git diff --cached --quiet; then
'native releases require a committed source tree so the source archive matches the binary' >&2
exit 1
fi
revision=$(git rev-parse --verify HEAD)
revision=$(./scripts/source-revision.sh)

./scripts/check-licenses.sh
cargo build --locked --release -p onenote-viewer
ONENOTE_VIEWER_SOURCE_REVISION="$revision" \
cargo build --locked --release -p onenote-viewer

archive="OneNoteViewer-${version}-linux-${arch}.tar.gz"
executable="OneNoteViewer-${version}-linux-${arch}.bin"
Expand Down
32 changes: 32 additions & 0 deletions scripts/source-revision.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
set -eu

root=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
revision=${ONENOTE_VIEWER_SOURCE_REVISION:-}

if [ -z "$revision" ]; then
revision=$(git -C "$root" rev-parse --verify HEAD)
if ! git -C "$root" diff --quiet || ! git -C "$root" diff --cached --quiet; then
revision="${revision}-dirty"
fi
fi

case "$revision" in
*-dirty) object_id=${revision%-dirty} ;;
*) object_id=$revision ;;
esac
case "${#object_id}" in
40|64) ;;
*)
printf 'invalid source revision: %s\n' "$revision" >&2
exit 1
;;
esac
case "$object_id" in
''|*[!0-9a-f]*)
printf 'invalid source revision: %s\n' "$revision" >&2
exit 1
;;
esac

printf '%s\n' "$revision"
Loading