all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#69377] [PATCH] gnu: Add sioyek.
@ 2024-02-25 10:12 dan
  2024-02-25 15:53 ` Hilton Chain via Guix-patches via
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: dan @ 2024-02-25 10:12 UTC (permalink / raw)
  To: 69377

* gnu/packages/pdf.scm (sioyek): New variable.

Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
---
 gnu/packages/pdf.scm | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 0d796f65bb..587c952e37 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2024 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1710,3 +1711,69 @@ (define-public weasyprint
 
 Keywords: html2pdf, htmltopdf")
     (license license:bsd-3)))
+
+(define-public sioyek
+  (package
+    (name "sioyek")
+    (version "2.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ahrm/sioyek.git")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
+       ;; XXX: Fix for mupdf-0.23.0+ <https://github.com/ahrm/sioyek/issues/804>.
+       (patches (list (origin
+                        (method url-fetch)
+                        (uri (string-append
+                              "https://git.alpinelinux.org/aports/plain/community"
+                              "/sioyek/mupdf-0.23.0.patch?id="
+                              "86e913eccf19b97a16f25d9b6cdf0f50232f1226"))
+                        (sha256 (base32
+                                 "0wddl7qznr7x9kmqjb05f9pag8m4w29bnnw8ghzsi1zz9ska2jmh")))))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'patch-lib-and-path
+                     (lambda _
+                       (substitute* "pdf_viewer_build_config.pro"
+                         (("-lmupdf-third")
+                          "")
+                         (("/share/sioyek")
+                          "/share")
+                         (("/etc/sioyek")
+                          "/etc"))
+                       (substitute* "pdf_viewer/main.cpp"
+                         (("/usr/share/sioyek")
+                          (string-append #$output "/share"))
+                         (("/etc/sioyek")
+                          (string-append #$output "/etc")))))
+                   (replace 'configure
+                     (lambda _
+                       (invoke "qmake"
+                               (string-append "PREFIX="
+                                              #$output))))
+                   (add-after 'install 'instal-man-page
+                     (lambda _
+                       (install-file "resources/sioyek.1"
+                                     (string-append #$output "/share/man/man1")))))))
+    (inputs (list freetype
+                  gumbo-parser
+                  harfbuzz
+                  jbig2dec
+                  libjpeg-turbo
+                  mujs
+                  mupdf
+                  openjpeg
+                  qt3d-5
+                  qtbase-5
+                  zlib))
+    (home-page "https://sioyek.info")
+    (synopsis
+     "A PDF viewer with a focus on technical books and research papers")
+    (description
+     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
+    (license license:gpl3+)))

base-commit: 1306beaf3f6c8ddded2a956f5863bc65aad78882
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#69377] [PATCH] gnu: Add sioyek.
  2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
@ 2024-02-25 15:53 ` Hilton Chain via Guix-patches via
  2024-02-25 18:08 ` [bug#69377] [PATCH v2] " dan
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Hilton Chain via Guix-patches via @ 2024-02-25 15:53 UTC (permalink / raw)
  To: dan; +Cc: 69377

Hi dan,

On Sun, 25 Feb 2024 18:12:32 +0800,
dan wrote:
>
> * gnu/packages/pdf.scm (sioyek): New variable.
>
> Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
> ---
>  gnu/packages/pdf.scm | 67 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
>
> diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
> index 0d796f65bb..587c952e37 100644
> --- a/gnu/packages/pdf.scm
> +++ b/gnu/packages/pdf.scm
> @@ -25,6 +25,7 @@
>  ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
>  ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
>  ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
> +;;; Copyright © 2024 dan <i@dan.games>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -1710,3 +1711,69 @@ (define-public weasyprint
>
>  Keywords: html2pdf, htmltopdf")
>      (license license:bsd-3)))
> +
> +(define-public sioyek
> +  (package
> +    (name "sioyek")
> +    (version "2.0.0")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/ahrm/sioyek.git")

Please remove the ‘.git’ suffix, in GitHub it's used for redirection.

> +             (commit (string-append "v" version))))
> +       (sha256
> +        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
> +       ;; XXX: Fix for mupdf-0.23.0+ <https://github.com/ahrm/sioyek/issues/804>.
> +       (patches (list (origin
> +                        (method url-fetch)
> +                        (uri (string-append
> +                              "https://git.alpinelinux.org/aports/plain/community"
> +                              "/sioyek/mupdf-0.23.0.patch?id="
> +                              "86e913eccf19b97a16f25d9b6cdf0f50232f1226"))
> +                        (sha256 (base32
> +                                 "0wddl7qznr7x9kmqjb05f9pag8m4w29bnnw8ghzsi1zz9ska2jmh")))))))

Please add the patch (with attribution) under gnu/packages/patches instead.

‘file-name’ field is missing, by the way.

> +    (build-system gnu-build-system)
> +    (arguments
> +     (list
> +      #:phases #~(modify-phases %standard-phases
> +                   (add-after 'unpack 'patch-lib-and-path
> +                     (lambda _
> +                       (substitute* "pdf_viewer_build_config.pro"
> +                         (("-lmupdf-third")
> +                          "")

Removing ‘-lmupdf-third’ can be added as a source snippet.

> +                         (("/share/sioyek")
> +                          "/share")
> +                         (("/etc/sioyek")
> +                          "/etc"))
> +                       (substitute* "pdf_viewer/main.cpp"
> +                         (("/usr/share/sioyek")
> +                          (string-append #$output "/share"))
> +                         (("/etc/sioyek")
> +                          (string-append #$output "/etc")))))

Please keep /etc/sioyek and /share/sioyek, think where files will be when
installed into a profile.

> +                   (replace 'configure
> +                     (lambda _
> +                       (invoke "qmake"
> +                               (string-append "PREFIX="
> +                                              #$output))))

This ‘PREFIX’ can be added to ‘#:configure-flags’.

> +                   (add-after 'install 'instal-man-page
> +                     (lambda _
> +                       (install-file "resources/sioyek.1"
> +                                     (string-append #$output "/share/man/man1")))))))
> +    (inputs (list freetype
> +                  gumbo-parser
> +                  harfbuzz
> +                  jbig2dec
> +                  libjpeg-turbo
> +                  mujs
> +                  mupdf
> +                  openjpeg
> +                  qt3d-5
> +                  qtbase-5
> +                  zlib))
> +    (home-page "https://sioyek.info")
> +    (synopsis
> +     "A PDF viewer with a focus on technical books and research papers")

Don't use an article at the beginning of synopsis.

> +    (description
> +     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
> +    (license license:gpl3+)))
>
> base-commit: 1306beaf3f6c8ddded2a956f5863bc65aad78882
> --
> 2.41.0

Otherwise LGTM, please send a revised patch.


Thanks




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug#69377] [PATCH v2] gnu: Add sioyek.
  2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
  2024-02-25 15:53 ` Hilton Chain via Guix-patches via
