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