Skip to content

Commit f544e10

Browse files
committed
gnome-papers 48.5 (new formula)
1 parent 0bba9b5 commit f544e10

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

Formula/g/gnome-papers.rb

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
class GnomePapers < Formula
2+
desc "Document viewer for PDF and other document formats aimed at the GNOME desktop"
3+
homepage "https://apps.gnome.org/Papers/"
4+
url "https://download.gnome.org/sources/papers/48/papers-48.5.tar.xz"
5+
sha256 "0cc8d72c71d3d8aab1be10ae1941a4cd92cd1e2a7e830ab7680e2c82dfb19c0b"
6+
license "GPL-2.0-or-later"
7+
8+
depends_on "desktop-file-utils" => :build
9+
depends_on "gobject-introspection" => :build
10+
depends_on "itstool" => :build
11+
depends_on "meson" => :build
12+
depends_on "ninja" => :build
13+
depends_on "pkgconf" => [:build, :test]
14+
depends_on "rust" => :build
15+
16+
depends_on "adwaita-icon-theme"
17+
depends_on "cairo"
18+
depends_on "djvulibre"
19+
depends_on "exempi"
20+
depends_on "gdk-pixbuf"
21+
depends_on "glib"
22+
depends_on "gtk4"
23+
depends_on "hicolor-icon-theme"
24+
depends_on "libadwaita"
25+
depends_on "libarchive"
26+
depends_on "libspelling"
27+
depends_on "libtiff"
28+
depends_on "poppler"
29+
30+
uses_from_macos "zlib"
31+
32+
on_macos do
33+
depends_on "gettext"
34+
end
35+
36+
on_linux do
37+
depends_on "gettext" => :build # for msgfmt
38+
end
39+
40+
def install
41+
ENV["DESTDIR"] = "/"
42+
43+
if OS.mac?
44+
# https://github.com/gettext-rs/gettext-rs/tree/master/gettext-sys#environment-variables
45+
ENV["GETTEXT_DIR"] = Formula["gettext"].prefix.to_s
46+
47+
ENV.append "RUSTFLAGS", "--codegen link-args=-Wl,-rpath,#{rpath}"
48+
end
49+
50+
# Export pps_job_run for testing. Remove this workaround in 49.x.
51+
inreplace "libview/pps-job.h", /^(gboolean pps_job_run)/, "PPS_PUBLIC \\1"
52+
53+
args = %w[
54+
-Dviewer=true
55+
-Dpreviewer=true
56+
-Dthumbnailer=true
57+
-Dnautilus=false
58+
-Dcomics=enabled
59+
-Ddjvu=enabled
60+
-Dpdf=enabled
61+
-Dtiff=enabled
62+
-Dtests=false
63+
-Ddocumentation=false
64+
-Duser_doc=false
65+
-Dintrospection=enabled
66+
-Dsysprof=disabled
67+
-Dkeyring=enabled
68+
-Dgtk_unix_print=enabled
69+
-Dspell_check=enabled
70+
]
71+
72+
system "meson", "setup", "build", *args, *std_meson_args
73+
system "meson", "compile", "-C", "build", "--verbose"
74+
system "meson", "install", "-C", "build"
75+
end
76+
77+
def post_install
78+
system Formula["glib"].opt_bin/"glib-compile-schemas", HOMEBREW_PREFIX/"share/glib-2.0/schemas"
79+
system Formula["gtk4"].opt_bin/"gtk4-update-icon-cache", "-f", "-t", HOMEBREW_PREFIX/"share/icons/hicolor"
80+
end
81+
82+
test do
83+
resource "test-pdf" do
84+
url "https://gitlab.freedesktop.org/poppler/test/-/raw/1aca8a13eeaa37403f9330febcb4745affcfd139/tests/text.pdf"
85+
sha256 "9fac4cf9ac688f067ee38ddddcf9f237d4f6adf29601672e4ef1765c63997880"
86+
end
87+
88+
resource("test-pdf").stage testpath
89+
(testpath/"test.c").write <<~C
90+
#include <glib.h>
91+
#define I_KNOW_THE_PAPERS_LIBS_ARE_UNSTABLE_AND_HAVE_TALKED_WITH_THE_AUTHORS
92+
#include <papers-document.h>
93+
#include <papers-view.h>
94+
95+
int main(void) {
96+
g_autoptr(GFile) file = NULL;
97+
g_autoptr(PpsJob) job = NULL;
98+
g_autoptr(PpsDocument) document = NULL;
99+
g_autoptr(PpsPage) page = NULL;
100+
g_autofree gchar *uri = NULL;
101+
const gchar *file_path = "text.pdf";
102+
gint n_pages;
103+
gboolean has_backend;
104+
105+
has_backend = pps_init();
106+
g_assert_true(has_backend);
107+
108+
file = g_file_new_for_path(file_path);
109+
g_assert_nonnull(file);
110+
111+
uri = g_file_get_uri(file);
112+
g_assert_nonnull(uri);
113+
114+
job = pps_job_load_new();
115+
g_assert_nonnull(job);
116+
117+
pps_job_load_set_uri(PPS_JOB_LOAD(job), uri);
118+
pps_job_run(job);
119+
120+
document = pps_job_load_get_loaded_document(PPS_JOB_LOAD(job));
121+
g_assert_nonnull(document);
122+
123+
n_pages = pps_document_get_n_pages(document);
124+
g_assert(n_pages == 1);
125+
126+
page = pps_document_get_page(document, 0);
127+
g_assert_nonnull(page);
128+
129+
pps_shutdown();
130+
131+
return 0;
132+
}
133+
C
134+
pkg_config_flags = shell_output("pkg-config --cflags --libs papers-document-4.0 papers-view-4.0").chomp.split
135+
system ENV.cc, "test.c", *pkg_config_flags
136+
system "./a.out"
137+
assert_match version.to_s, shell_output("#{bin}/papers --version")
138+
end
139+
end

0 commit comments

Comments
 (0)