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-02-10 04:33:28 +01:00
|
|
|
#include <girara.h>
|
2010-11-18 02:35:33 +01:00
|
|
|
|
2011-04-19 19:24:03 +02:00
|
|
|
#include "document.h"
|
|
|
|
|
|
|
|
typedef struct page_offset_s
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
} page_offset_t;
|
|
|
|
|
2011-02-01 15:48:16 +01:00
|
|
|
/**
|
|
|
|
* Checks if the given file exists
|
|
|
|
*
|
|
|
|
* @param path Path to the file
|
|
|
|
* @return true if the file exists, otherwise false
|
|
|
|
*/
|
2010-11-18 02:35:33 +01:00
|
|
|
bool file_exists(const char* path);
|
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
|
|
|
|
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-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
|
|
|
|
*/
|
2010-11-29 14:58:56 +01:00
|
|
|
bool execute_command(char* const argv[], char** output);
|
2011-02-01 15:48:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a blank page
|
|
|
|
*
|
|
|
|
* @param width The width of the page
|
|
|
|
* @param height The height of the page
|
|
|
|
* @return The widget of the page or NULL if an error occured
|
|
|
|
*/
|
2010-12-29 11:46:13 +01:00
|
|
|
GtkWidget* page_blank(unsigned int width, unsigned int height);
|
2010-11-18 02:35:33 +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
|
|
|
|
* @param tree_it The Tree iterator
|
|
|
|
* @param list_it The index list iterator
|
|
|
|
*/
|
|
|
|
void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree);
|
|
|
|
|
2011-03-05 21:00:41 +01:00
|
|
|
/**
|
|
|
|
* This function is used to concatenate multiple strings. Argument list has to
|
|
|
|
* be ended with NULL. Returned string has to be freed with free().
|
|
|
|
*
|
|
|
|
* @param string1 First string
|
|
|
|
* @param ... Additional strings
|
|
|
|
* @return Concatenated string or NULL if an error occured
|
|
|
|
*/
|
|
|
|
char* string_concat(const char* string1, ...);
|
|
|
|
|
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
|
|
|
|
* @return The calculated offset or NULL if an error occured
|
|
|
|
*/
|
|
|
|
page_offset_t* page_calculate_offset(zathura_page_t* page);
|
|
|
|
|
2010-11-10 20:47:53 +01:00
|
|
|
#endif // UTILS_H
|