From e87ed2a5b3fe9f0f0a3f761218e0e3efe976d1db Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 17 Mar 2018 18:42:55 +0100 Subject: [PATCH 01/23] Increase test timeout --- tests/meson.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index ccf96e3..90f8954 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -20,5 +20,7 @@ if check.found() c_args: defines + flags ) - test('tests', tests) + test('tests', tests, + timeout: 60*60 + ) endif From 6f1006468488d0af0f290b98b81a8d1133cf3fb9 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 10:35:12 +0100 Subject: [PATCH 02/23] Fix typo --- zathura/plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zathura/plugin.c b/zathura/plugin.c index 74efec4..52f8700 100644 --- a/zathura/plugin.c +++ b/zathura/plugin.c @@ -269,7 +269,7 @@ register_plugin(zathura_plugin_manager_t* plugin_manager, zathura_plugin_t* plug if (plugin_mapping_new(plugin_manager, type, plugin) == false) { girara_error("plugin: filetype already registered: %s", type); } else { - girara_debug("plugin: filetype mapping addded: %s", type); + girara_debug("plugin: filetype mapping added: %s", type); at_least_one = true; } ); From 309c83d4ec1b90c2b6455a9edaf97703c3676a90 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 17:14:22 +0100 Subject: [PATCH 03/23] Fix typos in comments --- zathura/database-sqlite.c | 2 +- zathura/render.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zathura/database-sqlite.c b/zathura/database-sqlite.c index 1c20bdf..45c0191 100644 --- a/zathura/database-sqlite.c +++ b/zathura/database-sqlite.c @@ -138,7 +138,7 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path) "vadj_ratio FLOAT," "PRIMARY KEY(file, id));"; - /* ceate jumplist table */ + /* create jumplist table */ static const char SQL_JUMPLIST_INIT[] = "CREATE TABLE IF NOT EXISTS jumplist (" "id INTEGER PRIMARY KEY AUTOINCREMENT," diff --git a/zathura/render.c b/zathura/render.c index e7ddc6c..2ba4aff 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -595,7 +595,7 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width, /* TODO: split handling of image handling off * Ideally we would create a mask surface for the location of the images and - * we would blit the the recolored and unmodified surfaces together to get the + * we would blit the recolored and unmodified surfaces together to get the * same effect. */ From dcd860ef6d2023339735dc76cb09594e63c2f290 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 17:27:07 +0100 Subject: [PATCH 04/23] Update German translation --- po/de.po | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/po/de.po b/po/de.po index ee02f1b..7148e28 100644 --- a/po/de.po +++ b/po/de.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-03-16 01:11+0100\n" -"PO-Revision-Date: 2018-03-16 01:11+0100\n" +"PO-Revision-Date: 2018-03-18 17:21+0100\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: German (http://www.transifex.com/pwmt/zathura/language/de/)\n" "Language: de\n" @@ -17,6 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.0.6\n" #: data/org.pwmt.zathura.appdata.xml.in:7 data/org.pwmt.zathura.desktop.in:5 msgid "Zathura" @@ -33,10 +34,14 @@ msgid "" "mainly focuses on keyboard interaction. Zathura makes it possible to " "completely view and navigate through documents without using a mouse." msgstr "" +"Zathura ist ein anpassbarer und funktionaler Dokumentenbetrachter. Er bietet " +"eine minimalistische und platzsparende Oberfläche und Verwendung ist auf " +"Tastaturinteraktionen fokussiert. Zathura ermöglicht es ein Dokument " +"gänzlich ohne der Verwendung einer Maus zu betrachten." #: data/org.pwmt.zathura.appdata.xml.in:21 msgid "SyncTeX forward and backward synchronization support." -msgstr "Unterstützung für SyncTeX-Synchronisation" +msgstr "Unterstützung für SyncTeX-Synchronisation." #: data/org.pwmt.zathura.appdata.xml.in:22 msgid "Quickmarks and bookmarks." From 3d4551b263a2c7d95d294261275521a41310fbd2 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 18:03:05 +0100 Subject: [PATCH 05/23] Check against DBL_EPSILON instead of 0 Also clean up some other bits of the recolor code. --- zathura/render.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/zathura/render.c b/zathura/render.c index 2ba4aff..9391c45 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -541,17 +541,17 @@ emit_completed_signal(void* data) Assumes that l is in the interval l1, l2 and corrects the value to force u=0 on l1 and l2 */ static double -colorumax(const double* h, double l, double l1, double l2) +colorumax(const double h[3], double l, double l1, double l2) { - if (h[0] == 0 && h[1] == 0 && h[2] == 0) { + if (fabs(h[0]) <= DBL_EPSILON && fabs(h[1]) <= DBL_EPSILON && fabs(h[2]) <= DBL_EPSILON) { return 0; } - const double lv = (l - l1)/(l2 - l1); /* Remap l to the whole interval 0,1 */ + const double lv = (l - l1) / (l2 - l1); /* Remap l to the whole interval [0,1] */ double u = 1000000; double v = u; for (int k = 0; k < 3; k++) { - if (h[k] > 0) { + if (h[k] > DBL_EPSILON) { const double uu = fabs((1-l)/h[k]); const double vv = fabs((1-lv)/h[k]); @@ -561,7 +561,7 @@ colorumax(const double* h, double l, double l1, double l2) if (vv < v) { v = vv; } - } else if (h[k] < 0) { + } else if (h[k] < -DBL_EPSILON) { const double uu = fabs(l/h[k]); const double vv = fabs(lv/h[k]); @@ -607,8 +607,9 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width, /* RGB weights for computing lightness. Must sum to one */ static const double a[] = {0.30, 0.59, 0.11}; -#define rgb1 priv->recolor.dark -#define rgb2 priv->recolor.light + const GdkRGBA rgb1 = priv->recolor.dark; + const GdkRGBA rgb2 = priv->recolor.light; + const double l1 = a[0]*rgb1.red + a[1]*rgb1.green + a[2]*rgb1.blue; const double l2 = a[0]*rgb2.red + a[1]*rgb2.green + a[2]*rgb2.blue; @@ -630,7 +631,7 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width, rectangles = girara_list_new(); if (rectangles == NULL) { found_images = false; - girara_warning("Failed to retrieve images.\n"); + girara_warning("Failed to retrieve images."); } if (found_images == true) { @@ -687,20 +688,17 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width, /* u is the maximum possible saturation for given h and l. s is a * rescaled saturation between 0 and 1 */ - double u = colorumax(h, l, 0, 1); - double s = 0; - if (u != 0) { - s = 1/u; - } + const double u = colorumax(h, l, 0, 1); + const double s = fabs(u) > DBL_EPSILON ? 1.0 / u : 0.0; /* Interpolates lightness between light and dark colors. white goes to * light, and black goes to dark. */ l = l * (l2 - l1) + l1; - u = colorumax(h, l, l1, l2); - data[2] = (unsigned char)round(255.*(l + s*u * h[0])); - data[1] = (unsigned char)round(255.*(l + s*u * h[1])); - data[0] = (unsigned char)round(255.*(l + s*u * h[2])); + const double su = s * colorumax(h, l, l1, l2); + data[2] = (unsigned char)round(255.*(l + su * h[0])); + data[1] = (unsigned char)round(255.*(l + su * h[1])); + data[0] = (unsigned char)round(255.*(l + su * h[2])); } else { /* linear interpolation between dark and light with color ligtness as * a parameter */ @@ -719,9 +717,6 @@ recolor(private_t* priv, zathura_page_t* page, unsigned int page_width, } cairo_surface_mark_dirty(surface); - -#undef rgb1 -#undef rgb2 } static bool From 9e76d3eb4e23f25e4536fe9ed70c162b0865d1ee Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 18:28:16 +0100 Subject: [PATCH 06/23] Use reasonable starting value --- zathura/render.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zathura/render.c b/zathura/render.c index 9391c45..20b988e 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -548,8 +548,8 @@ colorumax(const double h[3], double l, double l1, double l2) } const double lv = (l - l1) / (l2 - l1); /* Remap l to the whole interval [0,1] */ - double u = 1000000; - double v = u; + double u = DBL_MAX; + double v = DBL_MAX; for (int k = 0; k < 3; k++) { if (h[k] > DBL_EPSILON) { const double uu = fabs((1-l)/h[k]); From 02c30a7381f751f0a6ba3b166b00fcca7af577e5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 19:04:47 +0100 Subject: [PATCH 07/23] Simplify --- zathura/render.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/zathura/render.c b/zathura/render.c index 20b988e..f4b17c8 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -550,27 +550,13 @@ colorumax(const double h[3], double l, double l1, double l2) const double lv = (l - l1) / (l2 - l1); /* Remap l to the whole interval [0,1] */ double u = DBL_MAX; double v = DBL_MAX; - for (int k = 0; k < 3; k++) { + for (unsigned int k = 0; k < 3; ++k) { if (h[k] > DBL_EPSILON) { - const double uu = fabs((1-l)/h[k]); - const double vv = fabs((1-lv)/h[k]); - - if (uu < u) { - u = uu; - } - if (vv < v) { - v = vv; - } + u = fmin(fabs((1-l)/h[k]), u); + v = fmin(fabs((1-lv)/h[k]), v); } else if (h[k] < -DBL_EPSILON) { - const double uu = fabs(l/h[k]); - const double vv = fabs(lv/h[k]); - - if (uu < u) { - u = uu; - } - if (vv < v) { - v = vv; - } + u = fmin(fabs(l/h[k]), u); + v = fmin(fabs(lv/h[k]), v); } } @@ -742,7 +728,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render &page_height, &page_width, false); - zathura_device_factors_t device_factors = zathura_document_get_device_factors(document); + const zathura_device_factors_t device_factors = zathura_document_get_device_factors(document); page_width *= device_factors.x; page_height *= device_factors.y; From 63ef90697efaed3abcebe2c6970dfd4070f8a835 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 19:16:43 +0100 Subject: [PATCH 08/23] Fix typo in comment --- zathura/render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zathura/render.c b/zathura/render.c index f4b17c8..d0ad57e 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -873,7 +873,7 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data)) (priv_a->last_view_time > priv_b->last_view_time ? 1 : 0); } - /* sort aborted entries earlier so that the are thrown out of the queue */ + /* sort aborted entries earlier so that they are thrown out of the queue */ return job_a->aborted ? 1 : -1; } From 6976707376008549635d3130c7282975c55c139b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 19:21:26 +0100 Subject: [PATCH 09/23] Limit decimal part --- zathura/document.c | 2 +- zathura/render.c | 2 +- zathura/shortcuts.c | 12 ++++++------ zathura/synctex.c | 2 +- zathura/zathura.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zathura/document.c b/zathura/document.c index 46bd56e..8065763 100644 --- a/zathura/document.c +++ b/zathura/document.c @@ -549,7 +549,7 @@ zathura_document_set_device_factors(zathura_document_t* document, return; } if (fabs(x_factor) < DBL_EPSILON || fabs(y_factor) < DBL_EPSILON) { - girara_debug("Ignoring new device factors %f and %f: too small", + girara_debug("Ignoring new device factors %0.2f and %0.2f: too small", x_factor, y_factor); return; } diff --git a/zathura/render.c b/zathura/render.c index d0ad57e..9504ffb 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -847,7 +847,7 @@ render_all(zathura_t* zathura) const double width = zathura_page_get_width(page); page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true); - girara_debug("Queuing resize for page %u to %u x %u (%f x %f).", page_id, page_width, page_height, width, height); + girara_debug("Queuing resize for page %u to %u x %u (%0.2f x %0.2f).", page_id, page_width, page_height, width, height); GtkWidget* widget = zathura_page_get_widget(zathura, page); if (widget != NULL) { gtk_widget_set_size_request(widget, page_width, page_height); diff --git a/zathura/shortcuts.c b/zathura/shortcuts.c index f14a00b..ff3777d 100644 --- a/zathura/shortcuts.c +++ b/zathura/shortcuts.c @@ -1383,22 +1383,22 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* /* specify new zoom value */ if (argument->n == ZOOM_IN) { - girara_debug("Increasing zoom by %f.", zoom_step - 1.0); + girara_debug("Increasing zoom by %0.2f.", zoom_step - 1.0); zathura_document_set_zoom(zathura->document, old_zoom * zoom_step); } else if (argument->n == ZOOM_OUT) { - girara_debug("Decreasing zoom by %f.", zoom_step - 1.0); + girara_debug("Decreasing zoom by %0.2f.", zoom_step - 1.0); zathura_document_set_zoom(zathura->document, old_zoom / zoom_step); } else if (argument->n == ZOOM_SPECIFIC) { if (t == 0) { girara_debug("Setting zoom to 1."); zathura_document_set_zoom(zathura->document, 1.0); } else { - girara_debug("Setting zoom to %f.", t / 100.0); + girara_debug("Setting zoom to %0.2f.", t / 100.0); zathura_document_set_zoom(zathura->document, t / 100.0); } } else if (argument->n == ZOOM_SMOOTH) { const double dy = (event != NULL) ? event->y : 1.0; - girara_debug("Increasing zoom by %f.", zoom_step * dy - 1.0); + girara_debug("Increasing zoom by %0.2f.", zoom_step * dy - 1.0); zathura_document_set_zoom(zathura->document, old_zoom + zoom_step * dy); } else { girara_debug("Setting zoom to 1."); @@ -1411,11 +1411,11 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* const double new_zoom = zathura_document_get_zoom(zathura->document); if (fabs(new_zoom - old_zoom) <= DBL_EPSILON) { - girara_debug("New and old zoom level are too close: %f vs. %f, diff = %f", new_zoom, old_zoom, fabs(new_zoom - old_zoom)); + girara_debug("New and old zoom level are too close: %0.2f vs. %0.2f", new_zoom, old_zoom); return false; } - girara_debug("Re-rendering with new zoom level %f.", new_zoom); + girara_debug("Re-rendering with new zoom level %0.2f.", new_zoom); render_all(zathura); refresh_view(zathura); diff --git a/zathura/synctex.c b/zathura/synctex.c index a300c48..9274c29 100644 --- a/zathura/synctex.c +++ b/zathura/synctex.c @@ -314,7 +314,7 @@ synctex_highlight_rects(zathura_t* zathura, unsigned int page, } /* move to position */ - girara_debug("Jumping to page %u position (%f, %f).", page, pos_x, pos_y); + girara_debug("Jumping to page %u position (%0.2f, %0.2f).", page, pos_x, pos_y); zathura_jumplist_add(zathura); position_set(zathura, pos_x, pos_y); zathura_jumplist_add(zathura); diff --git a/zathura/zathura.c b/zathura/zathura.c index e40f369..1fb6163 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -194,7 +194,7 @@ zathura_update_view_ppi(zathura_t* zathura) double current_ppi = zathura_document_get_viewport_ppi(zathura->document); if (fabs(ppi - current_ppi) > DBL_EPSILON) { - girara_debug("monitor width: %d mm, pixels: %d, ppi: %f", width_mm, monitor_geom.width, ppi); + girara_debug("monitor width: %d mm, pixels: %d, ppi: %0.2f", width_mm, monitor_geom.width, ppi); zathura_document_set_viewport_ppi(zathura->document, ppi); render_all(zathura); refresh_view(zathura); From 6dc30dc68ba3132d05089ff9219f14d2f3c3aebf Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 18 Mar 2018 22:09:20 +0100 Subject: [PATCH 10/23] Acknowledge Jeremie Knuesel --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index b410917..6c817f6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -28,3 +28,4 @@ oblique Maxime Chéramy Alexander Shabalin Lingzhu Xiang +Jeremie Knuesel From 2446de2bc51d0eeed22351b6373ffcbd3d853422 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 3 Apr 2018 00:59:51 +0200 Subject: [PATCH 11/23] libm is only required on Linux --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 9dce1ae..df8b941 100644 --- a/meson.build +++ b/meson.build @@ -36,7 +36,7 @@ dbusinterfacesdir = join_paths(datadir, 'dbus-1', 'interfaces') plugindir = join_paths(get_option('libdir'), 'zathura') # required dependencies -libm = cc.find_library('libm') +libm = cc.find_library('libm', required: false) girara = dependency('girara-gtk3', version: '>=0.2.9') glib = dependency('glib-2.0', version: '>=2.50') gthread = dependency('gthread-2.0', version: '>=2.50') From 4223464db68529f9a2064ed760fb7746b3c0df6b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 11 Apr 2018 11:22:21 -0400 Subject: [PATCH 12/23] Depend on gio-unix-2.0 if not on Windows --- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index df8b941..63246e8 100644 --- a/meson.build +++ b/meson.build @@ -39,12 +39,13 @@ plugindir = join_paths(get_option('libdir'), 'zathura') libm = cc.find_library('libm', required: false) girara = dependency('girara-gtk3', version: '>=0.2.9') glib = dependency('glib-2.0', version: '>=2.50') +gio = dependency('gio-unix-2.0', required: host_machine.system() != 'windows') gthread = dependency('gthread-2.0', version: '>=2.50') gmodule = dependency('gmodule-no-export-2.0', version: '>=2.50') gtk3 = dependency('gtk+-3.0', version: '>=3.22') cairo = dependency('cairo') -build_dependencies = [libm, girara, glib, gthread, gmodule, gtk3, cairo] +build_dependencies = [libm, girara, glib, gio, gthread, gmodule, gtk3, cairo] # defines defines = [ From cb1cab71c83893568f40ef9e2707c5c69618980d Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 11 Apr 2018 13:10:42 -0400 Subject: [PATCH 13/23] Make some variables const --- zathura/zathura.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zathura/zathura.c b/zathura/zathura.c index 1fb6163..e6a67ab 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -163,7 +163,7 @@ zathura_update_view_ppi(zathura_t* zathura) } /* physical width of monitor */ - int width_mm = gdk_monitor_get_width_mm(monitor); + const int width_mm = gdk_monitor_get_width_mm(monitor); /* size of monitor in pixels */ GdkRectangle monitor_geom; @@ -184,7 +184,7 @@ zathura_update_view_ppi(zathura_t* zathura) { /* not using the cached value for the scale factor here to avoid issues * if this function is called before the cached value is updated */ - int device_factor = gtk_widget_get_scale_factor(zathura->ui.session->gtk.view); + const int device_factor = gtk_widget_get_scale_factor(zathura->ui.session->gtk.view); girara_debug("on Wayland, correcting PPI for device scale factor = %d", device_factor); if (device_factor != 0) { ppi /= device_factor; @@ -192,7 +192,7 @@ zathura_update_view_ppi(zathura_t* zathura) } #endif - double current_ppi = zathura_document_get_viewport_ppi(zathura->document); + const double current_ppi = zathura_document_get_viewport_ppi(zathura->document); if (fabs(ppi - current_ppi) > DBL_EPSILON) { girara_debug("monitor width: %d mm, pixels: %d, ppi: %0.2f", width_mm, monitor_geom.width, ppi); zathura_document_set_viewport_ppi(zathura->document, ppi); From 6d99a74d1aaa0cbcb19d9ecbff50c536f5072764 Mon Sep 17 00:00:00 2001 From: valoq Date: Sat, 24 Mar 2018 16:56:19 +0100 Subject: [PATCH 14/23] add missing syscall --- zathura/seccomp-filters.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zathura/seccomp-filters.c b/zathura/seccomp-filters.c index 1c49b71..53f86a2 100644 --- a/zathura/seccomp-filters.c +++ b/zathura/seccomp-filters.c @@ -155,6 +155,7 @@ seccomp_enable_strict_filter(void) ALLOW_RULE(getresgid); ALLOW_RULE(getresuid); ALLOW_RULE(getrlimit); + ALLOW_RULE(getpeername); /* ALLOW_RULE (getsockname); */ /* ALLOW_RULE (getsockopt); needed for access to x11 socket in network namespace (without abstract sockets) */ ALLOW_RULE(inotify_add_watch); From acf9a3bcc160492d389e77ac8a74a43aa0151503 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 5 Apr 2018 20:58:45 +0200 Subject: [PATCH 15/23] Fix typos --- zathura/database-plain.h | 2 +- zathura/database-sqlite.h | 2 +- zathura/database.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zathura/database-plain.h b/zathura/database-plain.h index a03f6ee..2dca276 100644 --- a/zathura/database-plain.h +++ b/zathura/database-plain.h @@ -6,7 +6,7 @@ #include "database.h" #define ZATHURA_TYPE_PLAINDATABASE \ - (zathura_plaindatabase_get_type ()) + (zathura_plaindatabase_get_type()) #define ZATHURA_PLAINDATABASE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_PLAINDATABASE, ZathuraPlainDatabase)) #define ZATHURA_IS_PLAINDATABASE(obj) \ diff --git a/zathura/database-sqlite.h b/zathura/database-sqlite.h index 88f8022..5095df9 100644 --- a/zathura/database-sqlite.h +++ b/zathura/database-sqlite.h @@ -6,7 +6,7 @@ #include "database.h" #define ZATHURA_TYPE_SQLDATABASE \ - (zathura_sqldatabase_get_type ()) + (zathura_sqldatabase_get_type()) #define ZATHURA_SQLDATABASE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_SQLDATABASE, ZathuraSQLDatabase)) #define ZATHURA_IS_SQLDATABASE(obj) \ diff --git a/zathura/database.h b/zathura/database.h index f4698d1..66df46f 100644 --- a/zathura/database.h +++ b/zathura/database.h @@ -21,7 +21,7 @@ typedef struct zathura_fileinfo_s { } zathura_fileinfo_t; #define ZATHURA_TYPE_DATABASE \ - (zathura_database_get_type ()) + (zathura_database_get_type()) #define ZATHURA_DATABASE(obj) \ (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_DATABASE, ZathuraDatabase)) #define ZATHURA_IS_DATABASE(obj) \ From c97d83f6cee24dc2afc607eef6210b1274048c8a Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 21 Apr 2018 13:11:10 +0200 Subject: [PATCH 16/23] Port to newer libsynctex --- meson.build | 3 +++ zathura/synctex.c | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 63246e8..1862fa0 100644 --- a/meson.build +++ b/meson.build @@ -82,6 +82,9 @@ endif if get_option('enable-synctex') and synctex.found() build_dependencies += synctex defines += '-DWITH_SYNCTEX' + if synctex.version() < '2.0.0' + defines += '-DWITH_SYNCTEX1' + endif endif if get_option('enable-magic') and magic.found() diff --git a/zathura/synctex.c b/zathura/synctex.c index 9274c29..9a46b09 100644 --- a/zathura/synctex.c +++ b/zathura/synctex.c @@ -16,6 +16,14 @@ #include "adjustment.h" #ifdef WITH_SYNCTEX +#ifdef WITH_SYNCTEX1 +typedef synctex_scanner_t synctex_scanner_p; +typedef synctex_node_t synctex_node_p; + +#define synctex_scanner_next_result(scanner) synctex_next_result(scanner) +#define synctex_display_query(scanner, file, line, column, page) synctex_display_query(scanner, file, line, column) +#endif + bool synctex_get_input_line_column(const char* filename, unsigned int page, int x, int y, char** input_file, unsigned int* line, unsigned int* column) @@ -24,13 +32,13 @@ synctex_get_input_line_column(const char* filename, unsigned int page, int x, in return false; } - synctex_scanner_t scanner = synctex_scanner_new_with_output_file(filename, NULL, 1); + synctex_scanner_p scanner = synctex_scanner_new_with_output_file(filename, NULL, 1); if (scanner == NULL) { girara_debug("Failed to create synctex scanner."); return false; } - synctex_scanner_t temp = synctex_scanner_parse(scanner); + synctex_scanner_p temp = synctex_scanner_parse(scanner); if (temp == NULL) { girara_debug("Failed to parse synctex file."); synctex_scanner_free(scanner); @@ -41,7 +49,7 @@ synctex_get_input_line_column(const char* filename, unsigned int page, int x, in if (synctex_edit_query(scanner, page + 1u, x, y) > 0) { /* Assume that a backward search returns at most one result. */ - synctex_node_t node = synctex_next_result(scanner); + synctex_node_p node = synctex_scanner_next_result(scanner); if (node != NULL) { if (input_file != NULL) { *input_file = g_strdup(synctex_scanner_get_name(scanner, synctex_node_tag(node))); @@ -127,13 +135,13 @@ synctex_rectangles_from_position(const char* filename, const char* input_file, ++line; ++column; - synctex_scanner_t scanner = synctex_scanner_new_with_output_file(filename, NULL, 1); + synctex_scanner_p scanner = synctex_scanner_new_with_output_file(filename, NULL, 1); if (scanner == NULL) { girara_debug("Failed to create synctex scanner."); return NULL; } - synctex_scanner_t temp = synctex_scanner_parse(scanner); + synctex_scanner_p temp = synctex_scanner_parse(scanner); if (temp == NULL) { girara_debug("Failed to parse synctex file."); synctex_scanner_free(scanner); @@ -143,11 +151,11 @@ synctex_rectangles_from_position(const char* filename, const char* input_file, girara_list_t* hitlist = girara_list_new2(g_free); girara_list_t* other_rects = girara_list_new2(g_free); - if (synctex_display_query(scanner, input_file, line, column) > 0) { - synctex_node_t node = NULL; + if (synctex_display_query(scanner, input_file, line, column, -1) > 0) { + synctex_node_p node = NULL; bool got_page = false; - while ((node = synctex_next_result (scanner)) != NULL) { + while ((node = synctex_scanner_next_result(scanner)) != NULL) { const unsigned int current_page = synctex_node_page(node) - 1; if (got_page == false) { got_page = true; From d1c326319df638d2ad8681aa364e25dbf7ad4a58 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Apr 2018 15:13:51 +0200 Subject: [PATCH 17/23] Fix icon install path --- data/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/meson.build b/data/meson.build index d56e693..a1d2cff 100644 --- a/data/meson.build +++ b/data/meson.build @@ -7,7 +7,7 @@ zathura_resources = gnome.compile_resources( ) install_data('org.pwmt.zathura.xml', install_dir: dbusinterfacesdir) -install_data('org.pwmt.zathura.png', install_dir: join_paths(datadir, 'icons', 'hicolor', '128x128')) +install_data('org.pwmt.zathura.png', install_dir: join_paths(datadir, 'icons', 'hicolor', '128x128', 'apps')) i18n = import('i18n') podir = join_paths(meson.source_root(), 'po') From 4c976e9455ea89c2ac47a8765aa941cc95e28e06 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Apr 2018 15:20:00 +0200 Subject: [PATCH 18/23] Fix man page formatting --- doc/man/zathurarc.5.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index 5b78644..181f7a3 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -324,6 +324,8 @@ Pass arguments Some shortcut function require or have optional arguments which influence the behaviour of them. Those can be passed as the last argument: +:: + map zoom in map zoom out From 68222109f50c249c0e3e4ec9f58c30fc63d281b0 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 26 Apr 2018 16:52:50 +0200 Subject: [PATCH 19/23] Pass parent window to gtk_print_operation_run (fixes #726) --- zathura/print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zathura/print.c b/zathura/print.c index df6087b..7ee7f1f 100644 --- a/zathura/print.c +++ b/zathura/print.c @@ -58,7 +58,7 @@ print(zathura_t* zathura) GError* error = NULL; GtkPrintOperationResult result = gtk_print_operation_run(print_operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, - NULL, &error); + GTK_WINDOW(zathura->ui.session->gtk.window), &error); if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"), From 3a68be9a9b3d0d2094b8d3537ce9bdacb1ae5624 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 26 Apr 2018 16:53:10 +0200 Subject: [PATCH 20/23] Correctly store print settings --- zathura/print.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/zathura/print.c b/zathura/print.c index 7ee7f1f..2dbb824 100644 --- a/zathura/print.c +++ b/zathura/print.c @@ -52,7 +52,6 @@ print(zathura_t* zathura) g_signal_connect(print_operation, "draw-page", G_CALLBACK(cb_print_draw_page), zathura); g_signal_connect(print_operation, "end-print", G_CALLBACK(cb_print_end), zathura); g_signal_connect(print_operation, "request-page-setup", G_CALLBACK(cb_print_request_page_setup), zathura); - g_signal_connect(print_operation, "done", G_CALLBACK(cb_print_done), zathura); /* print */ GError* error = NULL; @@ -64,6 +63,13 @@ print(zathura_t* zathura) girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"), error->message); g_error_free(error); + } else if (result == GTK_PRINT_OPERATION_RESULT_APPLY) { + g_clear_object(&zathura->print.settings); + g_clear_object(&zathura->print.page_setup); + + /* save previous settings */ + zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation)); + zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation)); } g_object_unref(print_operation); @@ -209,24 +215,3 @@ cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation), gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_PORTRAIT); } } - -static void -cb_print_done(GtkPrintOperation* operation, GtkPrintOperationResult result, - zathura_t* zathura) -{ - if (result == GTK_PRINT_OPERATION_RESULT_APPLY) { - g_clear_object(&zathura->print.settings); - g_clear_object(&zathura->print.page_setup); - - /* save previous settings */ - zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(operation)); - zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(operation)); - } else if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { - GError* error = NULL; - gtk_print_operation_get_error(operation, &error); - girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"), - error->message); - g_error_free(error); - } -} - From a8cb8d396b0bdc7ae7ba2061b49aad59a4dd9cc3 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 26 Apr 2018 17:05:47 +0200 Subject: [PATCH 21/23] Remove forward declarations --- zathura/print.c | 118 ++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 65 deletions(-) diff --git a/zathura/print.c b/zathura/print.c index 2dbb824..cb3ffe9 100644 --- a/zathura/print.c +++ b/zathura/print.c @@ -10,71 +10,6 @@ #include #include -static void cb_print_draw_page(GtkPrintOperation* print_operation, - GtkPrintContext* context, gint page_number, - zathura_t* zathura); -static void cb_print_end(GtkPrintOperation* print_operation, GtkPrintContext* - context, zathura_t* zathura); -static void cb_print_request_page_setup(GtkPrintOperation* print_operation, - GtkPrintContext* context, - gint page_number, GtkPageSetup* setup, - zathura_t* zathura); -static void cb_print_done(GtkPrintOperation* operation, - GtkPrintOperationResult result, zathura_t* zathura); - -void -print(zathura_t* zathura) -{ - g_return_if_fail(zathura != NULL); - g_return_if_fail(zathura->document != NULL); - - GtkPrintOperation* print_operation = gtk_print_operation_new(); - - /* print operation settings */ - gtk_print_operation_set_job_name(print_operation, zathura_document_get_path(zathura->document)); - gtk_print_operation_set_allow_async(print_operation, TRUE); - gtk_print_operation_set_n_pages(print_operation, zathura_document_get_number_of_pages(zathura->document)); - gtk_print_operation_set_current_page(print_operation, zathura_document_get_current_page_number(zathura->document)); - gtk_print_operation_set_use_full_page(print_operation, TRUE); - - if (zathura->print.settings != NULL) { - gtk_print_operation_set_print_settings(print_operation, - zathura->print.settings); - } - - if (zathura->print.page_setup != NULL) { - gtk_print_operation_set_default_page_setup(print_operation, - zathura->print.page_setup); - } - gtk_print_operation_set_embed_page_setup(print_operation, TRUE); - - /* print operation signals */ - g_signal_connect(print_operation, "draw-page", G_CALLBACK(cb_print_draw_page), zathura); - g_signal_connect(print_operation, "end-print", G_CALLBACK(cb_print_end), zathura); - g_signal_connect(print_operation, "request-page-setup", G_CALLBACK(cb_print_request_page_setup), zathura); - - /* print */ - GError* error = NULL; - GtkPrintOperationResult result = gtk_print_operation_run(print_operation, - GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, - GTK_WINDOW(zathura->ui.session->gtk.window), &error); - - if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { - girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"), - error->message); - g_error_free(error); - } else if (result == GTK_PRINT_OPERATION_RESULT_APPLY) { - g_clear_object(&zathura->print.settings); - g_clear_object(&zathura->print.page_setup); - - /* save previous settings */ - zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation)); - zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation)); - } - - g_object_unref(print_operation); -} - static void cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext* UNUSED(context), zathura_t* zathura) @@ -215,3 +150,56 @@ cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation), gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_PORTRAIT); } } + +void +print(zathura_t* zathura) +{ + g_return_if_fail(zathura != NULL); + g_return_if_fail(zathura->document != NULL); + + GtkPrintOperation* print_operation = gtk_print_operation_new(); + + /* print operation settings */ + gtk_print_operation_set_job_name(print_operation, zathura_document_get_path(zathura->document)); + gtk_print_operation_set_allow_async(print_operation, TRUE); + gtk_print_operation_set_n_pages(print_operation, zathura_document_get_number_of_pages(zathura->document)); + gtk_print_operation_set_current_page(print_operation, zathura_document_get_current_page_number(zathura->document)); + gtk_print_operation_set_use_full_page(print_operation, TRUE); + + if (zathura->print.settings != NULL) { + gtk_print_operation_set_print_settings(print_operation, + zathura->print.settings); + } + + if (zathura->print.page_setup != NULL) { + gtk_print_operation_set_default_page_setup(print_operation, + zathura->print.page_setup); + } + gtk_print_operation_set_embed_page_setup(print_operation, TRUE); + + /* print operation signals */ + g_signal_connect(print_operation, "draw-page", G_CALLBACK(cb_print_draw_page), zathura); + g_signal_connect(print_operation, "end-print", G_CALLBACK(cb_print_end), zathura); + g_signal_connect(print_operation, "request-page-setup", G_CALLBACK(cb_print_request_page_setup), zathura); + + /* print */ + GError* error = NULL; + GtkPrintOperationResult result = gtk_print_operation_run(print_operation, + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, + GTK_WINDOW(zathura->ui.session->gtk.window), &error); + + if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { + girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"), + error->message); + g_error_free(error); + } else if (result == GTK_PRINT_OPERATION_RESULT_APPLY) { + g_clear_object(&zathura->print.settings); + g_clear_object(&zathura->print.page_setup); + + /* save previous settings */ + zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation)); + zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation)); + } + + g_object_unref(print_operation); +} From 09d437058195d33853ad6406b40ed855438e4ff1 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 5 May 2018 07:23:38 +0200 Subject: [PATCH 22/23] Fix invalid function pointer cast --- zathura/utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zathura/utils.c b/zathura/utils.c index 6c3c4ad..c9281a0 100644 --- a/zathura/utils.c +++ b/zathura/utils.c @@ -63,6 +63,13 @@ file_valid_extension(zathura_t* zathura, const char* path) return (plugin == NULL) ? false : true; } +static void +index_element_free(void* data, GObject* UNUSED(object)) +{ + zathura_index_element_t* element = data; + zathura_index_element_free(element); +} + void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree) @@ -70,7 +77,7 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_list_t* list = girara_node_get_children(tree); GIRARA_LIST_FOREACH_BODY(list, girara_tree_node_t*, node, - zathura_index_element_t* index_element = (zathura_index_element_t*)girara_node_get_data(node); + zathura_index_element_t* index_element = girara_node_get_data(node); zathura_link_type_t type = zathura_link_get_type(index_element->link); zathura_link_target_t target = zathura_link_get_target(index_element->link); @@ -87,7 +94,7 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent, gchar* markup = g_markup_escape_text(index_element->title, -1); gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, markup, 1, description, 2, index_element, -1); g_free(markup); - g_object_weak_ref(G_OBJECT(model), (GWeakNotify) zathura_index_element_free, index_element); + g_object_weak_ref(G_OBJECT(model), index_element_free, index_element); g_free(description); if (girara_node_get_num_children(node) > 0) { From 6efed001fc9ed32a0ad49b260c0ae53c55febcc8 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 20 May 2018 15:08:22 +0200 Subject: [PATCH 23/23] Version 0.4.0 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 1862fa0..f42d5eb 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('zathura', 'c', - version: '0.3.9', + version: '0.4.0', meson_version: '>=0.45', default_options: 'c_std=c11', )