diff --git a/document.c b/document.c index b81ef5d..8d6642f 100644 --- a/document.c +++ b/document.c @@ -584,6 +584,26 @@ zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char return page->document->functions.page_image_save(page, image, file); } +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 (error) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_get_text == NULL) { + girara_error("%s not implemented", __FUNCTION__); + if (error) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_get_text(page, rectangle, error); +} + zathura_plugin_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) { diff --git a/document.h b/document.h index 21947fd..21494d3 100644 --- a/document.h +++ b/document.h @@ -268,6 +268,11 @@ struct zathura_document_s */ zathura_plugin_error_t (*page_image_save)(zathura_page_t* page, zathura_image_t* image, const char* file); + /** + * Get text for selection + */ + char* (*page_get_text)(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error); + /** * Renders the page */ @@ -475,6 +480,16 @@ girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_erro */ zathura_plugin_error_t zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file); +/** + * 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 + * occured + * @return The selected text (needs to be deallocated with g_free) + */ +char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error); + /** * Render page * diff --git a/page_widget.c b/page_widget.c index a35ba90..f33a3c1 100644 --- a/page_widget.c +++ b/page_widget.c @@ -97,9 +97,7 @@ zathura_page_widget_init(ZathuraPage* widget) /* we want mouse events */ gtk_widget_add_events(GTK_WIDGET(widget), - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_FOCUS_CHANGE_MASK); - /* widgets can focus */ - gtk_widget_set_can_focus(GTK_WIDGET(widget), TRUE); + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK); } GtkWidget*