-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
143 lines (124 loc) · 3.93 KB
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* See LICENSE file for license and copyright information */
#ifndef UTILS_H
#define UTILS_H
#include <stdbool.h>
#include <gtk/gtk.h>
#include <girara/types.h>
#include "document.h"
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
typedef struct page_offset_s
{
int x;
int y;
} page_offset_t;
/**
* Returns the file extension of a path
*
* @param path Path to the file
* @return The file extension or NULL
*/
const char* file_get_extension(const char* path);
/**
* 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);
/**
* 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);
/**
* Generates the document index based upon the list retreived from the document
* object.
*
* @param model The tree model
* @param parent The tree iterator parent
* @param tree The Tree iterator
*/
void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_node_t* tree);
/**
* 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 zathura Zathura session
* @param page The Page
* @param offset Applied offset
* @return The calculated offset or NULL if an error occured
*/
void page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset);
/**
* Rotate a rectangle by 0, 90, 180 or 270 degree
*
* @param rectangle the rectangle to rotate
* @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);
/**
* 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);
/**
* 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);
/**
* 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);
/**
* Re-adjust view
*
* @param zathura Zathura instance
* @param old_zoom Old zoom value
* @param delay true if action should be delayed
*/
void readjust_view_after_zooming(zathura_t* zathura, float old_zoom, bool delay);
/**
* 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);
/**
* Create zathura version string
*
* @param zathura The zathura instance
* @param markup Enable markup
* @return Version string
*/
char* zathura_get_version_string(zathura_t* zathura, bool markup);
#endif // UTILS_H