Mercurial > geeqie.yaz
annotate src/layout_util.c @ 65:322bb41c9b9e
Mon Aug 15 18:27:38 2005 John Ellis <johne@verizon.net>
* cache.c: Make cache loader tolerant of unknown line values, so that
a cache written by newer/older versions of GQview does not result in
recreating data that is actually there.
author | gqview |
---|---|
date | Mon, 15 Aug 2005 22:32:57 +0000 |
parents | 6281cc38e5ca |
children | a4c1b7014e6e |
rev | line source |
---|---|
9 | 1 /* |
2 * GQview | |
3 * (C) 2004 John Ellis | |
4 * | |
5 * Author: John Ellis | |
6 * | |
7 * This software is released under the GNU General Public License (GNU GPL). | |
8 * Please read the included file COPYING for more information. | |
9 * This software comes with no warranty of any kind, use at your own risk! | |
10 */ | |
11 | |
12 | |
13 #include "gqview.h" | |
14 #include "layout_util.h" | |
15 | |
16 #include "bar_info.h" | |
17 #include "bar_exif.h" | |
18 #include "bar_sort.h" | |
19 #include "cache_maint.h" | |
20 #include "collect.h" | |
21 #include "collect-dlg.h" | |
22 #include "dupe.h" | |
23 #include "editors.h" | |
24 #include "info.h" | |
25 #include "layout_image.h" | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
26 #include "pan-view.h" |
9 | 27 #include "pixbuf_util.h" |
28 #include "preferences.h" | |
29 #include "print.h" | |
30 #include "search.h" | |
31 #include "utilops.h" | |
32 #include "ui_bookmark.h" | |
33 #include "ui_fileops.h" | |
34 #include "ui_menu.h" | |
35 #include "ui_misc.h" | |
36 #include "ui_tabcomp.h" | |
37 | |
38 #include <gdk/gdkkeysyms.h> /* for keyboard values */ | |
39 | |
40 | |
41 #define MENU_EDIT_ACTION_OFFSET 16 | |
42 | |
43 | |
44 /* | |
45 *----------------------------------------------------------------------------- | |
46 * keyboard handler | |
47 *----------------------------------------------------------------------------- | |
48 */ | |
49 | |
50 static guint tree_key_overrides[] = { | |
51 GDK_Page_Up, GDK_KP_Page_Up, | |
52 GDK_Page_Down, GDK_KP_Page_Down, | |
53 GDK_Home, GDK_KP_Home, | |
54 GDK_End, GDK_KP_End | |
55 }; | |
56 | |
57 static gint layout_key_match(guint keyval) | |
58 { | |
59 gint i; | |
60 | |
61 for (i = 0; i < sizeof(tree_key_overrides) / sizeof(guint); i++) | |
62 { | |
63 if (keyval == tree_key_overrides[i]) return TRUE; | |
64 } | |
65 | |
66 return FALSE; | |
67 } | |
68 | |
69 static gint layout_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | |
70 { | |
71 LayoutWindow *lw = data; | |
72 gint stop_signal = FALSE; | |
73 gint x = 0; | |
74 gint y = 0; | |
75 | |
76 if (lw->path_entry && GTK_WIDGET_HAS_FOCUS(lw->path_entry)) | |
77 { | |
78 if (event->keyval == GDK_Escape && lw->path) | |
79 { | |
80 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path); | |
81 } | |
82 | |
83 /* the gtkaccelgroup of the window is stealing presses before they get to the entry (and more), | |
84 * so when the some widgets have focus, give them priority (HACK) | |
85 */ | |
86 if (gtk_widget_event(lw->path_entry, (GdkEvent *)event)) | |
87 { | |
88 return TRUE; | |
89 } | |
90 } | |
91 if (lw->vdt && GTK_WIDGET_HAS_FOCUS(lw->vdt->treeview) && | |
92 !layout_key_match(event->keyval) && | |
93 gtk_widget_event(lw->vdt->treeview, (GdkEvent *)event)) | |
94 { | |
95 return TRUE; | |
96 } | |
97 if (lw->bar_info && | |
98 bar_info_event(lw->bar_info, (GdkEvent *)event)) | |
99 { | |
100 return TRUE; | |
101 } | |
102 | |
103 if (lw->image && | |
104 (GTK_WIDGET_HAS_FOCUS(lw->image->widget) || (lw->tools && widget == lw->window)) ) | |
105 { | |
106 switch (event->keyval) | |
107 { | |
108 case GDK_Left: case GDK_KP_Left: | |
109 x -= 1; | |
110 stop_signal = TRUE; | |
111 break; | |
112 case GDK_Right: case GDK_KP_Right: | |
113 x += 1; | |
114 stop_signal = TRUE; | |
115 break; | |
116 case GDK_Up: case GDK_KP_Up: | |
117 y -= 1; | |
118 stop_signal = TRUE; | |
119 break; | |
120 case GDK_Down: case GDK_KP_Down: | |
121 y += 1; | |
122 stop_signal = TRUE; | |
123 break; | |
124 case GDK_BackSpace: | |
125 case 'B': case 'b': | |
126 layout_image_prev(lw); | |
127 stop_signal = TRUE; | |
128 break; | |
129 case GDK_space: | |
130 case 'N': case 'n': | |
131 layout_image_next(lw); | |
132 stop_signal = TRUE; | |
133 break; | |
134 case GDK_Menu: | |
135 layout_image_menu_popup(lw); | |
136 stop_signal = TRUE; | |
137 break; | |
138 } | |
139 } | |
140 | |
141 if (!stop_signal && !(event->state & GDK_CONTROL_MASK) ) | |
142 switch (event->keyval) | |
143 { | |
144 case '+': case GDK_KP_Add: | |
145 layout_image_zoom_adjust(lw, get_zoom_increment()); | |
146 stop_signal = TRUE; | |
147 break; | |
148 case GDK_KP_Subtract: | |
149 layout_image_zoom_adjust(lw, -get_zoom_increment()); | |
150 stop_signal = TRUE; | |
151 break; | |
152 case GDK_KP_Multiply: | |
153 layout_image_zoom_set(lw, 0.0); | |
154 stop_signal = TRUE; | |
155 break; | |
156 case GDK_KP_Divide: | |
157 case '1': | |
158 layout_image_zoom_set(lw, 1.0); | |
159 stop_signal = TRUE; | |
160 break; | |
161 case '2': | |
162 layout_image_zoom_set(lw, 2.0); | |
163 stop_signal = TRUE; | |
164 break; | |
165 case '3': | |
166 layout_image_zoom_set(lw, 3.0); | |
167 stop_signal = TRUE; | |
168 break; | |
169 case '4': | |
170 layout_image_zoom_set(lw, 4.0); | |
171 stop_signal = TRUE; | |
172 break; | |
173 case '7': | |
174 layout_image_zoom_set(lw, -4.0); | |
175 stop_signal = TRUE; | |
176 break; | |
177 case '8': | |
178 layout_image_zoom_set(lw, -3.0); | |
179 stop_signal = TRUE; | |
180 break; | |
181 case '9': | |
182 layout_image_zoom_set(lw, -2.0); | |
183 stop_signal = TRUE; | |
184 break; | |
185 case 'W': case 'w': | |
186 layout_image_zoom_set_fill_geometry(lw, FALSE); | |
187 break; | |
188 case 'H': case 'h': | |
189 layout_image_zoom_set_fill_geometry(lw, TRUE); | |
190 break; | |
191 case GDK_Page_Up: case GDK_KP_Page_Up: | |
192 layout_image_prev(lw); | |
193 stop_signal = TRUE; | |
194 break; | |
195 case GDK_Page_Down: case GDK_KP_Page_Down: | |
196 layout_image_next(lw); | |
197 stop_signal = TRUE; | |
198 break; | |
199 case GDK_Home: case GDK_KP_Home: | |
200 layout_image_first(lw); | |
201 stop_signal = TRUE; | |
202 break; | |
203 case GDK_End: case GDK_KP_End: | |
204 layout_image_last(lw); | |
205 stop_signal = TRUE; | |
206 break; | |
207 case GDK_Delete: case GDK_KP_Delete: | |
208 if (enable_delete_key) | |
209 { | |
210 file_util_delete(NULL, layout_selection_list(lw), widget); | |
211 stop_signal = TRUE; | |
212 } | |
213 break; | |
214 case GDK_Escape: | |
215 /* FIXME:interrupting thumbs no longer allowed */ | |
216 #if 0 | |
217 interrupt_thumbs(); | |
218 #endif | |
219 stop_signal = TRUE; | |
220 break; | |
221 case 'P': case 'p': | |
222 layout_image_slideshow_pause_toggle(lw); | |
223 break; | |
224 case 'V': case 'v': | |
225 if (!(event->state & GDK_MOD1_MASK)) layout_image_full_screen_toggle(lw); | |
226 break; | |
227 } | |
228 | |
229 if (event->state & GDK_SHIFT_MASK) | |
230 { | |
231 x *= 3; | |
232 y *= 3; | |
233 } | |
234 | |
235 if (x != 0 || y!= 0) | |
236 { | |
237 keyboard_scroll_calc(&x, &y, event); | |
238 layout_image_scroll(lw, x, y); | |
239 } | |
240 | |
241 if (stop_signal) g_signal_stop_emission_by_name(G_OBJECT(widget), "key_press_event"); | |
242 | |
243 return stop_signal; | |
244 } | |
245 | |
246 void layout_keyboard_init(LayoutWindow *lw, GtkWidget *window) | |
247 { | |
248 g_signal_connect(G_OBJECT(window), "key_press_event", | |
249 G_CALLBACK(layout_key_press_cb), lw); | |
250 } | |
251 | |
252 /* | |
253 *----------------------------------------------------------------------------- | |
254 * menu callbacks | |
255 *----------------------------------------------------------------------------- | |
256 */ | |
257 | |
258 static void layout_menu_new_window_cb(GtkAction *action, gpointer data) | |
259 { | |
260 LayoutWindow *lw = data; | |
261 LayoutWindow *nw; | |
262 | |
263 nw = layout_new(NULL, FALSE, FALSE); | |
264 layout_sort_set(nw, file_sort_method, file_sort_ascending); | |
265 layout_set_path(nw, layout_get_path(lw)); | |
266 } | |
267 | |
268 static void layout_menu_new_cb(GtkAction *action, gpointer data) | |
269 { | |
270 collection_window_new(NULL); | |
271 } | |
272 | |
273 static void layout_menu_open_cb(GtkAction *action, gpointer data) | |
274 { | |
275 collection_dialog_load(NULL); | |
276 } | |
277 | |
278 static void layout_menu_search_cb(GtkAction *action, gpointer data) | |
279 { | |
280 LayoutWindow *lw = data; | |
281 | |
282 search_new(lw->path, layout_image_get_path(lw)); | |
283 } | |
284 | |
285 static void layout_menu_dupes_cb(GtkAction *action, gpointer data) | |
286 { | |
287 dupe_window_new(DUPE_MATCH_NAME); | |
288 } | |
289 | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
290 static void layout_menu_pan_cb(GtkAction *action, gpointer data) |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
291 { |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
292 LayoutWindow *lw = data; |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
293 |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
294 pan_window_new(layout_get_path(lw)); |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
295 } |
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
296 |
9 | 297 static void layout_menu_print_cb(GtkAction *action, gpointer data) |
298 { | |
299 LayoutWindow *lw = data; | |
300 | |
301 print_window_new(layout_image_get_path(lw), layout_selection_list(lw), layout_list(lw), lw->window); | |
302 } | |
303 | |
304 static void layout_menu_dir_cb(GtkAction *action, gpointer data) | |
305 { | |
306 LayoutWindow *lw = data; | |
307 | |
308 file_util_create_dir(lw->path, lw->window); | |
309 } | |
310 | |
311 static void layout_menu_copy_cb(GtkAction *action, gpointer data) | |
312 { | |
313 LayoutWindow *lw = data; | |
314 | |
315 file_util_copy(NULL, layout_selection_list(lw), NULL, lw->window); | |
316 } | |
317 | |
318 static void layout_menu_move_cb(GtkAction *action, gpointer data) | |
319 { | |
320 LayoutWindow *lw = data; | |
321 | |
322 file_util_move(NULL, layout_selection_list(lw), NULL, lw->window); | |
323 } | |
324 | |
325 static void layout_menu_rename_cb(GtkAction *action, gpointer data) | |
326 { | |
327 LayoutWindow *lw = data; | |
328 | |
329 file_util_rename(NULL, layout_selection_list(lw), lw->window); | |
330 } | |
331 | |
332 static void layout_menu_delete_cb(GtkAction *action, gpointer data) | |
333 { | |
334 LayoutWindow *lw = data; | |
335 | |
336 file_util_delete(NULL, layout_selection_list(lw), lw->window); | |
337 } | |
338 | |
339 static void layout_menu_close_cb(GtkAction *action, gpointer data) | |
340 { | |
341 LayoutWindow *lw = data; | |
342 | |
343 layout_close(lw); | |
344 } | |
345 | |
346 static void layout_menu_exit_cb(GtkAction *action, gpointer data) | |
347 { | |
348 exit_gqview(); | |
349 } | |
350 | |
351 static void layout_menu_alter_90_cb(GtkAction *action, gpointer data) | |
352 { | |
353 LayoutWindow *lw = data; | |
354 | |
355 layout_image_alter(lw, ALTER_ROTATE_90); | |
356 } | |
357 | |
358 static void layout_menu_alter_90cc_cb(GtkAction *action, gpointer data) | |
359 { | |
360 LayoutWindow *lw = data; | |
361 | |
362 layout_image_alter(lw, ALTER_ROTATE_90_CC); | |
363 } | |
364 | |
365 static void layout_menu_alter_180_cb(GtkAction *action, gpointer data) | |
366 { | |
367 LayoutWindow *lw = data; | |
368 | |
369 layout_image_alter(lw, ALTER_ROTATE_180); | |
370 } | |
371 | |
372 static void layout_menu_alter_mirror_cb(GtkAction *action, gpointer data) | |
373 { | |
374 LayoutWindow *lw = data; | |
375 | |
376 layout_image_alter(lw, ALTER_MIRROR); | |
377 } | |
378 | |
379 static void layout_menu_alter_flip_cb(GtkAction *action, gpointer data) | |
380 { | |
381 LayoutWindow *lw = data; | |
382 | |
383 layout_image_alter(lw, ALTER_FLIP); | |
384 } | |
385 | |
386 static void layout_menu_info_cb(GtkAction *action, gpointer data) | |
387 { | |
388 LayoutWindow *lw = data; | |
389 GList *list; | |
390 const gchar *path = NULL; | |
391 | |
392 list = layout_selection_list(lw); | |
393 if (!list) path = layout_image_get_path(lw); | |
394 | |
395 info_window_new(path, list); | |
396 } | |
397 | |
398 static void layout_menu_select_all_cb(GtkAction *action, gpointer data) | |
399 { | |
400 LayoutWindow *lw = data; | |
401 | |
402 layout_select_all(lw); | |
403 } | |
404 | |
405 static void layout_menu_unselect_all_cb(GtkAction *action, gpointer data) | |
406 { | |
407 LayoutWindow *lw = data; | |
408 | |
409 layout_select_none(lw); | |
410 } | |
411 | |
412 static void layout_menu_config_cb(GtkAction *action, gpointer data) | |
413 { | |
414 show_config_window(); | |
415 } | |
416 | |
417 static void layout_menu_remove_thumb_cb(GtkAction *action, gpointer data) | |
418 { | |
419 cache_manager_show(); | |
420 } | |
421 | |
422 static void layout_menu_wallpaper_cb(GtkAction *action, gpointer data) | |
423 { | |
424 LayoutWindow *lw = data; | |
425 | |
426 layout_image_to_root(lw); | |
427 } | |
428 | |
429 static void layout_menu_zoom_in_cb(GtkAction *action, gpointer data) | |
430 { | |
431 LayoutWindow *lw = data; | |
432 | |
433 layout_image_zoom_adjust(lw, get_zoom_increment()); | |
434 } | |
435 | |
436 static void layout_menu_zoom_out_cb(GtkAction *action, gpointer data) | |
437 { | |
438 LayoutWindow *lw = data; | |
439 | |
440 layout_image_zoom_adjust(lw, -get_zoom_increment()); | |
441 } | |
442 | |
443 static void layout_menu_zoom_1_1_cb(GtkAction *action, gpointer data) | |
444 { | |
445 LayoutWindow *lw = data; | |
446 | |
447 layout_image_zoom_set(lw, 1.0); | |
448 } | |
449 | |
450 static void layout_menu_zoom_fit_cb(GtkAction *action, gpointer data) | |
451 { | |
452 LayoutWindow *lw = data; | |
453 | |
454 layout_image_zoom_set(lw, 0.0); | |
455 } | |
456 | |
457 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data) | |
458 { | |
459 LayoutWindow *lw = data; | |
460 | |
461 layout_thumb_set(lw, gtk_toggle_action_get_active(action)); | |
462 } | |
463 | |
464 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) | |
465 { | |
466 LayoutWindow *lw = data; | |
467 | |
468 layout_views_set(lw, lw->tree_view, (gtk_radio_action_get_current_value(action) == 1)); | |
469 } | |
470 | |
471 static void layout_menu_tree_cb(GtkToggleAction *action, gpointer data) | |
472 { | |
473 LayoutWindow *lw = data; | |
474 | |
475 layout_views_set(lw, gtk_toggle_action_get_active(action), lw->icon_view); | |
476 } | |
477 | |
478 static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data) | |
479 { | |
480 LayoutWindow *lw = data; | |
481 | |
482 layout_image_full_screen_toggle(lw); | |
483 } | |
484 | |
485 static void layout_menu_refresh_cb(GtkAction *action, gpointer data) | |
486 { | |
487 LayoutWindow *lw = data; | |
488 | |
489 layout_refresh(lw); | |
490 } | |
491 | |
492 static void layout_menu_float_cb(GtkToggleAction *action, gpointer data) | |
493 { | |
494 LayoutWindow *lw = data; | |
495 | |
496 if (lw->tools_float != gtk_toggle_action_get_active(action)) | |
497 { | |
498 layout_tools_float_toggle(lw); | |
499 } | |
500 } | |
501 | |
502 static void layout_menu_hide_cb(GtkAction *action, gpointer data) | |
503 { | |
504 LayoutWindow *lw = data; | |
505 | |
506 layout_tools_hide_toggle(lw); | |
507 } | |
508 | |
509 static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data) | |
510 { | |
511 LayoutWindow *lw = data; | |
512 | |
513 if (lw->toolbar_hidden != gtk_toggle_action_get_active(action)) | |
514 { | |
515 layout_toolbar_toggle(lw); | |
516 } | |
517 } | |
518 | |
519 static void layout_menu_bar_info_cb(GtkToggleAction *action, gpointer data) | |
520 { | |
521 LayoutWindow *lw = data; | |
522 | |
523 if (lw->bar_info_enabled != gtk_toggle_action_get_active(action)) | |
524 { | |
525 layout_bar_info_toggle(lw); | |
526 } | |
527 } | |
528 | |
529 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) | |
530 { | |
531 LayoutWindow *lw = data; | |
532 | |
533 if (lw->bar_exif_enabled != gtk_toggle_action_get_active(action)) | |
534 { | |
535 layout_bar_exif_toggle(lw); | |
536 } | |
537 } | |
538 | |
539 static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data) | |
540 { | |
541 LayoutWindow *lw = data; | |
542 | |
543 if (lw->bar_sort_enabled != gtk_toggle_action_get_active(action)) | |
544 { | |
545 layout_bar_sort_toggle(lw); | |
546 } | |
547 } | |
548 | |
549 static void layout_menu_slideshow_cb(GtkAction *action, gpointer data) | |
550 { | |
551 LayoutWindow *lw = data; | |
552 | |
553 layout_image_slideshow_toggle(lw); | |
554 } | |
555 | |
556 static void layout_menu_help_cb(GtkAction *action, gpointer data) | |
557 { | |
558 help_window_show("html_contents"); | |
559 } | |
560 | |
561 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data) | |
562 { | |
563 help_window_show("documentation"); | |
564 } | |
565 | |
566 static void layout_menu_notes_cb(GtkAction *action, gpointer data) | |
567 { | |
568 help_window_show("release_notes"); | |
569 } | |
570 | |
571 static void layout_menu_about_cb(GtkAction *action, gpointer data) | |
572 { | |
573 show_about_window(); | |
574 } | |
575 | |
576 /* | |
577 *----------------------------------------------------------------------------- | |
578 * edit menu | |
579 *----------------------------------------------------------------------------- | |
580 */ | |
581 | |
582 static void layout_menu_edit_cb(GtkAction *action, gpointer data) | |
583 { | |
584 LayoutWindow *lw = data; | |
585 GList *list; | |
586 gint n; | |
587 | |
588 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "edit_index")); | |
589 | |
590 list = layout_selection_list(lw); | |
591 start_editor_from_path_list(n, list); | |
592 path_list_free(list); | |
593 } | |
594 | |
595 static void layout_menu_edit_update(LayoutWindow *lw) | |
596 { | |
597 gint i; | |
598 | |
599 /* main edit menu */ | |
600 | |
601 if (!lw->action_group) return; | |
602 | |
603 for (i = 0; i < 10; i++) | |
604 { | |
605 gchar *key; | |
606 GtkAction *action; | |
607 | |
608 key = g_strdup_printf("Editor%d", i); | |
609 | |
610 action = gtk_action_group_get_action(lw->action_group, key); | |
611 g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i)); | |
612 | |
613 if (editor_command[i] && strlen(editor_command[i]) > 0) | |
614 { | |
615 gchar *text; | |
616 | |
617 if (editor_name[i] && strlen(editor_name[i]) > 0) | |
618 { | |
619 text = g_strdup_printf(_("in %s..."), editor_name[i]); | |
620 } | |
621 else | |
622 { | |
623 text = g_strdup(_("in (unknown)...")); | |
624 } | |
625 g_object_set(action, "label", text, | |
626 "sensitive", TRUE, NULL); | |
627 g_free(text); | |
628 } | |
629 else | |
630 { | |
631 g_object_set(action, "label", _("empty"), | |
632 "sensitive", FALSE, NULL); | |
633 } | |
634 | |
635 g_free(key); | |
636 } | |
637 } | |
638 | |
639 void layout_edit_update_all(void) | |
640 { | |
641 GList *work; | |
642 | |
643 work = layout_window_list; | |
644 while (work) | |
645 { | |
646 LayoutWindow *lw = work->data; | |
647 work = work->next; | |
648 | |
649 layout_menu_edit_update(lw); | |
650 } | |
651 } | |
652 | |
653 /* | |
654 *----------------------------------------------------------------------------- | |
655 * recent menu | |
656 *----------------------------------------------------------------------------- | |
657 */ | |
658 | |
659 static void layout_menu_recent_cb(GtkWidget *widget, gpointer data) | |
660 { | |
661 gint n; | |
662 gchar *path; | |
663 | |
664 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index")); | |
665 | |
666 path = g_list_nth_data(history_list_get_by_key("recent"), n); | |
667 | |
668 if (!path) return; | |
669 | |
670 /* make a copy of it */ | |
671 path = g_strdup(path); | |
672 collection_window_new(path); | |
673 g_free(path); | |
674 } | |
675 | |
676 static void layout_menu_recent_update(LayoutWindow *lw) | |
677 { | |
678 GtkWidget *menu; | |
679 GtkWidget *recent; | |
680 GtkWidget *item; | |
681 GList *list; | |
682 gint n; | |
683 | |
684 if (!lw->ui_manager) return; | |
685 | |
686 list = history_list_get_by_key("recent"); | |
687 n = 0; | |
688 | |
689 menu = gtk_menu_new(); | |
690 | |
691 while (list) | |
692 { | |
693 item = menu_item_add_simple(menu, filename_from_path((gchar *)list->data), | |
694 G_CALLBACK(layout_menu_recent_cb), lw); | |
695 g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n)); | |
696 list = list->next; | |
697 n++; | |
698 } | |
699 | |
700 if (n == 0) | |
701 { | |
702 menu_item_add(menu, _("Empty"), NULL, NULL); | |
703 } | |
704 | |
705 recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent"); | |
706 gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu); | |
707 gtk_widget_set_sensitive(recent, (n != 0)); | |
708 } | |
709 | |
710 void layout_recent_update_all(void) | |
711 { | |
712 GList *work; | |
713 | |
714 work = layout_window_list; | |
715 while (work) | |
716 { | |
717 LayoutWindow *lw = work->data; | |
718 work = work->next; | |
719 | |
720 layout_menu_recent_update(lw); | |
721 } | |
722 } | |
723 | |
724 void layout_recent_add_path(const gchar *path) | |
725 { | |
726 if (!path) return; | |
727 | |
728 history_list_add_to_key("recent", path, recent_list_max); | |
729 | |
730 layout_recent_update_all(); | |
731 } | |
732 | |
733 /* | |
734 *----------------------------------------------------------------------------- | |
735 * menu | |
736 *----------------------------------------------------------------------------- | |
737 */ | |
738 | |
739 #define CB G_CALLBACK | |
740 | |
741 static GtkActionEntry menu_entries[] = { | |
742 { "FileMenu", NULL, N_("_File") }, | |
743 { "EditMenu", NULL, N_("_Edit") }, | |
744 { "AdjustMenu", NULL, N_("_Adjust") }, | |
745 { "ViewMenu", NULL, N_("_View") }, | |
746 { "HelpMenu", NULL, N_("_Help") }, | |
747 | |
748 { "NewWindow", GTK_STOCK_NEW, N_("New _window"), NULL, NULL, CB(layout_menu_new_window_cb) }, | |
749 { "NewCollection", GTK_STOCK_INDEX,N_("_New collection"), "C", NULL, CB(layout_menu_new_cb) }, | |
750 { "OpenCollection", GTK_STOCK_OPEN, N_("_Open collection..."),"O", NULL, CB(layout_menu_open_cb) }, | |
751 { "OpenRecent", NULL, N_("Open _recent") }, | |
752 { "Search", GTK_STOCK_FIND, N_("_Search..."), "F3", NULL, CB(layout_menu_search_cb) }, | |
753 { "FindDupes", GTK_STOCK_FIND, N_("_Find duplicates..."),"D", NULL, CB(layout_menu_dupes_cb) }, | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
754 { "PanView", NULL, N_("Pan _view"), "<control>J", NULL, CB(layout_menu_pan_cb) }, |
9 | 755 { "Print", GTK_STOCK_PRINT,N_("_Print..."), "<shift>P", NULL, CB(layout_menu_print_cb) }, |
756 { "NewFolder", NULL, N_("N_ew folder..."), "<control>F", NULL, CB(layout_menu_dir_cb) }, | |
757 { "Copy", NULL, N_("_Copy..."), "<control>C", NULL, CB(layout_menu_copy_cb) }, | |
758 { "Move", NULL, N_("_Move..."), "<control>M", NULL, CB(layout_menu_move_cb) }, | |
759 { "Rename", NULL, N_("_Rename..."), "<control>R", NULL, CB(layout_menu_rename_cb) }, | |
760 { "Delete", GTK_STOCK_DELETE, N_("_Delete..."), "<control>D", NULL, CB(layout_menu_delete_cb) }, | |
761 { "CloseWindow", GTK_STOCK_CLOSE,N_("C_lose window"), "<control>W", NULL, CB(layout_menu_close_cb) }, | |
762 { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", NULL, CB(layout_menu_exit_cb) }, | |
763 | |
764 { "Editor0", NULL, "editor0", "<control>1", NULL, CB(layout_menu_edit_cb) }, | |
765 { "Editor1", NULL, "editor1", "<control>2", NULL, CB(layout_menu_edit_cb) }, | |
766 { "Editor2", NULL, "editor2", "<control>3", NULL, CB(layout_menu_edit_cb) }, | |
767 { "Editor3", NULL, "editor3", "<control>4", NULL, CB(layout_menu_edit_cb) }, | |
768 { "Editor4", NULL, "editor4", "<control>5", NULL, CB(layout_menu_edit_cb) }, | |
769 { "Editor5", NULL, "editor5", "<control>6", NULL, CB(layout_menu_edit_cb) }, | |
770 { "Editor6", NULL, "editor6", "<control>7", NULL, CB(layout_menu_edit_cb) }, | |
771 { "Editor7", NULL, "editor7", "<control>8", NULL, CB(layout_menu_edit_cb) }, | |
772 { "Editor8", NULL, "editor8", "<control>9", NULL, CB(layout_menu_edit_cb) }, | |
773 { "Editor9", NULL, "editor9", "<control>0", NULL, CB(layout_menu_edit_cb) }, | |
774 { "RotateCW", NULL, N_("_Rotate clockwise"), "bracketright", NULL, CB(layout_menu_alter_90_cb) }, | |
775 { "RotateCCW", NULL, N_("Rotate _counterclockwise"), "bracketleft", NULL, CB(layout_menu_alter_90cc_cb) }, | |
776 { "Rotate180", NULL, N_("Rotate 1_80"), "<shift>R", NULL, CB(layout_menu_alter_180_cb) }, | |
777 { "Mirror", NULL, N_("_Mirror"), "<shift>M", NULL, CB(layout_menu_alter_mirror_cb) }, | |
778 { "Flip", NULL, N_("_Flip"), "<shift>F", NULL, CB(layout_menu_alter_flip_cb) }, | |
779 { "Properties",GTK_STOCK_PROPERTIES, N_("_Properties"), "<control>P", NULL, CB(layout_menu_info_cb) }, | |
780 { "SelectAll", NULL, N_("Select _all"), "<control>A", NULL, CB(layout_menu_select_all_cb) }, | |
781 { "SelectNone", NULL, N_("Select _none"), "<control><shift>A",NULL, CB(layout_menu_unselect_all_cb) }, | |
782 { "Preferences",GTK_STOCK_PREFERENCES,N_("P_references..."), "<control>O", NULL, CB(layout_menu_config_cb) }, | |
783 { "Maintenance", NULL, N_("_Thumbnail maintenance..."),NULL, NULL, CB(layout_menu_remove_thumb_cb) }, | |
784 { "Wallpaper", NULL, N_("Set as _wallpaper"),NULL, NULL, CB(layout_menu_wallpaper_cb) }, | |
785 | |
786 { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "equal", NULL, CB(layout_menu_zoom_in_cb) }, | |
787 { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "minus", NULL, CB(layout_menu_zoom_out_cb) }, | |
788 { "Zoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "Z", NULL, CB(layout_menu_zoom_1_1_cb) }, | |
789 { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "X", NULL, CB(layout_menu_zoom_fit_cb) }, | |
790 { "FullScreen", NULL, N_("F_ull screen"), "F", NULL, CB(layout_menu_fullscreen_cb) }, | |
791 { "HideTools", NULL, N_("_Hide file list"), "<control>H", NULL, CB(layout_menu_hide_cb) }, | |
792 { "SlideShow", NULL, N_("Toggle _slideshow"),"S", NULL, CB(layout_menu_slideshow_cb) }, | |
793 { "Refresh", GTK_STOCK_REFRESH, N_("_Refresh"), "R", NULL, CB(layout_menu_refresh_cb) }, | |
794 | |
795 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL, CB(layout_menu_help_cb) }, | |
796 { "HelpShortcuts", NULL, N_("_Keyboard shortcuts"),NULL, NULL, CB(layout_menu_help_keys_cb) }, | |
797 { "HelpNotes", NULL, N_("_Release notes"), NULL, NULL, CB(layout_menu_notes_cb) }, | |
798 { "About", NULL, N_("_About"), NULL, NULL, CB(layout_menu_about_cb) } | |
799 }; | |
800 | |
801 static GtkToggleActionEntry menu_toggle_entries[] = { | |
802 { "Thumbnails", NULL, N_("_Thumbnails"), "T", NULL, CB(layout_menu_thumb_cb) }, | |
803 { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, CB(layout_menu_tree_cb) }, | |
804 { "FloatTools", NULL, N_("_Float file list"), "L", NULL, CB(layout_menu_float_cb) }, | |
805 { "HideToolbar", NULL, N_("Hide tool_bar"), NULL, NULL, CB(layout_menu_toolbar_cb) }, | |
806 { "SBarKeywords", NULL, N_("_Keywords"), "<control>K", NULL, CB(layout_menu_bar_info_cb) }, | |
807 { "SBarExif", NULL, N_("E_xif data"), "<control>E", NULL, CB(layout_menu_bar_exif_cb) }, | |
808 { "SBarSort", NULL, N_("Sort _manager"), "<control>S", NULL, CB(layout_menu_bar_sort_cb) } | |
809 }; | |
810 | |
811 static GtkRadioActionEntry menu_radio_entries[] = { | |
812 { "ViewList", NULL, N_("_List"), "<control>L", NULL, 0 }, | |
813 { "ViewIcons", NULL, N_("I_cons"), "<control>I", NULL, 1 } | |
814 }; | |
815 | |
816 #undef CB | |
817 | |
818 static const char *menu_ui_description = | |
819 "<ui>" | |
820 " <menubar name='MainMenu'>" | |
821 " <menu action='FileMenu'>" | |
822 " <menuitem action='NewWindow'/>" | |
823 " <menuitem action='NewCollection'/>" | |
824 " <menuitem action='OpenCollection'/>" | |
825 " <menuitem action='OpenRecent'/>" | |
826 " <separator/>" | |
827 " <menuitem action='Search'/>" | |
828 " <menuitem action='FindDupes'/>" | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
829 " <menuitem action='PanView'/>" |
9 | 830 " <separator/>" |
831 " <menuitem action='Print'/>" | |
832 " <menuitem action='NewFolder'/>" | |
833 " <separator/>" | |
834 " <menuitem action='Copy'/>" | |
835 " <menuitem action='Move'/>" | |
836 " <menuitem action='Rename'/>" | |
837 " <menuitem action='Delete'/>" | |
838 " <separator/>" | |
839 " <menuitem action='CloseWindow'/>" | |
840 " <menuitem action='Quit'/>" | |
841 " </menu>" | |
842 " <menu action='EditMenu'>" | |
843 " <menuitem action='Editor0'/>" | |
844 " <menuitem action='Editor1'/>" | |
845 " <menuitem action='Editor2'/>" | |
846 " <menuitem action='Editor3'/>" | |
847 " <menuitem action='Editor4'/>" | |
848 " <menuitem action='Editor5'/>" | |
849 " <menuitem action='Editor6'/>" | |
850 " <menuitem action='Editor7'/>" | |
851 " <menuitem action='Editor8'/>" | |
852 " <menuitem action='Editor9'/>" | |
853 " <separator/>" | |
854 " <menu action='AdjustMenu'>" | |
855 " <menuitem action='RotateCW'/>" | |
856 " <menuitem action='RotateCCW'/>" | |
857 " <menuitem action='Rotate180'/>" | |
858 " <menuitem action='Mirror'/>" | |
859 " <menuitem action='Flip'/>" | |
860 " </menu>" | |
861 " <menuitem action='Properties'/>" | |
862 " <separator/>" | |
863 " <menuitem action='SelectAll'/>" | |
864 " <menuitem action='SelectNone'/>" | |
865 " <separator/>" | |
866 " <menuitem action='Preferences'/>" | |
867 " <menuitem action='Maintenance'/>" | |
868 " <separator/>" | |
869 " <menuitem action='Wallpaper'/>" | |
870 " </menu>" | |
871 " <menu action='ViewMenu'>" | |
872 " <separator/>" | |
873 " <menuitem action='ZoomIn'/>" | |
874 " <menuitem action='ZoomOut'/>" | |
875 " <menuitem action='Zoom100'/>" | |
876 " <menuitem action='ZoomFit'/>" | |
877 " <separator/>" | |
878 " <menuitem action='Thumbnails'/>" | |
879 " <menuitem action='ViewList'/>" | |
880 " <menuitem action='ViewIcons'/>" | |
881 " <separator/>" | |
882 " <menuitem action='FolderTree'/>" | |
883 " <menuitem action='FullScreen'/>" | |
884 " <separator/>" | |
885 " <menuitem action='FloatTools'/>" | |
886 " <menuitem action='HideTools'/>" | |
887 " <menuitem action='HideToolbar'/>" | |
888 " <separator/>" | |
889 " <menuitem action='SBarKeywords'/>" | |
890 " <menuitem action='SBarExif'/>" | |
891 " <menuitem action='SBarSort'/>" | |
892 " <separator/>" | |
893 " <menuitem action='SlideShow'/>" | |
894 " <menuitem action='Refresh'/>" | |
895 " </menu>" | |
896 " <menu action='HelpMenu'>" | |
897 " <separator/>" | |
898 " <menuitem action='HelpContents'/>" | |
899 " <menuitem action='HelpShortcuts'/>" | |
900 " <menuitem action='HelpNotes'/>" | |
901 " <separator/>" | |
902 " <menuitem action='About'/>" | |
903 " </menu>" | |
904 " </menubar>" | |
905 "</ui>"; | |
906 | |
907 | |
908 static gchar *menu_translate(const gchar *path, gpointer data) | |
909 { | |
910 return _(path); | |
911 } | |
912 | |
913 void layout_actions_setup(LayoutWindow *lw) | |
914 { | |
915 GError *error; | |
916 | |
917 if (lw->ui_manager) return; | |
918 | |
919 lw->action_group = gtk_action_group_new ("MenuActions"); | |
920 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL); | |
921 | |
922 gtk_action_group_add_actions(lw->action_group, | |
923 menu_entries, G_N_ELEMENTS(menu_entries), lw); | |
924 gtk_action_group_add_toggle_actions(lw->action_group, | |
925 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw); | |
926 gtk_action_group_add_radio_actions(lw->action_group, | |
927 menu_radio_entries, G_N_ELEMENTS(menu_radio_entries), | |
928 0, G_CALLBACK(layout_menu_list_cb), lw); | |
929 | |
930 lw->ui_manager = gtk_ui_manager_new(); | |
931 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); | |
932 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0); | |
933 | |
934 error = NULL; | |
935 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error)) | |
936 { | |
937 g_message ("building menus failed: %s", error->message); | |
938 g_error_free (error); | |
939 exit (EXIT_FAILURE); | |
940 } | |
941 } | |
942 | |
943 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window) | |
944 { | |
945 GtkAccelGroup *group; | |
946 | |
947 if (!lw->ui_manager) return; | |
948 | |
949 group = gtk_ui_manager_get_accel_group(lw->ui_manager); | |
950 gtk_window_add_accel_group(GTK_WINDOW(window), group); | |
951 } | |
952 | |
953 GtkWidget *layout_actions_menu_bar(LayoutWindow *lw) | |
954 { | |
955 return gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu"); | |
956 } | |
957 | |
958 | |
959 /* | |
960 *----------------------------------------------------------------------------- | |
961 * toolbar | |
962 *----------------------------------------------------------------------------- | |
963 */ | |
964 | |
965 static void layout_button_thumb_cb(GtkWidget *widget, gpointer data) | |
966 { | |
967 LayoutWindow *lw = data; | |
968 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
969 layout_thumb_set(lw, gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget))); |
9 | 970 } |
971 | |
972 static void layout_button_home_cb(GtkWidget *widget, gpointer data) | |
973 { | |
974 LayoutWindow *lw = data; | |
975 const gchar *path = homedir(); | |
976 | |
977 if (path) layout_set_path(lw, path); | |
978 } | |
979 | |
980 static void layout_button_refresh_cb(GtkWidget *widget, gpointer data) | |
981 { | |
982 LayoutWindow *lw = data; | |
983 | |
984 layout_refresh(lw); | |
985 } | |
986 | |
987 static void layout_button_zoom_in_cb(GtkWidget *widget, gpointer data) | |
988 { | |
989 LayoutWindow *lw = data; | |
990 | |
991 layout_image_zoom_adjust(lw, get_zoom_increment()); | |
992 } | |
993 | |
994 static void layout_button_zoom_out_cb(GtkWidget *widget, gpointer data) | |
995 { | |
996 LayoutWindow *lw = data; | |
997 | |
998 layout_image_zoom_adjust(lw, -get_zoom_increment()); | |
999 } | |
1000 | |
1001 static void layout_button_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
1002 { | |
1003 LayoutWindow *lw = data; | |
1004 | |
1005 layout_image_zoom_set(lw, 0.0); | |
1006 } | |
1007 | |
1008 static void layout_button_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
1009 { | |
1010 LayoutWindow *lw = data; | |
1011 | |
1012 layout_image_zoom_set(lw, 1.0); | |
1013 } | |
1014 | |
1015 static void layout_button_config_cb(GtkWidget *widget, gpointer data) | |
1016 { | |
1017 show_config_window(); | |
1018 } | |
1019 | |
1020 static void layout_button_float_cb(GtkWidget *widget, gpointer data) | |
1021 { | |
1022 LayoutWindow *lw = data; | |
1023 | |
1024 layout_tools_float_toggle(lw); | |
1025 } | |
1026 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1027 static void layout_button_custom_icon(GtkWidget *button, const gchar *key) |
9 | 1028 { |
1029 GtkWidget *icon; | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1030 GdkPixbuf *pixbuf; |
9 | 1031 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1032 pixbuf = pixbuf_inline(key); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1033 if (!pixbuf) return; |
9 | 1034 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1035 icon = gtk_image_new_from_pixbuf(pixbuf); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1036 g_object_unref(pixbuf); |
9 | 1037 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1038 pref_toolbar_button_set_icon(button, icon, NULL); |
9 | 1039 gtk_widget_show(icon); |
1040 } | |
1041 | |
1042 GtkWidget *layout_button_bar(LayoutWindow *lw) | |
1043 { | |
1044 GtkWidget *box; | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1045 GtkWidget *button; |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1046 |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1047 box = pref_toolbar_new(NULL, GTK_TOOLBAR_ICONS); |
9 | 1048 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1049 button = pref_toolbar_button(box, NULL, _("_Thumbnails"), TRUE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1050 _("Show thumbnails"), G_CALLBACK(layout_button_thumb_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1051 layout_button_custom_icon(button, PIXBUF_INLINE_ICON_THUMB); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1052 lw->thumb_button = button; |
9 | 1053 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1054 pref_toolbar_button(box, GTK_STOCK_HOME, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1055 _("Change to home folder"), G_CALLBACK(layout_button_home_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1056 pref_toolbar_button(box, GTK_STOCK_REFRESH, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1057 _("Refresh file list"), G_CALLBACK(layout_button_refresh_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1058 pref_toolbar_button(box, GTK_STOCK_ZOOM_IN, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1059 _("Zoom in"), G_CALLBACK(layout_button_zoom_in_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1060 pref_toolbar_button(box, GTK_STOCK_ZOOM_OUT, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1061 _("Zoom out"), G_CALLBACK(layout_button_zoom_out_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1062 pref_toolbar_button(box, GTK_STOCK_ZOOM_FIT, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1063 _("Fit image to window"), G_CALLBACK(layout_button_zoom_fit_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1064 pref_toolbar_button(box, GTK_STOCK_ZOOM_100, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1065 _("Set zoom 1:1"), G_CALLBACK(layout_button_zoom_1_1_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1066 pref_toolbar_button(box, GTK_STOCK_PREFERENCES, NULL, FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1067 _("Configure options"), G_CALLBACK(layout_button_config_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1068 button = pref_toolbar_button(box, NULL, _("_Float"), FALSE, |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1069 _("Float Controls"), G_CALLBACK(layout_button_float_cb), lw); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1070 layout_button_custom_icon(button, PIXBUF_INLINE_ICON_FLOAT); |
9 | 1071 |
1072 return box; | |
1073 } | |
1074 | |
1075 /* | |
1076 *----------------------------------------------------------------------------- | |
1077 * misc | |
1078 *----------------------------------------------------------------------------- | |
1079 */ | |
1080 | |
1081 static void layout_util_sync_views(LayoutWindow *lw) | |
1082 { | |
1083 GtkAction *action; | |
1084 | |
1085 if (!lw->action_group) return; | |
1086 | |
1087 action = gtk_action_group_get_action(lw->action_group, "FolderTree"); | |
1088 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tree_view); | |
1089 | |
1090 action = gtk_action_group_get_action(lw->action_group, "ViewIcons"); | |
1091 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->icon_view); | |
1092 | |
1093 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); | |
1094 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tools_float); | |
1095 | |
1096 action = gtk_action_group_get_action(lw->action_group, "SBarKeywords"); | |
1097 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_info_enabled); | |
1098 | |
1099 action = gtk_action_group_get_action(lw->action_group, "SBarExif"); | |
1100 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_exif_enabled); | |
1101 | |
1102 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); | |
1103 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_sort_enabled); | |
1104 | |
1105 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); | |
1106 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->toolbar_hidden); | |
1107 } | |
1108 | |
1109 void layout_util_sync_thumb(LayoutWindow *lw) | |
1110 { | |
1111 GtkAction *action; | |
1112 | |
1113 if (!lw->action_group) return; | |
1114 | |
1115 action = gtk_action_group_get_action(lw->action_group, "Thumbnails"); | |
1116 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->thumbs_enabled); | |
1117 g_object_set(action, "sensitive", !lw->icon_view, NULL); | |
1118 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1119 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->thumbs_enabled); |
9 | 1120 gtk_widget_set_sensitive(lw->thumb_button, !lw->icon_view); |
1121 } | |
1122 | |
1123 void layout_util_sync(LayoutWindow *lw) | |
1124 { | |
1125 layout_util_sync_views(lw); | |
1126 layout_util_sync_thumb(lw); | |
1127 layout_menu_recent_update(lw); | |
1128 layout_menu_edit_update(lw); | |
1129 } | |
1130 | |
1131 /* | |
1132 *----------------------------------------------------------------------------- | |
1133 * icons (since all the toolbar icons are included here, best place as any) | |
1134 *----------------------------------------------------------------------------- | |
1135 */ | |
1136 | |
1137 PixmapFolders *folder_icons_new(void) | |
1138 { | |
1139 PixmapFolders *pf; | |
1140 | |
1141 pf = g_new0(PixmapFolders, 1); | |
1142 | |
1143 pf->close = pixbuf_inline(PIXBUF_INLINE_FOLDER_CLOSED); | |
1144 pf->open = pixbuf_inline(PIXBUF_INLINE_FOLDER_OPEN); | |
1145 pf->deny = pixbuf_inline(PIXBUF_INLINE_FOLDER_LOCKED); | |
1146 pf->parent = pixbuf_inline(PIXBUF_INLINE_FOLDER_UP); | |
1147 | |
1148 return pf; | |
1149 } | |
1150 | |
1151 void folder_icons_free(PixmapFolders *pf) | |
1152 { | |
1153 if (!pf) return; | |
1154 | |
1155 g_object_unref(pf->close); | |
1156 g_object_unref(pf->open); | |
1157 g_object_unref(pf->deny); | |
1158 g_object_unref(pf->parent); | |
1159 | |
1160 g_free(pf); | |
1161 } | |
1162 | |
1163 /* | |
1164 *----------------------------------------------------------------------------- | |
1165 * sidebars | |
1166 *----------------------------------------------------------------------------- | |
1167 */ | |
1168 | |
1169 #define SIDEBAR_WIDTH 288 | |
1170 | |
1171 static void layout_bar_info_destroyed(GtkWidget *widget, gpointer data) | |
1172 { | |
1173 LayoutWindow *lw = data; | |
1174 | |
1175 lw->bar_info = NULL; | |
1176 | |
1177 if (lw->utility_box) | |
1178 { | |
1179 /* destroyed from within itself */ | |
1180 lw->bar_info_enabled = FALSE; | |
1181 layout_util_sync_views(lw); | |
1182 } | |
1183 } | |
1184 | |
1185 static GList *layout_bar_info_list_cb(gpointer data) | |
1186 { | |
1187 LayoutWindow *lw = data; | |
1188 | |
1189 return layout_selection_list(lw); | |
1190 } | |
1191 | |
1192 static void layout_bar_info_new(LayoutWindow *lw) | |
1193 { | |
1194 if (!lw->utility_box) return; | |
1195 | |
1196 lw->bar_info = bar_info_new(layout_image_get_path(lw), FALSE, lw->utility_box); | |
1197 bar_info_set_selection_func(lw->bar_info, layout_bar_info_list_cb, lw); | |
1198 bar_info_selection(lw->bar_info, layout_selection_count(lw, NULL) - 1); | |
1199 bar_info_size_request(lw->bar_info, SIDEBAR_WIDTH * 3 / 4); | |
1200 g_signal_connect(G_OBJECT(lw->bar_info), "destroy", | |
1201 G_CALLBACK(layout_bar_info_destroyed), lw); | |
1202 lw->bar_info_enabled = TRUE; | |
1203 | |
1204 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_info, FALSE, FALSE, 0); | |
1205 gtk_widget_show(lw->bar_info); | |
1206 } | |
1207 | |
1208 static void layout_bar_info_close(LayoutWindow *lw) | |
1209 { | |
1210 if (lw->bar_info) | |
1211 { | |
1212 bar_info_close(lw->bar_info); | |
1213 lw->bar_info = NULL; | |
1214 } | |
1215 lw->bar_info_enabled = FALSE; | |
1216 } | |
1217 | |
1218 void layout_bar_info_toggle(LayoutWindow *lw) | |
1219 { | |
1220 if (lw->bar_info_enabled) | |
1221 { | |
1222 layout_bar_info_close(lw); | |
1223 } | |
1224 else | |
1225 { | |
1226 layout_bar_info_new(lw); | |
1227 } | |
1228 } | |
1229 | |
1230 static void layout_bar_info_new_image(LayoutWindow *lw) | |
1231 { | |
1232 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1233 | |
1234 bar_info_set(lw->bar_info, layout_image_get_path(lw)); | |
1235 } | |
1236 | |
1237 static void layout_bar_info_new_selection(LayoutWindow *lw, gint count) | |
1238 { | |
1239 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1240 | |
1241 bar_info_selection(lw->bar_info, count - 1); | |
1242 } | |
1243 | |
1244 static void layout_bar_info_maint_renamed(LayoutWindow *lw) | |
1245 { | |
1246 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1247 | |
1248 bar_info_maint_renamed(lw->bar_info, layout_image_get_path(lw)); | |
1249 } | |
1250 | |
1251 static void layout_bar_exif_destroyed(GtkWidget *widget, gpointer data) | |
1252 { | |
1253 LayoutWindow *lw = data; | |
1254 | |
1255 if (lw->bar_exif) | |
1256 { | |
1257 lw->bar_exif_advanced = bar_exif_is_advanced(lw->bar_exif); | |
1258 } | |
1259 | |
1260 lw->bar_exif = NULL; | |
1261 if (lw->utility_box) | |
1262 { | |
1263 /* destroyed from within itself */ | |
1264 lw->bar_exif_enabled = FALSE; | |
1265 layout_util_sync_views(lw); | |
1266 } | |
1267 } | |
1268 | |
1269 static void layout_bar_exif_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
1270 { | |
1271 LayoutWindow *lw = data; | |
1272 | |
1273 if (lw->bar_exif) | |
1274 { | |
1275 lw->bar_exif_size = allocation->width; | |
1276 } | |
1277 } | |
1278 | |
1279 static void layout_bar_exif_new(LayoutWindow *lw) | |
1280 { | |
1281 if (!lw->utility_box) return; | |
1282 | |
1283 lw->bar_exif = bar_exif_new(TRUE, layout_image_get_path(lw), | |
1284 lw->bar_exif_advanced, lw->utility_box); | |
1285 g_signal_connect(G_OBJECT(lw->bar_exif), "destroy", | |
1286 G_CALLBACK(layout_bar_exif_destroyed), lw); | |
1287 g_signal_connect(G_OBJECT(lw->bar_exif), "size_allocate", | |
1288 G_CALLBACK(layout_bar_exif_sized), lw); | |
1289 lw->bar_exif_enabled = TRUE; | |
1290 | |
1291 if (lw->bar_exif_size < 1) lw->bar_exif_size = SIDEBAR_WIDTH; | |
1292 gtk_widget_set_size_request(lw->bar_exif, lw->bar_exif_size, -1); | |
1293 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_exif, FALSE, FALSE, 0); | |
1294 if (lw->bar_info) gtk_box_reorder_child(GTK_BOX(lw->utility_box), lw->bar_exif, 1); | |
1295 gtk_widget_show(lw->bar_exif); | |
1296 } | |
1297 | |
1298 static void layout_bar_exif_close(LayoutWindow *lw) | |
1299 { | |
1300 if (lw->bar_exif) | |
1301 { | |
1302 bar_exif_close(lw->bar_exif); | |
1303 lw->bar_exif = NULL; | |
1304 } | |
1305 lw->bar_exif_enabled = FALSE; | |
1306 } | |
1307 | |
1308 void layout_bar_exif_toggle(LayoutWindow *lw) | |
1309 { | |
1310 if (lw->bar_exif_enabled) | |
1311 { | |
1312 layout_bar_exif_close(lw); | |
1313 } | |
1314 else | |
1315 { | |
1316 layout_bar_exif_new(lw); | |
1317 } | |
1318 } | |
1319 | |
1320 static void layout_bar_exif_new_image(LayoutWindow *lw) | |
1321 { | |
1322 if (!lw->bar_exif || !lw->bar_exif_enabled) return; | |
1323 | |
1324 bar_exif_set(lw->bar_exif, layout_image_get_path(lw)); | |
1325 } | |
1326 | |
1327 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) | |
1328 { | |
1329 LayoutWindow *lw = data; | |
1330 | |
1331 lw->bar_sort = NULL; | |
1332 | |
1333 if (lw->utility_box) | |
1334 { | |
1335 /* destroyed from within itself */ | |
1336 lw->bar_sort_enabled = FALSE; | |
1337 | |
1338 layout_util_sync_views(lw); | |
1339 } | |
1340 } | |
1341 | |
1342 static void layout_bar_sort_new(LayoutWindow *lw) | |
1343 { | |
1344 if (!lw->utility_box) return; | |
1345 | |
1346 lw->bar_sort = bar_sort_new(lw); | |
1347 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy", | |
1348 G_CALLBACK(layout_bar_sort_destroyed), lw); | |
1349 lw->bar_sort_enabled = TRUE; | |
1350 | |
1351 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0); | |
1352 gtk_widget_show(lw->bar_sort); | |
1353 } | |
1354 | |
1355 static void layout_bar_sort_close(LayoutWindow *lw) | |
1356 { | |
1357 if (lw->bar_sort) | |
1358 { | |
1359 bar_sort_close(lw->bar_sort); | |
1360 lw->bar_sort = NULL; | |
1361 } | |
1362 lw->bar_sort_enabled = FALSE; | |
1363 } | |
1364 | |
1365 void layout_bar_sort_toggle(LayoutWindow *lw) | |
1366 { | |
1367 if (lw->bar_sort_enabled) | |
1368 { | |
1369 layout_bar_sort_close(lw); | |
1370 } | |
1371 else | |
1372 { | |
1373 layout_bar_sort_new(lw); | |
1374 } | |
1375 } | |
1376 | |
1377 void layout_bars_new_image(LayoutWindow *lw) | |
1378 { | |
1379 layout_bar_info_new_image(lw); | |
1380 layout_bar_exif_new_image(lw); | |
1381 } | |
1382 | |
1383 void layout_bars_new_selection(LayoutWindow *lw, gint count) | |
1384 { | |
1385 layout_bar_info_new_selection(lw, count); | |
1386 } | |
1387 | |
1388 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image) | |
1389 { | |
1390 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); | |
1391 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | |
1392 gtk_widget_show(image); | |
1393 | |
1394 if (lw->bar_sort_enabled) | |
1395 { | |
1396 layout_bar_sort_new(lw); | |
1397 } | |
1398 | |
1399 if (lw->bar_info_enabled) | |
1400 { | |
1401 layout_bar_info_new(lw); | |
1402 } | |
1403 | |
1404 if (lw->bar_exif_enabled) | |
1405 { | |
1406 layout_bar_exif_new(lw); | |
1407 } | |
1408 | |
1409 return lw->utility_box; | |
1410 } | |
1411 | |
1412 void layout_bars_close(LayoutWindow *lw) | |
1413 { | |
1414 layout_bar_sort_close(lw); | |
1415 layout_bar_exif_close(lw); | |
1416 layout_bar_info_close(lw); | |
1417 } | |
1418 | |
1419 void layout_bars_maint_renamed(LayoutWindow *lw) | |
1420 { | |
1421 layout_bar_info_maint_renamed(lw); | |
1422 } | |
1423 |