zathura/utils.h

108 lines
3 KiB
C
Raw Normal View History

2010-11-10 20:31:15 +01:00
/* See LICENSE file for license and copyright information */
#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>
#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-02-01 15:48:16 +01:00
/**
* Returns the file extension of a path
*
* @param path Path to the file
* @return The file extension or NULL
*/
2010-11-18 02:35:33 +01:00
const char* file_get_extension(const char* path);
2011-02-01 15:48:16 +01: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-01 15:48:16 +01:00
/**
* Executes a system command and saves its output into output
*
* @param argv The command
* @param output Pointer where the output will be saved
* @return true if no error occured, otherwise false
*/
bool execute_command(char* const argv[], char** output);
2011-02-01 15:48:16 +01:00
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);
2011-04-19 19:24:03 +02:00
/**
* Calculates the offset of the page to the top of the viewing area as
* well as to the left side of it. The result has to be freed.
*
* @param page The Page
2012-02-08 15:30:13 +01:00
* @param offset Applied offset
2011-04-19 19:24:03 +02:00
* @return The calculated offset or NULL if an error occured
*/
void page_calculate_offset(zathura_page_t* page, page_offset_t* offset);
2011-04-19 19:24:03 +02:00
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
*/
zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, int height, int width);
/**
* 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-02-08 21:34:53 +01:00
/**
* Set adjustment of a GtkAdjustment respecting its limits.
* @param adjust the GtkAdkustment instance
* @param value the new adjustment
*/
void set_adjustment(GtkAdjustment* adjust, gdouble value);
2012-02-08 22:23:45 +01:00
/**
* Calculate the page size according to the corrent scaling and rotation if
* desired.
* @param page the page
* @param page_height the resulting page height
* @param page_width the resultung page width
* @param rotate honor page's rotation
*/
void
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate);
#endif // UTILS_H