gliv-1.7
[gliv.git] / src / gliv.h
blob203954b7e7d6ef09efa73fe177bcd9ce08388ff7
1 /* Faster but has to be undefined when debugging. */
2 #define G_DISABLE_CAST_CHECKS
3 #define GTK_NO_CHECK_CASTS
5 #include <gtk/gtk.h>
7 #ifdef HAVE_CONFIG_H
8 # include "../config.h"
9 #endif
11 #ifdef ENABLE_NLS
12 # include <libintl.h>
13 # define _(str) (gettext((str)))
14 #else
15 # define _(str) (str)
16 #endif
18 /* Just to mark constant translatable strings, like in rcfile.c. */
19 #define N_(str) (str)
21 #if HAVE_ISO_C_VARARGS
23 # define ERROR_MSG(...) \
24 do { \
25 gchar *message; \
27 message = g_strdup_printf(__VA_ARGS__); \
28 g_printerr(message); \
29 g_free(message); \
30 } while (0)
32 # define g_build_filename(...) \
33 clean_filename_free(g_build_filename(__VA_ARGS__))
35 #elif HAVE_GNU_C_VARARGS
37 # define ERROR_MSG(format...) \
38 do { \
39 gchar *message; \
41 message = g_strdup_printf(format); \
42 g_printerr(message); \
43 g_free(message); \
44 } while (0)
46 # define g_build_filename(str...) \
47 clean_filename_free(g_build_filename(str))
49 #else
50 # error "No variadic macros"
51 #endif
53 /* Instead of finding it in a system or glib header. */
54 #define PI 3.1415926535897932384626433832795029L
56 /* User configurable settings. */
58 #define ZOOM_FACTOR 1.1
59 #define MOVE_OFFSET 20.0
60 #define BIG_ROTATION (PI / 4.0) /* 45 deg */
61 #define SMALL_ROTATION (PI / 1800.0) /* 0.1 deg */
62 #define MIPMAP_RATIO 0.75
64 /* Font for the help box. */
65 #define FONT "courier Medium 12"
68 /* End of user configurable settings. */
70 /* Loader according to filename extension. */
71 typedef enum {
72 LOADER_NONE, /* Unrecognized extension. */
73 LOADER_NORMAL, /* GdkPixbuf, then ImageMagick. */
74 LOADER_DECOMP /* ImageMagick with decompression. */
75 } loader_t;
78 struct format {
79 const gchar *name;
80 const loader_t loader;
83 /* Bits for the refresh() function. */
84 #define REFRESH_IMAGE (1 << 0)
85 #define REFRESH_NOW (1 << 1)
86 #define REFRESH_STATUS (1 << 2)
87 #define APPEND_HISTORY (1 << 3)
89 /* Infos that can be freed once the map is created. */
90 typedef struct {
91 gint width;
92 gint height;
93 gint x_tiles;
94 gint y_tiles;
95 GdkPixbuf *pixbuf;
96 } loading_data;
98 typedef struct {
99 gfloat x0;
100 gfloat y0;
101 gfloat x1;
102 gfloat y1;
103 } tile_dim;
105 typedef struct {
106 gint nb_tiles;
107 tile_dim *tiles;
108 guint *tex_ids;
109 guint list;
110 loading_data *map_init;
111 } texture_map;
113 /* The gliv_image structure. */
114 typedef struct {
115 GList *node;
116 gint number;
117 gchar *ident;
118 gint width;
119 gint height;
120 gint nb_maps;
121 texture_map *maps;
122 gboolean has_alpha;
123 } gliv_image;
125 /* Options controlled by the user. */
126 typedef struct {
127 gboolean fullscreen;
128 gboolean maximize;
129 gboolean scaledown;
130 gboolean menu_bar;
131 gboolean status_bar;
132 gboolean scrollbars;
133 gboolean zoom_pointer;
134 gboolean alpha_checks;
135 gboolean dither;
136 gboolean force;
137 gboolean build_menus;
138 gboolean mipmap;
139 gboolean mnemonics;
140 gboolean loop;
141 gint delay;
142 gint duration;
143 gint history_size;
144 gint bg_col[3];
145 gint alpha1[3];
146 gint alpha2[3];
147 } options_struct;
149 /* Some global flags and variables. */
150 typedef struct {
151 gboolean cursor_hidden;
152 gboolean help;
153 gboolean alpha_checks_changed;
154 gboolean filtering_enabled;
155 gint max_texture_size;
156 GtkAllocation *wid_size;
157 gint scr_width;
158 gint scr_height;
159 } rt_struct;
161 /* callbacks.c */
162 void install_callbacks(gpointer object);
163 void process_events(void);
165 /* files_list.c */
166 gint get_list_length(void);
167 GList *get_list_head(void);
168 void remove_from_list(GList * node);
169 void reorder_files(gboolean shuffle);
170 gchar **get_sorted_files_array(void);
171 void init_list(gchar ** names, gint num, gboolean recursive,
172 gboolean shuffle, gboolean sort);
173 void place_next(const gchar * filename);
174 gboolean insert_after_current(gchar ** names, gint nb, gboolean shuffle);
175 void confirm_remove_current(void);
176 void delete_selected_image(void);
178 /* foreach_file.c */
179 typedef void (*foreach_file_func) (const gchar * path);
180 void foreach_file(const gchar * path, foreach_file_func func);
182 /* formats.c */
183 const struct format *ext_to_loader(const gchar * str, guint len);
185 /* gl_widget.c */
186 void update_bg_color(void);
187 gboolean toggle_cursor(gboolean visible);
188 void schedule_hide_cursor(void);
189 void create_gl_widget(void);
191 /* gliv.c */
192 G_GNUC_NORETURN void quit(gint code);
194 /* help.c */
195 gboolean toggle_help(void);
196 void show_about_box(void);
198 /* history.c */
199 void init_history(void);
200 void append_history(void);
201 void undo(void);
202 void redo(void);
203 void clear_history(void);
205 /* imagemagick.c */
206 GdkPixbuf *load_with_imagemagick(const gchar * filename);
207 gboolean have_imagemagick(void);
208 void imagemagick_finish(void);
210 /* images_menus.c */
211 void set_rebuilding_entry(GtkMenuItem * item);
212 void rebuild_directories(GtkMenuItem * root);
213 void rebuild_images(GtkMenuItem * root);
214 void rebuild_images_menus(void);
216 /* loading.c */
217 gboolean is_loading(void);
218 void destroy_image(gliv_image * im);
219 void install_segv_handler(void);
220 void fill_ident(gliv_image * im);
221 gboolean is_loadable(const gchar * filename);
222 GdkPixbuf *load_gdk_pixbuf(const gchar * filename);
223 gliv_image *load_file(const gchar * filename);
225 /* matrix.c */
226 G_GNUC_PURE gfloat get_matrix_zoom(void);
227 G_GNUC_PURE gfloat get_matrix_angle(void);
228 G_GNUC_PURE gboolean float_equal(gfloat a, gfloat b);
229 void get_matrix_bounding_box(gfloat * min_x, gfloat * max_x,
230 gfloat * min_y, gfloat * max_y);
231 void write_gl_matrix(void);
232 void matrix_cpy(gfloat * dest, gfloat * src);
233 gboolean matrix_tile_visible(tile_dim * tile);
234 G_GNUC_PURE gboolean is_matrix_symmetry(void);
235 G_GNUC_PURE gboolean get_matrix_has_changed(void);
236 G_GNUC_PURE gboolean is_filtering_needed(void);
237 gboolean matrix_set_max_zoom(gint width, gint height, gboolean do_it);
238 void matrix_reset(void);
239 void matrix_rotate(gfloat angle);
240 void matrix_move(gfloat x, gfloat y);
241 void matrix_zoom(gfloat ratio, gfloat x, gfloat y);
242 void matrix_flip_h(void);
243 void matrix_flip_v(void);
245 /* menus.c */
246 void set_menu_label(GtkMenuItem * item, const gchar * text, gboolean mnemonic);
247 GtkAccelGroup *create_menus(void);
249 /* move_pointer.c */
250 void move_pointer(gint dest_x, gint dest_y);
252 /* next_image.c */
253 void after_reorder(gint new_id);
254 gboolean load_direction(gint dir);
255 void open_next_image(void);
256 void load_first_image(void);
257 void load_second_image(void);
258 void open_file(const gchar * filename, gboolean add_dir, gboolean shuffle_flag);
259 void reload_all_images(void);
260 void menu_load(const gchar * filename);
261 void unload(GList * node);
262 void set_slide_show_menu(GtkMenuItem * item);
263 void start_slide_show(void);
264 gboolean slide_show_started(void);
265 void toggle_slide_show(void);
266 void begin_with_slide_show(void);
268 /* open_dialog.c */
269 gboolean menu_open(void);
271 /* options.c */
272 void show_options(void);
274 /* rcfile.c */
275 options_struct *load_rc(gboolean from_file);
276 void load_accelerators(void);
277 void save_rc(options_struct * opt);
279 /* rendering.c */
280 void render(void);
281 void zoom_in(gfloat ratio);
282 void refresh(gint what);
284 /* str_utils.c */
285 const gchar *add_mnemonic(const gchar * str);
286 const gchar *locale_to_utf8(const gchar * str);
287 gchar *clean_filename(const gchar * filename);
288 gchar *clean_filename_free(gchar * filename);
289 gchar *fast_build_filename(const gchar * dir, const gchar * file);
290 gchar *str_escape(const gchar * str);
292 /* textures.c */
293 void prioritize_textures(gliv_image * im, gboolean is_prio);
294 void create_maps(gliv_image * im);
296 /* windows.c */
297 void show_dialog(GtkWidget * widget, const gchar * name,
298 gboolean unused_with_gtk2);
299 void set_loading_entry(const gchar * filename);
300 void toggle_menu_bar(void);
301 void toggle_status_bar(void);
302 void toggle_scrollbars(void);
303 void update_status_bar(void);
304 void update_scrollbars(gboolean redraw);
305 void refresh_all(void);
306 void create_windows(void);
307 void goto_window(gboolean force_resize);
308 void toggle_fullscreen(gboolean enable);
309 void update_window_title(void);
310 GtkWindow *get_current_window(void);
312 /* zoom_frame.c */
313 void draw_zoom_frame(gboolean draw);
314 void set_zoom_frame(gint x, gint y, gint width, gint height);
315 void clear_zoom_frame(void);
316 void zoom_frame(void);