1
|
1 /*
|
|
2 * GQview image viewer
|
3
|
3 * (C)2000 John Ellis
|
1
|
4 *
|
|
5 * Author: John Ellis
|
|
6 *
|
|
7 */
|
|
8
|
|
9 #include "gqview.h"
|
|
10
|
|
11 #include "icons/icon_thumb.xpm"
|
|
12 #include "icons/icon_home.xpm"
|
|
13 #include "icons/icon_reload.xpm"
|
|
14 #include "icons/icon_zoom_in.xpm"
|
|
15 #include "icons/icon_zoom_out.xpm"
|
|
16 #include "icons/icon_zoom_fit.xpm"
|
|
17 #include "icons/icon_zoom_norm.xpm"
|
|
18 #include "icons/icon_config.xpm"
|
|
19 #include "icons/icon_float.xpm"
|
|
20
|
|
21
|
|
22 static void add_menu_item(GtkWidget *menu, gchar *label, GtkAccelGroup *accel_group,
|
|
23 guint accel_key, guint accel_mods, GtkSignalFunc func, gpointer data);
|
|
24
|
|
25 static void add_edit_items(GtkWidget *menu, GtkSignalFunc func, GtkAccelGroup *accel_grp);
|
|
26
|
|
27 static void add_button_to_bar(GtkWidget *hbox, gchar **pixmap_data,
|
|
28 GtkTooltips *tooltips, gchar *tip_text,
|
|
29 GtkSignalFunc func, gpointer data);
|
|
30
|
|
31 static void set_thumbnails(gint mode)
|
|
32 {
|
|
33 if (thumbnails_enabled == mode) return;
|
|
34 thumbnails_enabled = mode;
|
|
35 gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(thumb_menu_item), thumbnails_enabled);
|
|
36 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(thumb_button), thumbnails_enabled);
|
|
37 filelist_populate_clist();
|
|
38 }
|
|
39
|
|
40 /*
|
|
41 *-----------------------------------------------------------------------------
|
|
42 * menu and button callbacks (private)
|
|
43 *-----------------------------------------------------------------------------
|
|
44 */
|
|
45
|
|
46 static void exit_cb(GtkWidget *widget, gpointer data)
|
|
47 {
|
|
48 exit_gqview();
|
|
49 }
|
|
50
|
|
51 static void about_cb(GtkWidget *widget, gpointer data)
|
|
52 {
|
|
53 show_about_window();
|
|
54 }
|
|
55
|
|
56 static void create_dir_cb(GtkWidget *widget, gpointer data)
|
|
57 {
|
|
58 file_util_create_dir(current_path);
|
|
59 }
|
|
60
|
|
61 static void zoom_in_cb(GtkWidget *widget, gpointer data)
|
|
62 {
|
|
63 image_adjust_zoom(1);
|
|
64 }
|
|
65
|
|
66 static void zoom_out_cb(GtkWidget *widget, gpointer data)
|
|
67 {
|
|
68 image_adjust_zoom(-1);
|
|
69 }
|
|
70
|
|
71 static void zoom_1_1_cb(GtkWidget *widget, gpointer data)
|
|
72 {
|
|
73 image_set_zoom(1);
|
|
74 }
|
|
75
|
|
76 static void zoom_fit_cb(GtkWidget *widget, gpointer data)
|
|
77 {
|
|
78 image_set_zoom(0);
|
|
79 }
|
|
80
|
|
81 static void thumb_menu_cb(GtkWidget *widget, gpointer data)
|
|
82 {
|
|
83 set_thumbnails(GTK_CHECK_MENU_ITEM(widget)->active);
|
|
84 }
|
|
85
|
|
86 static void thumb_button_cb(GtkWidget *widget, gpointer data)
|
|
87 {
|
|
88 set_thumbnails(GTK_TOGGLE_BUTTON(widget)->active);
|
|
89 }
|
|
90
|
|
91 static void refresh_cb(GtkWidget *widget, gpointer data)
|
|
92 {
|
|
93 gchar *buf = g_strdup(current_path);
|
|
94 filelist_change_to(buf);
|
|
95 g_free(buf);
|
|
96 }
|
|
97
|
|
98 static void float_cb(GtkWidget *widget, gpointer data)
|
|
99 {
|
|
100 toolwindow_float();
|
|
101 }
|
|
102
|
|
103 static void hide_cb(GtkWidget *widget, gpointer data)
|
|
104 {
|
|
105 toolwindow_hide();
|
|
106 }
|
|
107
|
|
108 static void slideshow_cb(GtkWidget *widget, gpointer data)
|
|
109 {
|
|
110 slideshow_toggle();
|
|
111 }
|
|
112
|
|
113 static void home_dir_cb(GtkWidget *widget, gpointer data)
|
|
114 {
|
|
115 gchar *path = homedir();
|
|
116 if (path) filelist_change_to(path);
|
|
117 }
|
|
118
|
|
119 static void config_cb(GtkWidget *widget, gpointer data)
|
|
120 {
|
|
121 show_config_window();
|
|
122 }
|
|
123
|
|
124 static void remove_thumb_cb(GtkWidget *widget, gpointer data)
|
|
125 {
|
|
126 maintain_thumbnail_dir("/", TRUE);
|
|
127 }
|
|
128
|
|
129 static void full_screen_cb(GtkWidget *widget, gpointer data)
|
|
130 {
|
|
131 full_screen_toggle();
|
|
132 }
|
|
133
|
3
|
134 static void wallpaper_image_cb(GtkWidget *widget, gpointer data)
|
|
135 {
|
|
136 image_to_root();
|
|
137 }
|
1
|
138
|
|
139 /*
|
|
140 *-----------------------------------------------------------------------------
|
|
141 * image menu callbacks (private)
|
|
142 *-----------------------------------------------------------------------------
|
|
143 */
|
|
144
|
|
145 static void copy_image_cb(GtkWidget *widget, gpointer data)
|
|
146 {
|
|
147 full_screen_stop();
|
|
148 file_util_copy(image_get_path(), NULL, current_path);
|
|
149 }
|
|
150
|
|
151 static void move_image_cb(GtkWidget *widget, gpointer data)
|
|
152 {
|
|
153 full_screen_stop();
|
|
154 file_util_move(image_get_path(), NULL, current_path);
|
|
155 }
|
|
156
|
|
157 static void rename_image_cb(GtkWidget *widget, gpointer data)
|
|
158 {
|
|
159 full_screen_stop();
|
|
160 file_util_rename(image_get_path(), NULL);
|
|
161 }
|
|
162
|
|
163 static void delete_image_cb(GtkWidget *widget, gpointer data)
|
|
164 {
|
|
165 full_screen_stop();
|
|
166 file_util_delete(image_get_path(), NULL);
|
|
167 }
|
|
168
|
|
169 /*
|
|
170 *-----------------------------------------------------------------------------
|
|
171 * file menu callbacks (private)
|
|
172 *-----------------------------------------------------------------------------
|
|
173 */
|
|
174
|
|
175 static void copy_file_cb(GtkWidget *widget, gpointer data)
|
|
176 {
|
|
177 file_util_copy(NULL, file_get_selected_list(), current_path);
|
|
178 }
|
|
179
|
|
180 static void move_file_cb(GtkWidget *widget, gpointer data)
|
|
181 {
|
|
182 file_util_move(NULL, file_get_selected_list(), current_path);
|
|
183 }
|
|
184
|
|
185 static void rename_file_cb(GtkWidget *widget, gpointer data)
|
|
186 {
|
|
187 file_util_rename(NULL, file_get_selected_list());
|
|
188 }
|
|
189
|
|
190 static void delete_file_cb(GtkWidget *widget, gpointer data)
|
|
191 {
|
|
192 file_util_delete(NULL, file_get_selected_list());
|
|
193 }
|
|
194
|
|
195 /*
|
|
196 *-----------------------------------------------------------------------------
|
|
197 * filelist popup menu callbacks (private)
|
|
198 *-----------------------------------------------------------------------------
|
|
199 */
|
|
200
|
|
201 static void popup_copy_file_cb(GtkWidget *widget, gpointer data)
|
|
202 {
|
|
203 if (file_clicked_is_selected())
|
|
204 {
|
|
205 file_util_copy(NULL, file_get_selected_list(), current_path);
|
|
206 }
|
|
207 else
|
|
208 {
|
|
209 gchar *path = file_clicked_get_path();
|
|
210 file_util_copy(path, NULL, current_path);
|
|
211 g_free(path);
|
|
212 }
|
|
213 }
|
|
214
|
|
215 static void popup_move_file_cb(GtkWidget *widget, gpointer data)
|
|
216 {
|
|
217 if (file_clicked_is_selected())
|
|
218 {
|
|
219 file_util_move(NULL, file_get_selected_list(), current_path);
|
|
220 }
|
|
221 else
|
|
222 {
|
|
223 gchar *path = file_clicked_get_path();
|
|
224 file_util_move(path, NULL, current_path);
|
|
225 g_free(path);
|
|
226 }
|
|
227 }
|
|
228
|
|
229 static void popup_rename_file_cb(GtkWidget *widget, gpointer data)
|
|
230 {
|
|
231 if (file_clicked_is_selected())
|
|
232 {
|
|
233 file_util_rename(NULL, file_get_selected_list());
|
|
234 }
|
|
235 else
|
|
236 {
|
|
237 gchar *path = file_clicked_get_path();
|
|
238 file_util_rename(path, NULL);
|
|
239 g_free(path);
|
|
240 }
|
|
241 }
|
|
242
|
|
243 static void popup_delete_file_cb(GtkWidget *widget, gpointer data)
|
|
244 {
|
|
245 if (file_clicked_is_selected())
|
|
246 {
|
|
247 file_util_delete(NULL, file_get_selected_list());
|
|
248 }
|
|
249 else
|
|
250 {
|
|
251 gchar *path = file_clicked_get_path();
|
|
252 file_util_delete(path, NULL);
|
|
253 g_free(path);
|
|
254 }
|
|
255 }
|
|
256
|
|
257 static void edit_image_cb(GtkWidget *widget, gpointer data)
|
|
258 {
|
|
259 gint n = GPOINTER_TO_INT(data);
|
|
260 start_editor_from_image(n);
|
|
261 }
|
|
262
|
|
263 static void edit_list_cb(GtkWidget *widget, gpointer data)
|
|
264 {
|
|
265 gint n = GPOINTER_TO_INT(data);
|
|
266 start_editor_from_list(n);
|
|
267 }
|
|
268
|
|
269 static void edit_full_cb(GtkWidget *widget, gpointer data)
|
|
270 {
|
|
271 gint n = GPOINTER_TO_INT(data);
|
|
272 full_screen_stop();
|
|
273 start_editor_from_image(n);
|
|
274 }
|
|
275
|
|
276 static void edit_view_cb(GtkWidget *widget, gpointer data)
|
|
277 {
|
|
278 gint n = GPOINTER_TO_INT(data);
|
|
279 view_window_active_edit(n);
|
|
280 }
|
|
281
|
3
|
282 static void wallpaper_view_cb(GtkWidget *widget, gpointer data)
|
|
283 {
|
|
284 gint n = GPOINTER_TO_INT(data);
|
|
285 view_window_active_to_root(n);
|
|
286 }
|
|
287
|
1
|
288 static void popup_edit_list_cb(GtkWidget *widget, gpointer data)
|
|
289 {
|
|
290 gint n = GPOINTER_TO_INT(data);
|
|
291
|
|
292 if (file_clicked_is_selected())
|
|
293 {
|
|
294 start_editor_from_list(n);
|
|
295 }
|
|
296 else
|
|
297 {
|
|
298 gchar *path;
|
|
299 start_editor_from_file(n, path);
|
|
300 g_free(path);
|
|
301 }
|
|
302 }
|
|
303
|
|
304 static void new_window_file_cb(GtkWidget *widget, gpointer data)
|
|
305 {
|
|
306 gchar *path = file_clicked_get_path();
|
|
307 view_window_new(path);
|
|
308 g_free(path);
|
|
309 }
|
|
310
|
|
311 static void new_window_image_cb(GtkWidget *widget, gpointer data)
|
|
312 {
|
|
313 view_window_new(image_get_path());
|
|
314 }
|
|
315
|
|
316 static void menu_file_popup_hide_cb(GtkWidget *widget, gpointer data)
|
|
317 {
|
|
318 file_clist_highlight_unset();
|
|
319 }
|
|
320
|
|
321
|
|
322 /*
|
|
323 *-----------------------------------------------------------------------------
|
|
324 * menu addition utilities (private)
|
|
325 *-----------------------------------------------------------------------------
|
|
326 */
|
|
327
|
|
328 static void add_menu_item(GtkWidget *menu, gchar *label, GtkAccelGroup *accel_group,
|
|
329 guint accel_key, guint accel_mods, GtkSignalFunc func, gpointer data)
|
|
330 {
|
|
331 GtkWidget *item;
|
|
332
|
|
333 item = gtk_menu_item_new_with_label(label);
|
|
334 gtk_widget_add_accelerator (item, "activate", accel_group, accel_key, accel_mods, GTK_ACCEL_VISIBLE);
|
|
335 gtk_signal_connect (GTK_OBJECT (item), "activate",(GtkSignalFunc) func, data);
|
|
336 gtk_menu_append(GTK_MENU(menu), item);
|
|
337 gtk_widget_show(item);
|
|
338 }
|
|
339
|
|
340 void add_menu_popup_item(GtkWidget *menu, gchar *label,
|
|
341 GtkSignalFunc func, gpointer data)
|
|
342 {
|
|
343 GtkWidget *item;
|
|
344
|
|
345 item = gtk_menu_item_new_with_label(label);
|
|
346 gtk_signal_connect (GTK_OBJECT (item), "activate",(GtkSignalFunc) func, data);
|
|
347 gtk_menu_append(GTK_MENU(menu), item);
|
|
348 gtk_widget_show(item);
|
|
349 }
|
|
350
|
|
351 void add_menu_divider(GtkWidget *menu)
|
|
352 {
|
|
353 GtkWidget *item = gtk_menu_item_new();
|
|
354 gtk_menu_append(GTK_MENU(menu),item);
|
|
355 gtk_widget_show(item);
|
|
356 }
|
|
357
|
|
358 /*
|
|
359 *-----------------------------------------------------------------------------
|
|
360 * edit menu routines
|
|
361 *-----------------------------------------------------------------------------
|
|
362 */
|
|
363
|
|
364 static void add_edit_items(GtkWidget *menu, GtkSignalFunc func, GtkAccelGroup *accel_grp)
|
|
365 {
|
|
366 gint i;
|
|
367 for (i = 0; i < 8; i++)
|
|
368 {
|
|
369 if (editor_command[i] && strlen(editor_command[i]) > 0)
|
|
370 {
|
|
371 gchar *text;
|
|
372 if (editor_name[i] && strlen(editor_name[i]) > 0)
|
|
373 text = g_strdup_printf(_("in %s..."), editor_name[i]);
|
|
374 else
|
|
375 text = g_strdup(_("in (unknown)..."));
|
|
376 if (accel_grp)
|
|
377 add_menu_item(menu, text, accel_grp, i + 49, GDK_CONTROL_MASK, func, GINT_TO_POINTER(i));
|
|
378 else
|
|
379 add_menu_popup_item(menu, text, func, GINT_TO_POINTER(i));
|
|
380 g_free(text);
|
|
381 }
|
|
382 }
|
|
383 }
|
|
384
|
|
385 void update_edit_menus(GtkAccelGroup *accel_grp)
|
|
386 {
|
|
387 GtkWidget *menu;
|
|
388
|
|
389 /* main edit menu */
|
|
390
|
|
391 menu = gtk_menu_new();
|
|
392 add_edit_items(menu, edit_list_cb, accel_grp);
|
|
393 add_menu_divider(menu);
|
|
394 add_menu_item(menu, _("Options..."), accel_grp, 'O', GDK_CONTROL_MASK, config_cb, NULL);
|
|
395 add_menu_divider(menu);
|
|
396 add_menu_item(menu, _("Remove old thumbnails"), accel_grp, 'T', GDK_CONTROL_MASK, remove_thumb_cb, NULL);
|
3
|
397 add_menu_divider(menu);
|
|
398 add_menu_item(menu, _("Set as wallpaper"), accel_grp, 'W', GDK_CONTROL_MASK, wallpaper_image_cb, NULL);
|
1
|
399 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_edit), menu);
|
|
400
|
|
401 /* file edit popup */
|
|
402 menu = gtk_menu_new();
|
|
403 add_edit_items(menu, popup_edit_list_cb, NULL);
|
|
404 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_filelist_edit), menu);
|
|
405
|
|
406 /* image edit popup */
|
|
407 menu = gtk_menu_new();
|
|
408 add_edit_items(menu, edit_image_cb, NULL);
|
3
|
409 add_menu_divider(menu);
|
|
410 add_menu_popup_item(menu, _("Set as wallpaper"), wallpaper_image_cb, NULL);
|
1
|
411 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_image_edit), menu);
|
|
412
|
|
413 /* full screen edit popup */
|
|
414 menu = gtk_menu_new();
|
|
415 add_edit_items(menu, edit_full_cb, NULL);
|
|
416 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_window_full_edit), menu);
|
|
417
|
|
418 /* view edit popup */
|
|
419 menu = gtk_menu_new();
|
|
420 add_edit_items(menu, edit_view_cb, NULL);
|
3
|
421 add_menu_divider(menu);
|
|
422 add_menu_popup_item(menu, _("Set as wallpaper"), wallpaper_view_cb, NULL);
|
1
|
423 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_window_view_edit), menu);
|
|
424 }
|
|
425
|
|
426 /*
|
|
427 *-----------------------------------------------------------------------------
|
|
428 * menu bar setup routines
|
|
429 *-----------------------------------------------------------------------------
|
|
430 */
|
|
431
|
|
432 GtkWidget *create_menu_bar(GtkAccelGroup *accel_grp)
|
|
433 {
|
|
434 GtkWidget *bar;
|
|
435 GtkWidget *menu;
|
|
436
|
|
437 bar = gtk_menu_bar_new();
|
|
438
|
|
439 /* file menu */
|
|
440 menu_file = gtk_menu_item_new_with_label(_("File"));
|
|
441 gtk_widget_show(menu_file);
|
|
442
|
|
443 menu = gtk_menu_new();
|
|
444 add_menu_item(menu, _("Create Dir..."), accel_grp, 'N', GDK_CONTROL_MASK, create_dir_cb, NULL);
|
|
445 add_menu_divider(menu);
|
|
446 add_menu_item(menu, _("Copy..."), accel_grp, 'C', GDK_CONTROL_MASK, copy_file_cb, NULL);
|
|
447 add_menu_item(menu, _("Move..."), accel_grp, 'M', GDK_CONTROL_MASK, move_file_cb, NULL);
|
|
448 add_menu_item(menu, _("Rename..."), accel_grp, 'R', GDK_CONTROL_MASK, rename_file_cb, NULL);
|
|
449 add_menu_item(menu, _("Delete..."), accel_grp, 'D', GDK_CONTROL_MASK, delete_file_cb, NULL);
|
|
450 add_menu_divider(menu);
|
|
451 add_menu_item(menu, _("Exit"), accel_grp, 'Q', GDK_CONTROL_MASK, exit_cb, NULL);
|
|
452
|
|
453 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_file),menu);
|
|
454 gtk_menu_bar_append(GTK_MENU_BAR(bar),menu_file);
|
|
455
|
|
456 /* edit menu */
|
|
457 menu_edit = gtk_menu_item_new_with_label(_("Edit"));
|
|
458 gtk_widget_show(menu_edit);
|
|
459
|
|
460 menu = gtk_menu_new();
|
|
461
|
|
462 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_edit), menu);
|
|
463 gtk_menu_bar_append(GTK_MENU_BAR(bar), menu_edit);
|
|
464
|
|
465 /* view menu */
|
|
466 menu_view = gtk_menu_item_new_with_label(_("View"));
|
|
467 gtk_widget_show(menu_view);
|
|
468
|
|
469 menu = gtk_menu_new();
|
|
470 add_menu_item(menu, _("Zoom in"), accel_grp, '=', FALSE, zoom_in_cb, NULL);
|
|
471 add_menu_item(menu, _("Zoom out"), accel_grp, '-', FALSE, zoom_out_cb, NULL);
|
|
472 add_menu_item(menu, _("Zoom 1:1"), accel_grp, 'Z', FALSE, zoom_1_1_cb, NULL);
|
|
473 add_menu_item(menu, _("Fit image to window"), accel_grp, 'X', FALSE, zoom_fit_cb, NULL);
|
|
474 add_menu_divider(menu);
|
|
475
|
3
|
476 add_menu_item(menu, _("Full screen"), accel_grp, 'V', FALSE, full_screen_cb, NULL);
|
1
|
477 thumb_menu_item = gtk_check_menu_item_new_with_label(_("Thumbnails"));
|
3
|
478 gtk_check_menu_item_set_state(GTK_CHECK_MENU_ITEM(thumb_menu_item), thumbnails_enabled);
|
1
|
479 gtk_widget_add_accelerator (thumb_menu_item, "activate", accel_grp, 'T', FALSE, GTK_ACCEL_VISIBLE);
|
|
480 gtk_signal_connect (GTK_OBJECT (thumb_menu_item), "activate",(GtkSignalFunc) thumb_menu_cb, thumb_menu_item);
|
|
481 gtk_menu_append(GTK_MENU(menu), thumb_menu_item);
|
|
482 gtk_widget_show(thumb_menu_item);
|
|
483
|
|
484 add_menu_divider(menu);
|
|
485 add_menu_item(menu, _("Refresh Lists"), accel_grp, 'R', FALSE, refresh_cb, NULL);
|
|
486 add_menu_item(menu, _("(Un)Float file list"), accel_grp, 'F', FALSE, float_cb, NULL);
|
|
487 add_menu_item(menu, _("(Un)Hide file list"), accel_grp, 'H', FALSE, hide_cb, NULL);
|
|
488
|
|
489 add_menu_divider(menu);
|
|
490 add_menu_item(menu, _("Toggle slideshow"), accel_grp, 'S', FALSE, slideshow_cb, NULL);
|
|
491
|
|
492 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_view), menu);
|
|
493 gtk_menu_bar_append(GTK_MENU_BAR(bar), menu_view);
|
|
494
|
|
495 /* help menu */
|
|
496 menu_help = gtk_menu_item_new_with_label(_("Help"));
|
|
497 gtk_widget_show(menu_help);
|
|
498
|
|
499 menu = gtk_menu_new();
|
|
500 add_menu_item(menu, _("About"), accel_grp, 'A', GDK_CONTROL_MASK, about_cb, NULL);
|
|
501
|
|
502 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_help), menu);
|
|
503 gtk_menu_bar_append(GTK_MENU_BAR(bar), menu_help);
|
|
504
|
|
505 return bar;
|
|
506 }
|
|
507
|
|
508 /*
|
|
509 *-----------------------------------------------------------------------------
|
|
510 * menu file list routines (private)
|
|
511 *-----------------------------------------------------------------------------
|
|
512 */
|
|
513
|
|
514 static void create_menu_file_list_popup()
|
|
515 {
|
|
516 menu_file_popup = gtk_menu_new();
|
|
517 gtk_signal_connect(GTK_OBJECT(menu_file_popup), "hide", (GtkSignalFunc) menu_file_popup_hide_cb, NULL);
|
|
518
|
|
519 menu_filelist_edit = gtk_menu_item_new_with_label(_("Edit"));
|
|
520 gtk_menu_append(GTK_MENU(menu_file_popup), menu_filelist_edit);
|
|
521 gtk_widget_show(menu_filelist_edit);
|
|
522
|
|
523 add_menu_popup_item(menu_file_popup, _("View in new window"), new_window_file_cb, NULL);
|
|
524
|
|
525 add_menu_divider(menu_file_popup);
|
|
526 add_menu_popup_item(menu_file_popup, _("Copy..."), popup_copy_file_cb, NULL);
|
|
527 add_menu_popup_item(menu_file_popup, _("Move..."), popup_move_file_cb, NULL);
|
|
528 add_menu_popup_item(menu_file_popup, _("Rename..."), popup_rename_file_cb, NULL);
|
|
529 add_menu_popup_item(menu_file_popup, _("Delete..."), popup_delete_file_cb, NULL);
|
|
530 add_menu_divider(menu_file_popup);
|
|
531 add_menu_popup_item(menu_file_popup, _("Refresh"), refresh_cb, NULL);
|
|
532 }
|
|
533
|
|
534 /*
|
|
535 *-----------------------------------------------------------------------------
|
|
536 * menu image routines (private)
|
|
537 *-----------------------------------------------------------------------------
|
|
538 */
|
|
539
|
|
540 static void create_menu_image_popup()
|
|
541 {
|
|
542 menu_image_popup = gtk_menu_new();
|
|
543
|
|
544 add_menu_popup_item(menu_image_popup, _("Zoom in"), zoom_in_cb, NULL);
|
|
545 add_menu_popup_item(menu_image_popup, _("Zoom out"), zoom_out_cb, NULL);
|
|
546 add_menu_popup_item(menu_image_popup, _("Zoom 1:1"), zoom_1_1_cb, NULL);
|
|
547 add_menu_popup_item(menu_image_popup, _("Fit image to window"), zoom_fit_cb, NULL);
|
|
548 add_menu_divider(menu_image_popup);
|
|
549
|
|
550 menu_image_edit = gtk_menu_item_new_with_label(_("Edit"));
|
|
551 gtk_menu_append(GTK_MENU(menu_image_popup), menu_image_edit);
|
|
552 gtk_widget_show(menu_image_edit);
|
|
553
|
|
554 add_menu_popup_item(menu_image_popup, _("View in new window"), new_window_image_cb, NULL);
|
|
555
|
|
556 add_menu_divider(menu_image_popup);
|
|
557 add_menu_popup_item(menu_image_popup, _("Copy..."), copy_image_cb, NULL);
|
|
558 add_menu_popup_item(menu_image_popup, _("Move..."), move_image_cb, NULL);
|
|
559 add_menu_popup_item(menu_image_popup, _("Rename..."), rename_image_cb, NULL);
|
|
560 add_menu_popup_item(menu_image_popup, _("Delete..."), delete_image_cb, NULL);
|
|
561 add_menu_divider(menu_image_popup);
|
|
562 add_menu_popup_item(menu_image_popup, _("(Un)Hide file list"), hide_cb, NULL);
|
|
563 add_menu_popup_item(menu_image_popup, _("Full screen"), full_screen_cb, NULL);
|
|
564 }
|
|
565
|
|
566 /*
|
|
567 *-----------------------------------------------------------------------------
|
|
568 * menu full screen routines (private)
|
|
569 *-----------------------------------------------------------------------------
|
|
570 */
|
|
571
|
|
572 /* this re-grabs the keyboard when the menu closes, needed for override redirect */
|
|
573 static void menu_full_popup_hide_cb(GtkWidget *widget, gpointer data)
|
|
574 {
|
|
575 if (full_screen_window)
|
|
576 {
|
|
577 gdk_keyboard_grab(full_screen_window->window, TRUE, GDK_CURRENT_TIME);
|
|
578 }
|
|
579 }
|
|
580
|
|
581 static void create_menu_full_screen_popup()
|
|
582 {
|
|
583 menu_window_full = gtk_menu_new();
|
|
584 add_menu_popup_item(menu_window_full, _("Zoom in"), zoom_in_cb, NULL);
|
|
585 add_menu_popup_item(menu_window_full, _("Zoom out"), zoom_out_cb, NULL);
|
|
586 add_menu_popup_item(menu_window_full, _("Zoom 1:1"), zoom_1_1_cb, NULL);
|
|
587 add_menu_popup_item(menu_window_full, _("Fit image to window"), zoom_fit_cb, NULL);
|
|
588 add_menu_divider(menu_window_full);
|
|
589
|
|
590 menu_window_full_edit = gtk_menu_item_new_with_label(_("Edit"));
|
|
591 gtk_menu_append(GTK_MENU(menu_window_full), menu_window_full_edit);
|
|
592 gtk_widget_show(menu_window_full_edit);
|
|
593
|
|
594 add_menu_divider(menu_window_full);
|
|
595 add_menu_popup_item(menu_window_full, _("Copy..."), copy_image_cb, NULL);
|
|
596 add_menu_popup_item(menu_window_full, _("Move..."), move_image_cb, NULL);
|
|
597 add_menu_popup_item(menu_window_full, _("Rename..."), rename_image_cb, NULL);
|
|
598 add_menu_popup_item(menu_window_full, _("Delete..."), delete_image_cb, NULL);
|
|
599
|
|
600 add_menu_divider(menu_window_full);
|
|
601 add_menu_popup_item(menu_window_full, _("Exit full screen"), full_screen_cb, NULL);
|
|
602
|
|
603 gtk_signal_connect(GTK_OBJECT(menu_window_full), "hide", (GtkSignalFunc) menu_full_popup_hide_cb, NULL);
|
|
604 }
|
|
605
|
|
606 void create_menu_popups()
|
|
607 {
|
|
608 create_menu_file_list_popup();
|
|
609 create_menu_image_popup();
|
|
610 create_menu_full_screen_popup();
|
|
611 create_menu_view_popup();
|
|
612 }
|
|
613
|
|
614 /*
|
|
615 *-----------------------------------------------------------------------------
|
|
616 * toolbar routines
|
|
617 *-----------------------------------------------------------------------------
|
|
618 */
|
|
619
|
|
620 static void add_button_to_bar(GtkWidget *hbox, gchar **pixmap_data,
|
|
621 GtkTooltips *tooltips, gchar *tip_text,
|
|
622 GtkSignalFunc func, gpointer data)
|
|
623 {
|
|
624 GtkWidget *button;
|
|
625 GtkStyle *style;
|
|
626 GtkWidget *pixmapwid;
|
|
627 GdkPixmap *pixmap;
|
|
628 GdkBitmap *mask;
|
|
629
|
|
630 style = gtk_widget_get_style(mainwindow);
|
|
631
|
|
632 button = gtk_button_new ();
|
|
633 gtk_signal_connect (GTK_OBJECT (button), "clicked",(GtkSignalFunc) func, thumb_button);
|
|
634 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
635 gtk_widget_show (button);
|
|
636 gtk_tooltips_set_tip (tooltips, button, tip_text, NULL);
|
|
637
|
|
638 pixmap = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask,
|
|
639 &style->bg[GTK_STATE_NORMAL], (gchar **)pixmap_data);
|
|
640 pixmapwid = gtk_pixmap_new(pixmap, mask);
|
|
641 gtk_widget_show(pixmapwid);
|
|
642 gtk_container_add(GTK_CONTAINER(button), pixmapwid);
|
|
643 }
|
|
644
|
|
645 GtkWidget *create_button_bar(GtkTooltips *tooltips)
|
|
646 {
|
|
647 GtkWidget *hbox;
|
|
648 GtkStyle *style;
|
|
649 GtkWidget *pixmapwid;
|
|
650 GdkPixmap *pixmap;
|
|
651 GdkBitmap *mask;
|
|
652
|
|
653 style = gtk_widget_get_style(mainwindow);
|
|
654 hbox = gtk_hbox_new(FALSE, 0);
|
|
655
|
|
656 thumb_button = gtk_toggle_button_new ();
|
3
|
657 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(thumb_button), thumbnails_enabled);
|
1
|
658 gtk_signal_connect (GTK_OBJECT (thumb_button), "clicked",(GtkSignalFunc) thumb_button_cb, thumb_button);
|
|
659 gtk_box_pack_start (GTK_BOX (hbox), thumb_button, FALSE, FALSE, 0);
|
|
660 gtk_widget_show (thumb_button);
|
|
661 gtk_tooltips_set_tip (tooltips, thumb_button, _("Create thumbnails"), NULL);
|
|
662
|
|
663 pixmap = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask,
|
|
664 &style->bg[GTK_STATE_NORMAL], (gchar **)icon_thumb_xpm );
|
|
665 pixmapwid = gtk_pixmap_new(pixmap, mask);
|
|
666 gtk_widget_show(pixmapwid);
|
|
667 gtk_container_add(GTK_CONTAINER(thumb_button), pixmapwid);
|
|
668
|
|
669 add_button_to_bar(hbox, (gchar **)icon_home_xpm,
|
|
670 tooltips, _("Change to home directory"), home_dir_cb, NULL);
|
|
671 add_button_to_bar(hbox, (gchar **)icon_reload_xpm,
|
|
672 tooltips, _("Refresh file list"), refresh_cb, NULL);
|
|
673 add_button_to_bar(hbox, (gchar **)icon_zoom_in_xpm,
|
|
674 tooltips, _("Zoom in"), zoom_in_cb, NULL);
|
|
675 add_button_to_bar(hbox, (gchar **)icon_zoom_out_xpm,
|
|
676 tooltips, _("Zoom out"), zoom_out_cb, NULL);
|
|
677 add_button_to_bar(hbox, (gchar **)icon_zoom_fit_xpm,
|
|
678 tooltips, _("Fit image to window"), zoom_fit_cb, NULL);
|
|
679 add_button_to_bar(hbox, (gchar **)icon_zoom_norm_xpm,
|
|
680 tooltips, _("Set zoom 1:1"), zoom_1_1_cb, NULL);
|
|
681 add_button_to_bar(hbox, (gchar **)icon_config_xpm,
|
|
682 tooltips, _("Configure options"), config_cb, NULL);
|
|
683 add_button_to_bar(hbox, (gchar **)icon_float_xpm,
|
|
684 tooltips, _("Float Controls"), float_cb, NULL);
|
|
685
|
|
686 return hbox;
|
|
687 }
|
|
688
|