From f59a6f539e4c00dba9d5f491451cad96014933b3 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 25 Nov 2013 18:57:59 +0100 Subject: [PATCH 01/61] Remove GTK+2 support Signed-off-by: Sebastian Ramacher --- config.c | 1 - page-widget.c | 53 +-------------------------------------------------- zathura.c | 25 ------------------------ zathura.h | 9 +-------- 4 files changed, 2 insertions(+), 86 deletions(-) diff --git a/config.c b/config.c index 33c1419..72b5100 100644 --- a/config.c +++ b/config.c @@ -15,7 +15,6 @@ #include #include #include -#include #include static void diff --git a/page-widget.c b/page-widget.c index 6f328bc..720fed9 100644 --- a/page-widget.c +++ b/page-widget.c @@ -61,9 +61,6 @@ typedef struct zathura_page_widget_private_s { zathura_page_widget_private_t)) static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo); -#if GTK_MAJOR_VERSION == 2 -static gboolean zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event); -#endif static void zathura_page_widget_finalize(GObject* object); static void zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec); static void zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec); @@ -111,11 +108,7 @@ zathura_page_widget_class_init(ZathuraPageClass* class) /* overwrite methods */ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class); -#if GTK_MAJOR_VERSION == 2 - widget_class->expose_event = zathura_page_widget_expose; -#else widget_class->draw = zathura_page_widget_draw; -#endif widget_class->size_allocate = zathura_page_widget_size_allocate; widget_class->button_press_event = cb_zathura_page_widget_button_press_event; widget_class->button_release_event = cb_zathura_page_widget_button_release_event; @@ -368,43 +361,15 @@ zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, } } -#if GTK_MAJOR_VERSION == 2 -static gboolean -zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) -{ - cairo_t* cairo = gdk_cairo_create(gtk_widget_get_window(widget)); - if (cairo == NULL) { - girara_error("Could not retrieve cairo object"); - return FALSE; - } - - /* set clip region */ - cairo_rectangle(cairo, event->area.x, event->area.y, event->area.width, event->area.height); - cairo_clip(cairo); - - const gboolean ret = zathura_page_widget_draw(widget, cairo); - cairo_destroy(cairo); - return ret; -} -#endif - static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) { zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); mutex_lock(&(priv->lock)); - zathura_document_t* document = zathura_page_get_document(priv->page); - -#if GTK_MAJOR_VERSION == 2 - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - const unsigned int page_height = allocation.height; - const unsigned int page_width = allocation.width; -#else + zathura_document_t* document = zathura_page_get_document(priv->page); const unsigned int page_height = gtk_widget_get_allocated_height(widget); const unsigned int page_width = gtk_widget_get_allocated_width(widget); -#endif if (priv->surface != NULL) { cairo_save(cairo); @@ -620,11 +585,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) grect.y = rectangle->y1; grect.width = (rectangle->x2 + 1) - rectangle->x1; grect.height = (rectangle->y2 + 1) - rectangle->y1; -#if GTK_MAJOR_VERSION == 2 - gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(widget)), &grect, TRUE); -#else gtk_widget_queue_draw_area(GTK_WIDGET(widget), grect.x, grect.y, grect.width, grect.height); -#endif } static void @@ -890,19 +851,7 @@ cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page) const int width = cairo_image_surface_get_width(surface); const int height = cairo_image_surface_get_height(surface); -#if GTK_MAJOR_VERSION == 2 - GdkPixmap* pixmap = gdk_pixmap_new(gtk_widget_get_window(GTK_WIDGET(item)), width, height, -1); - cairo_t* cairo = gdk_cairo_create(pixmap); - - cairo_set_source_surface(cairo, surface, 0, 0); - cairo_paint(cairo); - cairo_destroy(cairo); - - GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, - 0, width, height); -#else GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height); -#endif g_signal_emit(page, signals[IMAGE_SELECTED], 0, pixbuf); g_object_unref(pixbuf); cairo_surface_destroy(surface); diff --git a/zathura.c b/zathura.c index 2449698..55b72e5 100644 --- a/zathura.c +++ b/zathura.c @@ -146,13 +146,9 @@ zathura_init(zathura_t* zathura) G_CALLBACK(cb_refresh_view), zathura); /* page view */ -#if (GTK_MAJOR_VERSION == 3) zathura->ui.page_widget = gtk_grid_new(); gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); -#else - zathura->ui.page_widget = gtk_table_new(0, 0, TRUE); -#endif if (zathura->ui.page_widget == NULL) { goto error_free; } @@ -184,13 +180,10 @@ zathura_init(zathura_t* zathura) } gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget); -#if (GTK_MAJOR_VERSION == 3) gtk_widget_set_hexpand_set(zathura->ui.page_widget_alignment, TRUE); gtk_widget_set_hexpand(zathura->ui.page_widget_alignment, FALSE); gtk_widget_set_vexpand_set(zathura->ui.page_widget_alignment, TRUE); gtk_widget_set_vexpand(zathura->ui.page_widget_alignment, FALSE); -#endif - gtk_widget_show(zathura->ui.page_widget); @@ -325,11 +318,7 @@ zathura_free(zathura_t* zathura) } void -#if (GTK_MAJOR_VERSION == 2) -zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid) -#else zathura_set_xid(zathura_t* zathura, Window xid) -#endif { g_return_if_fail(zathura != NULL); @@ -1060,30 +1049,16 @@ page_widget_set_mode(zathura_t* zathura, unsigned int page_padding, unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); -#if (GTK_MAJOR_VERSION == 3) gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); -#else - gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); - gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); - - unsigned int ncol = pages_per_row; - unsigned int nrow = (number_of_pages + first_page_column - 1 + ncol - 1) / ncol; - gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), nrow, ncol); -#endif - for (unsigned int i = 0; i < number_of_pages; i++) { int x = (i + first_page_column - 1) % pages_per_row; int y = (i + first_page_column - 1) / pages_per_row; zathura_page_t* page = zathura_document_get_page(zathura->document, i); GtkWidget* page_widget = zathura_page_get_widget(zathura, page); -#if (GTK_MAJOR_VERSION == 3) gtk_grid_attach(GTK_GRID(zathura->ui.page_widget), page_widget, x, y, 1, 1); -#else - gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), page_widget, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); -#endif } gtk_widget_show_all(zathura->ui.page_widget); diff --git a/zathura.h b/zathura.h index 4b198ed..633e73f 100644 --- a/zathura.h +++ b/zathura.h @@ -6,13 +6,10 @@ #include #include #include +#include #include "macros.h" #include "types.h" -#if (GTK_MAJOR_VERSION == 3) -#include -#endif - enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP, PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD, @@ -190,11 +187,7 @@ void zathura_free(zathura_t* zathura); * @param zathura The zathura session * @param xid The window id */ -#if (GTK_MAJOR_VERSION == 2) -void zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid); -#else void zathura_set_xid(zathura_t* zathura, Window xid); -#endif /** * Set the path to the configuration directory From 80a54e70f8f78cd82af875a019c478d211527d7e Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 25 Nov 2013 18:59:02 +0100 Subject: [PATCH 02/61] Update README Signed-off-by: Sebastian Ramacher --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 111cdf2..04bf619 100644 --- a/README +++ b/README @@ -5,9 +5,9 @@ girara user interface library and several document libraries. Requirements ------------ -gtk2 (>= 2.18) or gtk3 +gtk3 glib (>= 2.28) -girara +girara (>= 0.1.8) sqlite3 (optional, >= 3.5.9) check (for tests) intltool From 0406cbe495ff13aaa7917f64f760b79286636283 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 25 Nov 2013 19:02:43 +0100 Subject: [PATCH 03/61] Drop compat code for glib < 2.28 Signed-off-by: Sebastian Ramacher --- glib-compat.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/glib-compat.h b/glib-compat.h index d13e59f..c76ccca 100644 --- a/glib-compat.h +++ b/glib-compat.h @@ -20,14 +20,4 @@ #define mutex_free(m) g_mutex_clear((m)) #endif -/* g_get_real_time appeared in 2.28 */ -#if !GLIB_CHECK_VERSION(2, 27, 0) -inline static gint64 g_get_real_time(void) -{ - GTimeVal tv; - g_get_current_time(&tv); - return (((gint64) tv.tv_sec) * 1000000) + tv.tv_usec; -} -#endif - #endif From 7d5a5868114d449ea6bb8cd2b15b0883ddb2034b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 25 Nov 2013 19:05:46 +0100 Subject: [PATCH 04/61] Drop more GTK+2 code Signed-off-by: Sebastian Ramacher --- main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/main.c b/main.c index 7f3ac59..bd81b98 100644 --- a/main.c +++ b/main.c @@ -47,12 +47,7 @@ main(int argc, char* argv[]) bool print_version = false; bool synctex = false; int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED; - -#if GTK_CHECK_VERSION(3, 0, 0) - Window embed = 0; -#else - GdkNativeWindow embed = 0; -#endif + Window embed = 0; GOptionEntry entries[] = { { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" }, From 6ae3a7eab80777a1bac9ca1e5e4630047519b8d8 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 26 Nov 2013 09:57:20 +0100 Subject: [PATCH 05/61] Document PgDn and PgUp --- zathura.1.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zathura.1.rst b/zathura.1.rst index 8c74946..4da2e27 100644 --- a/zathura.1.rst +++ b/zathura.1.rst @@ -61,8 +61,10 @@ OPTIONS MOUSE AND KEY BINDINGS ====================== -J, K - Go to the next or previous page +J, PgDn + Go to the next page +K, PgUp + Go to the previous page h, k, j, l Scroll to the left, down, up or right direction Left, Down, Up, Right From 2c76fde31fbc972361dbf792bd4613eb5dd25e40 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 28 Nov 2013 14:16:17 +0100 Subject: [PATCH 06/61] Make sure there are no outstanding requests if the page size gets changed Signed-off-by: Sebastian Ramacher --- page-widget.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/page-widget.c b/page-widget.c index 6f328bc..aac3f7b 100644 --- a/page-widget.c +++ b/page-widget.c @@ -608,7 +608,10 @@ static void zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation) { GTK_WIDGET_CLASS(zathura_page_widget_parent_class)->size_allocate(widget, allocation); - zathura_page_widget_update_surface(ZATHURA_PAGE(widget), NULL); + + ZathuraPage* page = ZATHURA_PAGE(widget); + zathura_page_widget_abort_render_request(page); + zathura_page_widget_update_surface(page, NULL); } static void From 6ee0f265a31cee622fb304bacf493141a346d787 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 29 Nov 2013 15:57:40 +0100 Subject: [PATCH 07/61] CS Signed-off-by: Sebastian Ramacher --- shortcuts.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index 3908167..b806637 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -495,13 +495,16 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, t = 1; } - unsigned int view_width=0, view_height=0; + unsigned int view_width = 0; + unsigned int view_height = 0; zathura_document_get_viewport_size(zathura->document, &view_height, &view_width); - unsigned int cell_width=0, cell_height=0; + unsigned int cell_width = 0; + unsigned int cell_height = 0; zathura_document_get_cell_size(zathura->document, &cell_height, &cell_width); - unsigned int doc_width=0, doc_height=0; + unsigned int doc_width = 0; + unsigned int doc_height = 0; zathura_document_get_document_size(zathura->document, &doc_height, &doc_width); float scroll_step = 40; @@ -544,8 +547,8 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, direction = 1.0; } - double vstep = (double)(cell_height + padding) / (double)doc_height; - double hstep = (double)(cell_width + padding) / (double)doc_width; + const double vstep = (double)(cell_height + padding) / (double)doc_height; + const double hstep = (double)(cell_width + padding) / (double)doc_width; /* compute new position */ switch(argument->n) { From 6788776bae4bd9fc601da706354bc1963918ff24 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 29 Nov 2013 17:08:01 +0100 Subject: [PATCH 08/61] Bail out early if we get TOP or BOTTOM --- shortcuts.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index b806637..b34b1a4 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -491,6 +491,15 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, return false; } + /* if TOP or BOTTOM, go there and we are done */ + if (argument->n == TOP) { + position_set(zathura, -1, 0); + return false; + } else if (argument->n == BOTTOM) { + position_set(zathura, -1, 1.0); + return false; + } + if (t == 0) { t = 1; } @@ -527,31 +536,21 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, double pos_x = zathura_document_get_position_x(zathura->document); double pos_y = zathura_document_get_position_y(zathura->document); - double page_id = zathura_document_get_current_page_number(zathura->document); - double direction = 1.0; - /* if TOP or BOTTOM, go there and we are done */ - if (argument->n == TOP) { - position_set(zathura, -1, 0); - return false; - } else if (argument->n == BOTTOM) { - position_set(zathura, -1, 1.0); - return false; - } + const unsigned int page_id = zathura_document_get_current_page_number(zathura->document); /* compute the direction of scrolling */ - if ( (argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) || - (argument->n == UP) || (argument->n == FULL_UP) || (argument->n == HALF_UP)) { + double direction = 1.0; + if ((argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) || + (argument->n == UP) || (argument->n == FULL_UP) || (argument->n == HALF_UP)) { direction = -1.0; - } else { - direction = 1.0; } const double vstep = (double)(cell_height + padding) / (double)doc_height; const double hstep = (double)(cell_width + padding) / (double)doc_width; /* compute new position */ - switch(argument->n) { + switch (argument->n) { case FULL_UP: case FULL_DOWN: pos_y += direction * (1.0 - scroll_full_overlap) * vstep; @@ -603,9 +602,9 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, } /* snap to the border if we change page */ - double dummy; - unsigned int new_page_id = position_to_page_number(zathura->document, pos_x, pos_y); + const unsigned int new_page_id = position_to_page_number(zathura->document, pos_x, pos_y); if (scroll_page_aware == true && page_id != new_page_id) { + double dummy = 0.0; switch(argument->n) { case FULL_LEFT: case HALF_LEFT: From 064db002870b5b83bda385690adcf5d0e575112a Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 29 Nov 2013 17:24:28 +0100 Subject: [PATCH 09/61] Half / full page scroll need to respect the view port size They are not using the page size from the document. Signed-off-by: Sebastian Ramacher --- shortcuts.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index b34b1a4..fa5e2c7 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -508,10 +508,6 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, unsigned int view_height = 0; zathura_document_get_viewport_size(zathura->document, &view_height, &view_width); - unsigned int cell_width = 0; - unsigned int cell_height = 0; - zathura_document_get_cell_size(zathura->document, &cell_height, &cell_width); - unsigned int doc_width = 0; unsigned int doc_height = 0; zathura_document_get_document_size(zathura->document, &doc_height, &doc_width); @@ -546,8 +542,8 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, direction = -1.0; } - const double vstep = (double)(cell_height + padding) / (double)doc_height; - const double hstep = (double)(cell_width + padding) / (double)doc_width; + const double vstep = (double)view_height / (double)doc_height; + const double hstep = (double)view_width / (double)doc_width; /* compute new position */ switch (argument->n) { From 5a932e014c16ebddb37a9242c903482e2f2b1ee8 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 29 Nov 2013 18:05:40 +0100 Subject: [PATCH 10/61] No need for padding anymore Signed-off-by: Sebastian Ramacher --- shortcuts.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index fa5e2c7..5d141cb 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -527,9 +527,6 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, bool scroll_wrap = false; girara_setting_get(session, "scroll-wrap", &scroll_wrap); - int padding = 1; - girara_setting_get(session, "page-padding", &padding); - double pos_x = zathura_document_get_position_x(zathura->document); double pos_y = zathura_document_get_position_y(zathura->document); @@ -579,11 +576,11 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, } /* handle boundaries */ - double end_x = 0.5 * (double)view_width / (double)doc_width; - double end_y = 0.5 * (double)view_height / (double)doc_height; + const double end_x = 0.5 * (double)view_width / (double)doc_width; + const double end_y = 0.5 * (double)view_height / (double)doc_height; - double new_x = scroll_wrap ? 1.0 - end_x : end_x; - double new_y = scroll_wrap ? 1.0 - end_y : end_y; + const double new_x = scroll_wrap ? 1.0 - end_x : end_x; + const double new_y = scroll_wrap ? 1.0 - end_y : end_y; if (pos_x < end_x) { pos_x = new_x; From cff05ac10e3643dfb8fa20d2c8c63b1d1f1ba8c1 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 1 Dec 2013 15:47:28 +0100 Subject: [PATCH 11/61] Replace some GdkColors with GdkRGBA Signed-off-by: Sebastian Ramacher --- page-widget.c | 8 +++---- render.c | 62 +++++++++++++++++---------------------------------- render.h | 4 ++-- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/page-widget.c b/page-widget.c index 9e136b9..e39d66e 100644 --- a/page-widget.c +++ b/page-widget.c @@ -464,9 +464,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) } else { /* set background color */ if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) { - GdkColor color; + GdkRGBA color; zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, &color, NULL); - cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); + cairo_set_source_rgb(cairo, color.red, color.green, color.blue); } else { GdkColor color = priv->zathura->ui.colors.render_loading_bg; cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); @@ -480,9 +480,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) /* write text */ if (render_loading == true) { if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) { - GdkColor color; + GdkRGBA color; zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, NULL, &color); - cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); + cairo_set_source_rgb(cairo, color.red, color.green, color.blue); } else { GdkColor color = priv->zathura->ui.colors.render_loading_fg; cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); diff --git a/render.c b/render.c index f572a82..d98f03d 100644 --- a/render.c +++ b/render.c @@ -1,6 +1,7 @@ /* See LICENSE file for license and copyright information */ #include +#include #include #include #include "glib-compat.h" @@ -24,7 +25,6 @@ static void render_request_finalize(GObject* object); static void render_job(void* data, void* user_data); static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data); -static void color2double(const GdkColor* col, double* v); static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer); static void page_cache_invalidate_all(ZathuraRenderer* renderer); static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result); @@ -43,10 +43,8 @@ typedef struct private_s { bool enabled; bool hue; - double light[3]; - GdkColor light_gdk; - double dark[3]; - GdkColor dark_gdk; + GdkRGBA light; + GdkRGBA dark; } recolor; /* @@ -317,22 +315,16 @@ zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable) void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer, - const GdkColor* light, const GdkColor* dark) + const GdkRGBA* light, const GdkRGBA* dark) { g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); private_t* priv = GET_PRIVATE(renderer); if (light != NULL) { - priv->recolor.light_gdk.red = light->red; - priv->recolor.light_gdk.blue = light->blue; - priv->recolor.light_gdk.green = light->green; - color2double(light, priv->recolor.light); + memcpy(&priv->recolor.light, light, sizeof(GdkRGBA)); } if (dark != NULL) { - priv->recolor.dark_gdk.red = dark->red; - priv->recolor.dark_gdk.blue = dark->blue; - priv->recolor.dark_gdk.green = dark->green; - color2double(dark, priv->recolor.dark); + memcpy(&priv->recolor.dark, dark, sizeof(GdkRGBA)); } } @@ -343,33 +335,29 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer, g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); if (dark != NULL) { - GdkColor color; - gdk_color_parse(dark, &color); + GdkRGBA color; + gdk_rgba_parse(&color, dark); zathura_renderer_set_recolor_colors(renderer, NULL, &color); } if (light != NULL) { - GdkColor color; - gdk_color_parse(light, &color); + GdkRGBA color; + gdk_rgba_parse(&color, light); zathura_renderer_set_recolor_colors(renderer, &color, NULL); } } void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer, - GdkColor* light, GdkColor* dark) + GdkRGBA* light, GdkRGBA* dark) { g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); private_t* priv = GET_PRIVATE(renderer); if (light != NULL) { - light->red = priv->recolor.light_gdk.red; - light->blue = priv->recolor.light_gdk.blue; - light->green = priv->recolor.light_gdk.green; + memcpy(light, &priv->recolor.light, sizeof(GdkRGBA)); } if (dark != NULL) { - dark->red = priv->recolor.dark_gdk.red; - dark->blue = priv->recolor.dark_gdk.blue; - dark->green = priv->recolor.dark_gdk.green; + memcpy(dark, &priv->recolor.dark, sizeof(GdkRGBA)); } } @@ -503,14 +491,6 @@ emit_completed_signal(void* data) return FALSE; } -static void -color2double(const GdkColor* col, double* v) -{ - v[0] = (double) col->red / 65535.; - v[1] = (double) col->green / 65535.; - v[2] = (double) col->blue / 65535.; -} - /* Returns the maximum possible saturation for given h and l. Assumes that l is in the interval l1, l2 and corrects the value to force u=0 on l1 and l2 */ @@ -575,13 +555,13 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height, #define rgb1 priv->recolor.dark #define rgb2 priv->recolor.light - const double l1 = (a[0]*rgb1[0] + a[1]*rgb1[1] + a[2]*rgb1[2]); - const double l2 = (a[0]*rgb2[0] + a[1]*rgb2[1] + a[2]*rgb2[2]); + 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; const double rgb_diff[] = { - rgb2[0] - rgb1[0], - rgb2[1] - rgb1[1], - rgb2[2] - rgb1[2] + rgb2.red - rgb1.red, + rgb2.green - rgb1.green, + rgb2.blue - rgb1.blue }; for (unsigned int y = 0; y < page_height; y++) { @@ -626,9 +606,9 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height, } else { /* linear interpolation between dark and light with color ligtness as * a parameter */ - data[2] = (unsigned char)round(255.*(l * rgb_diff[0] + rgb1[0])); - data[1] = (unsigned char)round(255.*(l * rgb_diff[1] + rgb1[1])); - data[0] = (unsigned char)round(255.*(l * rgb_diff[2] + rgb1[2])); + data[2] = (unsigned char)round(255.*(l * rgb_diff[0] + rgb1.red)); + data[1] = (unsigned char)round(255.*(l * rgb_diff[1] + rgb1.green)); + data[0] = (unsigned char)round(255.*(l * rgb_diff[2] + rgb1.blue)); } } } diff --git a/render.h b/render.h index 07368f6..016c6b2 100644 --- a/render.h +++ b/render.h @@ -78,7 +78,7 @@ void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, * @param dark dark color */ void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer, - const GdkColor* light, const GdkColor* dark); + const GdkRGBA* light, const GdkRGBA* dark); /** * Set light and dark colors for recoloring. * @param renderer a renderer object @@ -94,7 +94,7 @@ void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer, * @param dark dark color */ void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer, - GdkColor* light, GdkColor* dark); + GdkRGBA* light, GdkRGBA* dark); /** * Stop rendering. * @param renderer a render object From 43c3ba86f4caeb7b6f6f4269afa92b5d3cb1e191 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 1 Dec 2013 16:04:04 +0100 Subject: [PATCH 12/61] Replace some more GdkColors with GdkRGBA Signed-off-by: Sebastian Ramacher --- config.c | 8 ++++---- page-widget.c | 22 +++++++++++----------- zathura.h | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config.c b/config.c index 72b5100..8482d82 100644 --- a/config.c +++ b/config.c @@ -52,9 +52,9 @@ cb_color_change(girara_session_t* session, const char* name, char* string_value = (char*) value; if (g_strcmp0(name, "highlight-color") == 0) { - gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color)); + gdk_rgba_parse(&(zathura->ui.colors.highlight_color), string_value); } else if (g_strcmp0(name, "highlight-active-color") == 0) { - gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active)); + gdk_rgba_parse(&(zathura->ui.colors.highlight_color_active), string_value); } else if (g_strcmp0(name, "recolor-darkcolor") == 0) { if (zathura->sync.render_thread != NULL) { zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value); @@ -64,9 +64,9 @@ cb_color_change(girara_session_t* session, const char* name, zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL); } } else if (g_strcmp0(name, "render-loading-bg") == 0) { - gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_bg)); + gdk_rgba_parse(&(zathura->ui.colors.render_loading_bg), string_value); } else if (g_strcmp0(name, "render-loading-fg") == 0) { - gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_fg)); + gdk_rgba_parse(&(zathura->ui.colors.render_loading_fg), string_value); } render_all(zathura); diff --git a/page-widget.c b/page-widget.c index e39d66e..9c9020a 100644 --- a/page-widget.c +++ b/page-widget.c @@ -416,8 +416,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link)); /* draw position */ - GdkColor color = priv->zathura->ui.colors.highlight_color; - cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency); + const GdkRGBA color = priv->zathura->ui.colors.highlight_color; + cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency); cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1)); cairo_fill(cairo); @@ -441,11 +441,11 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) /* draw position */ if (idx == priv->search.current) { - GdkColor color = priv->zathura->ui.colors.highlight_color_active; - cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency); + const GdkRGBA color = priv->zathura->ui.colors.highlight_color_active; + cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency); } else { - GdkColor color = priv->zathura->ui.colors.highlight_color; - cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency); + const GdkRGBA color = priv->zathura->ui.colors.highlight_color; + cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency); } cairo_rectangle(cairo, rectangle.x1, rectangle.y1, (rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1)); @@ -455,8 +455,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) } /* draw selection */ if (priv->mouse.selection.y2 != -1 && priv->mouse.selection.x2 != -1) { - GdkColor color = priv->zathura->ui.colors.highlight_color; - cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency); + const GdkRGBA color = priv->zathura->ui.colors.highlight_color; + cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency); cairo_rectangle(cairo, priv->mouse.selection.x1, priv->mouse.selection.y1, (priv->mouse.selection.x2 - priv->mouse.selection.x1), (priv->mouse.selection.y2 - priv->mouse.selection.y1)); cairo_fill(cairo); @@ -468,8 +468,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, &color, NULL); cairo_set_source_rgb(cairo, color.red, color.green, color.blue); } else { - GdkColor color = priv->zathura->ui.colors.render_loading_bg; - cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); + const GdkRGBA color = priv->zathura->ui.colors.render_loading_bg; + cairo_set_source_rgb(cairo, color.red, color.green, color.blue); } cairo_rectangle(cairo, 0, 0, page_width, page_height); cairo_fill(cairo); @@ -484,7 +484,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, NULL, &color); cairo_set_source_rgb(cairo, color.red, color.green, color.blue); } else { - GdkColor color = priv->zathura->ui.colors.render_loading_fg; + const GdkRGBA color = priv->zathura->ui.colors.render_loading_fg; cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); } diff --git a/zathura.h b/zathura.h index 633e73f..e5577f3 100644 --- a/zathura.h +++ b/zathura.h @@ -57,10 +57,10 @@ struct zathura_s struct { - GdkColor highlight_color; /**< Color for highlighting */ - GdkColor highlight_color_active; /** Color for highlighting */ - GdkColor render_loading_bg; /**< Background color for render "Loading..." */ - GdkColor render_loading_fg; /**< Foreground color for render "Loading..." */ + GdkRGBA highlight_color; /**< Color for highlighting */ + GdkRGBA highlight_color_active; /** Color for highlighting */ + GdkRGBA render_loading_bg; /**< Background color for render "Loading..." */ + GdkRGBA render_loading_fg; /**< Foreground color for render "Loading..." */ } colors; GtkWidget *page_widget_alignment; From 0ac744c07635007cbd97beea400a23e1469736cc Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 3 Dec 2013 17:04:58 +0100 Subject: [PATCH 13/61] I guess this mutex is no longer needed Signed-off-by: Sebastian Ramacher --- page-widget.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/page-widget.c b/page-widget.c index 9c9020a..59dbd8b 100644 --- a/page-widget.c +++ b/page-widget.c @@ -24,7 +24,12 @@ typedef struct zathura_page_widget_private_s { zathura_t* zathura; /**< Zathura object */ cairo_surface_t* surface; /**< Cairo surface */ ZathuraRenderRequest* render_request; /* Request object */ - mutex lock; /**< Lock */ + /** Lock + * + * This mutex can probably be removed. All functions are now called from the + * main thread. + */ + mutex lock; bool cached; /**< Cached state */ struct { From 60001b2ede121f676bf42ab441a55356d9913f6c Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 3 Dec 2013 17:05:09 +0100 Subject: [PATCH 14/61] A const Signed-off-by: Sebastian Ramacher --- config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.c b/config.c index 8482d82..fb38dbc 100644 --- a/config.c +++ b/config.c @@ -50,7 +50,7 @@ cb_color_change(girara_session_t* session, const char* name, g_return_if_fail(name != NULL); zathura_t* zathura = session->global.data; - char* string_value = (char*) value; + const char* string_value = (const char*) value; if (g_strcmp0(name, "highlight-color") == 0) { gdk_rgba_parse(&(zathura->ui.colors.highlight_color), string_value); } else if (g_strcmp0(name, "highlight-active-color") == 0) { From 5b3e0b7fc7e64bd589fcf87ea908b6fdf01d3a38 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 3 Dec 2013 20:29:44 +0100 Subject: [PATCH 15/61] Some consts here and there --- render.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/render.c b/render.c index d98f03d..a5bee64 100644 --- a/render.c +++ b/render.c @@ -497,17 +497,17 @@ emit_completed_signal(void* data) static double colorumax(const double* h, double l, double l1, double l2) { - double u, uu, v, vv, lv; if (h[0] == 0 && h[1] == 0 && h[2] == 0) { return 0; } - lv = (l - l1)/(l2 - l1); /* Remap l to the whole interval 0,1 */ - u = v = 1000000; + 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) { - uu = fabs((1-l)/h[k]); - vv = fabs((1-lv)/h[k]); + const double uu = fabs((1-l)/h[k]); + const double vv = fabs((1-lv)/h[k]); if (uu < u) { u = uu; @@ -516,8 +516,8 @@ colorumax(const double* h, double l, double l1, double l2) v = vv; } } else if (h[k] < 0) { - uu = fabs(l/h[k]); - vv = fabs(lv/h[k]); + const double uu = fabs(l/h[k]); + const double vv = fabs(lv/h[k]); if (uu < u) { u = uu; From 1d398dfaf08e77c2ebe0b76a696c3be26da69328 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 3 Dec 2013 20:30:44 +0100 Subject: [PATCH 16/61] Remove mutex from page widget This should not introduce any problems. All functions of the page widget are now called from the main thread. Signed-off-by: Sebastian Ramacher --- page-widget.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/page-widget.c b/page-widget.c index 59dbd8b..2c77b89 100644 --- a/page-widget.c +++ b/page-widget.c @@ -7,7 +7,6 @@ #include #include -#include "glib-compat.h" #include "links.h" #include "page-widget.h" #include "page.h" @@ -24,12 +23,6 @@ typedef struct zathura_page_widget_private_s { zathura_t* zathura; /**< Zathura object */ cairo_surface_t* surface; /**< Cairo surface */ ZathuraRenderRequest* render_request; /* Request object */ - /** Lock - * - * This mutex can probably be removed. All functions are now called from the - * main thread. - */ - mutex lock; bool cached; /**< Cached state */ struct { @@ -197,8 +190,6 @@ zathura_page_widget_init(ZathuraPage* widget) priv->mouse.selection_basepoint.x = -1; priv->mouse.selection_basepoint.y = -1; - mutex_init(&(priv->lock)); - /* we want mouse events */ gtk_widget_add_events(GTK_WIDGET(widget), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); @@ -249,8 +240,6 @@ zathura_page_widget_finalize(GObject* object) girara_list_free(priv->links.list); } - mutex_free(&(priv->lock)); - G_OBJECT_CLASS(zathura_page_widget_parent_class)->finalize(object); } @@ -370,7 +359,6 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) { zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); - mutex_lock(&(priv->lock)); zathura_document_t* document = zathura_page_get_document(priv->page); const unsigned int page_height = gtk_widget_get_allocated_height(widget); @@ -507,7 +495,6 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) /* render real page */ zathura_render_request(priv->render_request, g_get_real_time()); } - mutex_unlock(&(priv->lock)); return FALSE; } @@ -522,7 +509,6 @@ void zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface) { zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); - mutex_lock(&(priv->lock)); if (priv->surface != NULL) { cairo_surface_destroy(priv->surface); priv->surface = NULL; @@ -531,7 +517,6 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface priv->surface = surface; cairo_surface_reference(surface); } - mutex_unlock(&(priv->lock)); /* force a redraw here */ if (priv->surface != NULL) { zathura_page_widget_redraw_canvas(widget); From 42a8382a4590aea0564bcf7c37440e3a7a84805a Mon Sep 17 00:00:00 2001 From: Sebastian Neuser Date: Mon, 16 Dec 2013 19:42:35 +0100 Subject: [PATCH 17/61] Set position on document load only if no page was specified --- zathura.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zathura.c b/zathura.c index 55b72e5..89f06aa 100644 --- a/zathura.c +++ b/zathura.c @@ -786,10 +786,13 @@ document_open(zathura_t* zathura, const char* path, const char* password, gtk_widget_show(zathura->pages[page_id]); } - /* set position */ + /* Set page */ page_set(zathura, zathura_document_get_current_page_number(document)); - if (file_info.position_x != 0 || file_info.position_y != 0) { - position_set(zathura, file_info.position_x, file_info.position_y); + + /* Set position (only if restoring from history file) */ + if (file_info.current_page == zathura_document_get_current_page_number(document) + && (file_info.position_x != 0 || file_info.position_y != 0)) { + position_set(zathura, file_info.position_x, file_info.position_y); } return true; From 87af53afbbb18e9243c0800ea9e95c8f6155d5f5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 17 Dec 2013 16:26:13 +0100 Subject: [PATCH 18/61] Make inital values more explicit Signed-off-by: Sebastian Ramacher --- zathura.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zathura.c b/zathura.c index 89f06aa..4dd7cad 100644 --- a/zathura.c +++ b/zathura.c @@ -536,8 +536,17 @@ document_open(zathura_t* zathura, const char* path, const char* password, } /* read history file */ - zathura_fileinfo_t file_info = { 0, 0, 1, 0, 0, 0, 0, 0 }; - bool known_file = zathura_db_get_fileinfo(zathura->database, file_path, &file_info); + zathura_fileinfo_t file_info = { + .current_page = 0, + .page_offset = 0, + .scale = 1, + .rotation = 0, + .pages_per_row = 0, + .first_page_column = 0, + .position_x = 0, + .position_y = 0 + }; + const bool known_file = zathura_db_get_fileinfo(zathura->database, file_path, &file_info); /* set page offset */ zathura_document_set_page_offset(document, file_info.page_offset); From 660a3e7757a2b9f0de61f68546c002230d2e82b7 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 17 Dec 2013 16:27:34 +0100 Subject: [PATCH 19/61] CS Signed-off-by: Sebastian Ramacher --- zathura.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zathura.c b/zathura.c index 4dd7cad..647bc8d 100644 --- a/zathura.c +++ b/zathura.c @@ -799,9 +799,9 @@ document_open(zathura_t* zathura, const char* path, const char* password, page_set(zathura, zathura_document_get_current_page_number(document)); /* Set position (only if restoring from history file) */ - if (file_info.current_page == zathura_document_get_current_page_number(document) - && (file_info.position_x != 0 || file_info.position_y != 0)) { - position_set(zathura, file_info.position_x, file_info.position_y); + if (file_info.current_page == zathura_document_get_current_page_number(document) && + (file_info.position_x != 0 || file_info.position_y != 0)) { + position_set(zathura, file_info.position_x, file_info.position_y); } return true; From 45a997c88e4bfe2e6fb1126520b619cbc0b74fcb Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 17 Dec 2013 16:32:50 +0100 Subject: [PATCH 20/61] More consts Signed-off-by: Sebastian Ramacher --- zathura.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zathura.c b/zathura.c index 647bc8d..9caa762 100644 --- a/zathura.c +++ b/zathura.c @@ -786,8 +786,8 @@ document_open(zathura_t* zathura, const char* path, const char* password, /* adjust_view calls render_all in some cases and render_all calls * gtk_widget_set_size_request. To be sure that it's really called, do it * here once again. */ - double height = zathura_page_get_height(page); - double width = zathura_page_get_width(page); + const double height = zathura_page_get_height(page); + const double width = zathura_page_get_width(page); page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true); gtk_widget_set_size_request(zathura->pages[page_id], page_width, page_height); From e8bc7b1e491d0f0f9ed790ef4afa0056e3cb5c26 Mon Sep 17 00:00:00 2001 From: Sebastian Neuser Date: Tue, 17 Dec 2013 15:34:40 +0100 Subject: [PATCH 21/61] Implement shortcuts for scrolling to page top/bottom --- config.c | 4 ++++ shortcuts.c | 21 ++++++++++++++++----- zathura.h | 3 ++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/config.c b/config.c index fb38dbc..76ca03e 100644 --- a/config.c +++ b/config.c @@ -281,6 +281,8 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_scroll, NORMAL, UP, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_scroll, NORMAL, DOWN, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_scroll, NORMAL, RIGHT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_H, NULL, sc_scroll, NORMAL, PAGE_TOP, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_L, NULL, sc_scroll, NORMAL, PAGE_BOTTOM, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_t, NULL, sc_scroll, NORMAL, HALF_LEFT, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL); @@ -436,6 +438,8 @@ config_load_default(zathura_t* zathura) girara_argument_mapping_add(gsession, "left", LEFT); girara_argument_mapping_add(gsession, "next", NEXT); girara_argument_mapping_add(gsession, "out", ZOOM_OUT); + girara_argument_mapping_add(gsession, "page-top", PAGE_TOP); + girara_argument_mapping_add(gsession, "page-bottom", PAGE_BOTTOM); girara_argument_mapping_add(gsession, "previous", PREVIOUS); girara_argument_mapping_add(gsession, "right", RIGHT); girara_argument_mapping_add(gsession, "specific", ZOOM_SPECIFIC); diff --git a/shortcuts.c b/shortcuts.c index 5d141cb..e0a141f 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -500,6 +500,22 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, return false; } + /* Retrieve current page and position */ + const unsigned int page_id = zathura_document_get_current_page_number(zathura->document); + double pos_x = zathura_document_get_position_x(zathura->document); + double pos_y = zathura_document_get_position_y(zathura->document); + + /* If PAGE_TOP or PAGE_BOTTOM, go there and we are done */ + if (argument->n == PAGE_TOP) { + page_number_to_position(zathura->document, page_id, 0.5, 0.0, &pos_x, &pos_y); + position_set(zathura, -1, pos_y); + return false; + } else if (argument->n == PAGE_BOTTOM) { + page_number_to_position(zathura->document, page_id, 0.5, 1.0, &pos_x, &pos_y); + position_set(zathura, -1, pos_y); + return false; + } + if (t == 0) { t = 1; } @@ -527,11 +543,6 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, bool scroll_wrap = false; girara_setting_get(session, "scroll-wrap", &scroll_wrap); - double pos_x = zathura_document_get_position_x(zathura->document); - double pos_y = zathura_document_get_position_y(zathura->document); - - const unsigned int page_id = zathura_document_get_current_page_number(zathura->document); - /* compute the direction of scrolling */ double direction = 1.0; if ((argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) || diff --git a/zathura.h b/zathura.h index e5577f3..5f63d01 100644 --- a/zathura.h +++ b/zathura.h @@ -16,7 +16,8 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, BACKWARD, CONTINUOUS, DELETE_LAST, EXPAND, EXPAND_ALL, COLLAPSE_ALL, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, HALF_LEFT, HALF_RIGHT, FULL_LEFT, FULL_RIGHT, NEXT_CHAR, - PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW }; + PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW, + PAGE_BOTTOM, PAGE_TOP }; /* unspecified page number */ enum { From 976b6ab16413d1e4c685278f1f0b4837bb431feb Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 17 Dec 2013 18:05:23 +0100 Subject: [PATCH 22/61] Document page-top and page-bottom Signed-off-by: Sebastian Ramacher --- zathurarc.5.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zathurarc.5.rst b/zathurarc.5.rst index d4bc152..54e8edd 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -262,6 +262,8 @@ Possible arguments are: * left * next * out +* page-bottom +* page-top * previous * right * rotate-ccw From 3dcae9604535cc3d293cebe9575b8ec151239d09 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 17 Dec 2013 18:07:04 +0100 Subject: [PATCH 23/61] Document new shortcuts Signed-off-by: Sebastian Ramacher --- zathura.1.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zathura.1.rst b/zathura.1.rst index 4da2e27..36384ed 100644 --- a/zathura.1.rst +++ b/zathura.1.rst @@ -75,6 +75,8 @@ t, ^f, ^b, space, , y Scroll a full page left, down, up or right gg, G, nG Goto to the first, the last or to the nth page +H, L + Goto top or bottom of the current page ^o, ^i Move backward and forward through the jump list ^j, ^k From b3c2327fbb213d9afbfe44039bd29e10b2c91934 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 23 Dec 2013 15:41:44 +0100 Subject: [PATCH 24/61] Make synctex_view available Also fix argv handling. Signed-off-by: Sebastian Ramacher --- synctex.c | 47 +++++++++++++++++++++++++++++------------------ synctex.h | 1 + types.h | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/synctex.c b/synctex.c index 3a9ea29..2bf5d90 100644 --- a/synctex.c +++ b/synctex.c @@ -52,7 +52,6 @@ static GScannerConfig scanner_config = { static void synctex_record_hits(zathura_t* zathura, int page_idx, girara_list_t* hits, bool first); static double scan_float(GScanner* scanner); -static bool synctex_view(zathura_t* zathura, char* position); void synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y) @@ -71,18 +70,19 @@ synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y) return; } - int page_idx = zathura_page_get_index(page); - char *buffer = g_strdup_printf("%d:%d:%d:%s", page_idx + 1, x, y, filename); - + char** argv = g_malloc0(sizeof(char*) * (zathura->synctex.editor != NULL ? + 6 : 4)); + argv[0] = g_strdup("synctex"); + argv[1] = g_strdup("edit"); + argv[2] = g_strdup("-o"); + argv[3] = g_strdup_printf("%d:%d:%d:%s", zathura_page_get_index(page) + 1, x, y, filename); if (zathura->synctex.editor != NULL) { - char* argv[] = {"synctex", "edit", "-o", buffer, "-x", zathura->synctex.editor, NULL}; - g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); - } else { - char* argv[] = {"synctex", "edit", "-o", buffer, NULL}; - g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); + argv[4] = g_strdup("-x"); + argv[5] = g_strdup(zathura->synctex.editor); } - g_free(buffer); + g_spawn_async(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL); + g_strfreev(argv); } static void @@ -96,7 +96,7 @@ synctex_record_hits(zathura_t* zathura, int page_idx, girara_list_t* hits, bool g_object_set(page_widget, "draw-links", FALSE, NULL); g_object_set(page_widget, "search-results", hits, NULL); - if (first) { + if (first == true) { page_set(zathura, zathura_page_get_index(page)); g_object_set(page_widget, "search-current", 0, NULL); } @@ -115,15 +115,26 @@ scan_float(GScanner* scanner) } } -static bool -synctex_view(zathura_t* zathura, char* position) +bool +synctex_view(zathura_t* zathura, const char* position) { - char* filename = g_strdup(zathura_document_get_path(zathura->document)); - char* argv[] = {"synctex", "view", "-i", position, "-o", filename, NULL}; - gint output; + if (zathura->document == NULL) { + return false; + } - bool ret = g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, &output, NULL, NULL); - g_free(filename); + char** argv = g_malloc0(sizeof(char*) * 6); + argv[0] = g_strdup("synctex"); + argv[1] = g_strdup("view"); + argv[2] = g_strdup("-i"); + argv[3] = g_strdup(position); + argv[4] = g_strdup("-o"); + argv[5] = g_strdup(zathura_document_get_path(zathura->document)); + + gint output; + bool ret = g_spawn_async_with_pipes(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, NULL, NULL, + &output, NULL, NULL); + g_strfreev(argv); if (ret == false) { return false; diff --git a/synctex.h b/synctex.h index 1514117..85a6d07 100644 --- a/synctex.h +++ b/synctex.h @@ -6,5 +6,6 @@ #include "types.h" void synctex_edit(zathura_t* zathura, zathura_page_t* page, int x, int y); +bool synctex_view(zathura_t* zathura, const char* position); #endif diff --git a/types.h b/types.h index 433bcb5..a211e8f 100644 --- a/types.h +++ b/types.h @@ -33,7 +33,7 @@ typedef struct zathura_plugin_manager_s zathura_plugin_manager_t; /** * Renderer */ -typedef struct zathura_renderer_s ZathuraRenderer; +typedef struct zathura_renderer_s ZathuraRenderer; /** * Error types From f7fddf750e8d7e5d8cd79f4be5dfaf997d134994 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 23 Dec 2013 18:14:23 +0100 Subject: [PATCH 25/61] Initial D-Bus interface for synctex Signed-off-by: Sebastian Ramacher --- synctex-dbus.c | 225 +++++++++++++++++++++++++++++++++++++++++++++++++ synctex-dbus.h | 49 +++++++++++ types.h | 5 ++ zathura.c | 10 +++ zathura.h | 1 + 5 files changed, 290 insertions(+) create mode 100644 synctex-dbus.c create mode 100644 synctex-dbus.h diff --git a/synctex-dbus.c b/synctex-dbus.c new file mode 100644 index 0000000..66116a2 --- /dev/null +++ b/synctex-dbus.c @@ -0,0 +1,225 @@ +/* See LICENSE file for license and copyright information */ + +#include "synctex-dbus.h" +#include "synctex.h" +#include "macros.h" +#include "zathura.h" +#include "document.h" +#include +#include +#include +#include + +G_DEFINE_TYPE(ZathuraSynctexDbus, zathura_synctex_dbus, G_TYPE_OBJECT) + +/* template for bus name */ +static const char DBUS_NAME_TEMPLATE[] = "org.pwmt.zathura.PID-%d"; +/* template for object path */ +const char DBUS_OBJPATH[] = "/org/pwmt/zathura/synctex"; + +typedef struct private_s { + zathura_t* zathura; + GDBusNodeInfo* introspection_data; + GDBusConnection* connection; + guint owner_id; + guint registration_id; +} private_t; + +#define GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \ + private_t)) + +/* Introspection data for the service we are exporting */ +static const char SYNCTEX_DBUS_INTROSPECTION[] = + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + ""; + +static const GDBusInterfaceVTable interface_vtable; + +static bool synctex_dbus_view(ZathuraSynctexDbus* synctex_view, + const char* position); + +static void +finalize(GObject* object) +{ + ZathuraSynctexDbus* synctex_dbus = ZATHURA_SYNCTEX_DBUS(object); + private_t* priv = GET_PRIVATE(synctex_dbus); + + if (priv->connection != NULL && priv->registration_id > 0) { + g_dbus_connection_unregister_object(priv->connection, priv->registration_id); + } + + if (priv->owner_id > 0) { + g_bus_unown_name(priv->owner_id); + } + + if (priv->introspection_data != NULL) { + g_dbus_node_info_unref(priv->introspection_data); + } + + G_OBJECT_CLASS(zathura_synctex_dbus_parent_class)->finalize(object); +} + +static void +zathura_synctex_dbus_class_init(ZathuraSynctexDbusClass* class) +{ + /* initialize methods */ + class->view = synctex_dbus_view; + + /* add private members */ + g_type_class_add_private(class, sizeof(private_t)); + + /* overwrite methods */ + GObjectClass* object_class = G_OBJECT_CLASS(class); + object_class->finalize = finalize; +} + +static void +zathura_synctex_dbus_init(ZathuraSynctexDbus* synctex_dbus) +{ + private_t* priv = GET_PRIVATE(synctex_dbus); + priv->zathura = NULL; + priv->introspection_data = NULL; + priv->connection = NULL; + priv->owner_id = 0; + priv->registration_id = 0; +} + +static void +bus_acquired(GDBusConnection* connection, const gchar* name, void* data) +{ + girara_debug("Bus acquired at '%s'.", name); + + ZathuraSynctexDbus* dbus = data; + private_t* priv = GET_PRIVATE(dbus); + + GError* error = NULL; + priv->registration_id = g_dbus_connection_register_object(connection, + DBUS_OBJPATH, priv->introspection_data->interfaces[0], + &interface_vtable, dbus, NULL, &error); + + if (priv->registration_id == 0) { + girara_warning("Failed to register object on D-Bus connection: %s", + error->message); + g_error_free(error); + return; + } + + priv->connection = connection; +} + +static void +name_acquired(GDBusConnection* UNUSED(connection), const gchar* name, + void* UNUSED(data)) +{ + girara_debug("Acquired '%s' on session bus.", name); +} + +static void +name_lost(GDBusConnection* UNUSED(connection), const gchar* name, + void* UNUSED(data)) +{ + girara_debug("Lost connection or failed to acquire '%s' on session bus.", + name); +} + +ZathuraSynctexDbus* +zathura_synctex_dbus_new(zathura_t* zathura) +{ + GObject* obj = g_object_new(ZATHURA_TYPE_SYNCTEX_DBUS, NULL); + if (obj == NULL) { + return NULL; + } + + ZathuraSynctexDbus* synctex_dbus = ZATHURA_SYNCTEX_DBUS(obj); + private_t* priv = GET_PRIVATE(synctex_dbus); + priv->zathura = zathura; + + GError* error = NULL; + priv->introspection_data = g_dbus_node_info_new_for_xml(SYNCTEX_DBUS_INTROSPECTION, &error); + if (priv->introspection_data == NULL) { + girara_warning("Failed to parse introspection data: %s", error->message); + g_error_free(error); + g_object_unref(obj); + return NULL; + } + + char* well_known_name = g_strdup_printf(DBUS_NAME_TEMPLATE, getpid()); + priv->owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, + well_known_name, G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired, + name_acquired, name_lost, synctex_dbus, NULL); + g_free(well_known_name); + + return synctex_dbus; +} + +static bool +synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, const char* position) +{ + private_t* priv = GET_PRIVATE(synctex_dbus); + return synctex_view(priv->zathura, position); +} + +bool +zathura_synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, const char* position) +{ + g_return_val_if_fail(ZATHURA_IS_SYNCTEX_DBUS(synctex_dbus), false); + g_return_val_if_fail(position != NULL, false); + + return ZATHURA_SYNCTEX_DBUS_GET_CLASS(synctex_dbus)->view(synctex_dbus, + position); +} + +/* D-Bus handler */ + +static void +handle_method_call(GDBusConnection* UNUSED(connection), + const gchar* UNUSED(sender), const gchar* UNUSED(object_path), + const gchar* UNUSED(interface_name), + const gchar* method_name, GVariant* parameters, + GDBusMethodInvocation* invocation, void* data) +{ + ZathuraSynctexDbus* synctex_dbus = data; + + if (g_strcmp0(method_name, "View") == 0) { + gchar* position = NULL; + g_variant_get(parameters, "(s)", &position); + + const bool ret = zathura_synctex_dbus_view(synctex_dbus, position); + g_free(position); + + GVariant* result = g_variant_new("(b)", ret); + g_dbus_method_invocation_return_value(invocation, result); + } +} + +static GVariant* +handle_get_property(GDBusConnection* UNUSED(connection), + const gchar* UNUSED(sender), const gchar* UNUSED(object_path), + const gchar* UNUSED(interface_name), const gchar* property_name, + GError** UNUSED(error), void* data) +{ + ZathuraSynctexDbus* synctex_dbus = data; + private_t* priv = GET_PRIVATE(synctex_dbus); + + if (g_strcmp0(property_name, "filename") == 0) { + return g_variant_new_string(zathura_document_get_path(priv->zathura->document)); + } + + return NULL; +} + +static const GDBusInterfaceVTable interface_vtable = +{ + .method_call = handle_method_call, + .get_property = handle_get_property, + .set_property = NULL +}; + diff --git a/synctex-dbus.h b/synctex-dbus.h new file mode 100644 index 0000000..749bf10 --- /dev/null +++ b/synctex-dbus.h @@ -0,0 +1,49 @@ +/* See LICENSE file for license and copyright information */ + +#ifndef SYNCTEX_DBUS_H +#define SYNCTEX_DBUS_H + +#include +#include +#include +#include "types.h" + +typedef struct zathura_synctex_dbus_class_s ZathuraSynctexDbusClass; + +struct zathura_synctex_dbus_s +{ + GObject parent; +}; + +struct zathura_synctex_dbus_class_s +{ + GObjectClass parent_class; + + bool (*view)(ZathuraSynctexDbus* synctex_dbus, const char* position); +}; + +#define ZATHURA_TYPE_SYNCTEX_DBUS \ + (zathura_synctex_dbus_get_type()) +#define ZATHURA_SYNCTEX_DBUS(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \ + ZathuraSynctexDbus)) +#define ZATHURA_SYNCTEX_DBUS_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \ + ZathuraSynctexDbus)) +#define ZATHURA_IS_SYNCTEX_DBUS(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_SYNCTEX_DBUS)) +#define ZATHURA_IS_SYNCTEX_DBUS_CLASS(obj) \ + (G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_SYNCTEX_DBUS)) +#define ZATHURA_SYNCTEX_DBUS_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_SYNCTEX_DBUS, \ + ZathuraSynctexDbusClass)) + +GType zathura_synctex_dbus_get_type(void); + +ZathuraSynctexDbus* zathura_synctex_dbus_new(zathura_t* zathura); + +/* bool zathura_synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, + const char* position); */ + + +#endif diff --git a/types.h b/types.h index a211e8f..71dce5d 100644 --- a/types.h +++ b/types.h @@ -35,6 +35,11 @@ typedef struct zathura_plugin_manager_s zathura_plugin_manager_t; */ typedef struct zathura_renderer_s ZathuraRenderer; +/** + * Synctex DBus manager + */ +typedef struct zathura_synctex_dbus_s ZathuraSynctexDbus; + /** * Error types */ diff --git a/zathura.c b/zathura.c index 9caa762..d62ec2e 100644 --- a/zathura.c +++ b/zathura.c @@ -34,6 +34,7 @@ #include "page-widget.h" #include "plugin.h" #include "adjustment.h" +#include "synctex-dbus.h" typedef struct zathura_document_info_s { zathura_t* zathura; @@ -804,6 +805,9 @@ document_open(zathura_t* zathura, const char* path, const char* password, position_set(zathura, file_info.position_x, file_info.position_y); } + /* Start D-Bus */ + zathura->synctex.dbus = zathura_synctex_dbus_new(zathura); + return true; error_free: @@ -886,6 +890,12 @@ document_close(zathura_t* zathura, bool keep_monitor) /* stop rendering */ zathura_renderer_stop(zathura->sync.render_thread); + /* stop D-Bus */ + if (zathura->synctex.dbus != NULL) { + g_object_unref(zathura->synctex.dbus); + zathura->synctex.dbus = NULL; + } + /* remove monitor */ if (keep_monitor == false) { if (zathura->file_monitor.monitor != NULL) { diff --git a/zathura.h b/zathura.h index 5f63d01..1eded22 100644 --- a/zathura.h +++ b/zathura.h @@ -89,6 +89,7 @@ struct zathura_s { bool enabled; gchar* editor; + ZathuraSynctexDbus* dbus; } synctex; struct From 1b6a2b47534d0f64c6531f919ed8eb7481ec27fa Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:05:40 +0100 Subject: [PATCH 26/61] Initial D-Bus client implementation Signed-off-by: Sebastian Ramacher --- main.c | 41 +++++++++++++++-------- synctex-dbus.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++ synctex-dbus.h | 8 +++++ 3 files changed, 125 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 7f3ac59..a0982ab 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,7 @@ #include "zathura.h" #include "utils.h" +#include "synctex-dbus.h" /* main function */ int @@ -43,6 +44,7 @@ main(int argc, char* argv[]) gchar* loglevel = NULL; gchar* password = NULL; gchar* synctex_editor = NULL; + gchar* synctex_fwd = NULL; bool forkback = false; bool print_version = false; bool synctex = false; @@ -55,17 +57,18 @@ main(int argc, char* argv[]) #endif GOptionEntry entries[] = { - { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" }, - { "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" }, - { "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" }, - { "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, _("Path to the directories containing plugins"), "path" }, - { "fork", '\0',0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background"), NULL }, - { "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" }, - { "page", 'P', 0, G_OPTION_ARG_INT, &page_number, _("Page number to go to"), "number" }, - { "debug", 'l', 0, G_OPTION_ARG_STRING, &loglevel, _("Log level (debug, info, warning, error)"), "level" }, - { "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL }, - { "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL }, - { "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" }, + { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" }, + { "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" }, + { "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" }, + { "plugins-dir", 'p', 0, G_OPTION_ARG_STRING, &plugin_path, _("Path to the directories containing plugins"), "path" }, + { "fork", '\0', 0, G_OPTION_ARG_NONE, &forkback, _("Fork into the background"), NULL }, + { "password", 'w', 0, G_OPTION_ARG_STRING, &password, _("Document password"), "password" }, + { "page", 'P', 0, G_OPTION_ARG_INT, &page_number, _("Page number to go to"), "number" }, + { "debug", 'l', 0, G_OPTION_ARG_STRING, &loglevel, _("Log level (debug, info, warning, error)"), "level" }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL }, + { "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL }, + { "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" }, + { "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Synctex forward ..."), "position" }, { NULL, '\0', 0, 0, NULL, NULL, NULL } }; @@ -82,11 +85,23 @@ main(int argc, char* argv[]) } g_option_context_free(context); + if (synctex_fwd != NULL) { + if (argc != 2) { + girara_error(_("Too many arguments or missing filename while running with --syntex-forward")); + return -1; + } + + if (synctex_forward_position(argv[1], synctex_fwd) == true) { + return 0; + } + } + + /* Fork into the background if the user really wants to ... */ if (forkback == true) { - int pid = fork(); + const int pid = fork(); if (pid > 0) { /* parent */ - exit(0); + return 0; } else if (pid < 0) { /* error */ girara_error("Couldn't fork."); } diff --git a/synctex-dbus.c b/synctex-dbus.c index 66116a2..a9f2926 100644 --- a/synctex-dbus.c +++ b/synctex-dbus.c @@ -223,3 +223,92 @@ static const GDBusInterfaceVTable interface_vtable = .set_property = NULL }; +static const unsigned int TIMEOUT = 3000; + +bool +synctex_forward_position(const char* filename, const char* position) +{ + if (filename == NULL || position == NULL) { + return false; + } + + GError* error = NULL; + GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, + NULL, &error); + /* GDBusProxy* proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.DBus", + "/org/freedesktop/DBus", "org.freedesktop.DBus", NULL, &error); */ + if (connection == NULL) { + girara_error("Could not create proxy for 'org.freedesktop.DBus': %s", + error->message); + g_error_free(error); + return false; + } + + GVariant* vnames = g_dbus_connection_call_sync(connection, + "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", + "ListNames", NULL, G_VARIANT_TYPE("(as)"), G_DBUS_CALL_FLAGS_NONE, + TIMEOUT, NULL, &error); + if (vnames == NULL) { + girara_error("Could not list available names: %s", error->message); + g_error_free(error); + // g_object_unref(proxy); + g_object_unref(connection); + return false; + } + + GVariantIter* iter = NULL; + g_variant_get(vnames, "(as)", &iter); + + gchar* name = NULL; + bool found_one = false; + while (g_variant_iter_loop(iter, "s", &name) == TRUE) { + if (g_str_has_prefix(name, "org.pwmt.zathura.PID") == FALSE) { + continue; + } + girara_debug("Found name: %s", name); + + GVariant* vfilename = g_dbus_connection_call_sync(connection, + name, DBUS_OBJPATH, "org.freedesktop.DBus.Properties", + "Get", g_variant_new("(ss)", "org.pwmt.zathura.Synctex", "filename"), + G_VARIANT_TYPE("(v)"), G_DBUS_CALL_FLAGS_NONE, + TIMEOUT, NULL, &error); + if (vfilename == NULL) { + girara_error("Failed to query 'filename' property from '%s': %s", + name, error->message); + g_error_free(error); + continue; + } + + GVariant* tmp = NULL; + g_variant_get(vfilename, "(v)", &tmp); + gchar* remote_filename = g_variant_dup_string(tmp, NULL); + girara_debug("Filename from '%s': %s", name, remote_filename); + g_variant_unref(tmp); + g_variant_unref(vfilename); + + if (g_strcmp0(filename, remote_filename) != 0) { + g_free(remote_filename); + continue; + } + + g_free(remote_filename); + found_one = true; + + GVariant* ret = g_dbus_connection_call_sync(connection, + name, DBUS_OBJPATH, "org.pwmt.zathura.Synctex", "View", + g_variant_new("(s)", position), G_VARIANT_TYPE("(b)"), + G_DBUS_CALL_FLAGS_NONE, TIMEOUT, NULL, &error); + if (ret == NULL) { + girara_error("Failed to run View on '%s': %s", name, error->message); + g_error_free(error); + } else { + g_variant_unref(ret); + } + } + g_variant_iter_free(iter); + g_variant_unref(vnames); + + return found_one; +} + diff --git a/synctex-dbus.h b/synctex-dbus.h index 749bf10..1cb2501 100644 --- a/synctex-dbus.h +++ b/synctex-dbus.h @@ -45,5 +45,13 @@ ZathuraSynctexDbus* zathura_synctex_dbus_new(zathura_t* zathura); /* bool zathura_synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, const char* position); */ +/** + * Forward synctex position to zathura instance having the right file open. + * @param filename filename + * @param position synctex position + * @returns true if a instance was found that has the given filename open, false + * otherwise + */ +bool synctex_forward_position(const char* filename, const char* position); #endif From ccab5cf829db955ddccc854a448f8ac78f62d53d Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:09:27 +0100 Subject: [PATCH 27/61] Close the connection Signed-off-by: Sebastian Ramacher --- synctex-dbus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/synctex-dbus.c b/synctex-dbus.c index a9f2926..4de17da 100644 --- a/synctex-dbus.c +++ b/synctex-dbus.c @@ -308,6 +308,7 @@ synctex_forward_position(const char* filename, const char* position) } g_variant_iter_free(iter); g_variant_unref(vnames); + g_object_unref(connection); return found_one; } From b36c078710719fec35b4c598fde3cc1b38621ec5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:17:21 +0100 Subject: [PATCH 28/61] Add interface definition Signed-off-by: Sebastian Ramacher --- org.pwmt.zathura.synctex.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 org.pwmt.zathura.synctex.xml diff --git a/org.pwmt.zathura.synctex.xml b/org.pwmt.zathura.synctex.xml new file mode 100644 index 0000000..eb3538e --- /dev/null +++ b/org.pwmt.zathura.synctex.xml @@ -0,0 +1,10 @@ + + + + + + + + + + From fb000b9607a45d090cf26fb431fd93a289aaed1b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:19:50 +0100 Subject: [PATCH 29/61] Install D-Bus interface definitions Signed-off-by: Sebastian Ramacher --- Makefile | 8 +++++++- config.mk | 1 + synctex-dbus.c | 12 +++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e1f4a54..a08418c 100644 --- a/Makefile +++ b/Makefile @@ -128,6 +128,7 @@ dist: clean build-manpages ${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \ ${PROJECT}.desktop version.h.in \ ${PROJECT}.1 ${PROJECT}rc.5 \ + org.pwmt.zathura.synxtex.xml \ ${PROJECT}-${VERSION} $(QUIET)cp tests/Makefile tests/config.mk tests/*.c \ ${PROJECT}-${VERSION}/tests @@ -184,7 +185,12 @@ install-headers: ${PROJECT}.pc $(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}/pkgconfig $(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig -install: all install-headers install-manpages +install-dbus: + $(ECHO) installing D-Bus interface definitions + $(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR) + $(QUIET)install -m 644 org.pwmt.zathura.synxtex.xml $(DESTDIR)$(DBUSINTERFACEDIR) + +install: all install-headers install-manpages install-dbus $(ECHO) installing executable file $(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin $(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin diff --git a/config.mk b/config.mk index 620faa7..e167660 100644 --- a/config.mk +++ b/config.mk @@ -43,6 +43,7 @@ MANPREFIX ?= ${PREFIX}/share/man DESKTOPPREFIX ?= ${PREFIX}/share/applications LIBDIR ?= ${PREFIX}/lib INCLUDEDIR ?= ${PREFIX}/include +DBUSINTERFACEDIR =? ${PREFIX}/share/dbus-1/interfaces # plugin directory PLUGINDIR ?= ${LIBDIR}/zathura diff --git a/synctex-dbus.c b/synctex-dbus.c index 4de17da..6d003f8 100644 --- a/synctex-dbus.c +++ b/synctex-dbus.c @@ -14,8 +14,10 @@ G_DEFINE_TYPE(ZathuraSynctexDbus, zathura_synctex_dbus, G_TYPE_OBJECT) /* template for bus name */ static const char DBUS_NAME_TEMPLATE[] = "org.pwmt.zathura.PID-%d"; -/* template for object path */ -const char DBUS_OBJPATH[] = "/org/pwmt/zathura/synctex"; +/* object path */ +static const char DBUS_OBJPATH[] = "/org/pwmt/zathura/synctex"; +/* interface name */ +static const char DBUS_INTERFACE[] = "org.pwmt.zathura.synctex"; typedef struct private_s { zathura_t* zathura; @@ -32,7 +34,7 @@ typedef struct private_s { /* Introspection data for the service we are exporting */ static const char SYNCTEX_DBUS_INTROSPECTION[] = "\n" - " \n" + " \n" " \n" " \n" " \n" @@ -270,7 +272,7 @@ synctex_forward_position(const char* filename, const char* position) GVariant* vfilename = g_dbus_connection_call_sync(connection, name, DBUS_OBJPATH, "org.freedesktop.DBus.Properties", - "Get", g_variant_new("(ss)", "org.pwmt.zathura.Synctex", "filename"), + "Get", g_variant_new("(ss)", DBUS_INTERFACE, "filename"), G_VARIANT_TYPE("(v)"), G_DBUS_CALL_FLAGS_NONE, TIMEOUT, NULL, &error); if (vfilename == NULL) { @@ -296,7 +298,7 @@ synctex_forward_position(const char* filename, const char* position) found_one = true; GVariant* ret = g_dbus_connection_call_sync(connection, - name, DBUS_OBJPATH, "org.pwmt.zathura.Synctex", "View", + name, DBUS_OBJPATH, DBUS_INTERFACE, "View", g_variant_new("(s)", position), G_VARIANT_TYPE("(b)"), G_DBUS_CALL_FLAGS_NONE, TIMEOUT, NULL, &error); if (ret == NULL) { From f5983a842942bcdbae0cf8ce55f4f20885698298 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:25:20 +0100 Subject: [PATCH 30/61] Remove some unneeded stuff Signed-off-by: Sebastian Ramacher --- synctex-dbus.c | 26 ++------------------------ synctex-dbus.h | 5 ----- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/synctex-dbus.c b/synctex-dbus.c index 6d003f8..d64b3af 100644 --- a/synctex-dbus.c +++ b/synctex-dbus.c @@ -45,9 +45,6 @@ static const char SYNCTEX_DBUS_INTROSPECTION[] = static const GDBusInterfaceVTable interface_vtable; -static bool synctex_dbus_view(ZathuraSynctexDbus* synctex_view, - const char* position); - static void finalize(GObject* object) { @@ -72,9 +69,6 @@ finalize(GObject* object) static void zathura_synctex_dbus_class_init(ZathuraSynctexDbusClass* class) { - /* initialize methods */ - class->view = synctex_dbus_view; - /* add private members */ g_type_class_add_private(class, sizeof(private_t)); @@ -162,23 +156,6 @@ zathura_synctex_dbus_new(zathura_t* zathura) return synctex_dbus; } -static bool -synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, const char* position) -{ - private_t* priv = GET_PRIVATE(synctex_dbus); - return synctex_view(priv->zathura, position); -} - -bool -zathura_synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, const char* position) -{ - g_return_val_if_fail(ZATHURA_IS_SYNCTEX_DBUS(synctex_dbus), false); - g_return_val_if_fail(position != NULL, false); - - return ZATHURA_SYNCTEX_DBUS_GET_CLASS(synctex_dbus)->view(synctex_dbus, - position); -} - /* D-Bus handler */ static void @@ -189,12 +166,13 @@ handle_method_call(GDBusConnection* UNUSED(connection), GDBusMethodInvocation* invocation, void* data) { ZathuraSynctexDbus* synctex_dbus = data; + private_t* priv = GET_PRIVATE(synctex_dbus); if (g_strcmp0(method_name, "View") == 0) { gchar* position = NULL; g_variant_get(parameters, "(s)", &position); - const bool ret = zathura_synctex_dbus_view(synctex_dbus, position); + const bool ret = synctex_view(priv->zathura, position); g_free(position); GVariant* result = g_variant_new("(b)", ret); diff --git a/synctex-dbus.h b/synctex-dbus.h index 1cb2501..f180a5d 100644 --- a/synctex-dbus.h +++ b/synctex-dbus.h @@ -18,8 +18,6 @@ struct zathura_synctex_dbus_s struct zathura_synctex_dbus_class_s { GObjectClass parent_class; - - bool (*view)(ZathuraSynctexDbus* synctex_dbus, const char* position); }; #define ZATHURA_TYPE_SYNCTEX_DBUS \ @@ -42,9 +40,6 @@ GType zathura_synctex_dbus_get_type(void); ZathuraSynctexDbus* zathura_synctex_dbus_new(zathura_t* zathura); -/* bool zathura_synctex_dbus_view(ZathuraSynctexDbus* synctex_dbus, - const char* position); */ - /** * Forward synctex position to zathura instance having the right file open. * @param filename filename From 03e1fb1f90ce5364ee4e8691d892bb212663fd33 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 01:41:43 +0100 Subject: [PATCH 31/61] Set log level earlier Signed-off-by: Sebastian Ramacher --- main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index a0982ab..bacc52d 100644 --- a/main.c +++ b/main.c @@ -85,6 +85,15 @@ main(int argc, char* argv[]) } g_option_context_free(context); + /* Set log level. */ + if (loglevel == NULL || g_strcmp0(loglevel, "info") == 0) { + girara_set_debug_level(GIRARA_INFO); + } else if (g_strcmp0(loglevel, "warning") == 0) { + girara_set_debug_level(GIRARA_WARNING); + } else if (g_strcmp0(loglevel, "error") == 0) { + girara_set_debug_level(GIRARA_ERROR); + } + if (synctex_fwd != NULL) { if (argc != 2) { girara_error(_("Too many arguments or missing filename while running with --syntex-forward")); @@ -109,15 +118,6 @@ main(int argc, char* argv[]) setsid(); } - /* Set log level. */ - if (loglevel == NULL || g_strcmp0(loglevel, "info") == 0) { - girara_set_debug_level(GIRARA_INFO); - } else if (g_strcmp0(loglevel, "warning") == 0) { - girara_set_debug_level(GIRARA_WARNING); - } else if (g_strcmp0(loglevel, "error") == 0) { - girara_set_debug_level(GIRARA_ERROR); - } - zathura_set_xid(zathura, embed); zathura_set_config_dir(zathura, config_dir); zathura_set_data_dir(zathura, data_dir); From 5640bc78ec86782e0cc7a91065ebb107f5f42fc0 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 17:50:38 +0100 Subject: [PATCH 32/61] Add initial vim ftplugin --- tex_zathurasyntex.vim | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tex_zathurasyntex.vim diff --git a/tex_zathurasyntex.vim b/tex_zathurasyntex.vim new file mode 100644 index 0000000..652eab4 --- /dev/null +++ b/tex_zathurasyntex.vim @@ -0,0 +1,52 @@ +" See LICENSE file for license and copyright information + +" avoid re-execution +if exists("b:did_zathura_synctex_plugin") + finish +endif +let b:did_zathura_synctex_plugin = 1 + +" set up global variables +if !exists("g:zathura_synctex_latex_suite") + let g:zathura_synctex_latex_suite = 1 +endif + +function! Zathura_SyncTexForward() + let source = expand("%:p") + let input = shellescape(line(".").":".col(".").":".source) + let output = "" + if exists("*Tex_GetMainFileName") && g:zathura_synctex_latex_suite == 1 + " use Tex_GetMainFileName from latex-suite if it is available + let output = Tex_GetMainFileName(":p:r").".pdf" + else + " try to find synctex files and use them to determine the output file + let synctex_files = split(glob("%:p:h/*.synctex.gz"), "\n") + if len(synctex_files) == 0 + echo "No synctex file found" + return + endif + + let found = 0 + for synctex in synctex_files + let pdffile = substitute(synctex, "synctex.gz", "pdf", "") + let out = system("synctex view -i ".input." -o ".shellescape(pdffile)) + if match(out, "No tag for ".source) >= 0 + continue + endif + + let found = 1 + let output = pdffile + break + endfor + + if found == 0 + echo "No synctex file containing reference to source file found" + return + endif + endif + + let execstr = "silent !zathura --synctex-forward=".input." ".shellescape(output) + exec execstr +endfunction + +nmap f :call Zathura_SyncTexForward() From 2b446f4182fde0b3185c4349bbed2ef3fa220dd6 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 24 Dec 2013 17:58:50 +0100 Subject: [PATCH 33/61] Fail if no open instance has been found Signed-off-by: Sebastian Ramacher --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index bacc52d..80b0af5 100644 --- a/main.c +++ b/main.c @@ -96,12 +96,15 @@ main(int argc, char* argv[]) if (synctex_fwd != NULL) { if (argc != 2) { - girara_error(_("Too many arguments or missing filename while running with --syntex-forward")); + girara_error("Too many arguments or missing filename while running with --syntex-forward"); return -1; } if (synctex_forward_position(argv[1], synctex_fwd) == true) { return 0; + } else { + girara_error("Could not find open instance for '%s'., argv[1]); + return -1; } } From d0b7750065be077e1fb498784e7f039bb9582fff Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Fri, 27 Dec 2013 17:12:59 +0100 Subject: [PATCH 34/61] Fix quotes in girara_error call --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 80b0af5..dfc1f81 100644 --- a/main.c +++ b/main.c @@ -103,7 +103,7 @@ main(int argc, char* argv[]) if (synctex_forward_position(argv[1], synctex_fwd) == true) { return 0; } else { - girara_error("Could not find open instance for '%s'., argv[1]); + girara_error("Could not find open instance for '%s'", argv[1]); return -1; } } From 2940be27f1d840b43c0c7410d549b0057a68ce3a Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 20:16:00 +0100 Subject: [PATCH 35/61] Document --syntex-forward Signed-off-by: Sebastian Ramacher --- zathura.1.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zathura.1.rst b/zathura.1.rst index 36384ed..7c06ae7 100644 --- a/zathura.1.rst +++ b/zathura.1.rst @@ -14,6 +14,7 @@ SYNOPOSIS ========= | zathura [OPTION]... | zathura [OPTION]... FILE [FILE ...] +| zathura --syntex-forward INPUT FILE DESCRIPTION =========== @@ -58,6 +59,10 @@ OPTIONS -x [cmd], --synctex-editor-command [cmd] Set the synctex editor command +--syntex-forward [input], + Jump to the given position. The switch expcects the same format as specified + for syntex's view -i. + MOUSE AND KEY BINDINGS ====================== From 81e75539b34357ca6c4e7418bc868d3b4289b905 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 20:40:06 +0100 Subject: [PATCH 36/61] Use fullpath in for --syntex-forward Signed-off-by: Sebastian Ramacher --- main.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index dfc1f81..5e7d168 100644 --- a/main.c +++ b/main.c @@ -1,11 +1,17 @@ /* See LICENSE file for license and copyright information */ +#define _BSD_SOURCE +#define _XOPEN_SOURCE 700 + +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include #include #include "zathura.h" @@ -100,10 +106,19 @@ main(int argc, char* argv[]) return -1; } - if (synctex_forward_position(argv[1], synctex_fwd) == true) { + char* real_path = realpath(argv[1], NULL); + if (real_path == NULL) { + girara_error("Failed to determine real path: %s", strerror(errno)); + return -1; + } + + const bool ret = synctex_forward_position(argv[1], synctex_fwd); + free(real_path); + + if (ret == true) { return 0; } else { - girara_error("Could not find open instance for '%s'", argv[1]); + girara_error("Could not find open instance for '%s'", real_path); return -1; } } From de46558ecc55167b05b924b9c2db48785e731f8e Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 21:15:05 +0100 Subject: [PATCH 37/61] Update help string --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index ae6e89c..cf83892 100644 --- a/main.c +++ b/main.c @@ -69,7 +69,7 @@ main(int argc, char* argv[]) { "version", 'v', 0, G_OPTION_ARG_NONE, &print_version, _("Print version information"), NULL }, { "synctex", 's', 0, G_OPTION_ARG_NONE, &synctex, _("Enable synctex support"), NULL }, { "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" }, - { "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Synctex forward ..."), "position" }, + { "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" }, { NULL, '\0', 0, 0, NULL, NULL, NULL } }; From 24581734737b9463ffd0951baf178ba33daa02b3 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 21:15:41 +0100 Subject: [PATCH 38/61] Really use realpath Signed-off-by: Sebastian Ramacher --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index cf83892..c22e954 100644 --- a/main.c +++ b/main.c @@ -107,7 +107,7 @@ main(int argc, char* argv[]) return -1; } - const bool ret = synctex_forward_position(argv[1], synctex_fwd); + const bool ret = synctex_forward_position(real_path, synctex_fwd); free(real_path); if (ret == true) { From b1e8edf0d6baa9e6d0ad9184a887b26866d6ca07 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 21:26:38 +0100 Subject: [PATCH 39/61] Install vim ftplugin Signed-off-by: Sebastian Ramacher --- Makefile | 10 ++++++++-- config.mk | 3 ++- tex_zathurasyntex.vim => tex_zathurasynctex.vim | 0 3 files changed, 10 insertions(+), 3 deletions(-) rename tex_zathurasyntex.vim => tex_zathurasynctex.vim (100%) diff --git a/Makefile b/Makefile index a08418c..237d0a4 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,8 @@ dist: clean build-manpages ${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \ ${PROJECT}.desktop version.h.in \ ${PROJECT}.1 ${PROJECT}rc.5 \ - org.pwmt.zathura.synxtex.xml \ + org.pwmt.zathura.synctex.xml \ + tex_zathurasynctex.tex \ ${PROJECT}-${VERSION} $(QUIET)cp tests/Makefile tests/config.mk tests/*.c \ ${PROJECT}-${VERSION}/tests @@ -188,7 +189,12 @@ install-headers: ${PROJECT}.pc install-dbus: $(ECHO) installing D-Bus interface definitions $(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR) - $(QUIET)install -m 644 org.pwmt.zathura.synxtex.xml $(DESTDIR)$(DBUSINTERFACEDIR) + $(QUIET)install -m 644 org.pwmt.zathura.synctex.xml $(DESTDIR)$(DBUSINTERFACEDIR) + +install-vimftplugin: + $(ECHO) installing Vim filetype plugin + $(QUIET)mkdir -m 755 -p $(DESTDIR)$(VIMFTPLUGINDIR) + $(QUIET)install -m 644 tex_zathurasynctex.vim $(DESTDIR)$(VIMFTPLUGINDIR) install: all install-headers install-manpages install-dbus $(ECHO) installing executable file diff --git a/config.mk b/config.mk index e167660..c57531f 100644 --- a/config.mk +++ b/config.mk @@ -43,7 +43,8 @@ MANPREFIX ?= ${PREFIX}/share/man DESKTOPPREFIX ?= ${PREFIX}/share/applications LIBDIR ?= ${PREFIX}/lib INCLUDEDIR ?= ${PREFIX}/include -DBUSINTERFACEDIR =? ${PREFIX}/share/dbus-1/interfaces +DBUSINTERFACEDIR ?= ${PREFIX}/share/dbus-1/interfaces +VIMFTPLUGINDIR ?= ${PREFIX}/share/vim/addons/ftplugin # plugin directory PLUGINDIR ?= ${LIBDIR}/zathura diff --git a/tex_zathurasyntex.vim b/tex_zathurasynctex.vim similarity index 100% rename from tex_zathurasyntex.vim rename to tex_zathurasynctex.vim From 029364bd30e3f466ef1df58ab2360434429b5c26 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 22:21:59 +0100 Subject: [PATCH 40/61] Fix use after free Signed-off-by: Sebastian Ramacher --- main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index c22e954..2f0c52a 100644 --- a/main.c +++ b/main.c @@ -107,13 +107,12 @@ main(int argc, char* argv[]) return -1; } - const bool ret = synctex_forward_position(real_path, synctex_fwd); - free(real_path); - - if (ret == true) { + if (synctex_forward_position(real_path, synctex_fwd) == true) { + free(real_path); return 0; } else { girara_error("Could not find open instance for '%s'", real_path); + free(real_path); return -1; } } From 85e8833305608591398a41655e026c4e9b8848c3 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 27 Dec 2013 22:32:19 +0100 Subject: [PATCH 41/61] Move D-Bus interface definition and vim ftplugin to data Signed-off-by: Sebastian Ramacher --- Makefile | 7 +++---- .../org.pwmt.zathura.synctex.xml | 0 tex_zathurasynctex.vim => data/tex_zathurasynctex.vim | 0 3 files changed, 3 insertions(+), 4 deletions(-) rename org.pwmt.zathura.synctex.xml => data/org.pwmt.zathura.synctex.xml (100%) rename tex_zathurasynctex.vim => data/tex_zathurasynctex.vim (100%) diff --git a/Makefile b/Makefile index 237d0a4..83acc7a 100644 --- a/Makefile +++ b/Makefile @@ -128,9 +128,8 @@ dist: clean build-manpages ${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \ ${PROJECT}.desktop version.h.in \ ${PROJECT}.1 ${PROJECT}rc.5 \ - org.pwmt.zathura.synctex.xml \ - tex_zathurasynctex.tex \ ${PROJECT}-${VERSION} + $(QUIET)cp -r data ${PROJECT}-${VERSION} $(QUIET)cp tests/Makefile tests/config.mk tests/*.c \ ${PROJECT}-${VERSION}/tests $(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po @@ -189,12 +188,12 @@ install-headers: ${PROJECT}.pc install-dbus: $(ECHO) installing D-Bus interface definitions $(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR) - $(QUIET)install -m 644 org.pwmt.zathura.synctex.xml $(DESTDIR)$(DBUSINTERFACEDIR) + $(QUIET)install -m 644 data/org.pwmt.zathura.synctex.xml $(DESTDIR)$(DBUSINTERFACEDIR) install-vimftplugin: $(ECHO) installing Vim filetype plugin $(QUIET)mkdir -m 755 -p $(DESTDIR)$(VIMFTPLUGINDIR) - $(QUIET)install -m 644 tex_zathurasynctex.vim $(DESTDIR)$(VIMFTPLUGINDIR) + $(QUIET)install -m 644 data/tex_zathurasynctex.vim $(DESTDIR)$(VIMFTPLUGINDIR) install: all install-headers install-manpages install-dbus $(ECHO) installing executable file diff --git a/org.pwmt.zathura.synctex.xml b/data/org.pwmt.zathura.synctex.xml similarity index 100% rename from org.pwmt.zathura.synctex.xml rename to data/org.pwmt.zathura.synctex.xml diff --git a/tex_zathurasynctex.vim b/data/tex_zathurasynctex.vim similarity index 100% rename from tex_zathurasynctex.vim rename to data/tex_zathurasynctex.vim From 79e812dc5e0f5fa35a0a4687c0d4fe18eb134715 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 30 Dec 2013 06:46:09 +0100 Subject: [PATCH 42/61] Run command in vim script without breaking the screen --- tex_zathurasynctex.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tex_zathurasynctex.vim b/tex_zathurasynctex.vim index 652eab4..9f28889 100644 --- a/tex_zathurasynctex.vim +++ b/tex_zathurasynctex.vim @@ -45,8 +45,8 @@ function! Zathura_SyncTexForward() endif endif - let execstr = "silent !zathura --synctex-forward=".input." ".shellescape(output) - exec execstr + let execstr = "zathura --synctex-forward=".input." ".shellescape(output) + silent call system(execstr) endfunction nmap f :call Zathura_SyncTexForward() From 3c83a50cffe3f8efbd0e2bc63f8b2fcfc9a41db2 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 1 Jan 2014 16:49:34 +0100 Subject: [PATCH 43/61] Update copyright years --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index f9fa617..f115cbe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2013 pwmt.org +Copyright (c) 2009-2014 pwmt.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages From 6cd8f2d3f6896d5e2e2f35fa51d56ed07e7eb5b5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 1 Jan 2014 16:50:19 +0100 Subject: [PATCH 44/61] Run version check if config.mk changed --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 83acc7a..f73a7ed 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ DOBJECTS = $(patsubst %.c, %.do, $(SOURCE)) all: options ${PROJECT} po build-manpages # pkg-config based version checks -.version-checks/%: +.version-checks/%: config.mk $(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \ pkg-config --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \ echo "The minium required version of $(*) is $($(*)_MIN_VERSION)" && \ From d9a4c1862776c998dfe181d62e8bf3f2e9c65721 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 1 Jan 2014 18:14:17 +0100 Subject: [PATCH 45/61] Remove extra --- data/tex_zathurasynctex.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/tex_zathurasynctex.vim b/data/tex_zathurasynctex.vim index 9f28889..9096ecc 100644 --- a/data/tex_zathurasynctex.vim +++ b/data/tex_zathurasynctex.vim @@ -49,4 +49,4 @@ function! Zathura_SyncTexForward() silent call system(execstr) endfunction -nmap f :call Zathura_SyncTexForward() +nmap f :call Zathura_SyncTexForward() From aeaa900a9439976477486c2a0c94e5554d9a3cae Mon Sep 17 00:00:00 2001 From: Sebastian Neuser Date: Wed, 1 Jan 2014 19:19:28 +0100 Subject: [PATCH 46/61] Preserve horizontal position when scrolling to PAGE_TOP/BOTTOM --- shortcuts.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index e0a141f..23ea84e 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -507,12 +507,14 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, /* If PAGE_TOP or PAGE_BOTTOM, go there and we are done */ if (argument->n == PAGE_TOP) { - page_number_to_position(zathura->document, page_id, 0.5, 0.0, &pos_x, &pos_y); - position_set(zathura, -1, pos_y); + double dontcare = 0.5; + page_number_to_position(zathura->document, page_id, dontcare, 0.0, &dontcare, &pos_y); + position_set(zathura, pos_x, pos_y); return false; } else if (argument->n == PAGE_BOTTOM) { - page_number_to_position(zathura->document, page_id, 0.5, 1.0, &pos_x, &pos_y); - position_set(zathura, -1, pos_y); + double dontcare = 0.5; + page_number_to_position(zathura->document, page_id, dontcare, 1.0, &dontcare, &pos_y); + position_set(zathura, pos_x, pos_y); return false; } From 3a524935d23c9f4e8946c43f87140c708454026b Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 4 Jan 2014 20:19:53 +0100 Subject: [PATCH 47/61] Clean up Signed-off-by: Sebastian Ramacher --- data/tex_zathurasynctex.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/tex_zathurasynctex.vim b/data/tex_zathurasynctex.vim index 9096ecc..4ac8be9 100644 --- a/data/tex_zathurasynctex.vim +++ b/data/tex_zathurasynctex.vim @@ -1,4 +1,4 @@ -" See LICENSE file for license and copyright information +" See LICENSE file for license and copyright information " avoid re-execution if exists("b:did_zathura_synctex_plugin") From db1f2c98a8646875a7c02393a39972c38b00321e Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 4 Jan 2014 20:23:48 +0100 Subject: [PATCH 48/61] Update translations Signed-off-by: Sebastian Ramacher --- po/ca.po | 5 +-- po/cs.po | 2 +- po/de.po | 2 +- po/el.po | 2 +- po/eo.po | 2 +- po/es.po | 2 +- po/es_CL.po | 2 +- po/et.po | 2 +- po/fr.po | 39 +++++++++--------- po/he.po | 2 +- po/hr.po | 2 +- po/id_ID.po | 46 ++++++++++----------- po/it.po | 2 +- po/pl.po | 2 +- po/pt_BR.po | 30 +++++++------- po/ru.po | 117 ++++++++++++++++++++++++++-------------------------- po/ta_IN.po | 2 +- po/tr.po | 2 +- po/uk_UA.po | 2 +- 19 files changed, 131 insertions(+), 134 deletions(-) diff --git a/po/ca.po b/po/ca.po index b331ecb..0928982 100644 --- a/po/ca.po +++ b/po/ca.po @@ -2,15 +2,14 @@ # See LICENSE file for license and copyright information # # Translators: -# norbux , 2013 -# norbux , 2012 # mvdan , 2012 +# norbux , 2012-2013 msgid "" msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2014-01-04 20:20+0100\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Catalan (http://www.transifex.com/projects/p/zathura/language/" "ca/)\n" diff --git a/po/cs.po b/po/cs.po index 083a527..1ba1fa8 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Martin Pelikan \n" "Language-Team: pwmt.org \n" "Language: cs\n" diff --git a/po/de.po b/po/de.po index f8eb78c..a037f1b 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: German (http://www.transifex.com/projects/p/zathura/language/" "de/)\n" diff --git a/po/el.po b/po/el.po index e789213..217e6e8 100644 --- a/po/el.po +++ b/po/el.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Greek (http://www.transifex.com/projects/p/zathura/language/" "el/)\n" diff --git a/po/eo.po b/po/eo.po index db89adc..27d2a70 100644 --- a/po/eo.po +++ b/po/eo.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-05 01:06+0100\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: norbux \n" "Language-Team: Esperanto (http://www.transifex.com/projects/p/zathura/" "language/eo/)\n" diff --git a/po/es.po b/po/es.po index 1d69579..14c36aa 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Moritz Lipp \n" "Language-Team: Spanish (Castilian) (http://www.transifex.net/projects/p/" "zathura/language/es/)\n" diff --git a/po/es_CL.po b/po/es_CL.po index aae2625..40896ac 100644 --- a/po/es_CL.po +++ b/po/es_CL.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: watsh1ken \n" "Language-Team: Spanish (Chile) (http://www.transifex.net/projects/p/zathura/" "language/es_CL/)\n" diff --git a/po/et.po b/po/et.po index eb99602..dfc942f 100644 --- a/po/et.po +++ b/po/et.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Rivo Zängov \n" "Language-Team: Estonian (http://www.transifex.net/projects/p/zathura/" "language/et/)\n" diff --git a/po/fr.po b/po/fr.po index 7c36cb0..47e55b5 100644 --- a/po/fr.po +++ b/po/fr.po @@ -5,17 +5,18 @@ # bknecht , 2012 # Dorian , 2012 # Quentin Stiévenart , 2012 +# rike, 2014 # Stéphane Aulery , 2012 msgid "" msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" -"Last-Translator: Benoît Knecht \n" +"PO-Revision-Date: 2014-01-02 18:42+0000\n" "Language-Team: French (http://www.transifex.com/projects/p/zathura/language/" "fr/)\n" "Language: fr\n" +"Last-Translator: rike\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -84,35 +85,35 @@ msgstr "Aucun marque-page correspondant : %s" #: ../commands.c:162 msgid "Title" -msgstr "" +msgstr "Titre" #: ../commands.c:163 msgid "Author" -msgstr "" +msgstr "Auteur" #: ../commands.c:164 msgid "Subject" -msgstr "" +msgstr "Sujet" #: ../commands.c:165 msgid "Keywords" -msgstr "" +msgstr "Mots clé" #: ../commands.c:166 msgid "Creator" -msgstr "" +msgstr "Créateur" #: ../commands.c:167 msgid "Producer" -msgstr "" +msgstr "Producteur" #: ../commands.c:168 msgid "Creation date" -msgstr "" +msgstr "Date de création" #: ../commands.c:169 msgid "Modification date" -msgstr "" +msgstr "Date de modification" #: ../commands.c:174 ../commands.c:196 msgid "No information available." @@ -229,7 +230,7 @@ msgstr "Zoom maximum" #: ../config.c:151 msgid "Maximum number of pages to keep in the cache" -msgstr "" +msgstr "Nombre maximum de pages à garder en cache" #: ../config.c:153 msgid "Number of positions to remember in the jumplist" @@ -265,9 +266,7 @@ msgstr "Recoloriser les pages" #: ../config.c:169 msgid "When recoloring keep original hue and adjust lightness only" -msgstr "" -"Lors de la recoloration garder la teinte d'origine et ajuster seulement la " -"luminosité" +msgstr "Lors de la recoloration garder la teinte d'origine et ajuster seulement la luminosité" #: ../config.c:171 msgid "Wrap scrolling" @@ -287,11 +286,11 @@ msgstr "Zoom centré horizontalement" #: ../config.c:179 msgid "Align link target to the left" -msgstr "" +msgstr "Aligner la cible du lien à gauche" #: ../config.c:181 msgid "Let zoom be changed when following links" -msgstr "" +msgstr "Autoriser la modification du zoom quand on suit un lien" #: ../config.c:183 msgid "Center result horizontally" @@ -339,7 +338,7 @@ msgstr "Utiliser le nom de base du fichier dans le titre de la fenêtre" #: ../config.c:204 msgid "Display the page number in the window title" -msgstr "" +msgstr "Afficher le numéro de page dans le titre de la fenêtre" #: ../config.c:206 msgid "Use basename of the file in the statusbar" @@ -351,7 +350,7 @@ msgstr "Activer la prise en charge de synctex" #: ../config.c:210 msgid "The clipboard into which mouse-selected data will be written" -msgstr "" +msgstr "Le presse-papiers qui recevra les données sélectionnées avec la souris" #. define default inputbar commands #: ../config.c:369 @@ -510,11 +509,11 @@ msgstr "[Sans nom]" #: ../zathura.c:486 msgid "Could not read file from stdin and write it to a temporary file." -msgstr "" +msgstr "Impossible de lire le fichier depuis stdin et de le sauvegarder dans un fichier temporaire." #: ../zathura.c:535 msgid "Unsupported file type. Please install the necessary plugin." -msgstr "" +msgstr "Type de fichier non supporté. Veuillez installer l'extension nécessaire." #: ../zathura.c:545 msgid "Document does not contain any pages" diff --git a/po/he.po b/po/he.po index 35c6ffd..e6f3834 100644 --- a/po/he.po +++ b/po/he.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Hebrew (http://www.transifex.com/projects/p/zathura/language/" "he/)\n" diff --git a/po/hr.po b/po/hr.po index 3a1c2a7..eb022a6 100644 --- a/po/hr.po +++ b/po/hr.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Croatian (http://www.transifex.com/projects/p/zathura/" "language/hr/)\n" diff --git a/po/id_ID.po b/po/id_ID.po index 2af438b..28a00ea 100644 --- a/po/id_ID.po +++ b/po/id_ID.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-12-15 05:57+0000\n" "Last-Translator: andjeng \n" "Language-Team: Indonesian (Indonesia) (http://www.transifex.com/projects/p/" "zathura/language/id_ID/)\n" @@ -81,35 +81,35 @@ msgstr "Tidak ada bookmark: %s" #: ../commands.c:162 msgid "Title" -msgstr "" +msgstr "Judul" #: ../commands.c:163 msgid "Author" -msgstr "" +msgstr "Penulis" #: ../commands.c:164 msgid "Subject" -msgstr "" +msgstr "Subjek" #: ../commands.c:165 msgid "Keywords" -msgstr "" +msgstr "Kata kunci" #: ../commands.c:166 msgid "Creator" -msgstr "" +msgstr "Pembuat" #: ../commands.c:167 msgid "Producer" -msgstr "" +msgstr "Produser" #: ../commands.c:168 msgid "Creation date" -msgstr "" +msgstr "Tanggal pembuatan" #: ../commands.c:169 msgid "Modification date" -msgstr "" +msgstr "Tanggal ubahan" #: ../commands.c:174 ../commands.c:196 msgid "No information available." @@ -186,7 +186,7 @@ msgstr "Citra" #. zathura settings #: ../config.c:131 msgid "Database backend" -msgstr "" +msgstr "backend database" #: ../config.c:133 msgid "Zoom step" @@ -226,7 +226,7 @@ msgstr "Pembesaran maksimal" #: ../config.c:151 msgid "Maximum number of pages to keep in the cache" -msgstr "" +msgstr "Jumlah laman yang disimpan pada cache" #: ../config.c:153 msgid "Number of positions to remember in the jumplist" @@ -250,11 +250,11 @@ msgstr "Warna sorotan (aktif)" #: ../config.c:161 msgid "'Loading ...' background color" -msgstr "" +msgstr "'Memuat ...; warna latar" #: ../config.c:163 msgid "'Loading ...' foreground color" -msgstr "" +msgstr "'Memuat ...' warna depan" #: ../config.c:167 msgid "Recolor pages" @@ -282,11 +282,11 @@ msgstr "Pembesaran horisontal tengah" #: ../config.c:179 msgid "Align link target to the left" -msgstr "" +msgstr "Ratakan tautan ke kiri" #: ../config.c:181 msgid "Let zoom be changed when following links" -msgstr "" +msgstr "Biarkan pembesaran berubah saat mengikuti pranala" #: ../config.c:183 msgid "Center result horizontally" @@ -334,11 +334,11 @@ msgstr "Gunakan nama dasar file pada judul jendela" #: ../config.c:204 msgid "Display the page number in the window title" -msgstr "" +msgstr "Tampilkan nomor laman pada jendela judul" #: ../config.c:206 msgid "Use basename of the file in the statusbar" -msgstr "" +msgstr "Gunakan nama dasar berkas pada statusbar" #: ../config.c:208 ../main.c:67 msgid "Enable synctex support" @@ -346,7 +346,7 @@ msgstr "Support synctex" #: ../config.c:210 msgid "The clipboard into which mouse-selected data will be written" -msgstr "" +msgstr "Data yang dipilih tetikus akan ditulis ke clipboard" #. define default inputbar commands #: ../config.c:369 @@ -419,7 +419,7 @@ msgstr "Jangan menyorot hasil cari sekarang" #: ../config.c:386 msgid "Highlight current search results" -msgstr "" +msgstr "Sorot hasil pencarian sekarang" #: ../config.c:387 msgid "Show version information" @@ -469,7 +469,7 @@ msgstr "Kata sandi dokumen" #: ../main.c:64 msgid "Page number to go to" -msgstr "" +msgstr "Nomor halaman tujuan" #: ../main.c:65 msgid "Log level (debug, info, warning, error)" @@ -505,12 +505,12 @@ msgstr "[Tidak berjudul]" #: ../zathura.c:486 msgid "Could not read file from stdin and write it to a temporary file." -msgstr "" +msgstr "Tidak dapat membaca berkas dari stdin dan menulisnya ke berkas sementar" #: ../zathura.c:535 msgid "Unsupported file type. Please install the necessary plugin." -msgstr "" +msgstr "Tipe berkas tidak didukung. Silakan memasang plugin yang dibutuhkan." #: ../zathura.c:545 msgid "Document does not contain any pages" -msgstr "" +msgstr "Dokumen tidak mempunyai laman apapun" diff --git a/po/it.po b/po/it.po index 215c000..aebfb7b 100644 --- a/po/it.po +++ b/po/it.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Italian (http://www.transifex.com/projects/p/zathura/language/" "it/)\n" diff --git a/po/pl.po b/po/pl.po index 83bc94d..37df1db 100644 --- a/po/pl.po +++ b/po/pl.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: p \n" "Language-Team: Polish (http://www.transifex.net/projects/p/zathura/language/" "pl/)\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index 452e0ea..8422d95 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: salmora8 \n" "Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/" "zathura/language/pt_BR/)\n" @@ -82,35 +82,35 @@ msgstr "Não há favoritos: %s" #: ../commands.c:162 msgid "Title" -msgstr "" +msgstr "Título" #: ../commands.c:163 msgid "Author" -msgstr "" +msgstr "Autor" #: ../commands.c:164 msgid "Subject" -msgstr "" +msgstr "Assunto" #: ../commands.c:165 msgid "Keywords" -msgstr "" +msgstr "Palavras-chave" #: ../commands.c:166 msgid "Creator" -msgstr "" +msgstr "Criador" #: ../commands.c:167 msgid "Producer" -msgstr "" +msgstr "Produtor" #: ../commands.c:168 msgid "Creation date" -msgstr "" +msgstr "Data de criação" #: ../commands.c:169 msgid "Modification date" -msgstr "" +msgstr "Data de modificação" #: ../commands.c:174 ../commands.c:196 msgid "No information available." @@ -263,8 +263,7 @@ msgstr "Recolorir páginas" #: ../config.c:169 msgid "When recoloring keep original hue and adjust lightness only" -msgstr "" -"Quando recolorir, manter tonalidade original e ajustar somente a luminosidade" +msgstr "Quando recolorir, manter tonalidade original e ajustar somente a luminosidade" #: ../config.c:171 msgid "Wrap scrolling" @@ -288,7 +287,7 @@ msgstr "Alinhe destino do link à esquerda" #: ../config.c:181 msgid "Let zoom be changed when following links" -msgstr "" +msgstr "Zoom será mudado quando seguir os links" #: ../config.c:183 msgid "Center result horizontally" @@ -348,7 +347,7 @@ msgstr "Ativar suporte synctex" #: ../config.c:210 msgid "The clipboard into which mouse-selected data will be written" -msgstr "" +msgstr "A área de transferência em que o dados selecionados com o mouse vão ser escritos" #. define default inputbar commands #: ../config.c:369 @@ -507,12 +506,11 @@ msgstr "[Sem nome]" #: ../zathura.c:486 msgid "Could not read file from stdin and write it to a temporary file." -msgstr "" +msgstr "Não foi possível ler o arquivo a partir de stdin e gravá-lo em um arquivo temporário." #: ../zathura.c:535 msgid "Unsupported file type. Please install the necessary plugin." -msgstr "" -"Formato de arquivo não suportado. Por favor, instale o plugin necessário." +msgstr "Formato de arquivo não suportado. Por favor, instale o plugin necessário." #: ../zathura.c:545 msgid "Document does not contain any pages" diff --git a/po/ru.po b/po/ru.po index 6c62284..5eaf34b 100644 --- a/po/ru.po +++ b/po/ru.po @@ -5,16 +5,17 @@ # AlexanderR , 2013 # Alissa , 2013 # Mikhail Krutov <>, 2012 +# vp1981 , 2013 msgid "" msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" -"Last-Translator: Sebastian Ramacher \n" +"PO-Revision-Date: 2013-12-16 13:11+0000\n" "Language-Team: Russian (http://www.transifex.com/projects/p/zathura/language/" "ru/)\n" "Language: ru\n" +"Last-Translator: vp1981 \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -24,12 +25,12 @@ msgstr "" #: ../callbacks.c:297 #, c-format msgid "Invalid input '%s' given." -msgstr "Неправильный ввод: %s" +msgstr "Неправильный ввод: %s." #: ../callbacks.c:333 #, c-format msgid "Invalid index '%s' given." -msgstr "Получен неверный индекс %s" +msgstr "Получен неверный индекс: %s." #: ../callbacks.c:546 #, c-format @@ -41,11 +42,11 @@ msgstr "Выделенный текст скопирован в буфер: %s" #: ../commands.c:540 ../shortcuts.c:403 ../shortcuts.c:1163 #: ../shortcuts.c:1192 msgid "No document opened." -msgstr "Документ не открыт" +msgstr "Нет открытых документов." #: ../commands.c:42 ../commands.c:82 ../commands.c:109 ../commands.c:424 msgid "Invalid number of arguments given." -msgstr "Неверное число аргументов" +msgstr "Указано неверное число аргументов." #: ../commands.c:53 #, c-format @@ -55,7 +56,7 @@ msgstr "Не могу создать закладку %s" #: ../commands.c:55 #, c-format msgid "Could not create bookmark: %s" -msgstr "Не могу создать закладку %s" +msgstr "Не удалось создать закладку %s" #: ../commands.c:60 #, c-format @@ -84,93 +85,93 @@ msgstr "Закладки %s не существует" #: ../commands.c:162 msgid "Title" -msgstr "" +msgstr "Заголовок" #: ../commands.c:163 msgid "Author" -msgstr "" +msgstr "Автор" #: ../commands.c:164 msgid "Subject" -msgstr "" +msgstr "Тема" #: ../commands.c:165 msgid "Keywords" -msgstr "" +msgstr "Ключевые слова" #: ../commands.c:166 msgid "Creator" -msgstr "" +msgstr "Создатель" #: ../commands.c:167 msgid "Producer" -msgstr "" +msgstr "Производитель" #: ../commands.c:168 msgid "Creation date" -msgstr "" +msgstr "Время создания" #: ../commands.c:169 msgid "Modification date" -msgstr "" +msgstr "Время изменения" #: ../commands.c:174 ../commands.c:196 msgid "No information available." -msgstr "Нет доступной информации" +msgstr "Нет доступной информации." #: ../commands.c:234 msgid "Too many arguments." -msgstr "Слишком много аргументов" +msgstr "Слишком много аргументов." #: ../commands.c:245 msgid "No arguments given." -msgstr "Отсутствуют аргументы" +msgstr "Отсутствуют аргументы." #: ../commands.c:304 ../commands.c:330 msgid "Document saved." -msgstr "Документ сохранён" +msgstr "Документ сохранён." #: ../commands.c:306 ../commands.c:332 msgid "Failed to save document." -msgstr "Не удалось сохранить документ" +msgstr "Не удалось сохранить документ." #: ../commands.c:309 ../commands.c:335 msgid "Invalid number of arguments." -msgstr "Неверное количество аргументов" +msgstr "Неверное количество аргументов." #: ../commands.c:443 #, c-format msgid "Couldn't write attachment '%s' to '%s'." -msgstr "Не могу сохранить приложенный файл %s в %s" +msgstr "Не удалось сохранить приложенный файл «%s» в «%s»." #: ../commands.c:445 #, c-format msgid "Wrote attachment '%s' to '%s'." -msgstr "Файл %s сохранён в %s" +msgstr "Файл «%s» сохранён в «%s»." #: ../commands.c:489 #, c-format msgid "Wrote image '%s' to '%s'." -msgstr "Файл '%s' сохранён в '%s'" +msgstr "Изображение «%s» сохранено в «%s»." #: ../commands.c:491 #, c-format msgid "Couldn't write image '%s' to '%s'." -msgstr "Не могу сохранить приложенный файл %s в %s" +msgstr "Не удалось записать изображение «%s» в «%s»." #: ../commands.c:498 #, c-format msgid "Unknown image '%s'." -msgstr "Неизвестный файл %s." +msgstr "Неизвестное изображение «%s»." #: ../commands.c:502 #, c-format msgid "Unknown attachment or image '%s'." -msgstr "Неизвестное вложение %s." +msgstr "Неизвестное вложение или изображение «%s»." #: ../commands.c:553 msgid "Argument must be a number." -msgstr "Аргумент должен быть числом" +msgstr "Аргумент должен быть числом." #: ../completion.c:250 #, c-format @@ -179,7 +180,7 @@ msgstr "Страница %d" #: ../completion.c:293 msgid "Attachments" -msgstr "Прикепленные файлы" +msgstr "Прикреплённые файлы" #. add images #: ../completion.c:324 @@ -205,7 +206,7 @@ msgstr "Количество страниц в ряд" #: ../config.c:139 msgid "Column of the first page" -msgstr "" +msgstr "Столбец первой страницы" #: ../config.c:141 msgid "Scroll step" @@ -217,7 +218,7 @@ msgstr "Шаг горизонтальной прокрутки" #: ../config.c:145 msgid "Full page scroll overlap" -msgstr "" +msgstr "Перекрытие страниц при прокрутке" #: ../config.c:147 msgid "Zoom minimum" @@ -229,7 +230,7 @@ msgstr "Максимальное увеличение" #: ../config.c:151 msgid "Maximum number of pages to keep in the cache" -msgstr "" +msgstr "Максимальное количество страниц хранимых в кэше" #: ../config.c:153 msgid "Number of positions to remember in the jumplist" @@ -265,7 +266,7 @@ msgstr "Перекрасить страницы" #: ../config.c:169 msgid "When recoloring keep original hue and adjust lightness only" -msgstr "" +msgstr "При перекраске сохранять оттенок и изменять только осветление" #: ../config.c:171 msgid "Wrap scrolling" @@ -273,7 +274,7 @@ msgstr "Плавная прокрутка" #: ../config.c:173 msgid "Page aware scrolling" -msgstr "" +msgstr "Постраничная прокрутка" #: ../config.c:175 msgid "Advance number of pages per row" @@ -281,15 +282,15 @@ msgstr "Увеличить количество страниц в ряду" #: ../config.c:177 msgid "Horizontally centered zoom" -msgstr "" +msgstr "Центрировать увеличение по горизонтали" #: ../config.c:179 msgid "Align link target to the left" -msgstr "" +msgstr "Выровнять цель ссылки по левому краю" #: ../config.c:181 msgid "Let zoom be changed when following links" -msgstr "" +msgstr "Разрешить изменять размер при следовании по ссылкам" #: ../config.c:183 msgid "Center result horizontally" @@ -301,19 +302,19 @@ msgstr "Прозрачность подсветки" #: ../config.c:187 msgid "Render 'Loading ...'" -msgstr "Рендер 'Загружается ...'" +msgstr "Рендер «Загружается ...»" #: ../config.c:188 msgid "Adjust to when opening file" -msgstr "" +msgstr "Подогнать размеры при открытии документа" #: ../config.c:190 msgid "Show hidden files and directories" -msgstr "Показывать скрытые файлы и директории" +msgstr "Показывать скрытые файлы и каталоги" #: ../config.c:192 msgid "Show directories" -msgstr "Показывать директории" +msgstr "Показывать каталоги" #: ../config.c:194 msgid "Always open on first page" @@ -325,7 +326,7 @@ msgstr "Подсветить результаты поиска" #: ../config.c:198 msgid "Enable incremental search" -msgstr "Инкрементальный поиск" +msgstr "Включить инкрементальный поиск" #: ../config.c:200 msgid "Clear search results on abort" @@ -337,7 +338,7 @@ msgstr "Использовать базовое имя файла в загол #: ../config.c:204 msgid "Display the page number in the window title" -msgstr "Отображать номер страницы в заголовке" +msgstr "Показывать номер страницы в заголовке" #: ../config.c:206 msgid "Use basename of the file in the statusbar" @@ -345,11 +346,11 @@ msgstr "Использовать базовое имя файла в строк #: ../config.c:208 ../main.c:67 msgid "Enable synctex support" -msgstr "" +msgstr "Включить поддержку synctex" #: ../config.c:210 msgid "The clipboard into which mouse-selected data will be written" -msgstr "" +msgstr "Буфер для записи данных из области выделенных мышкой" #. define default inputbar commands #: ../config.c:369 @@ -398,7 +399,7 @@ msgstr "Сохранить документ" #: ../config.c:380 msgid "Save document (and force overwriting)" -msgstr "Сохранить документ (с перезапиьсю)" +msgstr "Сохранить документ (с перезаписью)" #: ../config.c:381 msgid "Save attachments" @@ -444,7 +445,7 @@ msgstr "Ссылка: %s" #: ../links.c:228 msgid "Link: Invalid" -msgstr "" +msgstr "Ссылка: неправильная" #: ../main.c:58 msgid "Reparents to window specified by xid" @@ -452,19 +453,19 @@ msgstr "Сменить материнское окно на окно, указа #: ../main.c:59 msgid "Path to the config directory" -msgstr "Путь к директории конфига" +msgstr "Путь к каталогу с настройкой" #: ../main.c:60 msgid "Path to the data directory" -msgstr "Путь к директории с данными" +msgstr "Путь к каталогу с данными" #: ../main.c:61 msgid "Path to the directories containing plugins" -msgstr "Путь к директории с плагинами" +msgstr "Путь к каталогу с плагинами" #: ../main.c:62 msgid "Fork into the background" -msgstr "Уйти в бэкграунд" +msgstr "Запустить в фоне" #: ../main.c:63 msgid "Document password" @@ -476,7 +477,7 @@ msgstr "Перейти к странице номер" #: ../main.c:65 msgid "Log level (debug, info, warning, error)" -msgstr "Уровень логирования (debug,info,warning,error)" +msgstr "Уровень журналирования (debug, info, warning, error)" #: ../main.c:66 msgid "Print version information" @@ -484,7 +485,7 @@ msgstr "Показать информацию о файле" #: ../main.c:68 msgid "Synctex editor (forwarded to the synctex command)" -msgstr "" +msgstr "Редактор для synctex (передаётся далее программе synctex)" #: ../page-widget.c:526 msgid "Loading..." @@ -496,19 +497,19 @@ msgstr "Скопировать изображение" #: ../page-widget.c:846 msgid "Save image as" -msgstr "Созранить как" +msgstr "Сохранить изображение как" #: ../shortcuts.c:1076 msgid "This document does not contain any index" -msgstr "В документе нету индекса" +msgstr "В документе нет индекса" #: ../zathura.c:213 ../zathura.c:959 msgid "[No name]" -msgstr "[No name]" +msgstr "[Без названия]" #: ../zathura.c:486 msgid "Could not read file from stdin and write it to a temporary file." -msgstr "" +msgstr "Не удалось прочитать файл со стандартного входа и записать его во временный файл." #: ../zathura.c:535 msgid "Unsupported file type. Please install the necessary plugin." @@ -516,4 +517,4 @@ msgstr "Тип файла не поддерживается. Установит #: ../zathura.c:545 msgid "Document does not contain any pages" -msgstr "Документ не содержит ни одной страницы" +msgstr "В документе нет страниц" diff --git a/po/ta_IN.po b/po/ta_IN.po index c0aa749..e130d3b 100644 --- a/po/ta_IN.po +++ b/po/ta_IN.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: mankand007 \n" "Language-Team: Tamil (India) (http://www.transifex.net/projects/p/zathura/" "language/ta_IN/)\n" diff --git a/po/tr.po b/po/tr.po index 81d20aa..18f3384 100644 --- a/po/tr.po +++ b/po/tr.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: hsngrms \n" "Language-Team: Turkish (http://www.transifex.net/projects/p/zathura/language/" "tr/)\n" diff --git a/po/uk_UA.po b/po/uk_UA.po index bf63e17..04c8e2a 100644 --- a/po/uk_UA.po +++ b/po/uk_UA.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: zathura\n" "Report-Msgid-Bugs-To: http://bugs.pwmt.org\n" "POT-Creation-Date: 2013-11-04 19:57+0100\n" -"PO-Revision-Date: 2013-11-01 13:12+0000\n" +"PO-Revision-Date: 2013-11-20 09:50+0000\n" "Last-Translator: Sebastian Ramacher \n" "Language-Team: Ukrainian (Ukraine) (http://www.transifex.com/projects/p/" "zathura/language/uk_UA/)\n" From f9ef7598a4690715dbab5764df4ffb0ef82179d2 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 14:57:48 +0100 Subject: [PATCH 49/61] Add syntex-dbus-service setting to en/disable D-Bus service for synctex --- config.c | 2 ++ main.c | 2 +- zathura.c | 8 ++++++-- zathurarc.5.rst | 9 ++++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 76ca03e..32a8326 100644 --- a/config.c +++ b/config.c @@ -205,6 +205,8 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL); + bool_value = true; + girara_setting_add(gsession, "synctex-dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service for synctex forward synchronization support"), NULL, NULL); string_value = "primary"; girara_setting_add(gsession, "selection-clipboard", string_value, STRING, false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL); diff --git a/main.c b/main.c index 2f0c52a..692f1d2 100644 --- a/main.c +++ b/main.c @@ -97,7 +97,7 @@ main(int argc, char* argv[]) if (synctex_fwd != NULL) { if (argc != 2) { - girara_error("Too many arguments or missing filename while running with --syntex-forward"); + girara_error("Too many arguments or missing filename while running with --synctex-forward"); return -1; } diff --git a/zathura.c b/zathura.c index d62ec2e..67b7a5d 100644 --- a/zathura.c +++ b/zathura.c @@ -805,8 +805,12 @@ document_open(zathura_t* zathura, const char* path, const char* password, position_set(zathura, file_info.position_x, file_info.position_y); } - /* Start D-Bus */ - zathura->synctex.dbus = zathura_synctex_dbus_new(zathura); + /* Start D-Bus service for synctex forward synchronization */ + bool synctex_dbus = true; + girara_setting_get(zathura->ui.session, "synctex-dbus-service", &synctex_dbus); + if (synctex_dbus == true) { + zathura->synctex.dbus = zathura_synctex_dbus_new(zathura); + } return true; diff --git a/zathurarc.5.rst b/zathurarc.5.rst index 54e8edd..deb826f 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -752,7 +752,7 @@ zoom-center ^^^^^^^^^^^ En/Disables horizontally centered zooming -* Value type: Bool +* Value type: Boolean * Default value: False zoom-max @@ -787,6 +787,13 @@ middle mouse button, or the Shift-Insert key combination. * Value type: String * Default value: primary +syntex-dbus-service +^^^^^^^^^^^^^^^^^^^ +En/disables the D-Bus service required for synctex forward synchronization. + +* Value type: Boolean +* Default value: true + SEE ALSO ======== From 9be3600440a0bc627c9e4c226fe4e08ed727c8f0 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 17:23:31 +0100 Subject: [PATCH 50/61] A typo Signed-off-by: Sebastian Ramacher --- zathurarc.5.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/zathurarc.5.rst b/zathurarc.5.rst index deb826f..8f2ff5d 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -708,21 +708,22 @@ Defines if scrolling by half or full pages stops at page boundaries. link-zoom ^^^^^^^^^ -En/Disables the hability of changing zoom when following links. +En/Disables the ability of changing zoom when following links. * Value type: Boolean * Default value: true link-hadjust ^^^^^^^^^^^^ -En/Disables aligning to the left internal link targets, for example from the index +En/Disables aligning to the left internal link targets, for example from the +index. * Value type: Boolean * Default value: true search-hadjust ^^^^^^^^^^^^^^ -En/Disables horizontally centered search results +En/Disables horizontally centered search results. * Value type: Boolean * Default value: true @@ -750,21 +751,21 @@ Use basename of the file in the statusbar. zoom-center ^^^^^^^^^^^ -En/Disables horizontally centered zooming +En/Disables horizontally centered zooming. * Value type: Boolean * Default value: False zoom-max ^^^^^^^^ -Defines the maximum percentage that the zoom level can be +Defines the maximum percentage that the zoom level can be. * Value type: Integer * Default value: 1000 zoom-min ^^^^^^^^ -Defines the minimum percentage that the zoom level can be +Defines the minimum percentage that the zoom level can be. * Value type: Integer * Default value: 10 @@ -789,7 +790,7 @@ middle mouse button, or the Shift-Insert key combination. syntex-dbus-service ^^^^^^^^^^^^^^^^^^^ -En/disables the D-Bus service required for synctex forward synchronization. +En/Disables the D-Bus service required for synctex forward synchronization. * Value type: Boolean * Default value: true From fcbc9cf8838898bdf91bd281e316b21943a0b5fd Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 21:54:23 +0100 Subject: [PATCH 51/61] Move the deprecated stuff to the end Signed-off-by: Sebastian Ramacher --- glib-compat.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/glib-compat.h b/glib-compat.h index c76ccca..3e98dae 100644 --- a/glib-compat.h +++ b/glib-compat.h @@ -5,19 +5,20 @@ #include -/* GStaticMutex is deprecated starting with glib 2.32 */ -#if !GLIB_CHECK_VERSION(2, 31, 0) -#define mutex GStaticMutex -#define mutex_init(m) g_static_mutex_init((m)) -#define mutex_lock(m) g_static_mutex_lock((m)) -#define mutex_unlock(m) g_static_mutex_unlock((m)) -#define mutex_free(m) g_static_mutex_free((m)) -#else +/* GStaticMutex is deprecated starting with glib 2.32 and got replaced with + * GMutex */ +#if GLIB_CHECK_VERSION(2, 32, 0) #define mutex GMutex #define mutex_init(m) g_mutex_init((m)) #define mutex_lock(m) g_mutex_lock((m)) #define mutex_unlock(m) g_mutex_unlock((m)) #define mutex_free(m) g_mutex_clear((m)) +#else +#define mutex GStaticMutex +#define mutex_init(m) g_static_mutex_init((m)) +#define mutex_lock(m) g_static_mutex_lock((m)) +#define mutex_unlock(m) g_static_mutex_unlock((m)) +#define mutex_free(m) g_static_mutex_free((m)) #endif #endif From 3a0fe29336959adfa30d96eeb3e222ab68ab0841 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 22:06:44 +0100 Subject: [PATCH 52/61] Remove unused execute_command Signed-off-by: Sebastian Ramacher --- utils.c | 83 ++------------------------------------------------------- 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/utils.c b/utils.c index cd40ec6..f2cdca9 100644 --- a/utils.c +++ b/utils.c @@ -9,9 +9,10 @@ #include #include #include +#include #include -#include #include +#include #include #include "links.h" @@ -22,10 +23,6 @@ #include "page.h" #include "plugin.h" -#include - -#define BLOCK_SIZE 64 - const char* file_get_extension(const char* path) { @@ -59,82 +56,6 @@ file_valid_extension(zathura_t* zathura, const char* path) return (plugin == NULL) ? false : true; } -bool -execute_command(char* const argv[], char** output) -{ - if (!output) { - return false; - } - - int p[2]; - if (pipe(p)) { - return -1; - } - - pid_t pid = fork(); - - if (pid == -1) { // failure - return false; - } else if (pid == 0) { // child - dup2(p[1], 1); - close(p[0]); - - if (execvp(argv[0], argv) == -1) { - return false; - } - } else { // parent - dup2(p[0], 0); - close(p[1]); - - /* read output */ - unsigned int bc = BLOCK_SIZE; - unsigned int i = 0; - char* buffer = malloc(sizeof(char) * bc); - *output = NULL; - - if (!buffer) { - close(p[0]); - return false; - } - - char c; - while (1 == read(p[0], &c, 1)) { - buffer[i++] = c; - - if (i == bc) { - bc += BLOCK_SIZE; - char* tmp = realloc(buffer, sizeof(char) * bc); - - if (!tmp) { - free(buffer); - close(p[0]); - return false; - } - - buffer = tmp; - } - } - - char* tmp = realloc(buffer, sizeof(char) * (bc + 1)); - if (!tmp) { - free(buffer); - close(p[0]); - return false; - } - - buffer = tmp; - buffer[i] = '\0'; - - *output = buffer; - - /* wait for child to terminate */ - waitpid(pid, NULL, 0); - close(p[0]); - } - - return true; -} - void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree) From 6599b921a38b077ff3badd9aec4fdcf502e7bb85 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 22:21:50 +0100 Subject: [PATCH 53/61] Remove more unused functions Signed-off-by: Sebastian Ramacher --- utils.c | 26 -------------------------- utils.h | 28 ---------------------------- 2 files changed, 54 deletions(-) diff --git a/utils.c b/utils.c index f2cdca9..7623985 100644 --- a/utils.c +++ b/utils.c @@ -23,21 +23,6 @@ #include "page.h" #include "plugin.h" -const char* -file_get_extension(const char* path) -{ - if (path == NULL) { - return NULL; - } - - const char* res = strrchr(path, '.'); - if (res == NULL) { - return NULL; - } - - return res + 1; -} - bool file_valid_extension(zathura_t* zathura, const char* path) { @@ -87,17 +72,6 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent, GIRARA_LIST_FOREACH_END(list, gchar*, iter, name); } -void -page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset) -{ - g_return_if_fail(page != NULL); - g_return_if_fail(offset != NULL); - GtkWidget* widget = zathura_page_get_widget(zathura, page); - - g_return_if_fail(gtk_widget_translate_coordinates(widget, - zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true); -} - zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, double height, double width) { diff --git a/utils.h b/utils.h index 20da943..c061384 100644 --- a/utils.h +++ b/utils.h @@ -17,14 +17,6 @@ typedef struct page_offset_s int y; } page_offset_t; -/** - * Returns the file extension of a path - * - * @param path Path to the file - * @return The file extension or NULL - */ -const char* file_get_extension(const char* path); - /** * This function checks if the file has a valid extension. A extension is * evaluated as valid if it matches a supported filetype. @@ -35,15 +27,6 @@ const char* file_get_extension(const char* path); */ bool file_valid_extension(zathura_t* zathura, const char* path); -/** - * Executes a system command and saves its output into output - * - * @param argv The command - * @param output Pointer where the output will be saved - * @return true if no error occured, otherwise false - */ -bool execute_command(char* const argv[], char** output); - /** * Generates the document index based upon the list retreived from the document * object. @@ -54,17 +37,6 @@ bool execute_command(char* const argv[], char** output); */ void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree); -/** - * Calculates the offset of the page to the top of the viewing area as - * well as to the left side of it. The result has to be freed. - * - * @param zathura Zathura session - * @param page The Page - * @param offset Applied offset - * @return The calculated offset or NULL if an error occured - */ -void page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset); - /** * Rotate a rectangle by 0, 90, 180 or 270 degree * From dcc2e9f73669d373ee391dc5322964a5dbe962e7 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 22:29:30 +0100 Subject: [PATCH 54/61] Remove obsolete tests --- tests/test_utils.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/tests/test_utils.c b/tests/test_utils.c index a36b3a9..541707e 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -4,21 +4,6 @@ #include "../utils.h" -START_TEST(test_file_get_extension_null) { - fail_unless(file_get_extension(NULL) == NULL, NULL); -} END_TEST - -START_TEST(test_file_get_extension_none) { - const char* path = "test"; - fail_unless(file_get_extension(path) == NULL, NULL); -} END_TEST - -START_TEST(test_file_get_extension_single) { - const char* path = "test.pdf"; - const char* extension = file_get_extension(path); - fail_unless(strcmp(extension, "pdf") == 0, NULL); -} END_TEST - START_TEST(test_file_valid_extension_null) { fail_unless(file_valid_extension(NULL, NULL) == false, NULL); fail_unless(file_valid_extension((void*) 0xDEAD, NULL) == false, NULL); @@ -62,13 +47,6 @@ Suite* suite_utils() TCase* tcase = NULL; Suite* suite = suite_create("Utils"); - /* file exists */ - tcase = tcase_create("file_get_extension"); - tcase_add_test(tcase, test_file_get_extension_null); - tcase_add_test(tcase, test_file_get_extension_none); - tcase_add_test(tcase, test_file_get_extension_single); - suite_add_tcase(suite, tcase); - /* file valid extension */ tcase = tcase_create("file_valid_extension"); tcase_add_test(tcase, test_file_valid_extension_null); From 250c575f444923ff11f3c68578aeab15ec4d5cf4 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 23:05:43 +0100 Subject: [PATCH 55/61] CS Signed-off-by: Sebastian Ramacher --- utils.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/utils.c b/utils.c index 7623985..c30e4ef 100644 --- a/utils.c +++ b/utils.c @@ -244,26 +244,26 @@ replace_substring(const char* string, const char* old, const char* new) GdkAtom* get_selection(zathura_t* zathura) { - g_return_val_if_fail(zathura != NULL, NULL); + g_return_val_if_fail(zathura != NULL, NULL); - char* value; - girara_setting_get(zathura->ui.session, "selection-clipboard", &value); + char* value; + girara_setting_get(zathura->ui.session, "selection-clipboard", &value); - GdkAtom* selection = g_malloc(sizeof(GdkAtom)); - - if (strcmp(value, "primary") == 0) { - *selection = GDK_SELECTION_PRIMARY; - } else if (strcmp(value, "clipboard") == 0) { - *selection = GDK_SELECTION_CLIPBOARD; - } else { - girara_error("Invalid value for the selection-clipboard setting"); - g_free(value); - g_free(selection); - - return NULL; - } + GdkAtom* selection = g_malloc(sizeof(GdkAtom)); + if (strcmp(value, "primary") == 0) { + *selection = GDK_SELECTION_PRIMARY; + } else if (strcmp(value, "clipboard") == 0) { + *selection = GDK_SELECTION_CLIPBOARD; + } else { + girara_error("Invalid value for the selection-clipboard setting"); g_free(value); + g_free(selection); - return selection; + return NULL; + } + + g_free(value); + + return selection; } From ecf090b9b10d507026c1f9ada827bdac3837ed96 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 5 Jan 2014 23:40:37 +0100 Subject: [PATCH 56/61] Split guess_type methods into separate functions Also don't try to run file if we have libmagic available. Signed-off-by: Sebastian Ramacher --- document.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/document.c b/document.c index ffb0950..67cd26c 100644 --- a/document.c +++ b/document.c @@ -665,11 +665,9 @@ zathura_document_get_information(zathura_document_t* document, zathura_error_t* return result; } -static const gchar* -guess_type(const char* path) -{ - const gchar* content_type = NULL; #ifdef WITH_MAGIC +static const char* +guess_type_magic(const char* path) { const char* mime_type = NULL; /* creat magic cookie */ @@ -698,22 +696,30 @@ guess_type(const char* path) girara_debug("failed guessing filetype: %s", magic_error(magic)); goto cleanup; } + /* dup so we own the memory */ + mime_type = g_strdup(mime_type); girara_debug("magic detected filetype: %s", mime_type); - content_type = g_strdup(mime_type); cleanup: if (magic != NULL) { magic_close(magic); } - if (content_type != NULL) { - return content_type; - } - /* else fallback to g_content_type_guess method */ -#endif /*WITH_MAGIC*/ + return mime_type; +} +#else +static const char* +guess_type_magic(const char* UNUSED(path)) { + return NULL; +} +#endif + +static const char* +guess_type_glib(const char* path) +{ gboolean uncertain = FALSE; - content_type = g_content_type_guess(path, NULL, 0, &uncertain); + const char* content_type = g_content_type_guess(path, NULL, 0, &uncertain); if (content_type == NULL) { girara_debug("g_content_type failed\n"); } else { @@ -755,8 +761,26 @@ cleanup: } g_free((void*)content_type); - content_type = NULL; + return NULL; +} +static const char* +guess_type(const char* path) +{ + /* try libmagic first */ + const char* content_type = guess_type_magic(path); + if (content_type != NULL) { + return content_type; + } + /* else fallback to g_content_type_guess method */ + content_type = guess_type_glib(path); + if (content_type != NULL) { + return content_type; + } +#ifdef WITH_MAGIC + return NULL; +#else + /* and if libmagic is not available, try file as last resort */ girara_debug("falling back to file"); GString* command = g_string_new("file -b --mime-type "); @@ -784,6 +808,7 @@ cleanup: g_strdelimit(out, "\n\r", '\0'); return out; +#endif } zathura_plugin_t* From 5d2666daf5b51d7477df50bb13e10dd21e55258f Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 6 Jan 2014 01:18:56 +0100 Subject: [PATCH 57/61] Move file based detection into separate function --- document.c | 68 +++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/document.c b/document.c index 67cd26c..f7e7f22 100644 --- a/document.c +++ b/document.c @@ -708,11 +708,47 @@ cleanup: return mime_type; } + +static const char* +guess_type_file(const char* UNUSED(path)) +{ + return NULL; +} #else static const char* guess_type_magic(const char* UNUSED(path)) { return NULL; } + +static const char* +guess_type_file(const char* path) +{ + GString* command = g_string_new("file -b --mime-type "); + char* tmp = g_shell_quote(path); + + g_string_append(command, tmp); + g_free(tmp); + + GError* error = NULL; + char* out = NULL; + int ret = 0; + g_spawn_command_line_sync(command->str, &out, NULL, &ret, &error); + g_string_free(command, TRUE); + if (error != NULL) { + girara_warning("failed to execute command: %s", error->message); + g_error_free(error); + g_free(out); + return NULL; + } + if (WEXITSTATUS(ret) != 0) { + girara_warning("file failed with error code: %d", WEXITSTATUS(ret)); + g_free(out); + return NULL; + } + + g_strdelimit(out, "\n\r", '\0'); + return out; +} #endif static const char* @@ -777,38 +813,8 @@ guess_type(const char* path) if (content_type != NULL) { return content_type; } -#ifdef WITH_MAGIC - return NULL; -#else /* and if libmagic is not available, try file as last resort */ - girara_debug("falling back to file"); - - GString* command = g_string_new("file -b --mime-type "); - char* tmp = g_shell_quote(path); - - g_string_append(command, tmp); - g_free(tmp); - - GError* error = NULL; - char* out = NULL; - int ret = 0; - g_spawn_command_line_sync(command->str, &out, NULL, &ret, &error); - g_string_free(command, TRUE); - if (error != NULL) { - girara_warning("failed to execute command: %s", error->message); - g_error_free(error); - g_free(out); - return NULL; - } - if (WEXITSTATUS(ret) != 0) { - girara_warning("file failed with error code: %d", WEXITSTATUS(ret)); - g_free(out); - return NULL; - } - - g_strdelimit(out, "\n\r", '\0'); - return out; -#endif + return guess_type_file(path); } zathura_plugin_t* From 7b9fd65ce6a28ccf51a13b2da0605b814e632073 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 6 Jan 2014 15:34:03 +0100 Subject: [PATCH 58/61] A const Signed-off-by: Sebastian Ramacher --- config.c | 2 +- config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index 32a8326..6c12ae9 100644 --- a/config.c +++ b/config.c @@ -454,7 +454,7 @@ config_load_default(zathura_t* zathura) } void -config_load_file(zathura_t* zathura, char* path) +config_load_file(zathura_t* zathura, const char* path) { if (zathura == NULL || path == NULL) { return; diff --git a/config.h b/config.h index 4587468..1d107c6 100644 --- a/config.h +++ b/config.h @@ -21,6 +21,6 @@ void config_load_default(zathura_t* zathura); * @param zathura The zathura session * @param path Path to the configuration file */ -void config_load_file(zathura_t* zathura, char* path); +void config_load_file(zathura_t* zathura, const char* path); #endif // CONFIG_H From 4350053956dd9152e6008b9dbf7d9c7a66dc46f7 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 6 Jan 2014 15:34:17 +0100 Subject: [PATCH 59/61] Some clean up Signed-off-by: Sebastian Ramacher --- config.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index 6c12ae9..aea58d1 100644 --- a/config.c +++ b/config.c @@ -109,7 +109,6 @@ config_load_default(zathura_t* zathura) int int_value = 0; float float_value = 0; bool bool_value = false; - bool inc_search = true; char* string_value = NULL; girara_session_t* gsession = zathura->ui.session; @@ -193,8 +192,9 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "open-first-page", &bool_value, BOOLEAN, false, _("Always open on first page"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "nohlsearch", &bool_value, BOOLEAN, false, _("Highlight search results"), cb_nohlsearch_changed, NULL); - inc_search = false; - girara_setting_add(gsession, "incremental-search", &inc_search, BOOLEAN, false, _("Enable incremental search"), cb_incsearch_changed, NULL); +#define INCREMENTAL_SEARCH false + bool_value = INCREMENTAL_SEARCH; + girara_setting_add(gsession, "incremental-search", &bool_value, BOOLEAN, false, _("Enable incremental search"), cb_incsearch_changed, NULL); bool_value = true; girara_setting_add(gsession, "abort-clear-search", &bool_value, BOOLEAN, false, _("Clear search results on abort"), NULL, NULL); bool_value = false; @@ -389,8 +389,8 @@ config_load_default(zathura_t* zathura) girara_inputbar_command_add(gsession, "hlsearch", NULL, cmd_hlsearch, NULL, _("Highlight current search results")); girara_inputbar_command_add(gsession, "version", NULL, cmd_version, NULL, _("Show version information")); - girara_special_command_add(gsession, '/', cmd_search, inc_search, FORWARD, NULL); - girara_special_command_add(gsession, '?', cmd_search, inc_search, BACKWARD, NULL); + girara_special_command_add(gsession, '/', cmd_search, INCREMENTAL_SEARCH, FORWARD, NULL); + girara_special_command_add(gsession, '?', cmd_search, INCREMENTAL_SEARCH, BACKWARD, NULL); /* add shortcut mappings */ girara_shortcut_mapping_add(gsession, "abort", sc_abort); From 68b665a49d9749c37d03394c02c385666f536753 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 6 Jan 2014 16:02:58 +0100 Subject: [PATCH 60/61] Move config file loading to config.c --- config.c | 26 ++++++++++++++++++++++---- config.h | 5 +---- print.c | 4 ++-- zathura.c | 21 +-------------------- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/config.c b/config.c index aea58d1..e1faa6c 100644 --- a/config.c +++ b/config.c @@ -15,8 +15,12 @@ #include #include #include +#include #include +#define GLOBAL_RC "/etc/zathurarc" +#define ZATHURA_RC "zathurarc" + static void cb_jumplist_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data)) @@ -454,11 +458,25 @@ config_load_default(zathura_t* zathura) } void -config_load_file(zathura_t* zathura, const char* path) +config_load_files(zathura_t* zathura) { - if (zathura == NULL || path == NULL) { - return; + /* load global configuration files */ + char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS); + girara_list_t* config_dirs = girara_split_path_array(config_path); + ssize_t size = girara_list_size(config_dirs) - 1; + for (; size >= 0; --size) { + const char* dir = girara_list_nth(config_dirs, size); + char* file = g_build_filename(dir, ZATHURA_RC, NULL); + girara_config_parse(zathura->ui.session, file); + g_free(file); } + girara_list_free(config_dirs); + g_free(config_path); - girara_config_parse(zathura->ui.session, path); + girara_config_parse(zathura->ui.session, GLOBAL_RC); + + /* load local configuration files */ + char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL); + girara_config_parse(zathura->ui.session, configuration_file); + g_free(configuration_file); } diff --git a/config.h b/config.h index 1d107c6..833cfd5 100644 --- a/config.h +++ b/config.h @@ -3,9 +3,6 @@ #ifndef CONFIG_H #define CONFIG_H -#define GLOBAL_RC "/etc/zathurarc" -#define ZATHURA_RC "zathurarc" - #include "zathura.h" /** @@ -21,6 +18,6 @@ void config_load_default(zathura_t* zathura); * @param zathura The zathura session * @param path Path to the configuration file */ -void config_load_file(zathura_t* zathura, const char* path); +void config_load_files(zathura_t* zathura); #endif // CONFIG_H diff --git a/print.c b/print.c index 454512e..d1d6e3d 100644 --- a/print.c +++ b/print.c @@ -168,8 +168,8 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext* static void cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation), - GtkPrintContext* UNUSED(context), gint page_number, GtkPageSetup* setup, - zathura_t* zathura) + GtkPrintContext* UNUSED(context), gint page_number, + GtkPageSetup* setup, zathura_t* zathura) { if (zathura == NULL || zathura->document == NULL) { return; diff --git a/zathura.c b/zathura.c index 67b7a5d..dcfca92 100644 --- a/zathura.c +++ b/zathura.c @@ -101,26 +101,7 @@ zathura_init(zathura_t* zathura) /* configuration */ config_load_default(zathura); - - /* load global configuration files */ - char* config_path = girara_get_xdg_path(XDG_CONFIG_DIRS); - girara_list_t* config_dirs = girara_split_path_array(config_path); - ssize_t size = girara_list_size(config_dirs) - 1; - for (; size >= 0; --size) { - const char* dir = girara_list_nth(config_dirs, size); - char* file = g_build_filename(dir, ZATHURA_RC, NULL); - config_load_file(zathura, file); - g_free(file); - } - girara_list_free(config_dirs); - g_free(config_path); - - config_load_file(zathura, GLOBAL_RC); - - /* load local configuration files */ - char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL); - config_load_file(zathura, configuration_file); - g_free(configuration_file); + config_load_files(zathura); /* UI */ if (girara_session_init(zathura->ui.session, "zathura") == false) { From 40fe7cdd9e9035425b01267e53db2b89c5e19a77 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 7 Jan 2014 03:43:38 +0100 Subject: [PATCH 61/61] Some typos Signed-off-by: Sebastian Ramacher --- document.c | 4 ++-- print.c | 2 +- shortcuts.c | 2 +- utils.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/document.c b/document.c index f7e7f22..4667619 100644 --- a/document.c +++ b/document.c @@ -35,7 +35,7 @@ /** Read a most GT_MAX_READ bytes before falling back to file. */ static const size_t GT_MAX_READ = 1 << 16; -static const gchar* guess_type(const char* path); +static const char* guess_type(const char* path); /** * Document @@ -86,7 +86,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* return NULL; } - const gchar* content_type = guess_type(path); + const char* content_type = guess_type(path); if (content_type == NULL) { girara_error("Could not determine file type."); return NULL; diff --git a/print.c b/print.c index d1d6e3d..3ac1fd8 100644 --- a/print.c +++ b/print.c @@ -60,7 +60,7 @@ print(zathura_t* zathura) 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)); } else if (result == GTK_PRINT_OPERATION_RESULT_ERROR) { - girara_error("Error occured while printing progress"); + girara_error("Error pccurred while printing progress"); } g_object_unref(print_operation); diff --git a/shortcuts.c b/shortcuts.c index 23ea84e..91770ba 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -1287,7 +1287,7 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* zathura_document_set_adjust_mode(zathura->document, ZATHURA_ADJUST_NONE); - /* retreive zoom step value */ + /* retrieve zoom step value */ int value = 1; girara_setting_get(zathura->ui.session, "zoom-step", &value); diff --git a/utils.c b/utils.c index c30e4ef..382f3c4 100644 --- a/utils.c +++ b/utils.c @@ -210,7 +210,7 @@ replace_substring(const char* string, const char* old, const char* new) size_t old_len = strlen(old); size_t new_len = strlen(new); - /* count occurences */ + /* count occurrences */ unsigned int count = 0; unsigned int i = 0;