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
|
|
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();
|
3
|
254 void image_to_root();
|
1
|
255
|
|
256 /* filelist.c */
|
|
257 void update_status_label(gchar *text);
|
|
258 void rebuild_file_filter();
|
|
259 gint find_file_in_list(gchar *path);
|
|
260 GList *file_get_selected_list();
|
|
261 void free_selected_list(GList *list);
|
|
262 gint file_clicked_is_selected();
|
|
263 gchar *file_clicked_get_path();
|
|
264 gint file_count();
|
|
265 gint file_selection_count();
|
|
266 gchar *file_get_path(gint row);
|
|
267 gint file_is_selected(gint row);
|
|
268 void file_image_change_to(gint row);
|
|
269 void file_next_image();
|
|
270 void file_prev_image();
|
|
271 void file_first_image();
|
|
272 void file_last_image();
|
|
273 void file_is_gone(gchar *path, GList *ignore_list);
|
|
274 void file_is_renamed(gchar *source, gchar *dest);
|
|
275 void dir_select_cb(GtkWidget *widget, gint row, gint col,
|
|
276 GdkEvent *event, gpointer data);
|
|
277 void dir_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
|
|
278 void file_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data);
|
|
279 void file_select_cb(GtkWidget *widget, gint row, gint col,
|
|
280 GdkEvent *event, gpointer data);
|
|
281 void file_unselect_cb(GtkWidget *widget, gint row, gint col,
|
|
282 GdkEvent *event, gpointer data);
|
|
283 void file_clist_highlight_set();
|
|
284 void file_clist_highlight_unset();
|
3
|
285 void path_entry_tab_cb(gchar *newpath, gpointer data);
|
1
|
286 void path_entry_cb(gchar *newdir, gpointer data);
|
|
287 void interrupt_thumbs();
|
|
288 void filelist_populate_clist();
|
|
289 void filelist_refresh();
|
|
290 void filelist_change_to(gchar *path);
|
|
291
|
|
292 /* config.c */
|
|
293 void show_config_window();
|
|
294 void show_about_window();
|
|
295
|
|
296 /* rcfile.c */
|
|
297 void save_options();
|
|
298 void load_options();
|
|
299
|
|
300 /* tabcomp.c */
|
|
301 GtkWidget *tab_completion_new_with_history(GtkWidget **entry, GtkWidget *window, gchar *text,
|
|
302 const gchar *history_key, gint max_levels,
|
|
303 void (*enter_func)(gchar *, gpointer), gpointer data);
|
|
304 gchar *tab_completion_set_to_last_history(GtkWidget *entry);
|
|
305 void tab_completion_append_to_history(GtkWidget *entry, gchar *path);
|
|
306
|
|
307 GtkWidget *tab_completion_new(GtkWidget **entry, GtkWidget *window, gchar *text,
|
|
308 void (*enter_func)(gchar *, gpointer), gpointer data);
|
|
309 void tab_completion_add_to_entry(GtkWidget *entry, void (*enter_func)(gchar *, gpointer), gpointer data);
|
|
310 void tab_completion_add_tab_func(GtkWidget *entry, void (*tab_func)(gchar *, gpointer), gpointer data);
|
|
311 gchar *remove_trailing_slash(gchar *path);
|
|
312
|
|
313 /* fileops.c */
|
|
314 gchar *homedir();
|
|
315 int isfile(char *s);
|
|
316 int isdir(char *s);
|
|
317 int filesize(char *s);
|
|
318 time_t filetime(gchar *s);
|
|
319 int copy_file(char *s, char *t);
|
|
320 int move_file(char *s, char *t);
|
|
321 gchar *get_current_dir();
|
|
322
|
|
323 /* dnd.c */
|
|
324 void image_dnd_init(ImageWindow *imd);
|
|
325 void init_dnd();
|
|
326
|
|
327 /* pathsel.c */
|
|
328 GtkWidget *destination_widget_new(gchar *path, GtkWidget *entry);
|
|
329 void destination_widget_sync_to_entry(GtkWidget *entry);
|
|
330
|
|
331 #include "utildlg.h"
|
|
332
|
|
333 /* utilops.c */
|
|
334 void file_util_delete(gchar *source_path, GList *source_list);
|
|
335 void file_util_move(gchar *source_path, GList *source_list, gchar *dest_path);
|
|
336 void file_util_copy(gchar *source_path, GList *source_list, gchar *dest_path);
|
|
337 void file_util_rename(gchar *source_path, GList *source_list);
|
|
338 void file_util_create_dir(gchar *path);
|
|
339
|
|
340 /* thumb.c */
|
|
341 gint create_thumbnail(gchar *path, GdkPixmap **thumb_pixmap, GdkBitmap **thumb_mask);
|
|
342 gint maintain_thumbnail_dir(gchar *dir, gint recursive);
|
|
343
|
|
344 /* slideshow.c */
|
|
345 void slideshow_start();
|
|
346 void slideshow_stop();
|
3
|
347 void slideshow_next();
|
|
348 void slideshow_prev();
|
1
|
349 void slideshow_toggle();
|
|
350 gint slideshow_is_running();
|
|
351
|
|
352 /* img-view.c */
|
|
353 void view_window_new(gchar *path);
|
|
354 void view_window_active_edit(gint n);
|
3
|
355 void view_window_active_to_root(gint n);
|
1
|
356 void create_menu_view_popup();
|
|
357
|
|
358
|
|
359
|