Mercurial > geeqie.yaz
annotate src/layout_util.c @ 82:a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
* image.c, typedefs.h: Add ALTER_DESATURATE alteration type.
* img-view.c, layout_image.c, layout_util.c, menu.c: Allow to grayscale
the display of current image with [Shift]+[G] kyboard shortcut and
'adjust' submenu item.
* pixbuf_util.[ch] (pixbuf_desaturate_rect): Implement grayscale
function.
author | gqview |
---|---|
date | Thu, 19 Oct 2006 19:27:20 +0000 |
parents | 6281cc38e5ca |
children | ba3c39002a24 |
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 | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
386 static void layout_menu_alter_desaturate_cb(GtkAction *action, gpointer data) |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
387 { |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
388 LayoutWindow *lw = data; |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
389 |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
390 layout_image_alter(lw, ALTER_DESATURATE); |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
391 } |
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
392 |
9 | 393 static void layout_menu_info_cb(GtkAction *action, gpointer data) |
394 { | |
395 LayoutWindow *lw = data; | |
396 GList *list; | |
397 const gchar *path = NULL; | |
398 | |
399 list = layout_selection_list(lw); | |
400 if (!list) path = layout_image_get_path(lw); | |
401 | |
402 info_window_new(path, list); | |
403 } | |
404 | |
405 static void layout_menu_select_all_cb(GtkAction *action, gpointer data) | |
406 { | |
407 LayoutWindow *lw = data; | |
408 | |
409 layout_select_all(lw); | |
410 } | |
411 | |
412 static void layout_menu_unselect_all_cb(GtkAction *action, gpointer data) | |
413 { | |
414 LayoutWindow *lw = data; | |
415 | |
416 layout_select_none(lw); | |
417 } | |
418 | |
419 static void layout_menu_config_cb(GtkAction *action, gpointer data) | |
420 { | |
421 show_config_window(); | |
422 } | |
423 | |
424 static void layout_menu_remove_thumb_cb(GtkAction *action, gpointer data) | |
425 { | |
426 cache_manager_show(); | |
427 } | |
428 | |
429 static void layout_menu_wallpaper_cb(GtkAction *action, gpointer data) | |
430 { | |
431 LayoutWindow *lw = data; | |
432 | |
433 layout_image_to_root(lw); | |
434 } | |
435 | |
436 static void layout_menu_zoom_in_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_out_cb(GtkAction *action, gpointer data) | |
444 { | |
445 LayoutWindow *lw = data; | |
446 | |
447 layout_image_zoom_adjust(lw, -get_zoom_increment()); | |
448 } | |
449 | |
450 static void layout_menu_zoom_1_1_cb(GtkAction *action, gpointer data) | |
451 { | |
452 LayoutWindow *lw = data; | |
453 | |
454 layout_image_zoom_set(lw, 1.0); | |
455 } | |
456 | |
457 static void layout_menu_zoom_fit_cb(GtkAction *action, gpointer data) | |
458 { | |
459 LayoutWindow *lw = data; | |
460 | |
461 layout_image_zoom_set(lw, 0.0); | |
462 } | |
463 | |
464 static void layout_menu_thumb_cb(GtkToggleAction *action, gpointer data) | |
465 { | |
466 LayoutWindow *lw = data; | |
467 | |
468 layout_thumb_set(lw, gtk_toggle_action_get_active(action)); | |
469 } | |
470 | |
471 static void layout_menu_list_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) | |
472 { | |
473 LayoutWindow *lw = data; | |
474 | |
475 layout_views_set(lw, lw->tree_view, (gtk_radio_action_get_current_value(action) == 1)); | |
476 } | |
477 | |
478 static void layout_menu_tree_cb(GtkToggleAction *action, gpointer data) | |
479 { | |
480 LayoutWindow *lw = data; | |
481 | |
482 layout_views_set(lw, gtk_toggle_action_get_active(action), lw->icon_view); | |
483 } | |
484 | |
485 static void layout_menu_fullscreen_cb(GtkAction *action, gpointer data) | |
486 { | |
487 LayoutWindow *lw = data; | |
488 | |
489 layout_image_full_screen_toggle(lw); | |
490 } | |
491 | |
492 static void layout_menu_refresh_cb(GtkAction *action, gpointer data) | |
493 { | |
494 LayoutWindow *lw = data; | |
495 | |
496 layout_refresh(lw); | |
497 } | |
498 | |
499 static void layout_menu_float_cb(GtkToggleAction *action, gpointer data) | |
500 { | |
501 LayoutWindow *lw = data; | |
502 | |
503 if (lw->tools_float != gtk_toggle_action_get_active(action)) | |
504 { | |
505 layout_tools_float_toggle(lw); | |
506 } | |
507 } | |
508 | |
509 static void layout_menu_hide_cb(GtkAction *action, gpointer data) | |
510 { | |
511 LayoutWindow *lw = data; | |
512 | |
513 layout_tools_hide_toggle(lw); | |
514 } | |
515 | |
516 static void layout_menu_toolbar_cb(GtkToggleAction *action, gpointer data) | |
517 { | |
518 LayoutWindow *lw = data; | |
519 | |
520 if (lw->toolbar_hidden != gtk_toggle_action_get_active(action)) | |
521 { | |
522 layout_toolbar_toggle(lw); | |
523 } | |
524 } | |
525 | |
526 static void layout_menu_bar_info_cb(GtkToggleAction *action, gpointer data) | |
527 { | |
528 LayoutWindow *lw = data; | |
529 | |
530 if (lw->bar_info_enabled != gtk_toggle_action_get_active(action)) | |
531 { | |
532 layout_bar_info_toggle(lw); | |
533 } | |
534 } | |
535 | |
536 static void layout_menu_bar_exif_cb(GtkToggleAction *action, gpointer data) | |
537 { | |
538 LayoutWindow *lw = data; | |
539 | |
540 if (lw->bar_exif_enabled != gtk_toggle_action_get_active(action)) | |
541 { | |
542 layout_bar_exif_toggle(lw); | |
543 } | |
544 } | |
545 | |
546 static void layout_menu_bar_sort_cb(GtkToggleAction *action, gpointer data) | |
547 { | |
548 LayoutWindow *lw = data; | |
549 | |
550 if (lw->bar_sort_enabled != gtk_toggle_action_get_active(action)) | |
551 { | |
552 layout_bar_sort_toggle(lw); | |
553 } | |
554 } | |
555 | |
556 static void layout_menu_slideshow_cb(GtkAction *action, gpointer data) | |
557 { | |
558 LayoutWindow *lw = data; | |
559 | |
560 layout_image_slideshow_toggle(lw); | |
561 } | |
562 | |
563 static void layout_menu_help_cb(GtkAction *action, gpointer data) | |
564 { | |
565 help_window_show("html_contents"); | |
566 } | |
567 | |
568 static void layout_menu_help_keys_cb(GtkAction *action, gpointer data) | |
569 { | |
570 help_window_show("documentation"); | |
571 } | |
572 | |
573 static void layout_menu_notes_cb(GtkAction *action, gpointer data) | |
574 { | |
575 help_window_show("release_notes"); | |
576 } | |
577 | |
578 static void layout_menu_about_cb(GtkAction *action, gpointer data) | |
579 { | |
580 show_about_window(); | |
581 } | |
582 | |
583 /* | |
584 *----------------------------------------------------------------------------- | |
585 * edit menu | |
586 *----------------------------------------------------------------------------- | |
587 */ | |
588 | |
589 static void layout_menu_edit_cb(GtkAction *action, gpointer data) | |
590 { | |
591 LayoutWindow *lw = data; | |
592 GList *list; | |
593 gint n; | |
594 | |
595 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "edit_index")); | |
596 | |
597 list = layout_selection_list(lw); | |
598 start_editor_from_path_list(n, list); | |
599 path_list_free(list); | |
600 } | |
601 | |
602 static void layout_menu_edit_update(LayoutWindow *lw) | |
603 { | |
604 gint i; | |
605 | |
606 /* main edit menu */ | |
607 | |
608 if (!lw->action_group) return; | |
609 | |
610 for (i = 0; i < 10; i++) | |
611 { | |
612 gchar *key; | |
613 GtkAction *action; | |
614 | |
615 key = g_strdup_printf("Editor%d", i); | |
616 | |
617 action = gtk_action_group_get_action(lw->action_group, key); | |
618 g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i)); | |
619 | |
620 if (editor_command[i] && strlen(editor_command[i]) > 0) | |
621 { | |
622 gchar *text; | |
623 | |
624 if (editor_name[i] && strlen(editor_name[i]) > 0) | |
625 { | |
626 text = g_strdup_printf(_("in %s..."), editor_name[i]); | |
627 } | |
628 else | |
629 { | |
630 text = g_strdup(_("in (unknown)...")); | |
631 } | |
632 g_object_set(action, "label", text, | |
633 "sensitive", TRUE, NULL); | |
634 g_free(text); | |
635 } | |
636 else | |
637 { | |
638 g_object_set(action, "label", _("empty"), | |
639 "sensitive", FALSE, NULL); | |
640 } | |
641 | |
642 g_free(key); | |
643 } | |
644 } | |
645 | |
646 void layout_edit_update_all(void) | |
647 { | |
648 GList *work; | |
649 | |
650 work = layout_window_list; | |
651 while (work) | |
652 { | |
653 LayoutWindow *lw = work->data; | |
654 work = work->next; | |
655 | |
656 layout_menu_edit_update(lw); | |
657 } | |
658 } | |
659 | |
660 /* | |
661 *----------------------------------------------------------------------------- | |
662 * recent menu | |
663 *----------------------------------------------------------------------------- | |
664 */ | |
665 | |
666 static void layout_menu_recent_cb(GtkWidget *widget, gpointer data) | |
667 { | |
668 gint n; | |
669 gchar *path; | |
670 | |
671 n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index")); | |
672 | |
673 path = g_list_nth_data(history_list_get_by_key("recent"), n); | |
674 | |
675 if (!path) return; | |
676 | |
677 /* make a copy of it */ | |
678 path = g_strdup(path); | |
679 collection_window_new(path); | |
680 g_free(path); | |
681 } | |
682 | |
683 static void layout_menu_recent_update(LayoutWindow *lw) | |
684 { | |
685 GtkWidget *menu; | |
686 GtkWidget *recent; | |
687 GtkWidget *item; | |
688 GList *list; | |
689 gint n; | |
690 | |
691 if (!lw->ui_manager) return; | |
692 | |
693 list = history_list_get_by_key("recent"); | |
694 n = 0; | |
695 | |
696 menu = gtk_menu_new(); | |
697 | |
698 while (list) | |
699 { | |
700 item = menu_item_add_simple(menu, filename_from_path((gchar *)list->data), | |
701 G_CALLBACK(layout_menu_recent_cb), lw); | |
702 g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n)); | |
703 list = list->next; | |
704 n++; | |
705 } | |
706 | |
707 if (n == 0) | |
708 { | |
709 menu_item_add(menu, _("Empty"), NULL, NULL); | |
710 } | |
711 | |
712 recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenRecent"); | |
713 gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu); | |
714 gtk_widget_set_sensitive(recent, (n != 0)); | |
715 } | |
716 | |
717 void layout_recent_update_all(void) | |
718 { | |
719 GList *work; | |
720 | |
721 work = layout_window_list; | |
722 while (work) | |
723 { | |
724 LayoutWindow *lw = work->data; | |
725 work = work->next; | |
726 | |
727 layout_menu_recent_update(lw); | |
728 } | |
729 } | |
730 | |
731 void layout_recent_add_path(const gchar *path) | |
732 { | |
733 if (!path) return; | |
734 | |
735 history_list_add_to_key("recent", path, recent_list_max); | |
736 | |
737 layout_recent_update_all(); | |
738 } | |
739 | |
740 /* | |
741 *----------------------------------------------------------------------------- | |
742 * menu | |
743 *----------------------------------------------------------------------------- | |
744 */ | |
745 | |
746 #define CB G_CALLBACK | |
747 | |
748 static GtkActionEntry menu_entries[] = { | |
749 { "FileMenu", NULL, N_("_File") }, | |
750 { "EditMenu", NULL, N_("_Edit") }, | |
751 { "AdjustMenu", NULL, N_("_Adjust") }, | |
752 { "ViewMenu", NULL, N_("_View") }, | |
753 { "HelpMenu", NULL, N_("_Help") }, | |
754 | |
755 { "NewWindow", GTK_STOCK_NEW, N_("New _window"), NULL, NULL, CB(layout_menu_new_window_cb) }, | |
756 { "NewCollection", GTK_STOCK_INDEX,N_("_New collection"), "C", NULL, CB(layout_menu_new_cb) }, | |
757 { "OpenCollection", GTK_STOCK_OPEN, N_("_Open collection..."),"O", NULL, CB(layout_menu_open_cb) }, | |
758 { "OpenRecent", NULL, N_("Open _recent") }, | |
759 { "Search", GTK_STOCK_FIND, N_("_Search..."), "F3", NULL, CB(layout_menu_search_cb) }, | |
760 { "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
|
761 { "PanView", NULL, N_("Pan _view"), "<control>J", NULL, CB(layout_menu_pan_cb) }, |
9 | 762 { "Print", GTK_STOCK_PRINT,N_("_Print..."), "<shift>P", NULL, CB(layout_menu_print_cb) }, |
763 { "NewFolder", NULL, N_("N_ew folder..."), "<control>F", NULL, CB(layout_menu_dir_cb) }, | |
764 { "Copy", NULL, N_("_Copy..."), "<control>C", NULL, CB(layout_menu_copy_cb) }, | |
765 { "Move", NULL, N_("_Move..."), "<control>M", NULL, CB(layout_menu_move_cb) }, | |
766 { "Rename", NULL, N_("_Rename..."), "<control>R", NULL, CB(layout_menu_rename_cb) }, | |
767 { "Delete", GTK_STOCK_DELETE, N_("_Delete..."), "<control>D", NULL, CB(layout_menu_delete_cb) }, | |
768 { "CloseWindow", GTK_STOCK_CLOSE,N_("C_lose window"), "<control>W", NULL, CB(layout_menu_close_cb) }, | |
769 { "Quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", NULL, CB(layout_menu_exit_cb) }, | |
770 | |
771 { "Editor0", NULL, "editor0", "<control>1", NULL, CB(layout_menu_edit_cb) }, | |
772 { "Editor1", NULL, "editor1", "<control>2", NULL, CB(layout_menu_edit_cb) }, | |
773 { "Editor2", NULL, "editor2", "<control>3", NULL, CB(layout_menu_edit_cb) }, | |
774 { "Editor3", NULL, "editor3", "<control>4", NULL, CB(layout_menu_edit_cb) }, | |
775 { "Editor4", NULL, "editor4", "<control>5", NULL, CB(layout_menu_edit_cb) }, | |
776 { "Editor5", NULL, "editor5", "<control>6", NULL, CB(layout_menu_edit_cb) }, | |
777 { "Editor6", NULL, "editor6", "<control>7", NULL, CB(layout_menu_edit_cb) }, | |
778 { "Editor7", NULL, "editor7", "<control>8", NULL, CB(layout_menu_edit_cb) }, | |
779 { "Editor8", NULL, "editor8", "<control>9", NULL, CB(layout_menu_edit_cb) }, | |
780 { "Editor9", NULL, "editor9", "<control>0", NULL, CB(layout_menu_edit_cb) }, | |
781 { "RotateCW", NULL, N_("_Rotate clockwise"), "bracketright", NULL, CB(layout_menu_alter_90_cb) }, | |
782 { "RotateCCW", NULL, N_("Rotate _counterclockwise"), "bracketleft", NULL, CB(layout_menu_alter_90cc_cb) }, | |
783 { "Rotate180", NULL, N_("Rotate 1_80"), "<shift>R", NULL, CB(layout_menu_alter_180_cb) }, | |
784 { "Mirror", NULL, N_("_Mirror"), "<shift>M", NULL, CB(layout_menu_alter_mirror_cb) }, | |
785 { "Flip", NULL, N_("_Flip"), "<shift>F", NULL, CB(layout_menu_alter_flip_cb) }, | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
786 { "Grayscale", NULL, N_("_Grayscale"), "<shift>G", NULL, CB(layout_menu_alter_desaturate_cb) }, |
9 | 787 { "Properties",GTK_STOCK_PROPERTIES, N_("_Properties"), "<control>P", NULL, CB(layout_menu_info_cb) }, |
788 { "SelectAll", NULL, N_("Select _all"), "<control>A", NULL, CB(layout_menu_select_all_cb) }, | |
789 { "SelectNone", NULL, N_("Select _none"), "<control><shift>A",NULL, CB(layout_menu_unselect_all_cb) }, | |
790 { "Preferences",GTK_STOCK_PREFERENCES,N_("P_references..."), "<control>O", NULL, CB(layout_menu_config_cb) }, | |
791 { "Maintenance", NULL, N_("_Thumbnail maintenance..."),NULL, NULL, CB(layout_menu_remove_thumb_cb) }, | |
792 { "Wallpaper", NULL, N_("Set as _wallpaper"),NULL, NULL, CB(layout_menu_wallpaper_cb) }, | |
793 | |
794 { "ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom _in"), "equal", NULL, CB(layout_menu_zoom_in_cb) }, | |
795 { "ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom _out"), "minus", NULL, CB(layout_menu_zoom_out_cb) }, | |
796 { "Zoom100", GTK_STOCK_ZOOM_100, N_("Zoom _1:1"), "Z", NULL, CB(layout_menu_zoom_1_1_cb) }, | |
797 { "ZoomFit", GTK_STOCK_ZOOM_FIT, N_("_Zoom to fit"), "X", NULL, CB(layout_menu_zoom_fit_cb) }, | |
798 { "FullScreen", NULL, N_("F_ull screen"), "F", NULL, CB(layout_menu_fullscreen_cb) }, | |
799 { "HideTools", NULL, N_("_Hide file list"), "<control>H", NULL, CB(layout_menu_hide_cb) }, | |
800 { "SlideShow", NULL, N_("Toggle _slideshow"),"S", NULL, CB(layout_menu_slideshow_cb) }, | |
801 { "Refresh", GTK_STOCK_REFRESH, N_("_Refresh"), "R", NULL, CB(layout_menu_refresh_cb) }, | |
802 | |
803 { "HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", NULL, CB(layout_menu_help_cb) }, | |
804 { "HelpShortcuts", NULL, N_("_Keyboard shortcuts"),NULL, NULL, CB(layout_menu_help_keys_cb) }, | |
805 { "HelpNotes", NULL, N_("_Release notes"), NULL, NULL, CB(layout_menu_notes_cb) }, | |
806 { "About", NULL, N_("_About"), NULL, NULL, CB(layout_menu_about_cb) } | |
807 }; | |
808 | |
809 static GtkToggleActionEntry menu_toggle_entries[] = { | |
810 { "Thumbnails", NULL, N_("_Thumbnails"), "T", NULL, CB(layout_menu_thumb_cb) }, | |
811 { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, CB(layout_menu_tree_cb) }, | |
812 { "FloatTools", NULL, N_("_Float file list"), "L", NULL, CB(layout_menu_float_cb) }, | |
813 { "HideToolbar", NULL, N_("Hide tool_bar"), NULL, NULL, CB(layout_menu_toolbar_cb) }, | |
814 { "SBarKeywords", NULL, N_("_Keywords"), "<control>K", NULL, CB(layout_menu_bar_info_cb) }, | |
815 { "SBarExif", NULL, N_("E_xif data"), "<control>E", NULL, CB(layout_menu_bar_exif_cb) }, | |
816 { "SBarSort", NULL, N_("Sort _manager"), "<control>S", NULL, CB(layout_menu_bar_sort_cb) } | |
817 }; | |
818 | |
819 static GtkRadioActionEntry menu_radio_entries[] = { | |
820 { "ViewList", NULL, N_("_List"), "<control>L", NULL, 0 }, | |
821 { "ViewIcons", NULL, N_("I_cons"), "<control>I", NULL, 1 } | |
822 }; | |
823 | |
824 #undef CB | |
825 | |
826 static const char *menu_ui_description = | |
827 "<ui>" | |
828 " <menubar name='MainMenu'>" | |
829 " <menu action='FileMenu'>" | |
830 " <menuitem action='NewWindow'/>" | |
831 " <menuitem action='NewCollection'/>" | |
832 " <menuitem action='OpenCollection'/>" | |
833 " <menuitem action='OpenRecent'/>" | |
834 " <separator/>" | |
835 " <menuitem action='Search'/>" | |
836 " <menuitem action='FindDupes'/>" | |
12
147f4c4b9025
##### Note: GQview CVS on sourceforge is not always up to date, please use #####
gqview
parents:
9
diff
changeset
|
837 " <menuitem action='PanView'/>" |
9 | 838 " <separator/>" |
839 " <menuitem action='Print'/>" | |
840 " <menuitem action='NewFolder'/>" | |
841 " <separator/>" | |
842 " <menuitem action='Copy'/>" | |
843 " <menuitem action='Move'/>" | |
844 " <menuitem action='Rename'/>" | |
845 " <menuitem action='Delete'/>" | |
846 " <separator/>" | |
847 " <menuitem action='CloseWindow'/>" | |
848 " <menuitem action='Quit'/>" | |
849 " </menu>" | |
850 " <menu action='EditMenu'>" | |
851 " <menuitem action='Editor0'/>" | |
852 " <menuitem action='Editor1'/>" | |
853 " <menuitem action='Editor2'/>" | |
854 " <menuitem action='Editor3'/>" | |
855 " <menuitem action='Editor4'/>" | |
856 " <menuitem action='Editor5'/>" | |
857 " <menuitem action='Editor6'/>" | |
858 " <menuitem action='Editor7'/>" | |
859 " <menuitem action='Editor8'/>" | |
860 " <menuitem action='Editor9'/>" | |
861 " <separator/>" | |
862 " <menu action='AdjustMenu'>" | |
863 " <menuitem action='RotateCW'/>" | |
864 " <menuitem action='RotateCCW'/>" | |
865 " <menuitem action='Rotate180'/>" | |
866 " <menuitem action='Mirror'/>" | |
867 " <menuitem action='Flip'/>" | |
82
a4c1b7014e6e
Thu Oct 19 15:20:51 2006 John Ellis <johne@verizon.net>
gqview
parents:
41
diff
changeset
|
868 " <menuitem action='Grayscale'/>" |
9 | 869 " </menu>" |
870 " <menuitem action='Properties'/>" | |
871 " <separator/>" | |
872 " <menuitem action='SelectAll'/>" | |
873 " <menuitem action='SelectNone'/>" | |
874 " <separator/>" | |
875 " <menuitem action='Preferences'/>" | |
876 " <menuitem action='Maintenance'/>" | |
877 " <separator/>" | |
878 " <menuitem action='Wallpaper'/>" | |
879 " </menu>" | |
880 " <menu action='ViewMenu'>" | |
881 " <separator/>" | |
882 " <menuitem action='ZoomIn'/>" | |
883 " <menuitem action='ZoomOut'/>" | |
884 " <menuitem action='Zoom100'/>" | |
885 " <menuitem action='ZoomFit'/>" | |
886 " <separator/>" | |
887 " <menuitem action='Thumbnails'/>" | |
888 " <menuitem action='ViewList'/>" | |
889 " <menuitem action='ViewIcons'/>" | |
890 " <separator/>" | |
891 " <menuitem action='FolderTree'/>" | |
892 " <menuitem action='FullScreen'/>" | |
893 " <separator/>" | |
894 " <menuitem action='FloatTools'/>" | |
895 " <menuitem action='HideTools'/>" | |
896 " <menuitem action='HideToolbar'/>" | |
897 " <separator/>" | |
898 " <menuitem action='SBarKeywords'/>" | |
899 " <menuitem action='SBarExif'/>" | |
900 " <menuitem action='SBarSort'/>" | |
901 " <separator/>" | |
902 " <menuitem action='SlideShow'/>" | |
903 " <menuitem action='Refresh'/>" | |
904 " </menu>" | |
905 " <menu action='HelpMenu'>" | |
906 " <separator/>" | |
907 " <menuitem action='HelpContents'/>" | |
908 " <menuitem action='HelpShortcuts'/>" | |
909 " <menuitem action='HelpNotes'/>" | |
910 " <separator/>" | |
911 " <menuitem action='About'/>" | |
912 " </menu>" | |
913 " </menubar>" | |
914 "</ui>"; | |
915 | |
916 | |
917 static gchar *menu_translate(const gchar *path, gpointer data) | |
918 { | |
919 return _(path); | |
920 } | |
921 | |
922 void layout_actions_setup(LayoutWindow *lw) | |
923 { | |
924 GError *error; | |
925 | |
926 if (lw->ui_manager) return; | |
927 | |
928 lw->action_group = gtk_action_group_new ("MenuActions"); | |
929 gtk_action_group_set_translate_func(lw->action_group, menu_translate, NULL, NULL); | |
930 | |
931 gtk_action_group_add_actions(lw->action_group, | |
932 menu_entries, G_N_ELEMENTS(menu_entries), lw); | |
933 gtk_action_group_add_toggle_actions(lw->action_group, | |
934 menu_toggle_entries, G_N_ELEMENTS(menu_toggle_entries), lw); | |
935 gtk_action_group_add_radio_actions(lw->action_group, | |
936 menu_radio_entries, G_N_ELEMENTS(menu_radio_entries), | |
937 0, G_CALLBACK(layout_menu_list_cb), lw); | |
938 | |
939 lw->ui_manager = gtk_ui_manager_new(); | |
940 gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); | |
941 gtk_ui_manager_insert_action_group(lw->ui_manager, lw->action_group, 0); | |
942 | |
943 error = NULL; | |
944 if (!gtk_ui_manager_add_ui_from_string(lw->ui_manager, menu_ui_description, -1, &error)) | |
945 { | |
946 g_message ("building menus failed: %s", error->message); | |
947 g_error_free (error); | |
948 exit (EXIT_FAILURE); | |
949 } | |
950 } | |
951 | |
952 void layout_actions_add_window(LayoutWindow *lw, GtkWidget *window) | |
953 { | |
954 GtkAccelGroup *group; | |
955 | |
956 if (!lw->ui_manager) return; | |
957 | |
958 group = gtk_ui_manager_get_accel_group(lw->ui_manager); | |
959 gtk_window_add_accel_group(GTK_WINDOW(window), group); | |
960 } | |
961 | |
962 GtkWidget *layout_actions_menu_bar(LayoutWindow *lw) | |
963 { | |
964 return gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu"); | |
965 } | |
966 | |
967 | |
968 /* | |
969 *----------------------------------------------------------------------------- | |
970 * toolbar | |
971 *----------------------------------------------------------------------------- | |
972 */ | |
973 | |
974 static void layout_button_thumb_cb(GtkWidget *widget, gpointer data) | |
975 { | |
976 LayoutWindow *lw = data; | |
977 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
978 layout_thumb_set(lw, gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget))); |
9 | 979 } |
980 | |
981 static void layout_button_home_cb(GtkWidget *widget, gpointer data) | |
982 { | |
983 LayoutWindow *lw = data; | |
984 const gchar *path = homedir(); | |
985 | |
986 if (path) layout_set_path(lw, path); | |
987 } | |
988 | |
989 static void layout_button_refresh_cb(GtkWidget *widget, gpointer data) | |
990 { | |
991 LayoutWindow *lw = data; | |
992 | |
993 layout_refresh(lw); | |
994 } | |
995 | |
996 static void layout_button_zoom_in_cb(GtkWidget *widget, gpointer data) | |
997 { | |
998 LayoutWindow *lw = data; | |
999 | |
1000 layout_image_zoom_adjust(lw, get_zoom_increment()); | |
1001 } | |
1002 | |
1003 static void layout_button_zoom_out_cb(GtkWidget *widget, gpointer data) | |
1004 { | |
1005 LayoutWindow *lw = data; | |
1006 | |
1007 layout_image_zoom_adjust(lw, -get_zoom_increment()); | |
1008 } | |
1009 | |
1010 static void layout_button_zoom_fit_cb(GtkWidget *widget, gpointer data) | |
1011 { | |
1012 LayoutWindow *lw = data; | |
1013 | |
1014 layout_image_zoom_set(lw, 0.0); | |
1015 } | |
1016 | |
1017 static void layout_button_zoom_1_1_cb(GtkWidget *widget, gpointer data) | |
1018 { | |
1019 LayoutWindow *lw = data; | |
1020 | |
1021 layout_image_zoom_set(lw, 1.0); | |
1022 } | |
1023 | |
1024 static void layout_button_config_cb(GtkWidget *widget, gpointer data) | |
1025 { | |
1026 show_config_window(); | |
1027 } | |
1028 | |
1029 static void layout_button_float_cb(GtkWidget *widget, gpointer data) | |
1030 { | |
1031 LayoutWindow *lw = data; | |
1032 | |
1033 layout_tools_float_toggle(lw); | |
1034 } | |
1035 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1036 static void layout_button_custom_icon(GtkWidget *button, const gchar *key) |
9 | 1037 { |
1038 GtkWidget *icon; | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1039 GdkPixbuf *pixbuf; |
9 | 1040 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1041 pixbuf = pixbuf_inline(key); |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1042 if (!pixbuf) return; |
9 | 1043 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1044 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
|
1045 g_object_unref(pixbuf); |
9 | 1046 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1047 pref_toolbar_button_set_icon(button, icon, NULL); |
9 | 1048 gtk_widget_show(icon); |
1049 } | |
1050 | |
1051 GtkWidget *layout_button_bar(LayoutWindow *lw) | |
1052 { | |
1053 GtkWidget *box; | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1054 GtkWidget *button; |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1055 |
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1056 box = pref_toolbar_new(NULL, GTK_TOOLBAR_ICONS); |
9 | 1057 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1058 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
|
1059 _("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
|
1060 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
|
1061 lw->thumb_button = button; |
9 | 1062 |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1063 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
|
1064 _("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
|
1065 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
|
1066 _("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
|
1067 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
|
1068 _("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
|
1069 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
|
1070 _("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
|
1071 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
|
1072 _("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
|
1073 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
|
1074 _("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
|
1075 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
|
1076 _("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
|
1077 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
|
1078 _("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
|
1079 layout_button_custom_icon(button, PIXBUF_INLINE_ICON_FLOAT); |
9 | 1080 |
1081 return box; | |
1082 } | |
1083 | |
1084 /* | |
1085 *----------------------------------------------------------------------------- | |
1086 * misc | |
1087 *----------------------------------------------------------------------------- | |
1088 */ | |
1089 | |
1090 static void layout_util_sync_views(LayoutWindow *lw) | |
1091 { | |
1092 GtkAction *action; | |
1093 | |
1094 if (!lw->action_group) return; | |
1095 | |
1096 action = gtk_action_group_get_action(lw->action_group, "FolderTree"); | |
1097 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tree_view); | |
1098 | |
1099 action = gtk_action_group_get_action(lw->action_group, "ViewIcons"); | |
1100 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->icon_view); | |
1101 | |
1102 action = gtk_action_group_get_action(lw->action_group, "FloatTools"); | |
1103 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tools_float); | |
1104 | |
1105 action = gtk_action_group_get_action(lw->action_group, "SBarKeywords"); | |
1106 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_info_enabled); | |
1107 | |
1108 action = gtk_action_group_get_action(lw->action_group, "SBarExif"); | |
1109 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_exif_enabled); | |
1110 | |
1111 action = gtk_action_group_get_action(lw->action_group, "SBarSort"); | |
1112 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->bar_sort_enabled); | |
1113 | |
1114 action = gtk_action_group_get_action(lw->action_group, "HideToolbar"); | |
1115 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->toolbar_hidden); | |
1116 } | |
1117 | |
1118 void layout_util_sync_thumb(LayoutWindow *lw) | |
1119 { | |
1120 GtkAction *action; | |
1121 | |
1122 if (!lw->action_group) return; | |
1123 | |
1124 action = gtk_action_group_get_action(lw->action_group, "Thumbnails"); | |
1125 gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->thumbs_enabled); | |
1126 g_object_set(action, "sensitive", !lw->icon_view, NULL); | |
1127 | |
41
6281cc38e5ca
Wed Apr 27 15:17:57 2005 John Ellis <johne@verizon.net>
gqview
parents:
12
diff
changeset
|
1128 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(lw->thumb_button), lw->thumbs_enabled); |
9 | 1129 gtk_widget_set_sensitive(lw->thumb_button, !lw->icon_view); |
1130 } | |
1131 | |
1132 void layout_util_sync(LayoutWindow *lw) | |
1133 { | |
1134 layout_util_sync_views(lw); | |
1135 layout_util_sync_thumb(lw); | |
1136 layout_menu_recent_update(lw); | |
1137 layout_menu_edit_update(lw); | |
1138 } | |
1139 | |
1140 /* | |
1141 *----------------------------------------------------------------------------- | |
1142 * icons (since all the toolbar icons are included here, best place as any) | |
1143 *----------------------------------------------------------------------------- | |
1144 */ | |
1145 | |
1146 PixmapFolders *folder_icons_new(void) | |
1147 { | |
1148 PixmapFolders *pf; | |
1149 | |
1150 pf = g_new0(PixmapFolders, 1); | |
1151 | |
1152 pf->close = pixbuf_inline(PIXBUF_INLINE_FOLDER_CLOSED); | |
1153 pf->open = pixbuf_inline(PIXBUF_INLINE_FOLDER_OPEN); | |
1154 pf->deny = pixbuf_inline(PIXBUF_INLINE_FOLDER_LOCKED); | |
1155 pf->parent = pixbuf_inline(PIXBUF_INLINE_FOLDER_UP); | |
1156 | |
1157 return pf; | |
1158 } | |
1159 | |
1160 void folder_icons_free(PixmapFolders *pf) | |
1161 { | |
1162 if (!pf) return; | |
1163 | |
1164 g_object_unref(pf->close); | |
1165 g_object_unref(pf->open); | |
1166 g_object_unref(pf->deny); | |
1167 g_object_unref(pf->parent); | |
1168 | |
1169 g_free(pf); | |
1170 } | |
1171 | |
1172 /* | |
1173 *----------------------------------------------------------------------------- | |
1174 * sidebars | |
1175 *----------------------------------------------------------------------------- | |
1176 */ | |
1177 | |
1178 #define SIDEBAR_WIDTH 288 | |
1179 | |
1180 static void layout_bar_info_destroyed(GtkWidget *widget, gpointer data) | |
1181 { | |
1182 LayoutWindow *lw = data; | |
1183 | |
1184 lw->bar_info = NULL; | |
1185 | |
1186 if (lw->utility_box) | |
1187 { | |
1188 /* destroyed from within itself */ | |
1189 lw->bar_info_enabled = FALSE; | |
1190 layout_util_sync_views(lw); | |
1191 } | |
1192 } | |
1193 | |
1194 static GList *layout_bar_info_list_cb(gpointer data) | |
1195 { | |
1196 LayoutWindow *lw = data; | |
1197 | |
1198 return layout_selection_list(lw); | |
1199 } | |
1200 | |
1201 static void layout_bar_info_new(LayoutWindow *lw) | |
1202 { | |
1203 if (!lw->utility_box) return; | |
1204 | |
1205 lw->bar_info = bar_info_new(layout_image_get_path(lw), FALSE, lw->utility_box); | |
1206 bar_info_set_selection_func(lw->bar_info, layout_bar_info_list_cb, lw); | |
1207 bar_info_selection(lw->bar_info, layout_selection_count(lw, NULL) - 1); | |
1208 bar_info_size_request(lw->bar_info, SIDEBAR_WIDTH * 3 / 4); | |
1209 g_signal_connect(G_OBJECT(lw->bar_info), "destroy", | |
1210 G_CALLBACK(layout_bar_info_destroyed), lw); | |
1211 lw->bar_info_enabled = TRUE; | |
1212 | |
1213 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_info, FALSE, FALSE, 0); | |
1214 gtk_widget_show(lw->bar_info); | |
1215 } | |
1216 | |
1217 static void layout_bar_info_close(LayoutWindow *lw) | |
1218 { | |
1219 if (lw->bar_info) | |
1220 { | |
1221 bar_info_close(lw->bar_info); | |
1222 lw->bar_info = NULL; | |
1223 } | |
1224 lw->bar_info_enabled = FALSE; | |
1225 } | |
1226 | |
1227 void layout_bar_info_toggle(LayoutWindow *lw) | |
1228 { | |
1229 if (lw->bar_info_enabled) | |
1230 { | |
1231 layout_bar_info_close(lw); | |
1232 } | |
1233 else | |
1234 { | |
1235 layout_bar_info_new(lw); | |
1236 } | |
1237 } | |
1238 | |
1239 static void layout_bar_info_new_image(LayoutWindow *lw) | |
1240 { | |
1241 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1242 | |
1243 bar_info_set(lw->bar_info, layout_image_get_path(lw)); | |
1244 } | |
1245 | |
1246 static void layout_bar_info_new_selection(LayoutWindow *lw, gint count) | |
1247 { | |
1248 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1249 | |
1250 bar_info_selection(lw->bar_info, count - 1); | |
1251 } | |
1252 | |
1253 static void layout_bar_info_maint_renamed(LayoutWindow *lw) | |
1254 { | |
1255 if (!lw->bar_info || !lw->bar_info_enabled) return; | |
1256 | |
1257 bar_info_maint_renamed(lw->bar_info, layout_image_get_path(lw)); | |
1258 } | |
1259 | |
1260 static void layout_bar_exif_destroyed(GtkWidget *widget, gpointer data) | |
1261 { | |
1262 LayoutWindow *lw = data; | |
1263 | |
1264 if (lw->bar_exif) | |
1265 { | |
1266 lw->bar_exif_advanced = bar_exif_is_advanced(lw->bar_exif); | |
1267 } | |
1268 | |
1269 lw->bar_exif = NULL; | |
1270 if (lw->utility_box) | |
1271 { | |
1272 /* destroyed from within itself */ | |
1273 lw->bar_exif_enabled = FALSE; | |
1274 layout_util_sync_views(lw); | |
1275 } | |
1276 } | |
1277 | |
1278 static void layout_bar_exif_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data) | |
1279 { | |
1280 LayoutWindow *lw = data; | |
1281 | |
1282 if (lw->bar_exif) | |
1283 { | |
1284 lw->bar_exif_size = allocation->width; | |
1285 } | |
1286 } | |
1287 | |
1288 static void layout_bar_exif_new(LayoutWindow *lw) | |
1289 { | |
1290 if (!lw->utility_box) return; | |
1291 | |
1292 lw->bar_exif = bar_exif_new(TRUE, layout_image_get_path(lw), | |
1293 lw->bar_exif_advanced, lw->utility_box); | |
1294 g_signal_connect(G_OBJECT(lw->bar_exif), "destroy", | |
1295 G_CALLBACK(layout_bar_exif_destroyed), lw); | |
1296 g_signal_connect(G_OBJECT(lw->bar_exif), "size_allocate", | |
1297 G_CALLBACK(layout_bar_exif_sized), lw); | |
1298 lw->bar_exif_enabled = TRUE; | |
1299 | |
1300 if (lw->bar_exif_size < 1) lw->bar_exif_size = SIDEBAR_WIDTH; | |
1301 gtk_widget_set_size_request(lw->bar_exif, lw->bar_exif_size, -1); | |
1302 gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_exif, FALSE, FALSE, 0); | |
1303 if (lw->bar_info) gtk_box_reorder_child(GTK_BOX(lw->utility_box), lw->bar_exif, 1); | |
1304 gtk_widget_show(lw->bar_exif); | |
1305 } | |
1306 | |
1307 static void layout_bar_exif_close(LayoutWindow *lw) | |
1308 { | |
1309 if (lw->bar_exif) | |
1310 { | |
1311 bar_exif_close(lw->bar_exif); | |
1312 lw->bar_exif = NULL; | |
1313 } | |
1314 lw->bar_exif_enabled = FALSE; | |
1315 } | |
1316 | |
1317 void layout_bar_exif_toggle(LayoutWindow *lw) | |
1318 { | |
1319 if (lw->bar_exif_enabled) | |
1320 { | |
1321 layout_bar_exif_close(lw); | |
1322 } | |
1323 else | |
1324 { | |
1325 layout_bar_exif_new(lw); | |
1326 } | |
1327 } | |
1328 | |
1329 static void layout_bar_exif_new_image(LayoutWindow *lw) | |
1330 { | |
1331 if (!lw->bar_exif || !lw->bar_exif_enabled) return; | |
1332 | |
1333 bar_exif_set(lw->bar_exif, layout_image_get_path(lw)); | |
1334 } | |
1335 | |
1336 static void layout_bar_sort_destroyed(GtkWidget *widget, gpointer data) | |
1337 { | |
1338 LayoutWindow *lw = data; | |
1339 | |
1340 lw->bar_sort = NULL; | |
1341 | |
1342 if (lw->utility_box) | |
1343 { | |
1344 /* destroyed from within itself */ | |
1345 lw->bar_sort_enabled = FALSE; | |
1346 | |
1347 layout_util_sync_views(lw); | |
1348 } | |
1349 } | |
1350 | |
1351 static void layout_bar_sort_new(LayoutWindow *lw) | |
1352 { | |
1353 if (!lw->utility_box) return; | |
1354 | |
1355 lw->bar_sort = bar_sort_new(lw); | |
1356 g_signal_connect(G_OBJECT(lw->bar_sort), "destroy", | |
1357 G_CALLBACK(layout_bar_sort_destroyed), lw); | |
1358 lw->bar_sort_enabled = TRUE; | |
1359 | |
1360 gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0); | |
1361 gtk_widget_show(lw->bar_sort); | |
1362 } | |
1363 | |
1364 static void layout_bar_sort_close(LayoutWindow *lw) | |
1365 { | |
1366 if (lw->bar_sort) | |
1367 { | |
1368 bar_sort_close(lw->bar_sort); | |
1369 lw->bar_sort = NULL; | |
1370 } | |
1371 lw->bar_sort_enabled = FALSE; | |
1372 } | |
1373 | |
1374 void layout_bar_sort_toggle(LayoutWindow *lw) | |
1375 { | |
1376 if (lw->bar_sort_enabled) | |
1377 { | |
1378 layout_bar_sort_close(lw); | |
1379 } | |
1380 else | |
1381 { | |
1382 layout_bar_sort_new(lw); | |
1383 } | |
1384 } | |
1385 | |
1386 void layout_bars_new_image(LayoutWindow *lw) | |
1387 { | |
1388 layout_bar_info_new_image(lw); | |
1389 layout_bar_exif_new_image(lw); | |
1390 } | |
1391 | |
1392 void layout_bars_new_selection(LayoutWindow *lw, gint count) | |
1393 { | |
1394 layout_bar_info_new_selection(lw, count); | |
1395 } | |
1396 | |
1397 GtkWidget *layout_bars_prepare(LayoutWindow *lw, GtkWidget *image) | |
1398 { | |
1399 lw->utility_box = gtk_hbox_new(FALSE, PREF_PAD_GAP); | |
1400 gtk_box_pack_start(GTK_BOX(lw->utility_box), image, TRUE, TRUE, 0); | |
1401 gtk_widget_show(image); | |
1402 | |
1403 if (lw->bar_sort_enabled) | |
1404 { | |
1405 layout_bar_sort_new(lw); | |
1406 } | |
1407 | |
1408 if (lw->bar_info_enabled) | |
1409 { | |
1410 layout_bar_info_new(lw); | |
1411 } | |
1412 | |
1413 if (lw->bar_exif_enabled) | |
1414 { | |
1415 layout_bar_exif_new(lw); | |
1416 } | |
1417 | |
1418 return lw->utility_box; | |
1419 } | |
1420 | |
1421 void layout_bars_close(LayoutWindow *lw) | |
1422 { | |
1423 layout_bar_sort_close(lw); | |
1424 layout_bar_exif_close(lw); | |
1425 layout_bar_info_close(lw); | |
1426 } | |
1427 | |
1428 void layout_bars_maint_renamed(LayoutWindow *lw) | |
1429 { | |
1430 layout_bar_info_maint_renamed(lw); | |
1431 } | |
1432 |