From 946fca66db38b02e8b206bfcce9c0c87123beb99 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 9 Feb 2012 01:25:17 +0100 Subject: [PATCH 01/55] update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cf9af95..fa31ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ zathura.pc *.gcno *.gcda gcov/ +*.swp From 900516d1f1ac6619ef3323e7a22882c5163c9d84 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 9 Feb 2012 02:58:53 +0100 Subject: [PATCH 02/55] Update documentation --- document.h | 2 +- utils.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/document.h b/document.h index e0aac6f..d31bca6 100644 --- a/document.h +++ b/document.h @@ -491,7 +491,7 @@ zathura_plugin_error_t zathura_page_image_save(zathura_page_t* page, zathura_ima * Get text for selection * @param page Page * @param rectangle Selection - * @error Set to an error value (see \ref zathura_plugin_error_t) if an error + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an error * occured * @return The selected text (needs to be deallocated with g_free) */ diff --git a/utils.h b/utils.h index 38124ca..331ef77 100644 --- a/utils.h +++ b/utils.h @@ -74,7 +74,8 @@ void page_calculate_offset(zathura_page_t* page, page_offset_t* offset); /** * Rotate a rectangle by 0, 90, 180 or 270 degree - * @param rect the rectangle to rotate + * + * @param rectangle the rectangle to rotate * @param degree rotation degree * @param height the height of the enclosing rectangle * @param width the width of the enclosing rectangle From 3fec0ed485b6940c685316a2f59887ca30425152 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 9 Feb 2012 11:25:00 +0100 Subject: [PATCH 03/55] Fix adjust-open setting --- config.c | 4 ++-- document.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index 3a3e3d6..d46fca2 100644 --- a/config.c +++ b/config.c @@ -60,8 +60,8 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL); bool_value = true; girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, "Render 'Loading ...'", NULL, NULL); - int_value = ADJUST_BESTFIT; - girara_setting_add(gsession, "adjust-open", &int_value, INT, false, "Adjust to when opening file", NULL, NULL); + string_value = "best-fit"; + girara_setting_add(gsession, "adjust-open", string_value, STRING, false, "Adjust to when opening file", NULL, NULL); /* define default shortcuts */ girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL); diff --git a/document.c b/document.c index dcab1a5..b7533a1 100644 --- a/document.c +++ b/document.c @@ -346,10 +346,17 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password g_signal_connect(G_OBJECT(document->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session); - /* apply open adjustment */ - int adjust_open = ADJUST_BESTFIT; - girara_setting_get(zathura->ui.session, "adjust-open", &adjust_open); + char* adjust_open = "best-fit"; + document->adjust_mode = ADJUST_BESTFIT; + if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) { + if (g_strcmp0(adjust_open, "best-fit") == 0) { + document->adjust_mode = ADJUST_BESTFIT; + } else if (g_strcmp0(adjust_open, "width") == 0) { + document->adjust_mode = ADJUST_WIDTH; + } + g_free(adjust_open); + } g_free(file_uri); From 043513558cbcb7c408d9deef579001994b5291e4 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 9 Feb 2012 12:31:39 +0100 Subject: [PATCH 04/55] Fix math.h include --- utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 36c9cc1..eb96b40 100644 --- a/utils.c +++ b/utils.c @@ -7,7 +7,7 @@ #include #include #include -#include "math.h" +#include #include "utils.h" #include "zathura.h" From 2adb25223cc256e19a6c26e970a2b25e6743608d Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 9 Feb 2012 18:30:36 +0100 Subject: [PATCH 05/55] Options for zoom_min/zoom_max --- config.c | 4 ++++ shortcuts.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index d46fca2..a5ebcad 100644 --- a/config.c +++ b/config.c @@ -48,6 +48,10 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, zathura); float_value = 40; girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, "Scroll step", NULL, NULL); + int_value = 10; + girara_setting_add(gsession, "zoom-min", &int_value, INT, false, "Zoom minimum", NULL, NULL); + int_value = 1000; + girara_setting_add(gsession, "zoom-max", &int_value, INT, false, "Zoom maximum", NULL, NULL); string_value = "#FFFFFF"; girara_setting_add(gsession, "recolor-darkcolor", string_value, STRING, false, "Recoloring (dark color)", NULL, NULL); diff --git a/shortcuts.c b/shortcuts.c index c5d8a0a..8ec1f4f 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -787,10 +787,18 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* } /* zoom limitations */ - if (zathura->document->scale < 0.1f) { - zathura->document->scale = 0.1f; - } else if (zathura->document->scale > 10.0f) { - zathura->document->scale = 10.0f; + int zoom_min_int = 10; + int zoom_max_int = 1000; + girara_setting_get(session, "zoom-min", &zoom_min_int); + girara_setting_get(session, "zoom-max", &zoom_max_int); + + float zoom_min = zoom_min_int * 0.01f; + float zoom_max = zoom_max_int * 0.01f; + + if (zathura->document->scale < zoom_min) { + zathura->document->scale = zoom_min; + } else if (zathura->document->scale > zoom_max) { + zathura->document->scale = zoom_max; } /* keep position */ From 95c851011888a9f95815475a4181fcfd3b7d3820 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Fri, 10 Feb 2012 14:13:08 +0100 Subject: [PATCH 06/55] Stay on the same page on :set pages-per-row (Closes: ##108) --- callbacks.c | 8 ++++++-- config.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/callbacks.c b/callbacks.c index 1ad6b7c..056dafc 100644 --- a/callbacks.c +++ b/callbacks.c @@ -97,18 +97,22 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi } void -cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* data) +cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data)) { g_return_if_fail(value != NULL); + g_return_if_fail(session != NULL); + g_return_if_fail(session->global.data != NULL); + zathura_t* zathura = session->global.data; int pages_per_row = *(int*) value; - zathura_t* zathura = data; if (pages_per_row < 1) { pages_per_row = 1; } + unsigned int current_page = zathura->document->current_page_number; page_widget_set_mode(zathura, pages_per_row); + page_set_delayed(zathura, current_page); } void diff --git a/config.c b/config.c index a5ebcad..dc21909 100644 --- a/config.c +++ b/config.c @@ -45,7 +45,7 @@ config_load_default(zathura_t* zathura) int_value = 1; girara_setting_add(gsession, "page-padding", &int_value, INT, true, "Padding between pages", NULL, NULL); int_value = 1; - girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, zathura); + girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, NULL); float_value = 40; girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, "Scroll step", NULL, NULL); int_value = 10; From 3facd5beb0613caef98fa7981570869f741e34d6 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sat, 11 Feb 2012 17:53:28 +0100 Subject: [PATCH 07/55] Replace image_save with image_get_cairo --- commands.c | 10 ++++++++-- document.c | 10 +++++----- document.h | 16 ++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/commands.c b/commands.c index 7455326..8816b4c 100644 --- a/commands.c +++ b/commands.c @@ -332,14 +332,20 @@ cmd_export(girara_session_t* session, girara_list_t* argument_list) } const char* attachment_name = girara_list_nth(argument_list, 0); - const char* file_name = girara_list_nth(argument_list, 1); + const char* file_name = girara_list_nth(argument_list, 1); + + if (file_name == NULL || attachment_name == NULL) { + return false; + } char* file_name2 = girara_fix_path(file_name); - if (!zathura_document_attachment_save(zathura->document, attachment_name, file_name)) { + + if (zathura_document_attachment_save(zathura->document, attachment_name, file_name) == false) { girara_notify(session, GIRARA_ERROR, "Couldn't write attachment '%s' to '%s'.", attachment_name, file_name); } else { girara_notify(session, GIRARA_INFO, "Wrote attachment '%s' to '%s'.", attachment_name, file_name2); } g_free(file_name2); + return true; } diff --git a/document.c b/document.c index b7533a1..e182087 100644 --- a/document.c +++ b/document.c @@ -610,19 +610,19 @@ zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error) return page->document->functions.page_images_get(page, error); } -zathura_plugin_error_t -zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file) +cairo_surface_t* +zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL || image == NULL || file == NULL) { + if (page == NULL || page->document == NULL || image == NULL) { return false; } - if (page->document->functions.page_image_save == NULL) { + if (page->document->functions.page_image_get_cairo == NULL) { girara_error("%s not implemented", __FUNCTION__); return false; } - return page->document->functions.page_image_save(page, image, file); + return page->document->functions.page_image_get_cairo(page, image, error); } char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error) diff --git a/document.h b/document.h index d31bca6..604470b 100644 --- a/document.h +++ b/document.h @@ -271,9 +271,9 @@ struct zathura_document_s girara_list_t* (*page_images_get)(zathura_page_t* page, zathura_plugin_error_t* error); /** - * Save image to a file + * Get the image */ - zathura_plugin_error_t (*page_image_save)(zathura_page_t* page, zathura_image_t* image, const char* file); + cairo_surface_t* (*page_image_get_cairo)(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error); /** * Get text for selection @@ -477,15 +477,15 @@ zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* list); girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error); /** - * Save image + * Get image * * @param page Page - * @param image The image - * @param file Path to the file - * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see - * zathura_plugin_error_t + * @param image Image identifier + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return The cairo image surface or NULL if an error occured */ -zathura_plugin_error_t zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file); +cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error); /** * Get text for selection From a7429131fd64865f43c97a781ccab24031fe7b65 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 12 Feb 2012 00:37:15 +0100 Subject: [PATCH 08/55] fix zathurarc.5.rst --- zathurarc.5.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zathurarc.5.rst b/zathurarc.5.rst index 7449e73..3717777 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -75,14 +75,14 @@ Defines the number of pages that are rendered next to each other in a row. * Value-type: Integer * Default value: 1 -recolor-dark-color +recolor-darkcolor ^^^^^^^^^^^^^^^^^^ Defines the color value that is used to represent dark colors in recoloring mode * Value-type: String * Default value: #FFFFFF -recolor-light-color +recolor-lightcolor ^^^^^^^^^^^^^^^^^^^ Defines the color value that is used to represent light colors in recoloring mode From 392275eed3f0895f9d693d94058af04f916f1636 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 12 Feb 2012 11:16:10 +0100 Subject: [PATCH 09/55] Resolve sc_follow issue --- shortcuts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shortcuts.c b/shortcuts.c index 8ec1f4f..da5d386 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -120,7 +120,7 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument), g_return_val_if_fail(session->global.data != NULL, false); zathura_t* zathura = session->global.data; - if (zathura->document == NULL) { + if (zathura->document == NULL || zathura->ui.session == NULL) { return false; } @@ -151,7 +151,7 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument), /* ask for input */ if (show_links == true) { - girara_dialog(zathura->ui.session, "Follow link:", FALSE, NULL, (girara_callback_inputbar_activate_t) cb_sc_follow, NULL); + girara_dialog(zathura->ui.session, "Follow link:", FALSE, NULL, (girara_callback_inputbar_activate_t) cb_sc_follow, zathura->ui.session); } return false; From 5dacede6929107fd9c6c82c320826518b87dddff Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 12 Feb 2012 12:22:11 +0100 Subject: [PATCH 10/55] use getter functions to make it compatible with GTK+3 --- page_widget.c | 2 +- utils.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/page_widget.c b/page_widget.c index 5c0f368..af0f572 100644 --- a/page_widget.c +++ b/page_widget.c @@ -391,7 +391,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) grect.y = rectangle->y1; grect.width = rectangle->x2 - rectangle->x1; grect.height = rectangle->y2 - rectangle->y1; - gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE); + gdk_window_invalidate_rect(gtk_widget_get_parent_window(GTK_WIDGET(widget)), &grect, TRUE); } static void diff --git a/utils.c b/utils.c index eb96b40..afc88fa 100644 --- a/utils.c +++ b/utils.c @@ -263,7 +263,8 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle) void set_adjustment(GtkAdjustment* adjustment, gdouble value) { - gtk_adjustment_set_value(adjustment, MAX(adjustment->lower, MIN(adjustment->upper - adjustment->page_size, value))); + gtk_adjustment_set_value(adjustment, MAX(gtk_adjustment_get_lower(adjustment), + MIN(gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment), value))); } void From 5c09bdd5e2ba5b5ccf0f91d2ca6e21a7ad31ffcf Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 12 Feb 2012 15:34:05 +0100 Subject: [PATCH 11/55] Fix segmentation fault in cb_pages_per_row_value_changed --- callbacks.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/callbacks.c b/callbacks.c index 056dafc..3452466 100644 --- a/callbacks.c +++ b/callbacks.c @@ -110,9 +110,12 @@ cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(nam pages_per_row = 1; } - unsigned int current_page = zathura->document->current_page_number; page_widget_set_mode(zathura, pages_per_row); - page_set_delayed(zathura, current_page); + + if (zathura->document != NULL) { + unsigned int current_page = zathura->document->current_page_number; + page_set_delayed(zathura, current_page); + } } void From b59e5686ec27a9cf7b4b0c133ce4fdffe15e412c Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 12 Feb 2012 16:35:33 +0100 Subject: [PATCH 12/55] Update style --- config.c | 2 +- zathura.c | 36 ++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config.c b/config.c index dc21909..1f2333a 100644 --- a/config.c +++ b/config.c @@ -210,7 +210,7 @@ config_load_default(zathura_t* zathura) void config_load_file(zathura_t* zathura, char* path) { - if (zathura == NULL) { + if (zathura == NULL || path == NULL) { return; } diff --git a/zathura.c b/zathura.c index a90177f..5793ce1 100644 --- a/zathura.c +++ b/zathura.c @@ -55,7 +55,7 @@ zathura_init(int argc, char* argv[]) g_option_context_add_main_entries(context, entries, NULL); GError* error = NULL; - if (!g_option_context_parse(context, &argc, &argv, &error)) + if (g_option_context_parse(context, &argc, &argv, &error) == false) { printf("Error parsing command line arguments: %s\n", error->message); g_option_context_free(context); @@ -86,7 +86,7 @@ zathura_init(int argc, char* argv[]) zathura->plugins.type_plugin_mapping = girara_list_new2( (girara_free_function_t)zathura_type_plugin_mapping_free); - if (config_dir) { + if (config_dir != NULL) { zathura->config.config_dir = g_strdup(config_dir); } else { gchar* path = girara_get_xdg_path(XDG_CONFIG); @@ -94,7 +94,7 @@ zathura_init(int argc, char* argv[]) g_free(path); } - if (data_dir) { + if (data_dir != NULL) { zathura->config.data_dir = g_strdup(config_dir); } else { gchar* path = girara_get_xdg_path(XDG_DATA); @@ -106,7 +106,7 @@ zathura_init(int argc, char* argv[]) g_mkdir_with_parents(zathura->config.config_dir, 0771); g_mkdir_with_parents(zathura->config.data_dir, 0771); - if (plugin_path) { + if (plugin_path != NULL) { girara_list_t* paths = girara_split_path_array(plugin_path); girara_list_merge(zathura->plugins.path, paths); girara_list_free(paths); @@ -172,7 +172,7 @@ zathura_init(int argc, char* argv[]) /* page view */ zathura->ui.page_widget = gtk_table_new(0, 0, TRUE); - if (!zathura->ui.page_widget) { + if (zathura->ui.page_widget == NULL) { goto error_free; } @@ -186,7 +186,7 @@ zathura_init(int argc, char* argv[]) /* page view alignment */ zathura->ui.page_widget_alignment = gtk_alignment_new(0.5, 0.5, 0, 0); - if (!zathura->ui.page_widget_alignment) { + if (zathura->ui.page_widget_alignment == NULL) { goto error_free; } gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget); @@ -205,7 +205,7 @@ zathura_init(int argc, char* argv[]) } zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL); - if (!zathura->ui.statusbar.page_number) { + if (zathura->ui.statusbar.page_number == NULL) { goto error_free; } @@ -267,11 +267,11 @@ zathura_init(int argc, char* argv[]) error_free: - if (zathura->ui.page_widget) { + if (zathura->ui.page_widget != NULL) { g_object_unref(zathura->ui.page_widget); } - if (zathura->ui.page_widget_alignment) { + if (zathura->ui.page_widget_alignment != NULL) { g_object_unref(zathura->ui.page_widget_alignment); } @@ -308,7 +308,7 @@ zathura_free(zathura_t* zathura) zathura_db_free(zathura->database); /* free print settings */ - if(zathura->print.settings != NULL) { + if (zathura->print.settings != NULL) { g_object_unref(zathura->print.settings); } @@ -414,13 +414,13 @@ document_info_open(gpointer data) bool document_open(zathura_t* zathura, const char* path, const char* password) { - if (!path) { + if (path == NULL) { goto error_out; } zathura_document_t* document = zathura_document_open(zathura, path, password); - if (!document) { + if (document == NULL) { goto error_out; } @@ -436,7 +436,7 @@ document_open(zathura_t* zathura, const char* path, const char* password) /* threads */ zathura->sync.render_thread = render_init(zathura); - if (!zathura->sync.render_thread) { + if (zathura->sync.render_thread == NULL) { goto error_free; } @@ -447,7 +447,7 @@ document_open(zathura_t* zathura, const char* path, const char* password) } /* bookmarks */ - if (!zathura_bookmarks_load(zathura, zathura->document->file_path)) { + if (zathura_bookmarks_load(zathura, zathura->document->file_path) == false) { girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path); } @@ -473,7 +473,7 @@ document_save(zathura_t* zathura, const char* path, bool overwrite) g_return_val_if_fail(path, false); gchar* file_path = girara_fix_path(path); - if (!overwrite && g_file_test(file_path, G_FILE_TEST_EXISTS)) + if ((overwrite == false) && g_file_test(file_path, G_FILE_TEST_EXISTS)) { girara_error("File already exists: %s. Use :write! to overwrite it.", file_path); g_free(file_path); @@ -488,7 +488,7 @@ document_save(zathura_t* zathura, const char* path, bool overwrite) static void remove_page_from_table(GtkWidget* page, gpointer permanent) { - if (!permanent) { + if (permanent == false) { g_object_ref(G_OBJECT(page)); } @@ -498,7 +498,7 @@ remove_page_from_table(GtkWidget* page, gpointer permanent) bool document_close(zathura_t* zathura) { - if (!zathura->document) { + if (zathura->document == NULL) { return false; } @@ -571,7 +571,7 @@ page_set(zathura_t* zathura, unsigned int page_id) /* render page */ zathura_page_t* page = zathura->document->pages[page_id]; - if (!page) { + if (page == NULL) { goto error_out; } From a4fab8c368d493d4ec5e3eb353a17f7b23154345 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 13 Feb 2012 12:43:22 +0100 Subject: [PATCH 13/55] some more work to be compatible with GTK+3 --- config.c | 145 +++++++++++++++++++++++++++--------------------------- zathura.c | 2 +- 2 files changed, 74 insertions(+), 73 deletions(-) diff --git a/config.c b/config.c index dc21909..066a825 100644 --- a/config.c +++ b/config.c @@ -12,6 +12,7 @@ #include #include #include +#include void config_load_default(zathura_t* zathura) @@ -68,78 +69,78 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "adjust-open", string_value, STRING, false, "Adjust to when opening file", NULL, NULL); /* define default shortcuts */ - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL); - girara_shortcut_add(gsession, 0, GDK_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL); - girara_shortcut_add(gsession, 0, GDK_i, NULL, sc_change_mode, NORMAL, INSERT, NULL); - girara_shortcut_add(gsession, 0, GDK_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL); - girara_shortcut_add(gsession, 0, GDK_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL); - girara_shortcut_add(gsession, 0, GDK_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/")); - girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/")); - girara_shortcut_add(gsession, 0, GDK_question, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("?")); - girara_shortcut_add(gsession, 0, GDK_colon, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":")); - girara_shortcut_add(gsession, 0, GDK_o, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":open ")); - girara_shortcut_add(gsession, 0, GDK_O, NULL, girara_sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open ")); - girara_shortcut_add(gsession, 0, GDK_f, NULL, sc_follow, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, NORMAL, TOP, NULL); - girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, FULLSCREEN, TOP, NULL); - girara_shortcut_add(gsession, 0, 0, "G", sc_goto, NORMAL, BOTTOM, NULL); - girara_shortcut_add(gsession, 0, 0, "G", sc_goto, FULLSCREEN, BOTTOM, NULL); - girara_shortcut_add(gsession, 0, GDK_J, NULL, sc_navigate, NORMAL, NEXT, NULL); - girara_shortcut_add(gsession, 0, GDK_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL); - girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_Right, NULL, sc_navigate, NORMAL, NEXT, NULL); - girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_Left, NULL, sc_navigate, NORMAL, PREVIOUS, NULL); - girara_shortcut_add(gsession, 0, GDK_Left, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); - girara_shortcut_add(gsession, 0, GDK_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); - girara_shortcut_add(gsession, 0, GDK_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL); - girara_shortcut_add(gsession, 0, GDK_Right, NULL, sc_navigate, FULLSCREEN, NEXT, NULL); - girara_shortcut_add(gsession, 0, GDK_k, NULL, sc_navigate_index, INDEX, UP, NULL); - girara_shortcut_add(gsession, 0, GDK_j, NULL, sc_navigate_index, INDEX, DOWN, NULL); - girara_shortcut_add(gsession, 0, GDK_h, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL); - girara_shortcut_add(gsession, 0, GDK_l, NULL, sc_navigate_index, INDEX, EXPAND, NULL); - girara_shortcut_add(gsession, 0, GDK_space, NULL, sc_navigate_index, INDEX, SELECT, NULL); - girara_shortcut_add(gsession, 0, GDK_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_i, NULL, sc_recolor, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_R, NULL, sc_reload, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_r, NULL, sc_rotate, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_h, NULL, sc_scroll, NORMAL, LEFT, NULL); - girara_shortcut_add(gsession, 0, GDK_j, NULL, sc_scroll, NORMAL, DOWN, NULL); - girara_shortcut_add(gsession, 0, GDK_k, NULL, sc_scroll, NORMAL, UP, NULL); - girara_shortcut_add(gsession, 0, GDK_l, NULL, sc_scroll, NORMAL, RIGHT, NULL); - girara_shortcut_add(gsession, 0, GDK_Left, NULL, sc_scroll, NORMAL, LEFT, NULL); - girara_shortcut_add(gsession, 0, GDK_Up, NULL, sc_scroll, NORMAL, UP, NULL); - girara_shortcut_add(gsession, 0, GDK_Down, NULL, sc_scroll, NORMAL, DOWN, NULL); - girara_shortcut_add(gsession, 0, GDK_Right, NULL, sc_scroll, NORMAL, RIGHT, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL); - girara_shortcut_add(gsession, 0, GDK_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL); - girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL); - girara_shortcut_add(gsession, 0, GDK_n, NULL, sc_search, NORMAL, FORWARD, NULL); - girara_shortcut_add(gsession, 0, GDK_N, NULL, sc_search, NORMAL, BACKWARD, NULL); - girara_shortcut_add(gsession, 0, GDK_Tab, NULL, sc_toggle_index, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_Tab, NULL, sc_toggle_index, INDEX, 0, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_m, NULL, girara_sc_toggle_inputbar, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_F5, NULL, sc_toggle_fullscreen, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_F5, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL); - girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_n, NULL, girara_sc_toggle_statusbar, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_q, NULL, sc_quit, NORMAL, 0, NULL); - girara_shortcut_add(gsession, 0, GDK_plus, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL); - girara_shortcut_add(gsession, 0, GDK_plus, NULL, sc_zoom, FULLSCREEN, ZOOM_IN, NULL); - girara_shortcut_add(gsession, 0, GDK_minus, NULL, sc_zoom, NORMAL, ZOOM_OUT, NULL); - girara_shortcut_add(gsession, 0, GDK_minus, NULL, sc_zoom, FULLSCREEN, ZOOM_OUT, NULL); - girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL); - girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL); - girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, NORMAL, ZOOM_IN, NULL); - girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, FULLSCREEN, ZOOM_IN, NULL); - girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, NORMAL, ZOOM_OUT, NULL); - girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, FULLSCREEN, ZOOM_OUT, NULL); - girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL); - girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL); - girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL); - girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_i, NULL, sc_change_mode, NORMAL, INSERT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/")); + girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/")); + girara_shortcut_add(gsession, 0, GDK_KEY_question, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("?")); + girara_shortcut_add(gsession, 0, GDK_KEY_colon, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":")); + girara_shortcut_add(gsession, 0, GDK_KEY_o, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":open ")); + girara_shortcut_add(gsession, 0, GDK_KEY_O, NULL, girara_sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open ")); + girara_shortcut_add(gsession, 0, GDK_KEY_f, NULL, sc_follow, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, NORMAL, TOP, NULL); + girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, FULLSCREEN, TOP, NULL); + girara_shortcut_add(gsession, 0, 0, "G", sc_goto, NORMAL, BOTTOM, NULL); + girara_shortcut_add(gsession, 0, 0, "G", sc_goto, FULLSCREEN, BOTTOM, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_J, NULL, sc_navigate, NORMAL, NEXT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL); + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Right, NULL, sc_navigate, NORMAL, NEXT, NULL); + girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Left, NULL, sc_navigate, NORMAL, PREVIOUS, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Left, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_navigate, FULLSCREEN, NEXT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_k, NULL, sc_navigate_index, INDEX, UP, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_j, NULL, sc_navigate_index, INDEX, DOWN, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_h, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_l, NULL, sc_navigate_index, INDEX, EXPAND, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_navigate_index, INDEX, SELECT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_recolor, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_R, NULL, sc_reload, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_r, NULL, sc_rotate, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_h, NULL, sc_scroll, NORMAL, LEFT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_j, NULL, sc_scroll, NORMAL, DOWN, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_k, NULL, sc_scroll, NORMAL, UP, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_l, NULL, sc_scroll, NORMAL, RIGHT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Left, NULL, sc_scroll, NORMAL, LEFT, NULL); + 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, 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); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL); + girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_n, NULL, sc_search, NORMAL, FORWARD, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_N, NULL, sc_search, NORMAL, BACKWARD, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Tab, NULL, sc_toggle_index, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_Tab, NULL, sc_toggle_index, INDEX, 0, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_m, NULL, girara_sc_toggle_inputbar, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_fullscreen, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL); + girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_n, NULL, girara_sc_toggle_statusbar, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, NORMAL, 0, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_plus, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_plus, NULL, sc_zoom, FULLSCREEN, ZOOM_IN, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_minus, NULL, sc_zoom, NORMAL, ZOOM_OUT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_minus, NULL, sc_zoom, FULLSCREEN, ZOOM_OUT, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL); + girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, NORMAL, ZOOM_IN, NULL); + girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, FULLSCREEN, ZOOM_IN, NULL); + girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, NORMAL, ZOOM_OUT, NULL); + girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, FULLSCREEN, ZOOM_OUT, NULL); + girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL); + girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL); + girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL); /* mouse events */ girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL); diff --git a/zathura.c b/zathura.c index a90177f..58073f1 100644 --- a/zathura.c +++ b/zathura.c @@ -492,7 +492,7 @@ remove_page_from_table(GtkWidget* page, gpointer permanent) g_object_ref(G_OBJECT(page)); } - gtk_container_remove(GTK_CONTAINER(page->parent), page); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(page)), page); } bool From bc0a9c99caa41435c0f9d301b929110d5f8e239a Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 13 Feb 2012 15:00:53 +0100 Subject: [PATCH 14/55] revert a GTK+3 compatibility change --- page_widget.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/page_widget.c b/page_widget.c index af0f572..b0c8891 100644 --- a/page_widget.c +++ b/page_widget.c @@ -391,7 +391,12 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) grect.y = rectangle->y1; grect.width = rectangle->x2 - rectangle->x1; grect.height = rectangle->y2 - rectangle->y1; +#if (GTK_MAJOR_VERSION == 3) + /* gtk_widget_get_parent_window is wrong here */ gdk_window_invalidate_rect(gtk_widget_get_parent_window(GTK_WIDGET(widget)), &grect, TRUE); +#else + gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE); +#endif } static void From 69b5cb0be58b3f57a7bfacd0b82d99caf9a5c66c Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 13:53:26 +0100 Subject: [PATCH 15/55] more GTK+3 support --- config.mk | 11 +++++++---- zathura.c | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config.mk b/config.mk index da58c87..254b5df 100644 --- a/config.mk +++ b/config.mk @@ -3,6 +3,9 @@ VERSION = 0.0.8.1 +# the GTK version to use +ZATHURA_GTK_VERSION ?= 2 + # paths PREFIX ?= /usr MANPREFIX ?= ${PREFIX}/share/man @@ -13,11 +16,11 @@ PLUGINDIR ?= ${PREFIX}/lib/zathura # libs # set this to 0 if you don't need to link against dl -GTK_INC ?= $(shell pkg-config --cflags gtk+-2.0) -GTK_LIB ?= $(shell pkg-config --libs gtk+-2.0 gthread-2.0) +GTK_INC ?= $(shell pkg-config --cflags gtk+-${ZATHURA_GTK_VERSION}.0) +GTK_LIB ?= $(shell pkg-config --libs gtk+-${ZATHURA_GTK_VERSION}.0 gthread-2.0) -GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk2) -GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk2) +GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION}) +GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk${ZATHURA_GTK_VERSION}) SQLITE_INC ?= $(shell pkg-config --cflags sqlite3) SQLITE_LIB ?= $(shell pkg-config --libs sqlite3) diff --git a/zathura.c b/zathura.c index fa16a4d..d195fca 100644 --- a/zathura.c +++ b/zathura.c @@ -38,12 +38,17 @@ zathura_t* zathura_init(int argc, char* argv[]) { /* parse command line options */ +#if (GTK_MAJOR_VERSION == 2) GdkNativeWindow embed = 0; +#endif + gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL; bool forkback = false; GOptionEntry entries[] = { +#if (GTK_MAJOR_VERSION == 2) { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, "Reparents to window specified by xid", "xid" }, +#endif { "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" }, @@ -162,7 +167,10 @@ zathura_init(int argc, char* argv[]) g_free(configuration_file); /* initialize girara */ +#if (GTK_MAJOR_VERSION == 2) zathura->ui.session->gtk.embed = embed; +#endif + if (girara_session_init(zathura->ui.session, "zathura") == false) { goto error_out; } From fd4429716f7e29d017889e43cff7d8ff61a677b6 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 14:26:44 +0100 Subject: [PATCH 16/55] Some more work towards GTK+3 For some reason the page widget is really large (641203x906843 pixels). This makes everything fail, i.e the GTK+3 stuff is not ready. --- page_widget.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/page_widget.c b/page_widget.c index b0c8891..e3ee81b 100644 --- a/page_widget.c +++ b/page_widget.c @@ -29,7 +29,10 @@ typedef struct zathura_page_widget_private_s { #define ZATHURA_PAGE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PAGE, 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); @@ -61,7 +64,11 @@ zathura_page_widget_class_init(ZathuraPageClass* class) /* overwrite methods */ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class); +#if GTK_MAJOR_VERSION == 3 + widget_class->draw = zathura_page_widget_draw; +#else widget_class->expose_event = zathura_page_widget_expose; +#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; @@ -219,6 +226,7 @@ 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) { @@ -232,14 +240,29 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) 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); g_static_mutex_lock(&(priv->lock)); + +#if GTK_MAJOR_VERSION == 2 + const unsigned int page_height = widget->allocation.height; + const unsigned int page_width = widget->allocation.width; +#else + 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); - unsigned int page_height = widget->allocation.height; - unsigned int page_width = widget->allocation.width; - switch (priv->page->document->rotate) { case 90: cairo_translate(cairo, page_width, 0); @@ -325,7 +348,7 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) } else { /* set background color */ cairo_set_source_rgb(cairo, 255, 255, 255); - cairo_rectangle(cairo, 0, 0, widget->allocation.width, widget->allocation.height); + cairo_rectangle(cairo, 0, 0, page_width, page_height); cairo_fill(cairo); bool render_loading = true; @@ -339,8 +362,8 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) cairo_set_font_size(cairo, 16.0); cairo_text_extents_t extents; cairo_text_extents(cairo, text, &extents); - double x = widget->allocation.width * 0.5 - (extents.width * 0.5 + extents.x_bearing); - double y = widget->allocation.height * 0.5 - (extents.height * 0.5 + extents.y_bearing); + double x = page_width * 0.5 - (extents.width * 0.5 + extents.x_bearing); + double y = page_height * 0.5 - (extents.height * 0.5 + extents.y_bearing); cairo_move_to(cairo, x, y); cairo_show_text(cairo, text); } @@ -348,8 +371,6 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) /* render real page */ render_page(priv->zathura->sync.render_thread, priv->page); } - cairo_destroy(cairo); - g_static_mutex_unlock(&(priv->lock)); return FALSE; } @@ -392,8 +413,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) grect.width = rectangle->x2 - rectangle->x1; grect.height = rectangle->y2 - rectangle->y1; #if (GTK_MAJOR_VERSION == 3) - /* gtk_widget_get_parent_window is wrong here */ - gdk_window_invalidate_rect(gtk_widget_get_parent_window(GTK_WIDGET(widget)), &grect, TRUE); + gtk_widget_queue_draw_area(GTK_WIDGET(widget), grect.x, grect.y, grect.width, grect.height); #else gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE); #endif From 9d04a7bfcf9d58352a126ee925f0c1e6aaf01e20 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 14:46:19 +0100 Subject: [PATCH 17/55] make highlight colors configurable during runtime --- config.c | 27 +++++++++++++++++++++++++-- page_widget.c | 5 +++-- zathura.c | 7 ------- zathura.h | 1 + 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/config.c b/config.c index 3be28b2..8606441 100644 --- a/config.c +++ b/config.c @@ -14,6 +14,26 @@ #include #include +static void +cb_color_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data)) +{ + g_return_if_fail(value != NULL); + g_return_if_fail(session != NULL); + g_return_if_fail(session->global.data != NULL); + g_return_if_fail(name != NULL); + zathura_t* zathura = session->global.data; + + char* string_value = (char*) value; + if (g_strcmp0(name, "highlight-color") == 0) { + gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color)); + } else if (g_strcmp0(name, "highlight-active-active") == 0) { + gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active)); + } + + /* TODO: cause a redraw here? */ +} + + void config_load_default(zathura_t* zathura) { @@ -59,8 +79,11 @@ config_load_default(zathura_t* zathura) string_value = "#000000"; girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL); - string_value = "#9FBC00"; - girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL); + girara_setting_add(gsession, "highlight-color", NULL, STRING, false, "Color for highlighting", cb_color_change, NULL); + girara_setting_set(gsession, "highlight-color", "#9FBC00"); + girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, "Color for highlighting (active)", cb_color_change, NULL); + girara_setting_set(gsession, "highlight-active-color", "#00BC00"); + float_value = 0.5; girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL); bool_value = true; diff --git a/page_widget.c b/page_widget.c index e3ee81b..40cdd0b 100644 --- a/page_widget.c +++ b/page_widget.c @@ -325,10 +325,11 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect); /* draw position */ - GdkColor color = priv->zathura->ui.colors.highlight_color; if (idx == priv->search_current) { - cairo_set_source_rgba(cairo, 0, color.green, color.blue, transparency); + GdkColor 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, color.green, color.blue, transparency); } cairo_rectangle(cairo, rectangle.x1, rectangle.y1, diff --git a/zathura.c b/zathura.c index d195fca..dadc00d 100644 --- a/zathura.c +++ b/zathura.c @@ -244,13 +244,6 @@ zathura_init(int argc, char* argv[]) g_free(string_value); } - string_value = NULL; - girara_setting_get(zathura->ui.session, "highlight-color", &string_value); - if (string_value != NULL) { - gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color)); - g_free(string_value); - } - /* database */ zathura->database = zathura_db_init(zathura->config.data_dir); if (zathura->database == NULL) { diff --git a/zathura.h b/zathura.h index c769474..2c27467 100644 --- a/zathura.h +++ b/zathura.h @@ -50,6 +50,7 @@ typedef struct zathura_s GdkColor recolor_dark_color; /**< Dark color for recoloring */ GdkColor recolor_light_color; /**< Light color for recoloring */ GdkColor highlight_color; /**< Color for highlighting */ + GdkColor highlight_color_active; /** Color for highlighting */ } colors; GtkWidget *page_widget_alignment; From 2f38126a7a9c97961b7271dec53dfff930593d13 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 14:53:45 +0100 Subject: [PATCH 18/55] make the recolor colors changeable too --- config.c | 13 ++++++++----- zathura.c | 15 --------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/config.c b/config.c index 8606441..faebe21 100644 --- a/config.c +++ b/config.c @@ -28,6 +28,10 @@ cb_color_change(girara_session_t* session, const char* name, girara_setting_type gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color)); } else if (g_strcmp0(name, "highlight-active-active") == 0) { gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active)); + } else if (g_strcmp0(name, "recolor-darkcolor") == 0) { + gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color)); + } else if (g_strcmp0(name, "recolor-lightcolor") == 0) { + gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color)); } /* TODO: cause a redraw here? */ @@ -74,11 +78,10 @@ config_load_default(zathura_t* zathura) int_value = 1000; girara_setting_add(gsession, "zoom-max", &int_value, INT, false, "Zoom maximum", NULL, NULL); - string_value = "#FFFFFF"; - girara_setting_add(gsession, "recolor-darkcolor", string_value, STRING, false, "Recoloring (dark color)", NULL, NULL); - string_value = "#000000"; - girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL); - + girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, "Recoloring (dark color)", cb_color_change, NULL); + girara_setting_set(gsession, "recolor-darkcolor", "#FFFFFF"); + girara_setting_add(gsession, "recolor-lightcolor", NULL, STRING, false, "Recoloring (light color)", cb_color_change, NULL); + girara_setting_set(gsession, "recolor-lightcolor", "#000000"); girara_setting_add(gsession, "highlight-color", NULL, STRING, false, "Color for highlighting", cb_color_change, NULL); girara_setting_set(gsession, "highlight-color", "#9FBC00"); girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, "Color for highlighting (active)", cb_color_change, NULL); diff --git a/zathura.c b/zathura.c index dadc00d..67f7233 100644 --- a/zathura.c +++ b/zathura.c @@ -229,21 +229,6 @@ zathura_init(int argc, char* argv[]) gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding); gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding); - /* parse colors */ - char* string_value = NULL; - girara_setting_get(zathura->ui.session, "recolor-darkcolor", &string_value); - if (string_value != NULL) { - gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color)); - g_free(string_value); - } - - string_value = NULL; - girara_setting_get(zathura->ui.session, "recolor-lightcolor", &string_value); - if (string_value != NULL) { - gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color)); - g_free(string_value); - } - /* database */ zathura->database = zathura_db_init(zathura->config.data_dir); if (zathura->database == NULL) { From beb9de669991e1dcccf5a2c40083d787d7ff9df2 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 14 Feb 2012 15:48:35 +0100 Subject: [PATCH 19/55] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 2684cf7..7d84c04 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2011 pwmt.org +Copyright (c) 2009-2012 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 e7f0e30d9954278d135bfb81b48a29da5ec83ce2 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 15:53:04 +0100 Subject: [PATCH 20/55] only call sc_adjust_window if the allocation of the window really changed --- callbacks.c | 16 ++++++++++++---- document.c | 2 ++ shortcuts.c | 4 ++++ zathura.c | 8 +++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/callbacks.c b/callbacks.c index 3452466..9a4b2a1 100644 --- a/callbacks.c +++ b/callbacks.c @@ -290,14 +290,22 @@ error_ret: } bool -cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* UNUSED(allocation), zathura_t* zathura) +cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t* zathura) { if (zathura == NULL || zathura->document == NULL) { return false; } - girara_argument_t argument = { zathura->document->adjust_mode, NULL }; - sc_adjust_window(zathura->ui.session, &argument, NULL, 0); + static int height = -1; + static int width = -1; - return true; + /* adjust only if the allocation changed */ + if (width != allocation->width || height != allocation->height) { + girara_argument_t argument = { zathura->document->adjust_mode, NULL }; + sc_adjust_window(zathura->ui.session, &argument, NULL, 0); + width = allocation->width; + height = allocation->height; + } + + return false; } diff --git a/document.c b/document.c index e182087..240b6e2 100644 --- a/document.c +++ b/document.c @@ -354,6 +354,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password document->adjust_mode = ADJUST_BESTFIT; } else if (g_strcmp0(adjust_open, "width") == 0) { document->adjust_mode = ADJUST_WIDTH; + } else { + document->adjust_mode = ADJUST_NONE; } g_free(adjust_open); } diff --git a/shortcuts.c b/shortcuts.c index da5d386..9a345f3 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -57,6 +57,10 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, } zathura->document->adjust_mode = argument->n; + if (argument->n == ADJUST_NONE) { + /* there is nothing todo */ + goto error_ret; + } /* get window size */ GtkAllocation allocation; diff --git a/zathura.c b/zathura.c index 67f7233..b452dfd 100644 --- a/zathura.c +++ b/zathura.c @@ -40,15 +40,15 @@ zathura_init(int argc, char* argv[]) /* parse command line options */ #if (GTK_MAJOR_VERSION == 2) GdkNativeWindow embed = 0; +#else + Window embed = 0; #endif gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL; bool forkback = false; GOptionEntry entries[] = { -#if (GTK_MAJOR_VERSION == 2) { "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, "Reparents to window specified by xid", "xid" }, -#endif { "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" }, @@ -167,9 +167,7 @@ zathura_init(int argc, char* argv[]) g_free(configuration_file); /* initialize girara */ -#if (GTK_MAJOR_VERSION == 2) zathura->ui.session->gtk.embed = embed; -#endif if (girara_session_init(zathura->ui.session, "zathura") == false) { goto error_out; @@ -184,7 +182,7 @@ zathura_init(int argc, char* argv[]) goto error_free; } - g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "size-allocate", G_CALLBACK(cb_view_resized), zathura); + g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate", G_CALLBACK(cb_view_resized), zathura); /* callbacks */ GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); From 8c10161acf0cb3a1a3a54d40d33893b7622f5e67 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 16:01:50 +0100 Subject: [PATCH 21/55] fix invalid read in render thread --- render.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/render.c b/render.c index 2311398..cfe9abd 100644 --- a/render.c +++ b/render.c @@ -112,7 +112,7 @@ render_free(render_thread_t* render_thread) } if (render_thread->list) { - girara_list_free(render_thread->list); + girara_list_clear(render_thread->list); } if (render_thread->cond) { @@ -121,6 +121,10 @@ render_free(render_thread_t* render_thread) g_cond_free(render_thread->cond); } + if (render_thread->list) { + girara_list_free(render_thread->list); + } + if (render_thread->lock) { g_mutex_free(render_thread->lock); } From dadcbf9ae8e37c94122d0b73b610bd7f1017a236 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 16:23:56 +0100 Subject: [PATCH 22/55] update the documentation --- zathurarc.5.rst | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/zathurarc.5.rst b/zathurarc.5.rst index 3717777..8ecb43d 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -65,35 +65,48 @@ page-padding The page padding defines the gap in pixels between each rendered page and can not be changed during runtime. -* Value-type: Integer +* Value type: Integer * Default value: 1 pages-per-row ^^^^^^^^^^^^^ Defines the number of pages that are rendered next to each other in a row. -* Value-type: Integer +* Value type: Integer * Default value: 1 +highligt-color +^^^^^^^^^^^^^^ +Defines the color value that is used to higlight things in the document, e.g all +search results. + +* Value type: String +* Default value: #9FBC00 + +highlight-active-color +^^^^^^^^^^^^^^^^^^^^^^ +Defines the color value that is used to mark the active highlight in the +document, e.g the current search results. + recolor-darkcolor ^^^^^^^^^^^^^^^^^^ Defines the color value that is used to represent dark colors in recoloring mode -* Value-type: String +* Value type: String * Default value: #FFFFFF recolor-lightcolor ^^^^^^^^^^^^^^^^^^^ Defines the color value that is used to represent light colors in recoloring mode -* Value-type: String +* Value type: String * Default value: #000000 zoom-step ^^^^^^^^^ Defines the amount of percent that is zoomed in or out on each comand. -* Value-type: Integer +* Value type: Integer * Default value: 10 map - Mapping a shortcut From 98b421120ebb6305d5d056fdff1344eae164b819 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 14 Feb 2012 16:30:15 +0100 Subject: [PATCH 23/55] store plugindir in zathura.pc --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 48949a2..fd969ed 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,7 @@ ${PROJECT}.pc: ${PROJECT}.pc.in config.mk $(QUIET)echo project=${PROJECT} > ${PROJECT}.pc $(QUIET)echo version=${VERSION} >> ${PROJECT}.pc $(QUIET)echo includedir=${PREFIX}/include >> ${PROJECT}.pc + $(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc $(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc valgrind: debug From fc2e97e9175b3e64808a9ad1a1b30b1ee9699898 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Tue, 14 Feb 2012 20:20:38 +0100 Subject: [PATCH 24/55] Fix typo in documentation --- zathurarc.5.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zathurarc.5.rst b/zathurarc.5.rst index 8ecb43d..3dbfbce 100644 --- a/zathurarc.5.rst +++ b/zathurarc.5.rst @@ -75,10 +75,10 @@ Defines the number of pages that are rendered next to each other in a row. * Value type: Integer * Default value: 1 -highligt-color -^^^^^^^^^^^^^^ -Defines the color value that is used to higlight things in the document, e.g all -search results. +highlight-color +^^^^^^^^^^^^^^^ +Defines the color value that is used to highlight things in the document, e.g +all search results. * Value type: String * Default value: #9FBC00 From b815fa6ecf6a1861c777ab44dbabcb75b6daf727 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 15 Feb 2012 00:21:51 +0100 Subject: [PATCH 25/55] Update to new girara event definitions --- config.c | 12 ++++++++---- shortcuts.c | 51 +++++++++++++++++++++------------------------------ 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/config.c b/config.c index faebe21..94eeb88 100644 --- a/config.c +++ b/config.c @@ -169,10 +169,14 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL); /* mouse events */ - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL); - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, 0, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, 0, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_UP, 0, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, 0, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_PRESS, 0, NULL); girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_RELEASE, 0, NULL); girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL); diff --git a/shortcuts.c b/shortcuts.c index 9a345f3..a97f297 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -200,22 +200,17 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e } /* scroll event */ - if (event->type == GIRARA_EVENT_SCROLL) { - switch (event->direction) { - case GIRARA_SCROLL_UP: - argument->n = UP; - break; - case GIRARA_SCROLL_DOWN: - argument->n = DOWN; - break; - case GIRARA_SCROLL_LEFT: - argument->n = LEFT; - break; - case GIRARA_SCROLL_RIGHT: - argument->n = RIGHT; - break; - } - + if (event->type == GIRARA_EVENT_SCROLL_UP) { + argument->n = UP; + return sc_scroll(session, argument, NULL, t); + } else if (event->type == GIRARA_EVENT_SCROLL_DOWN) { + argument->n = DOWN; + return sc_scroll(session, argument, NULL, t); + } else if (event->type == GIRARA_EVENT_SCROLL_LEFT) { + argument->n = LEFT; + return sc_scroll(session, argument, NULL, t); + } else if (event->type == GIRARA_EVENT_SCROLL_RIGHT) { + argument->n = RIGHT; return sc_scroll(session, argument, NULL, t); } else if (event->type == GIRARA_EVENT_BUTTON_PRESS) { x = event->x; @@ -257,22 +252,18 @@ sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_eve } /* scroll event */ - if (event->type == GIRARA_EVENT_SCROLL) { - switch (event->direction) { - case GIRARA_SCROLL_UP: - argument->n = ZOOM_IN; - break; - case GIRARA_SCROLL_DOWN: - argument->n = ZOOM_OUT; - break; - default: - return false; - } - - return sc_zoom(session, argument, NULL, t); + switch (event->type) { + case GIRARA_EVENT_SCROLL_UP: + argument->n = ZOOM_IN; + break; + case GIRARA_EVENT_SCROLL_DOWN: + argument->n = ZOOM_OUT; + break; + default: + return false; } - return false; + return sc_zoom(session, argument, NULL, t); } bool From 65d2241e06842c8978198e10a8a5de6f7a630ac6 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 15 Feb 2012 11:48:28 +0100 Subject: [PATCH 26/55] Simplify sc_mouse_scroll --- config.c | 22 ++++++++-------- shortcuts.c | 72 ++++++++++++++++++++++++++++------------------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/config.c b/config.c index 94eeb88..982f64f 100644 --- a/config.c +++ b/config.c @@ -169,17 +169,17 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL); /* mouse events */ - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, 0, NULL); - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, 0, NULL); - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); - girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_UP, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); - girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, 0, NULL); - girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_PRESS, 0, NULL); - girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_RELEASE, 0, NULL); - girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, UP, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); + girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, UP, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); + girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); + girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_PRESS, 0, NULL); + girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_RELEASE, 0, NULL); + girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL); /* define default inputbar commands */ girara_inputbar_command_add(gsession, "bmark", NULL, cmd_bookmark_create, NULL, "Add a bookmark"); diff --git a/shortcuts.c b/shortcuts.c index a97f297..db138e6 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -192,47 +192,51 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e g_return_val_if_fail(argument != NULL, false); g_return_val_if_fail(event != NULL, false); - static int x = 0; - static int y = 0; - if (zathura->document == NULL) { return false; } - /* scroll event */ - if (event->type == GIRARA_EVENT_SCROLL_UP) { - argument->n = UP; - return sc_scroll(session, argument, NULL, t); - } else if (event->type == GIRARA_EVENT_SCROLL_DOWN) { - argument->n = DOWN; - return sc_scroll(session, argument, NULL, t); - } else if (event->type == GIRARA_EVENT_SCROLL_LEFT) { - argument->n = LEFT; - return sc_scroll(session, argument, NULL, t); - } else if (event->type == GIRARA_EVENT_SCROLL_RIGHT) { - argument->n = RIGHT; - return sc_scroll(session, argument, NULL, t); - } else if (event->type == GIRARA_EVENT_BUTTON_PRESS) { - x = event->x; - y = event->y; - } else if (event->type == GIRARA_EVENT_BUTTON_RELEASE) { - x = 0; - y = 0; - } else if (event->type == GIRARA_EVENT_MOTION_NOTIFY) { - GtkAdjustment* x_adj = - gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); - GtkAdjustment* y_adj = - gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); + static int x = 0; + static int y = 0; - if (x_adj == NULL || y_adj == NULL) { - return false; - } + GtkAdjustment* x_adj = NULL; + GtkAdjustment* y_adj = NULL; - set_adjustment(x_adj, gtk_adjustment_get_value(x_adj) - (event->x - x)); - set_adjustment(y_adj, gtk_adjustment_get_value(y_adj) - (event->y - y)); + switch (event->type) { + /* scroll */ + case GIRARA_EVENT_SCROLL_UP: + case GIRARA_EVENT_SCROLL_DOWN: + case GIRARA_EVENT_SCROLL_LEFT: + case GIRARA_EVENT_SCROLL_RIGHT: + return sc_scroll(session, argument, NULL, t); - x = event->x; - y = event->y; + /* drag */ + case GIRARA_EVENT_BUTTON_PRESS: + x = event->x; + y = event->y; + break; + case GIRARA_EVENT_BUTTON_RELEASE: + x = 0; + y = 0; + break; + case GIRARA_EVENT_MOTION_NOTIFY: + x_adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); + y_adj =gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view)); + + if (x_adj == NULL || y_adj == NULL) { + return false; + } + + set_adjustment(x_adj, gtk_adjustment_get_value(x_adj) - (event->x - x)); + set_adjustment(y_adj, gtk_adjustment_get_value(y_adj) - (event->y - y)); + + x = event->x; + y = event->y; + break; + + /* unhandled events */ + default: + break; } return false; From 0767aa85bfe3f55cf9ff36b05467fe942fa463cb Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 16 Feb 2012 15:47:33 +0100 Subject: [PATCH 27/55] some error checking for zathura_page_get --- document.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/document.c b/document.c index 240b6e2..5c67d8f 100644 --- a/document.c +++ b/document.c @@ -513,6 +513,12 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plu page->number = page_id; page->visible = false; page->drawing_area = zathura_page_widget_new(page); + if (page->drawing_area == NULL) { + girara_error("couldn't create page widget"); + zathura_page_free(page); + return NULL; + } + page->document = document; unsigned int page_height = 0; From 0251fb75dd7b76de7534daba764d8fb04465f6df Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Thu, 16 Feb 2012 16:18:12 +0100 Subject: [PATCH 28/55] use gdk_threads_add_idle instead of g_idle_add --- callbacks.c | 4 ++-- zathura.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/callbacks.c b/callbacks.c index 9a4b2a1..984c902 100644 --- a/callbacks.c +++ b/callbacks.c @@ -263,13 +263,13 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog) g_free(input); } - g_idle_add(password_dialog, dialog); + gdk_threads_add_idle(password_dialog, dialog); return false; } /* try to open document again */ if (document_open(dialog->zathura, dialog->path, input) == false) { - g_idle_add(password_dialog, dialog); + gdk_threads_add_idle(password_dialog, dialog); } else { g_free(dialog->path); free(dialog); diff --git a/zathura.c b/zathura.c index b452dfd..1aed38e 100644 --- a/zathura.c +++ b/zathura.c @@ -244,7 +244,7 @@ zathura_init(int argc, char* argv[]) document_info->zathura = zathura; document_info->path = argv[1]; document_info->password = (argc >= 2) ? argv[2] : NULL; - g_idle_add(document_info_open, document_info); + gdk_threads_add_idle(document_info_open, document_info); } return zathura; @@ -537,7 +537,7 @@ page_set_delayed(zathura_t* zathura, unsigned int page_id) page_set_delayed_t* p = g_malloc(sizeof(page_set_delayed_t)); p->zathura = zathura; p->page = page_id; - g_idle_add(page_set_delayed_impl, p); + gdk_threads_add_idle(page_set_delayed_impl, p); return true; } From 7db78012de1a5e16f183ba6c38a7ac4dadc6092b Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Thu, 16 Feb 2012 16:36:09 +0100 Subject: [PATCH 29/55] Remove unneeded shortcut --- config.c | 1 - 1 file changed, 1 deletion(-) diff --git a/config.c b/config.c index 982f64f..a766258 100644 --- a/config.c +++ b/config.c @@ -99,7 +99,6 @@ config_load_default(zathura_t* zathura) girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL); - girara_shortcut_add(gsession, 0, GDK_KEY_i, NULL, sc_change_mode, NORMAL, INSERT, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/")); From 394fbd934dd421dd694a6b190780087f5a984d02 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Fri, 17 Feb 2012 00:43:01 +0100 Subject: [PATCH 30/55] Update style --- bookmarks.c | 20 +++++++++++++------- zathura.c | 4 +--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bookmarks.c b/bookmarks.c index e0a90ed..5fc94d5 100644 --- a/bookmarks.c +++ b/bookmarks.c @@ -32,8 +32,9 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) bookmark->id = g_strdup(id); bookmark->page = page; girara_list_append(zathura->bookmarks.bookmarks, bookmark); - if (zathura->database) { - if (!zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark)) { + + if (zathura->database != NULL) { + if (zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark) == false) { girara_warning("Failed to add bookmark to database."); } } @@ -48,15 +49,16 @@ zathura_bookmark_remove(zathura_t* zathura, const gchar* id) g_return_val_if_fail(id, false); zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, id); - if (!bookmark) { + if (bookmark == NULL) { return false; } - if (zathura->database) { - if (!zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id)) { + if (zathura->database != NULL) { + if (zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id) == false) { girara_warning("Failed to remove bookmark from database."); } } + girara_list_remove(zathura->bookmarks.bookmarks, bookmark); return true; @@ -74,7 +76,7 @@ zathura_bookmark_get(zathura_t* zathura, const gchar* id) void zathura_bookmark_free(zathura_bookmark_t* bookmark) { - if (!bookmark) { + if (bookmark == NULL) { return; } @@ -86,17 +88,19 @@ bool zathura_bookmarks_load(zathura_t* zathura, const gchar* file) { g_return_val_if_fail(zathura, false); g_return_val_if_fail(file, false); + if (zathura->database == NULL) { return false; } girara_list_t* bookmarks = zathura_db_load_bookmarks(zathura->database, file); - if (!bookmarks) { + if (bookmarks == NULL) { return false; } girara_list_free(zathura->bookmarks.bookmarks); zathura->bookmarks.bookmarks = bookmarks; + return true; } @@ -106,9 +110,11 @@ zathura_bookmarks_compare(zathura_bookmark_t* lhs, zathura_bookmark_t* rhs) if (lhs == NULL && rhs == NULL) { return 0; } + if (lhs == NULL) { return -1; } + if (rhs == NULL) { return 1; } diff --git a/zathura.c b/zathura.c index 1aed38e..ee0fa24 100644 --- a/zathura.c +++ b/zathura.c @@ -431,9 +431,7 @@ document_open(zathura_t* zathura, const char* path, const char* password) } /* bookmarks */ - if (zathura_bookmarks_load(zathura, zathura->document->file_path) == false) { - girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path); - } + zathura_bookmarks_load(zathura, zathura->document->file_path); page_set_delayed(zathura, document->current_page_number - 1); cb_view_vadjustment_value_changed(NULL, zathura); From 8fdf18b0881953186d32fd60ba9e4996739ffd55 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sat, 18 Feb 2012 00:30:47 +0100 Subject: [PATCH 31/55] Update plugin system return values and notifications --- document.c | 105 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/document.c b/document.c index 5c67d8f..857070f 100644 --- a/document.c +++ b/document.c @@ -387,7 +387,7 @@ error_free: zathura_plugin_error_t zathura_document_free(zathura_document_t* document) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { return false; } @@ -402,6 +402,7 @@ zathura_document_free(zathura_document_t* document) /* free document */ bool r = true; if (document->functions.document_free == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); } else { r = document->functions.document_free(document); @@ -419,11 +420,12 @@ zathura_document_free(zathura_document_t* document) zathura_plugin_error_t zathura_document_save_as(zathura_document_t* document, const char* path) { - if (document == NULL || path == NULL) { + if (document == NULL || path == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { return false; } if (document->functions.document_save_as == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); return false; } @@ -434,11 +436,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path) girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document, zathura_plugin_error_t* error) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { return NULL; } if (document->functions.document_index_generate == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); return NULL; } @@ -449,11 +452,12 @@ zathura_document_index_generate(zathura_document_t* document, zathura_plugin_err girara_list_t* zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_error_t* error) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { return NULL; } if (document->functions.document_attachments_get == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); return NULL; } @@ -464,11 +468,13 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_er zathura_plugin_error_t zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; } if (document->functions.document_attachment_save == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; } @@ -478,9 +484,9 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac char* zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_plugin_error_t* error) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; } return NULL; } @@ -489,6 +495,8 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t if (error != NULL) { *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; } + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); return NULL; } @@ -498,12 +506,19 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error) { - if (document == NULL) { + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } return NULL; } if (document->functions.page_get == NULL) { + girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } return NULL; } @@ -534,13 +549,14 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plu zathura_plugin_error_t zathura_page_free(zathura_page_t* page) { - if (page == NULL || page->document == NULL) { - return false; + if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { + return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; } if (page->document->functions.page_free == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); - return false; + return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; } return page->document->functions.page_free(page); @@ -549,12 +565,20 @@ zathura_page_free(zathura_page_t* page) girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL || text == NULL) { + if (page == NULL || page->document == NULL || text == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } return NULL; } if (page->document->functions.page_search_text == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } return NULL; } @@ -564,12 +588,20 @@ zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_ girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL) { + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } return NULL; } if (page->document->functions.page_links_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } return NULL; } @@ -585,12 +617,20 @@ zathura_page_links_free(girara_list_t* UNUSED(list)) girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL) { + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } return NULL; } if (page->document->functions.page_form_fields_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } return NULL; } @@ -600,19 +640,27 @@ zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* UNUSED(list)) { - return false; + return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; } girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL) { + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } return NULL; } if (page->document->functions.page_images_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); - return false; + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; } return page->document->functions.page_images_get(page, error); @@ -621,13 +669,22 @@ zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error) cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL || image == NULL) { - return false; + if (page == NULL || page->document == NULL || image == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == + NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; } if (page->document->functions.page_image_get_cairo == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); - return false; + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; } return page->document->functions.page_image_get_cairo(page, image, error); @@ -635,7 +692,7 @@ zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathu char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error) { - if (page == NULL || page->document == NULL) { + if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { if (error) { *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; } @@ -643,6 +700,7 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, } if (page->document->functions.page_get_text == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); if (error) { *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; @@ -656,11 +714,14 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) { - if (page == NULL || page->document == NULL || cairo == NULL) { + if (page == NULL || page->document == NULL || cairo == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == + NULL) { return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; } if (page->document->functions.page_render_cairo == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__); girara_error("%s not implemented", __FUNCTION__); return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; } From bf0bb6650372a9e374c6646546f3f51bf0a13e5d Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sat, 18 Feb 2012 09:21:34 +0100 Subject: [PATCH 32/55] Abort search if page_search_text is not implemented --- commands.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commands.c b/commands.c index 8816b4c..5796e64 100644 --- a/commands.c +++ b/commands.c @@ -286,6 +286,8 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu } bool firsthit = true; + zathura_plugin_error_t error = ZATHURA_PLUGIN_ERROR_OK; + for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; ++page_id) { zathura_page_t* page = zathura->document->pages[(page_id + zathura->document->current_page_number) % zathura->document->number_of_pages]; if (page == NULL) { @@ -294,11 +296,16 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu g_object_set(page->drawing_area, "draw-links", FALSE, NULL); - girara_list_t* result = zathura_page_search_text(page, input, NULL); + girara_list_t* result = zathura_page_search_text(page, input, &error); if (result == NULL || girara_list_size(result) == 0) { girara_list_free(result); g_object_set(page->drawing_area, "search-results", NULL, NULL); - continue; + + if (error == ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED) { + break; + } else { + continue; + } } g_object_set(page->drawing_area, "search-results", result, NULL); From 55c175b1e00bcfdf10f9819ff1feefcbcf852ea6 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sat, 18 Feb 2012 11:37:39 +0100 Subject: [PATCH 33/55] Update man page --- Makefile | 7 +- zathura.1 | 27 ----- zathura.1.rst | 149 +++++++++++++++++++++++++ zathurarc.5.rst | 287 ------------------------------------------------ 4 files changed, 153 insertions(+), 317 deletions(-) delete mode 100644 zathura.1 create mode 100644 zathura.1.rst delete mode 100644 zathurarc.5.rst diff --git a/Makefile b/Makefile index fd969ed..a7aae48 100644 --- a/Makefile +++ b/Makefile @@ -104,10 +104,11 @@ install: all ${PROJECT}.pc $(QUIET)cp -f zathura.h ${DESTDIR}${PREFIX}/include/${PROJECT} $(ECHO) installing manual pages $(QUIET)mkdir -p ${DESTDIR}${MANPREFIX}/man1 - $(QUIET)sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1 > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 $(QUIET)if which rst2man > /dev/null ; then \ - mkdir -p ${DESTDIR}${MANPREFIX}/man5 ; \ - rst2man ${PROJECT}rc.5.rst > ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5 ; \ + mkdir -p ${DESTDIR}${MANPREFIX}/man1 ; \ + sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1.rst > ${PROJECT}-v.1.rst ; \ + rst2man ${PROJECT}-v.1.rst > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 ; \ + rm -f ${PROJECT}-v.1.rst ; \ fi $(QUIET)mkdir -p ${DESTDIR}${DESKTOPPREFIX} $(ECHO) installing desktop file diff --git a/zathura.1 b/zathura.1 deleted file mode 100644 index a38bb6a..0000000 --- a/zathura.1 +++ /dev/null @@ -1,27 +0,0 @@ -.TH ZATHURA 1 zathura\-VERSION - -.SH NAME -zathura \- a document viewer - -.SH SYNOPSIS -.B zathura -.RB [options] -.RB [file] -.RB [password] - -.SH DESCRIPTION -zathura is a highly customizable and functional document viewer. - -.SH OPTIONS -.TP -.B "-e xid" -Reparents to window specified by xid. -.TP -.B "-c path" -Path to the config directory. -.TP -.B "-d path" -Path to the data directory. -.TP -.B "-p path" -Path to the plugin directory. diff --git a/zathura.1.rst b/zathura.1.rst new file mode 100644 index 0000000..d328899 --- /dev/null +++ b/zathura.1.rst @@ -0,0 +1,149 @@ +======= +zathura +======= + +----------------- +a document viewer +----------------- + +:Author: pwmt.org +:Date: VERSION +:Manual section: 1 + +SYNOPOSIS +========= +| zathura [OPTION]... +| zathura [OPTION]... FILE +| zathura [OPTION]... FILE PASSWORD + +DESCRIPTION +=========== +zathura is a highly customizable and functional document viewer. It provides a +minimalistic and space saving interface as well as an easy usage that mainly +focuses on keyboard interaction. + +OPTIONS +======= + +-e [xid], --reparent [xid] + Reparents to window specified by xid + +-c [path], --config-dir [path] + Path to the config directory + +-d [path], --data-dir [path] + Path to the data directory + +-p [path], --plugins-dir [path] + Path to the directory containing plugins + +--fork + Fork into the background + +MOUSE AND KEY BINDINGS +====================== + +J, K + Go to the next or previous page +h, k, j, l + Scroll to the left, down, up or right direction +Left, Down, Up, Right + Scroll to the left, down, up or right direction +^d, ^u + Scroll a half page down or up +^f, ^b, space, + Scroll a full page down or up +gg, G, nG + Goto to the first, the last or to the nth page +^c, Escape + Abort +a, s + Adjust window in best-fit or width mode +/, ? + Search for text +n, N + Search for the next or previous result +o, O + Open document +f + Follow links +\: + Enter command +r + Rotate by 90 degrees +^i + Recolor +R + Reload document +Tab + Show index and switch to **Index mode** +F5 + Switch to fullscreen mode +^m + Toggle inputbar +^n + Toggle statusbar ++, -, = + Zoom in, out or to the original size +zI, zO, z0 + Zoom in, out or to the original size +n= + Zoom to size n +mX + Set a quickmark to a letter or number X +'X + Goto quickmark saved at letter or number X +q + Quit + +Index mode +---------- + +k, j + Move to upper or lower entry +l + Expand entry +h + Collapse entry +space, Return + Select and open entry + +Mouse bindings +-------------- +Scroll + Scroll up or down +^Scroll + Zoom in or out +Hold Button2 + Pan the document +Button1 + Follow link + +COMMANDS +======== +bmark + Save a bookmark +bdelete + Delete a bookmark +blist + List bookmarks +close + Close document +info + Show document information +help + Show help page +open, o + Open a document +print + Print document +write, write! + Save document (and force overwriting) +export + Export attachments + +CONFIGURATION +============= +The default appearance and behaviour of zathura can be overwritten by modifying +the *zathurarc* file (default path: ~/.config/zathura/zathurarc). For a detailed +description please visit http://pwmt.org/projects/zathura/configuration diff --git a/zathurarc.5.rst b/zathurarc.5.rst deleted file mode 100644 index 3dbfbce..0000000 --- a/zathurarc.5.rst +++ /dev/null @@ -1,287 +0,0 @@ -=========== - zathurarc -=========== - --------------------------- -zathura configuration file --------------------------- - -:Author: pwmt.org -:Date: 02.02.2012 -:Manual section: 5 - -SYNOPOSIS -========= - -/etc/zathurarc, $XDG_CONFIG_HOME/zathura/zathurarc - -DESCRIPTION -=========== - -The zathurarc file is a simple plain text file that can be populated with -various commands to change the behaviour and the look of zathura which we are -going to describe in the following subsections. Each line (besides empty lines -and comments (which start with a prepended #)) is evaluated on its own, so it is -not possible to write multiple commands in one single line. - -The following commands can be used: - -set - Changing the options --------------------------- - -In addition to the build-in :set command zathura offers more options to be -changed and makes those changes permanent. To overwrite an option you just have -to add a line structured like the following: - -:: - set