add method to get text from selection

This commit is contained in:
Sebastian Ramacher 2012-02-08 23:20:22 +01:00
parent 2f5a7a3998
commit 7003df76a4
3 changed files with 36 additions and 3 deletions

View file

@ -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)
{

View file

@ -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
*

View file

@ -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*