1 /* SPDX-License-Identifier: Zlib */
2 
3 #ifndef CALLBACKS_H
4 #define CALLBACKS_H
5 
6 #include <gtk/gtk.h>
7 #include <girara/types.h>
8 #include <girara/macros.h>
9 
10 #include "internal.h"
11 #include "document.h"
12 #include "zathura.h"
13 
14 /**
15  * Quits the current zathura session
16  *
17  * @param widget The gtk window of zathura
18  * @param zathura Correspondending zathura session
19  * @return true if no error occurred and the event has been handled
20  */
21 gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
22 
23 /**
24  * This function gets called when the buffer of girara changes
25  *
26  * @param session The girara session
27  */
28 void cb_buffer_changed(girara_session_t* session);
29 
30 /**
31  * This function gets called when the value of the horizontal scrollbars
32  * changes (e.g.: by scrolling, moving to another page)
33  *
34  * @param adjustment The hadjustment of the page view
35  * @param data NULL
36  */
37 void cb_view_hadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
38 
39 /**
40  * This function gets called when the value of the vertical scrollbars
41  * changes (e.g.: by scrolling, moving to another page)
42  *
43  * @param adjustment The vadjustment of the page view
44  * @param data NULL
45  */
46 void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
47 
48 /**
49  * This function gets called when the bounds or the page_size of the horizontal
50  * scrollbar change (e.g. when the zoom level is changed).
51  *
52  * It adjusts the value of the horizontal scrollbar
53  *
54  * @param adjustment The horizontal adjustment of a gtkScrolledWindow
55  * @param data The zathura instance
56  */
57 void cb_view_hadjustment_changed(GtkAdjustment *adjustment, gpointer data);
58 
59 /**
60  * This function gets called when the bounds or the page_size of the vertical
61  * scrollbar change (e.g. when the zoom level is changed).
62  *
63  * It adjusts the value of the vertical scrollbar based on its previous
64  * adjustment, stored in the tracking adjustment zathura->ui.hadjustment.
65  *
66  * @param adjustment The vertical adjustment of a gtkScrolledWindow
67  * @param data The zathura instance
68  */
69 void cb_view_vadjustment_changed(GtkAdjustment *adjustment, gpointer data);
70 
71 /**
72  * This function gets called when the program need to refresh the document view.
73  *
74  * It adjusts the value of the scrollbars, triggering a redraw in the new
75  * position.
76  *
77  * @param view The view GtkWidget
78  * @param data The zathura instance
79  */
80 void cb_refresh_view(GtkWidget* view, gpointer data);
81 
82 /**
83  * This function gets called when the monitors associated with the GdkScreen
84  * change.
85  *
86  * It checks for a change of monitor PPI, storing the new value and triggering
87  * a refresh if appropriate.
88  *
89  * @param screen The GDK screen
90  * @param gpointer The zathura instance
91  */
92 void cb_monitors_changed(GdkScreen* screen, gpointer data);
93 
94 /**
95  * This function gets called when the screen associated with the view widget
96  * changes.
97  *
98  * It updates the connection on the monitors-changed signal and checks for a
99  * change of monitor PPI, storing the new value and triggering a refresh if
100  * appropriate.
101  *
102  * @param widget The view widget
103  * @param previous_screen The widget's previous screen
104  * @param gpointer The zathura instance
105  */
106 void cb_widget_screen_changed(GtkWidget* widget, GdkScreen* previous_screen, gpointer data);
107 
108 /**
109  * This function gets called when the main window's size, position or stacking
110  * changes.
111  *
112  * It checks for a change of monitor PPI (due to the window moving between
113  * different monitors), storing the new value and triggering a refresh if
114  * appropriate.
115  *
116  * @param widget The main window widget
117  * @param event The configure event
118  * @param gpointer The zathura instance
119  * @return true if no error occurred and the event has been handled
120  */
121 gboolean cb_widget_configured(GtkWidget* widget, GdkEvent* event, gpointer data);
122 
123 /**
124  * This function gets called when the view widget scale factor changes (e.g.
125  * when moving from a regular to a HiDPI screen).
126  *
127  * It records the new value and triggers a re-rendering of the document.
128  *
129  * @param object The view widget
130  * @param pspec The GParamSpec for the scale-factor property
131  * @param gpointer The zathura instance
132  */
133 void cb_scale_factor(GObject* object, GParamSpec* pspec, gpointer data);
134 
135 /**
136  * This function gets called when the value of the "pages-per-row"
137  * variable changes
138  *
139  * @param session The current girara session
140  * @param name The name of the row
141  * @param type The settings type
142  * @param value The value
143  * @param data Custom data
144  */
145 void cb_page_layout_value_changed(girara_session_t* session, const char* name,
146     girara_setting_type_t type, const void* value, void* data);
147 
148 /**
149  * Called when an index element is activated (e.g.: double click)
150  *
151  * @param tree_view Tree view
152  * @param path Path
153  * @param column Column
154  * @param zathura Zathura session
155  */
156 void cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
157     GtkTreeViewColumn* column, void* zathura);
158 
159 /**
160  * Called when input has been passed to the sc_follow dialog
161  *
162  * @param entry The dialog inputbar
163  * @param session The girara session
164  * @return true if no error occurred and the event has been handled
165  */
166 gboolean cb_sc_follow(GtkEntry* entry, void* session);
167 
168 /**
169  * Called when input has been passed to the sc_display_link dialog
170  *
171  * @param entry The dialog inputbar
172  * @param session The girara session
173  * @return true if no error occurred and the event has been handled
174  */
175 gboolean cb_sc_display_link(GtkEntry* entry, void* session);
176 
177 /**
178  * Emitted when file has been changed
179  *
180  * @param monitor The file monitor
181  * @param session The girara session
182  */
183 void cb_file_monitor(ZathuraFileMonitor* monitor, girara_session_t* session);
184 
185 /**
186  * Callback to read new password for file that should be opened
187  *
188  * @param entry The password entry
189  * @param dialog The dialog information
190  * @return true if input has been handled
191  */
192 gboolean cb_password_dialog(GtkEntry* entry, void* dialog);
193 
194 /**
195  * Emitted when the view has been resized
196  *
197  * @param widget View
198  * @param allocation Allocation
199  * @param zathura Zathura session
200  * @return true if signal has been handled successfully
201  */
202 gboolean cb_view_resized(GtkWidget* widget, GtkAllocation* allocation, zathura_t* zathura);
203 
204 /**
205  * Emitted when the 'recolor' setting is changed
206  *
207  * @param session Girara session
208  * @param name Name of the setting ("recolor")
209  * @param type Type of the setting (BOOLEAN)
210  * @param value New value
211  * @param data Custom data
212  */
213 void cb_setting_recolor_change(girara_session_t* session, const char* name,
214     girara_setting_type_t type, const void* value, void* data);
215 
216 /**
217  * Emitted when the 'recolor-keephue' setting is changed
218  *
219  * @param session Girara session
220  * @param name Name of the setting ("recolor")
221  * @param type Type of the setting (BOOLEAN)
222  * @param value New value
223  * @param data Custom data
224  */
225 void cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
226     girara_setting_type_t type, const void* value, void* data);
227 
228 /**
229  * Emitted when the 'recolor-reverse-video' setting is changed
230  *
231  * @param session Girara session
232  * @param name Name of the setting ("recolor")
233  * @param type Type of the setting (BOOLEAN)
234  * @param value New value
235  * @param data Custom data
236  */
237 void cb_setting_recolor_keep_reverse_video_change(girara_session_t* session,
238     const char* name, girara_setting_type_t type, const void* value, void* data);
239 
240 /**
241  * Unknown command handler which is used to handle the strict numeric goto
242  * command
243  *
244  * @param session The girara session
245  * @param input The command input
246  * @return true if the input has been handled
247  */
248 bool cb_unknown_command(girara_session_t* session, const char* input);
249 
250 /**
251  * Emitted when text has been selected in the page widget
252  *
253  * @param page page view widget
254  * @param text selected text
255  * @param data user data
256  */
257 void cb_page_widget_text_selected(ZathuraPage* page, const char* text,
258     void* data);
259 
260 void cb_page_widget_image_selected(ZathuraPage* page, GdkPixbuf* pixbuf,
261     void* data);
262 
263 void cb_page_widget_scaled_button_release(ZathuraPage* page,
264     GdkEventButton* event, void* data);
265 
266 void cb_page_widget_link(ZathuraPage* page, void* data);
267 
268 void update_visible_pages(zathura_t* zathura);
269 
270 /**
271  * Update window icon from cairo surface.
272  */
273 void cb_window_update_icon(ZathuraRenderRequest* request, cairo_surface_t* surface, void* data);
274 
275 
276 #endif // CALLBACKS_H
277