@ 2024-02-25 18:08 ` dan
  2024-02-25 18:27 ` dan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: dan @ 2024-02-25 18:08 UTC (permalink / raw)
  To: 69377; +Cc: hako

* gnu/packages/pdf.scm (sioyek): New variable.

Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
---
 gnu/packages/pdf.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 0d796f65bb..553642c170 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2024 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1710,3 +1711,58 @@ (define-public weasyprint
 
 Keywords: html2pdf, htmltopdf")
     (license license:bsd-3)))
+
+(define-public sioyek
+  (package
+    (name "sioyek")
+    (version "2.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ahrm/sioyek")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
+       (modules '((guix build utils)))
+       (snippet '(substitute* "pdf_viewer_build_config.pro"
+                   (("-lmupdf-third")
+                    "")))
+       ;; XXX: Fix for mupdf-0.23.0+ <https://github.com/ahrm/sioyek/issues/804>.
+       (patches (search-patches "sioyek-mupdf-0.23.0-fix-build.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:configure-flags #~(list (string-append "PREFIX="
+                                               #$output))
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'patch-paths
+                     (lambda _
+                       (substitute* "pdf_viewer/main.cpp"
+                         (("/usr/share")
+                          (string-append #$output "/share"))
+                         (("/etc")
+                          (string-append #$output "/etc")))))
+                   (replace 'configure
+                     (lambda* (#:key configure-flags #:allow-other-keys)
+                       (apply invoke "qmake" configure-flags)))
+                   (add-after 'install 'instal-man-page
+                     (lambda _
+                       (install-file "resources/sioyek.1"
+                                     (string-append #$output "/share/man/man1")))))))
+    (inputs (list freetype
+                  gumbo-parser
+                  harfbuzz
+                  jbig2dec
+                  libjpeg-turbo
+                  mujs
+                  mupdf
+                  openjpeg
+                  qt3d-5
+                  qtbase-5
+                  zlib))
+    (home-page "https://sioyek.info")
+    (synopsis "PDF viewer with a focus on technical books and research papers")
+    (description
+     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
+    (license license:gpl3+)))

base-commit: b25b94335a3ee8d68d2145da8e5ea0325ecea451
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#69377] [PATCH v2] gnu: Add sioyek.
  2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
  2024-02-25 15:53 ` Hilton Chain via Guix-patches via
  2024-02-25 18:08 ` [bug#69377] [PATCH v2] " dan
@ 2024-02-25 18:27 ` dan
  2024-02-25 18:31 ` [bug#69377] [PATCH v3] " dan
  2024-02-27 13:50 ` [bug#69377] [PATCH v4] " Hilton Chain via Guix-patches via
  4 siblings, 0 replies; 7+ messages in thread
From: dan @ 2024-02-25 18:27 UTC (permalink / raw)
  To: 69377; +Cc: hako

* gnu/packages/pdf.scm (sioyek): New variable.

Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
---
 .../sioyek-mupdf-0.23.0-fix-build.patch       | 73 +++++++++++++++++++
 gnu/packages/pdf.scm                          | 56 ++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch

diff --git a/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch b/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch
new file mode 100644
index 0000000000..4e0ee6de37
--- /dev/null
+++ b/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch
@@ -0,0 +1,73 @@
+diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp
+index f48d05e..0bc3855 100644
+--- a/pdf_viewer/document_view.cpp
++++ b/pdf_viewer/document_view.cpp
+@@ -1121,7 +1121,7 @@ std::vector<DocumentPos> DocumentView::find_line_definitions() {
+ 
+ 			std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
+ 			if (pdf_link.has_value()) {
+-				auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
++				auto parsed_uri = parse_uri(mupdf_context, current_document->doc, pdf_link.value().uri);
+ 				result.push_back({ parsed_uri.page - 1, parsed_uri.x, parsed_uri.y });
+ 				return result;
+ 			}
+diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
+index 19b568b..335a93f 100644
+--- a/pdf_viewer/main_widget.cpp
++++ b/pdf_viewer/main_widget.cpp
+@@ -170,7 +170,7 @@ void MainWidget::set_overview_position(int page, float offset) {
+ 
+ void MainWidget::set_overview_link(PdfLink link) {
+ 
+-    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+     if (page >= 1) {
+         set_overview_position(page - 1, offset_y);
+     }
+@@ -3178,7 +3178,7 @@ void MainWidget::handle_pending_text_command(std::wstring text) {
+ 					open_web_url(utf8_decode(selected_link->uri));
+                 }
+                 else{
+-					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
++					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, selected_link->uri);
+ 					long_jump_to_destination(page-1, offset_y);
+                 }
+             }
+@@ -3863,7 +3863,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
+ 		return;
+ 	}
+ 
+-	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+ 
+ 	// convert one indexed page to zero indexed page
+ 	page--;
+diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp
+index 22d4265..3150e66 100644
+--- a/pdf_viewer/utils.cpp
++++ b/pdf_viewer/utils.cpp
+@@ -116,8 +116,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
+ 	return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
+ }
+ 
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
+-	fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri) {
++	pdf_document* doc = pdf_document_from_fz_document(mupdf_context, fz_doc);
++	fz_link_dest dest = pdf_resolve_link_dest(mupdf_context, doc, uri.c_str());
+ 	return { dest.loc.page + 1, dest.x, dest.y };
+ }
+ 
+diff --git a/pdf_viewer/utils.h b/pdf_viewer/utils.h
+index 2a12211..643b030 100644
+--- a/pdf_viewer/utils.h
++++ b/pdf_viewer/utils.h
+@@ -55,7 +55,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
+ int mod(int a, int b);
+ bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
+ bool rects_intersect(fz_rect rect1, fz_rect rect2);
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri);
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);
+ 
+ template<typename T>
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 0d796f65bb..553642c170 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2024 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1710,3 +1711,58 @@ (define-public weasyprint
 
 Keywords: html2pdf, htmltopdf")
     (license license:bsd-3)))
+
+(define-public sioyek
+  (package
+    (name "sioyek")
+    (version "2.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ahrm/sioyek")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
+       (modules '((guix build utils)))
+       (snippet '(substitute* "pdf_viewer_build_config.pro"
+                   (("-lmupdf-third")
+                    "")))
+       ;; XXX: Fix for mupdf-0.23.0+ <https://github.com/ahrm/sioyek/issues/804>.
+       (patches (search-patches "sioyek-mupdf-0.23.0-fix-build.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:configure-flags #~(list (string-append "PREFIX="
+                                               #$output))
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'patch-paths
+                     (lambda _
+                       (substitute* "pdf_viewer/main.cpp"
+                         (("/usr/share")
+                          (string-append #$output "/share"))
+                         (("/etc")
+                          (string-append #$output "/etc")))))
+                   (replace 'configure
+                     (lambda* (#:key configure-flags #:allow-other-keys)
+                       (apply invoke "qmake" configure-flags)))
+                   (add-after 'install 'instal-man-page
+                     (lambda _
+                       (install-file "resources/sioyek.1"
+                                     (string-append #$output "/share/man/man1")))))))
+    (inputs (list freetype
+                  gumbo-parser
+                  harfbuzz
+                  jbig2dec
+                  libjpeg-turbo
+                  mujs
+                  mupdf
+                  openjpeg
+                  qt3d-5
+                  qtbase-5
+                  zlib))
+    (home-page "https://sioyek.info")
+    (synopsis "PDF viewer with a focus on technical books and research papers")
+    (description
+     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
+    (license license:gpl3+)))

base-commit: b25b94335a3ee8d68d2145da8e5ea0325ecea451
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#69377] [PATCH v3] gnu: Add sioyek.
  2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
                   ` (2 preceding siblings ...)
  2024-02-25 18:27 ` dan
@ 2024-02-25 18:31 ` dan
  2024-02-27 13:50 ` [bug#69377] [PATCH v4] " Hilton Chain via Guix-patches via
  4 siblings, 0 replies; 7+ messages in thread
From: dan @ 2024-02-25 18:31 UTC (permalink / raw)
  To: 69377

* gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch: New file.
* gnu/packages/pdf.scm (sioyek): New variable.

Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
---
 .../sioyek-mupdf-0.23.0-fix-build.patch       | 73 +++++++++++++++++++
 gnu/packages/pdf.scm                          | 56 ++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch

diff --git a/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch b/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch
new file mode 100644
index 0000000000..4e0ee6de37
--- /dev/null
+++ b/gnu/packages/patches/sioyek-mupdf-0.23.0-fix-build.patch
@@ -0,0 +1,73 @@
+diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp
+index f48d05e..0bc3855 100644
+--- a/pdf_viewer/document_view.cpp
++++ b/pdf_viewer/document_view.cpp
+@@ -1121,7 +1121,7 @@ std::vector<DocumentPos> DocumentView::find_line_definitions() {
+ 
+ 			std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
+ 			if (pdf_link.has_value()) {
+-				auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
++				auto parsed_uri = parse_uri(mupdf_context, current_document->doc, pdf_link.value().uri);
+ 				result.push_back({ parsed_uri.page - 1, parsed_uri.x, parsed_uri.y });
+ 				return result;
+ 			}
+diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
+index 19b568b..335a93f 100644
+--- a/pdf_viewer/main_widget.cpp
++++ b/pdf_viewer/main_widget.cpp
+@@ -170,7 +170,7 @@ void MainWidget::set_overview_position(int page, float offset) {
+ 
+ void MainWidget::set_overview_link(PdfLink link) {
+ 
+-    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+     if (page >= 1) {
+         set_overview_position(page - 1, offset_y);
+     }
+@@ -3178,7 +3178,7 @@ void MainWidget::handle_pending_text_command(std::wstring text) {
+ 					open_web_url(utf8_decode(selected_link->uri));
+                 }
+                 else{
+-					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
++					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, selected_link->uri);
+ 					long_jump_to_destination(page-1, offset_y);
+                 }
+             }
+@@ -3863,7 +3863,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
+ 		return;
+ 	}
+ 
+-	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+ 
+ 	// convert one indexed page to zero indexed page
+ 	page--;
+diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp
+index 22d4265..3150e66 100644
+--- a/pdf_viewer/utils.cpp
++++ b/pdf_viewer/utils.cpp
+@@ -116,8 +116,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
+ 	return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
+ }
+ 
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
+-	fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri) {
++	pdf_document* doc = pdf_document_from_fz_document(mupdf_context, fz_doc);
++	fz_link_dest dest = pdf_resolve_link_dest(mupdf_context, doc, uri.c_str());
+ 	return { dest.loc.page + 1, dest.x, dest.y };
+ }
+ 
+diff --git a/pdf_viewer/utils.h b/pdf_viewer/utils.h
+index 2a12211..643b030 100644
+--- a/pdf_viewer/utils.h
++++ b/pdf_viewer/utils.h
+@@ -55,7 +55,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
+ int mod(int a, int b);
+ bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
+ bool rects_intersect(fz_rect rect1, fz_rect rect2);
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri);
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);
+ 
+ template<typename T>
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 0d796f65bb..553642c170 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2024 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1710,3 +1711,58 @@ (define-public weasyprint
 
 Keywords: html2pdf, htmltopdf")
     (license license:bsd-3)))
+
+(define-public sioyek
+  (package
+    (name "sioyek")
+    (version "2.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ahrm/sioyek")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
+       (modules '((guix build utils)))
+       (snippet '(substitute* "pdf_viewer_build_config.pro"
+                   (("-lmupdf-third")
+                    "")))
+       ;; XXX: Fix for mupdf-0.23.0+ <https://github.com/ahrm/sioyek/issues/804>.
+       (patches (search-patches "sioyek-mupdf-0.23.0-fix-build.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:configure-flags #~(list (string-append "PREFIX="
+                                               #$output))
+      #:phases #~(modify-phases %standard-phases
+                   (add-after 'unpack 'patch-paths
+                     (lambda _
+                       (substitute* "pdf_viewer/main.cpp"
+                         (("/usr/share")
+                          (string-append #$output "/share"))
+                         (("/etc")
+                          (string-append #$output "/etc")))))
+                   (replace 'configure
+                     (lambda* (#:key configure-flags #:allow-other-keys)
+                       (apply invoke "qmake" configure-flags)))
+                   (add-after 'install 'instal-man-page
+                     (lambda _
+                       (install-file "resources/sioyek.1"
+                                     (string-append #$output "/share/man/man1")))))))
+    (inputs (list freetype
+                  gumbo-parser
+                  harfbuzz
+                  jbig2dec
+                  libjpeg-turbo
+                  mujs
+                  mupdf
+                  openjpeg
+                  qt3d-5
+                  qtbase-5
+                  zlib))
+    (home-page "https://sioyek.info")
+    (synopsis "PDF viewer with a focus on technical books and research papers")
+    (description
+     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
+    (license license:gpl3+)))

base-commit: b25b94335a3ee8d68d2145da8e5ea0325ecea451
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [bug#69377] [PATCH v4] gnu: Add sioyek.
  2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
                   ` (3 preceding siblings ...)
  2024-02-25 18:31 ` [bug#69377] [PATCH v3] " dan
@ 2024-02-27 13:50 ` Hilton Chain via Guix-patches via
  2024-03-09  3:20   ` bug#69377: " Hilton Chain via Guix-patches via
  4 siblings, 1 reply; 7+ messages in thread
From: Hilton Chain via Guix-patches via @ 2024-02-27 13:50 UTC (permalink / raw)
  To: 69377; +Cc: Hilton Chain, dan

From: dan <i@dan.games>

* gnu/packages/patches/sioyek-fix-build.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/pdf.scm (sioyek): New variable.

Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
Signed-off-by: Hilton Chain <hako@ultrarare.space>
---

Slightly adjusted, now wait for QA. :)

 gnu/local.mk                                |  1 +
 gnu/packages/patches/sioyek-fix-build.patch | 82 +++++++++++++++++++++
 gnu/packages/pdf.scm                        | 60 +++++++++++++++
 3 files changed, 143 insertions(+)
 create mode 100644 gnu/packages/patches/sioyek-fix-build.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 9997522fb5..323f686ef0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1831,6 +1831,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/sdl-pango-header-guard.patch		\
   %D%/packages/patches/sdl-pango-matrix_declarations.patch	\
   %D%/packages/patches/sdl-pango-sans-serif.patch		\
+  %D%/packages/patches/sioyek-fix-build.patch			\
   %D%/packages/patches/smalltalk-multiplication-overflow.patch	\
   %D%/packages/patches/sqlite-hurd.patch			\
   %D%/packages/patches/strace-readlink-tests.patch		\
diff --git a/gnu/packages/patches/sioyek-fix-build.patch b/gnu/packages/patches/sioyek-fix-build.patch
new file mode 100644
index 0000000000..87f19e353c
--- /dev/null
+++ b/gnu/packages/patches/sioyek-fix-build.patch
@@ -0,0 +1,82 @@
+Patch fetch from https://git.alpinelinux.org/aports/tree/community/sioyek/mupdf-0.23.0.patch
+
+From 86e913eccf19b97a16f25d9b6cdf0f50232f1226 Mon Sep 17 00:00:00 2001
+From: ptrcnull <git@ptrcnull.me>
+Date: Fri, 25 Aug 2023 22:44:26 +0200
+Subject: community/sioyek: fix build with mupdf-0.23.0
+
+---
+
+diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp
+index f48d05e..0bc3855 100644
+--- a/pdf_viewer/document_view.cpp
++++ b/pdf_viewer/document_view.cpp
+@@ -1121,7 +1121,7 @@ std::vector<DocumentPos> DocumentView::find_line_definitions() {
+
+ 			std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
+ 			if (pdf_link.has_value()) {
+-				auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
++				auto parsed_uri = parse_uri(mupdf_context, current_document->doc, pdf_link.value().uri);
+ 				result.push_back({ parsed_uri.page - 1, parsed_uri.x, parsed_uri.y });
+ 				return result;
+ 			}
+diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
+index 19b568b..335a93f 100644
+--- a/pdf_viewer/main_widget.cpp
++++ b/pdf_viewer/main_widget.cpp
+@@ -170,7 +170,7 @@ void MainWidget::set_overview_position(int page, float offset) {
+
+ void MainWidget::set_overview_link(PdfLink link) {
+
+-    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++    auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+     if (page >= 1) {
+         set_overview_position(page - 1, offset_y);
+     }
+@@ -3178,7 +3178,7 @@ void MainWidget::handle_pending_text_command(std::wstring text) {
+ 					open_web_url(utf8_decode(selected_link->uri));
+                 }
+                 else{
+-					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
++					auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, selected_link->uri);
+ 					long_jump_to_destination(page-1, offset_y);
+                 }
+             }
+@@ -3863,7 +3863,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
+ 		return;
+ 	}
+
+-	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++	auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+
+ 	// convert one indexed page to zero indexed page
+ 	page--;
+diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp
+index 22d4265..3150e66 100644
+--- a/pdf_viewer/utils.cpp
++++ b/pdf_viewer/utils.cpp
+@@ -116,8 +116,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
+ 	return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
+ }
+
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
+-	fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri) {
++	pdf_document* doc = pdf_document_from_fz_document(mupdf_context, fz_doc);
++	fz_link_dest dest = pdf_resolve_link_dest(mupdf_context, doc, uri.c_str());
+ 	return { dest.loc.page + 1, dest.x, dest.y };
+ }
+
+diff --git a/pdf_viewer/utils.h b/pdf_viewer/utils.h
+index 2a12211..643b030 100644
+--- a/pdf_viewer/utils.h
++++ b/pdf_viewer/utils.h
+@@ -55,7 +55,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
+ int mod(int a, int b);
+ bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
+ bool rects_intersect(fz_rect rect1, fz_rect rect2);
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri);
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);
+
+ template<typename T>
diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 0d796f65bb..f32403b954 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Paul A. Patience <paul@apatience.com>
 ;;; Copyright © 2022 Petr Hodina <phodina@protonmail.com>
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
+;;; Copyright © 2024 dan <i@dan.games>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1710,3 +1711,62 @@ (define-public weasyprint

 Keywords: html2pdf, htmltopdf")
     (license license:bsd-3)))
+
+(define-public sioyek
+  (package
+    (name "sioyek")
+    (version "2.0.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/ahrm/sioyek")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))
+       (modules '((guix build utils)))
+       ;; libmupdf-third.so no longer available since mupdf 1.18.0.
+       (snippet '(substitute* "pdf_viewer_build_config.pro"
+                   (("-lmupdf-third") "")))
+       ;; XXX: Fix build with mupdf-0.23.0+.
+       ;; See also: https://github.com/ahrm/sioyek/issues/804
+       (patches (search-patches "sioyek-fix-build.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:configure-flags
+      #~(list (string-append "PREFIX=" #$output))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'patch-paths
+            (lambda _
+              (substitute* "pdf_viewer/main.cpp"
+                (("/usr/share")
+                 (string-append #$output "/share"))
+                (("/etc")
+                 (string-append #$output "/etc")))))
+          (replace 'configure
+            (lambda* (#:key configure-flags #:allow-other-keys)
+              (apply invoke "qmake" configure-flags)))
+          (add-after 'install 'instal-man-page
+            (lambda _
+              (install-file "resources/sioyek.1"
+                            (string-append #$output "/share/man/man1")))))))
+    (inputs
+     (list freetype
+           gumbo-parser
+           harfbuzz
+           jbig2dec
+           libjpeg-turbo
+           mujs
+           mupdf
+           openjpeg
+           qt3d-5
+           qtbase-5
+           zlib))
+    (home-page "https://sioyek.info/")
+    (synopsis "PDF viewer with a focus on technical books and research papers")
+    (description
+     "Sioyek is a PDF viewer with a focus on textbooks and research papers.")
+    (license license:gpl3+)))

base-commit: 75bad75367fcf2c289fae3b40dbcc850f92177be
prerequisite-patch-id: c615f2b08070db6cbe847a2bdd5b7c0aae79789b
prerequisite-patch-id: fd7da036342f36a8c698f5c8975f9e48d3ade435
prerequisite-patch-id: a2c81c14423bb9858f33d7d26976e8eea61982b7
prerequisite-patch-id: e30fd25b1dc4aaaff76474153836cd48e8565eb9
prerequisite-patch-id: 1d070b26dc64ee2ec95f14c4f5fc23419f766810
prerequisite-patch-id: 03de992f0312d5f0ee3368ebc3c1fad7c955d095
prerequisite-patch-id: b330efe2b0713e30b766c3b84643df67eb1eae5d
prerequisite-patch-id: a233d53e8895d3f82af872fffb2e3858f44ceb23
prerequisite-patch-id: a2b6bd60bc05d7b5a75f15a06b1b614afd6a7033
prerequisite-patch-id: 9d60e5fdd3f1418caf15820650dd8c090c291c2b
--
2.41.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#69377: [PATCH v4] gnu: Add sioyek.
  2024-02-27 13:50 ` [bug#69377] [PATCH v4] " Hilton Chain via Guix-patches via
@ 2024-03-09  3:20   ` Hilton Chain via Guix-patches via
  0 siblings, 0 replies; 7+ messages in thread
From: Hilton Chain via Guix-patches via @ 2024-03-09  3:20 UTC (permalink / raw)
  To: dan; +Cc: 69377-done

Hi,

On Tue, 27 Feb 2024 21:50:04 +0800,
Hilton Chain wrote:
>
> From: dan <i@dan.games>
>
> * gnu/packages/patches/sioyek-fix-build.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/pdf.scm (sioyek): New variable.
>
> Change-Id: Id2708745bd7ef672b620b8e9c907126bdc5a1f55
> Signed-off-by: Hilton Chain <hako@ultrarare.space>
> ---
>
> Slightly adjusted, now wait for QA. :)
>
>  gnu/local.mk                                |  1 +
>  gnu/packages/patches/sioyek-fix-build.patch | 82 +++++++++++++++++++++
>  gnu/packages/pdf.scm                        | 60 +++++++++++++++
>  3 files changed, 143 insertions(+)
>  create mode 100644 gnu/packages/patches/sioyek-fix-build.patch


Applied as 52f9db6503b398bd2c9d73446c51ca99ee76fafe, thanks!




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-09  3:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-25 10:12 [bug#69377] [PATCH] gnu: Add sioyek dan
2024-02-25 15:53 ` Hilton Chain via Guix-patches via
2024-02-25 18:08 ` [bug#69377] [PATCH v2] " dan
2024-02-25 18:27 ` dan
2024-02-25 18:31 ` [bug#69377] [PATCH v3] " dan
2024-02-27 13:50 ` [bug#69377] [PATCH v4] " Hilton Chain via Guix-patches via
2024-03-09  3:20   ` bug#69377: " Hilton Chain via Guix-patches via

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.