2010-11-10 20:31:15 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
2010-11-10 20:47:53 +01:00
|
|
|
|
|
|
|
#ifndef UTILS_H
|
|
|
|
#define UTILS_H
|
|
|
|
|
2010-11-18 02:35:33 +01:00
|
|
|
#include <stdbool.h>
|
2010-12-28 09:47:09 +01:00
|
|
|
#include <gtk/gtk.h>
|
2011-10-23 17:01:15 +02:00
|
|
|
#include <girara/types.h>
|
2010-11-18 02:35:33 +01:00
|
|
|
|
2011-04-19 19:24:03 +02:00
|
|
|
#include "document.h"
|
|
|
|
|
2011-10-01 23:29:40 +02:00
|
|
|
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
|
|
|
|
|
2011-04-19 19:24:03 +02:00
|
|
|
typedef struct page_offset_s
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} page_offset_t;
|
|
|
|
|
2011-05-25 00:54:16 +02:00
|
|
|
/**
|
|
|
|
* This function checks if the file has a valid extension. A extension is
|
|
|
|
* evaluated as valid if it matches a supported filetype.
|
|
|
|
*
|
|
|
|
* @param zathura Zathura object
|
|
|
|
* @param path The path to the file
|
|
|
|
* @return true if the extension is valid, otherwise false
|
|
|
|
*/
|
|
|
|
bool file_valid_extension(zathura_t* zathura, const char* path);
|
|
|
|
|
2011-02-10 04:33:28 +01:00
|
|
|
/**
|
|
|
|
* Generates the document index based upon the list retreived from the document
|
|
|
|
* object.
|
|
|
|
*
|
|
|
|
* @param model The tree model
|
2012-02-08 15:30:13 +01:00
|
|
|
* @param parent The tree iterator parent
|
|
|
|
* @param tree The Tree iterator
|
2011-02-10 04:33:28 +01:00
|
|
|
*/
|
|
|
|
void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree);
|
|
|
|
|
2012-02-08 22:23:45 +01:00
|
|
|
/**
|
|
|
|
* Rotate a rectangle by 0, 90, 180 or 270 degree
|
2012-02-09 02:58:53 +01:00
|
|
|
*
|
|
|
|
* @param rectangle the rectangle to rotate
|
2012-02-08 22:23:45 +01:00
|
|
|
* @param degree rotation degree
|
|
|
|
* @param height the height of the enclosing rectangle
|
|
|
|
* @param width the width of the enclosing rectangle
|
|
|
|
* @return the rotated rectangle
|
|
|
|
*/
|
2013-02-23 16:48:19 +01:00
|
|
|
zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, double height, double width);
|
2012-02-08 22:23:45 +01:00
|
|
|
|
2012-01-19 00:37:58 +01:00
|
|
|
/**
|
|
|
|
* Calculates the new coordinates based on the rotation and scale level of the
|
|
|
|
* document for the given rectangle
|
|
|
|
*
|
|
|
|
* @param page Page where the rectangle should be
|
|
|
|
* @param rectangle The rectangle
|
|
|
|
* @return New rectangle
|
|
|
|
*/
|
|
|
|
zathura_rectangle_t recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle);
|
|
|
|
|
2012-04-03 09:02:45 +02:00
|
|
|
/**
|
|
|
|
* Returns the page widget of the page
|
|
|
|
*
|
|
|
|
* @param zathura The zathura instance
|
|
|
|
* @param page The page object
|
|
|
|
* @return The page widget of the page
|
|
|
|
* @return NULL if an error occured
|
|
|
|
*/
|
|
|
|
GtkWidget* zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page);
|
2012-02-08 22:23:45 +01:00
|
|
|
|
2012-04-22 19:12:45 +02:00
|
|
|
/**
|
|
|
|
* Set if the search results should be drawn or not
|
|
|
|
*
|
|
|
|
* @param zathura Zathura instance
|
|
|
|
* @param value true if they should be drawn, otherwise false
|
|
|
|
*/
|
|
|
|
void document_draw_search_results(zathura_t* zathura, bool value);
|
|
|
|
|
2012-07-12 10:37:58 +02:00
|
|
|
/**
|
|
|
|
* Create zathura version string
|
|
|
|
*
|
|
|
|
* @param zathura The zathura instance
|
|
|
|
* @param markup Enable markup
|
2013-10-20 19:20:03 +02:00
|
|
|
* @return Version string
|
2012-07-12 10:37:58 +02:00
|
|
|
*/
|
|
|
|
char* zathura_get_version_string(zathura_t* zathura, bool markup);
|
|
|
|
|
2013-08-31 06:18:31 +02:00
|
|
|
/**
|
|
|
|
* Get a pointer to the GdkAtom of the current clipboard.
|
|
|
|
*
|
|
|
|
* @param zathura The zathura instance
|
|
|
|
*
|
|
|
|
* @return A pointer to a GdkAtom object correspoinding to the current
|
|
|
|
* clipboard, or NULL.
|
|
|
|
*/
|
|
|
|
GdkAtom* get_selection(zathura_t* zathura);
|
|
|
|
|
2014-10-27 11:55:21 +01:00
|
|
|
/**
|
|
|
|
* Returns the valid scale value which needs to lie in the interval of zoom_min
|
|
|
|
* and zoom_max specified in the girara session
|
|
|
|
*
|
|
|
|
* @param[in] session The session
|
|
|
|
* @param[in] scale The proposed scale value
|
|
|
|
*
|
|
|
|
* @return The corrected scale value
|
|
|
|
*/
|
|
|
|
double zathura_correct_scale_value(girara_session_t* session, const double
|
|
|
|
scale);
|
|
|
|
|
2010-11-10 20:47:53 +01:00
|
|
|
#endif // UTILS_H
|