1f8fee6e2c1d107ca4ff38e06efb969acc7cc895
[geeqie.git] / src / gqview.h
1 /*
2  * GQview image viewer
3  * (C)1999 John Ellis
4  *
5  * Author: John Ellis
6  *
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #  include "config.h"
11 #endif
12
13 #include "intl.h"
14
15 /*
16  *-------------------------------------
17  * Standard library includes
18  *-------------------------------------
19  */
20
21 #include <pwd.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <time.h>
26 #include <unistd.h>
27 #include <sys/stat.h>
28 #include <dirent.h>
29
30 /*
31  *-------------------------------------
32  * includes for glib / gtk / imlib
33  *-------------------------------------
34  */
35
36 #include <gdk/gdk.h>
37 #include <gtk/gtk.h>
38 #include <gdk_imlib.h>
39
40 /*
41  *----------------------------------------------------------------------------
42  * defines
43  *----------------------------------------------------------------------------
44  */
45
46 #define RC_FILE_NAME ".gqviewrc"
47 #define RC_THUMB_DIR ".gqview_thmb"
48
49 #define ZOOM_RESET_ORIGINAL 0
50 #define ZOOM_RESET_FIT_WINDOW 1
51 #define ZOOM_RESET_NONE 2
52
53 typedef struct _ImageWindow ImageWindow;
54 struct _ImageWindow
55 {
56         GtkWidget *eventbox;
57         GtkWidget *table;
58         GtkWidget *viewport;
59         GtkWidget *image;
60
61         gchar *image_path;
62         gchar *image_name;
63
64         gint width;
65         gint height;
66         gint size;
67
68         gint old_width;
69         gint old_height;
70
71         gint unknown;
72         gint zoom;
73
74         GdkPixmap *image_pixmap;
75         GdkImlibImage *image_data;
76
77         gint in_drag;
78         gint drag_last_x;
79         gint drag_last_y;
80         gint drag_moved;
81
82         gint artificial_size;
83         gint new_img;
84
85         /* info, zoom labels & windows */
86
87         GtkWidget *top_window; /* window that gets title set to image filename */
88         GtkWidget *info_label; /* label set to show image h x w , size */
89         GtkWidget *zoom_label; /* label to display zoom */
90         gchar *title;          /* window title to display left of file name */
91         gint show_title_zoom;  /* option to include zoom in window title */
92
93         /* button functions */
94         void (*func_btn1)(ImageWindow *, GdkEventButton *, gpointer);
95         void (*func_btn2)(ImageWindow *, GdkEventButton *, gpointer);
96         void (*func_btn3)(ImageWindow *, GdkEventButton *, gpointer);
97
98         gpointer data_btn1;
99         gpointer data_btn2;
100         gpointer data_btn3;
101 };
102
103 /* image */
104 extern ImageWindow *main_image;
105
106 /* main window */
107 extern GtkWidget *mainwindow;
108 extern GtkWidget *mainwindow_hbox;
109 extern GtkWidget *mainwindow_vbox;
110 extern GtkAccelGroup *mainwindow_accel_grp;
111
112 extern GtkWidget *info_box;
113 extern GtkWidget *info_progress_bar;
114 extern GtkWidget *info_status;
115 extern GtkWidget *info_details;
116 extern GtkWidget *info_zoom;
117
118 /* full screen */
119 extern ImageWindow *normal_image;
120 extern ImageWindow *full_screen_image;
121 extern GtkWidget *full_screen_window;
122
123 /* tools floating window */
124 extern GtkWidget *toolwindow;
125
126 /* tools */
127 extern GtkWidget *tool_vbox;
128
129 extern GtkWidget *path_entry;
130 extern GtkWidget *history_menu;
131
132 extern GtkWidget *dir_clist;
133 extern GtkWidget *file_clist;
134
135 extern GtkWidget *menu_file;
136 extern GtkWidget *menu_edit;
137 extern GtkWidget *menu_view;
138 extern GtkWidget *menu_help;
139 extern GtkWidget *menu_file_popup;
140 extern GtkWidget *menu_filelist_edit;
141 extern GtkWidget *menu_image_popup;
142 extern GtkWidget *menu_image_edit;
143 extern GtkWidget *menu_window_full;
144 extern GtkWidget *menu_window_full_edit;
145 extern GtkWidget *menu_window_view;
146 extern GtkWidget *menu_window_view_edit;
147
148 extern GtkWidget *thumb_button;
149 extern GtkWidget *thumb_menu_item;
150
151 /* lists */
152 extern GList *dir_list;
153 extern GList *file_list;
154 extern gchar *current_path;
155
156 extern GList *filename_filter;
157
158 /* -- options -- */
159 extern gint main_window_w;
160 extern gint main_window_h;
161 extern gint main_window_x;
162 extern gint main_window_y;
163
164 extern gint float_window_w;
165 extern gint float_window_h;
166 extern gint float_window_x;
167 extern gint float_window_y;
168
169 extern gint save_window_positions;
170 extern gint tools_float;
171 extern gint tools_hidden;
172 extern gint progressive_key_scrolling;
173
174 extern gint startup_path_enable;
175 extern gchar *startup_path;
176 extern gint confirm_delete;
177 extern gint restore_tool;
178 extern gint zoom_mode;
179 extern gint fit_window;
180 extern gint limit_window_size;
181 extern gint max_window_size;
182 extern gint thumb_max_width;
183 extern gint thumb_max_height;
184 extern gint enable_thumb_caching;
185 extern gint use_xvpics_thumbnails;
186 extern gint show_dot_files;
187 extern gint file_filter_disable;
188 extern gint filter_include_jpg;
189 extern gint filter_include_xpm;
190 extern gint filter_include_tif;
191 extern gint filter_include_gif;
192 extern gint filter_include_png;
193 extern gint filter_include_ppm;
194 extern gint filter_include_pgm;
195 extern gint filter_include_pcx;
196 extern gint filter_include_bmp;
197 extern gchar *custom_filter;
198 extern gchar *editor_name[];
199 extern gchar *editor_command[];
200
201 extern gint thumbnails_enabled;
202
203 extern gint slideshow_delay;    /* in seconds */
204 extern gint slideshow_random;
205 extern gint slideshow_repeat;
206
207 extern gint debug;
208
209 /* logo & misc images */
210 extern const int logo_width;
211 extern const int logo_height;
212 extern const unsigned char logo[];
213
214 /* -- functions -- */
215
216 /* main.c */
217 gchar *filename_from_path(char *t);
218 gchar *remove_level_from_path(gchar *path);
219 void parse_out_relatives(gchar *path);
220 void start_editor_from_file(gint n, gchar *path);
221 void start_editor_from_image(gint n);
222 void start_editor_from_list(gint n);
223 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event);
224 gint key_press_cb(GtkWidget *widget, GdkEventKey *event);
225 void exit_gqview();
226
227 /* window.c */
228 void toolwindow_float();
229 void toolwindow_hide();
230 void create_main_window();
231
232 /* menu.c */
233 void add_menu_popup_item(GtkWidget *menu, gchar *label,
234                          GtkSignalFunc func, gpointer data);
235 void add_menu_divider(GtkWidget *menu);
236 void update_edit_menus(GtkAccelGroup *accel_grp);
237 GtkWidget *create_menu_bar(GtkAccelGroup *accel_grp);
238 void create_menu_popups();
239 GtkWidget *create_button_bar(GtkTooltips *tooltips);
240
241 /* img-main.c */
242 void full_screen_start();
243 void full_screen_stop();
244 void full_screen_toggle();
245 void image_scroll(gint x, gint y);
246 void image_adjust_zoom(gint increment);
247 void image_set_zoom(gint zoom);
248 void image_set_path(gchar *path);
249 gchar *image_get_path();
250 gchar *image_get_name();
251 void image_change_to(gchar *path);
252 void image_set_labels(GtkWidget *info, GtkWidget *zoom);
253 GtkWidget *image_create();
254
255 /* filelist.c */
256 void update_status_label(gchar *text);
257 void rebuild_file_filter();
258 gint find_file_in_list(gchar *path);
259 GList *file_get_selected_list();
260 void free_selected_list(GList *list);
261 gint file_clicked_is_selected();
262 gchar *file_clicked_get_path();
263 gint file_count();
264 gint file_selection_count();
265 gchar *file_get_path(gint row);
266 gint file_is_selected(gint row);
267 void file_image_change_to(gint row);
268 void file_next_image();
269 void file_prev_image();
270 void file_first_image();
271 void file_last_image();
272 void file_is_gone(gchar *path, GList *ignore_list);
273 void file_is_renamed(gchar *source, gchar *dest);
274 void dir_select_cb(GtkWidget *widget, gint row, gint col,
275                    GdkEvent *event, gpointer data);
276 void dir_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
277 void file_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
278 void file_select_cb(GtkWidget *widget, gint row, gint col,
279                    GdkEvent *event, gpointer data);
280 void file_unselect_cb(GtkWidget *widget, gint row, gint col,
281                    GdkEvent *event, gpointer data);
282 void file_clist_highlight_set();
283 void file_clist_highlight_unset();
284 void path_entry_cb(gchar *newdir, gpointer data);
285 void interrupt_thumbs();
286 void filelist_populate_clist();
287 void filelist_refresh();
288 void filelist_change_to(gchar *path);
289
290 /* config.c */
291 void show_config_window();
292 void show_about_window();
293
294 /* rcfile.c */
295 void save_options();
296 void load_options();
297
298 /* tabcomp.c */
299 GtkWidget *tab_completion_new_with_history(GtkWidget **entry, GtkWidget *window, gchar *text,
300                                            const gchar *history_key, gint max_levels,
301                                            void (*enter_func)(gchar *, gpointer), gpointer data);
302 gchar *tab_completion_set_to_last_history(GtkWidget *entry);
303 void tab_completion_append_to_history(GtkWidget *entry, gchar *path);
304
305 GtkWidget *tab_completion_new(GtkWidget **entry, GtkWidget *window, gchar *text,
306                               void (*enter_func)(gchar *, gpointer), gpointer data);
307 void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(gchar *, gpointer), gpointer data);
308 void tab_completion_add_tab_func(GtkWidget *entry, void (*tab_func)(gchar *, gpointer), gpointer data);
309 gchar *remove_trailing_slash(gchar *path);
310
311 /* fileops.c */
312 gchar *homedir();
313 int isfile(char *s);
314 int isdir(char *s);
315 int filesize(char *s);
316 time_t filetime(gchar *s);
317 int copy_file(char *s, char *t);
318 int move_file(char *s, char *t);
319 gchar *get_current_dir();
320
321 /* dnd.c */
322 void image_dnd_init(ImageWindow *imd);
323 void init_dnd();
324
325 /* pathsel.c */
326 GtkWidget *destination_widget_new(gchar *path, GtkWidget *entry);
327 void destination_widget_sync_to_entry(GtkWidget *entry);
328
329 #include "utildlg.h"
330
331 /* utilops.c */
332 void file_util_delete(gchar *source_path, GList *source_list);
333 void file_util_move(gchar *source_path, GList *source_list, gchar *dest_path);
334 void file_util_copy(gchar *source_path, GList *source_list, gchar *dest_path);
335 void file_util_rename(gchar *source_path, GList *source_list);
336 void file_util_create_dir(gchar *path);
337
338 /* thumb.c */
339 gint create_thumbnail(gchar *path, GdkPixmap **thumb_pixmap, GdkBitmap **thumb_mask);
340 gint maintain_thumbnail_dir(gchar *dir, gint recursive);
341
342 /* slideshow.c */
343 void slideshow_start();
344 void slideshow_stop();
345 void slideshow_toggle();
346 gint slideshow_is_running();
347
348 /* img-view.c */
349 void view_window_new(gchar *path);
350 void view_window_active_edit(gint n);
351 void create_menu_view_popup();
352
353
354