Mercurial > geeqie.yaz
comparison src/image.c @ 1431:7e180091e0b7
More gboolean and tidy up.
author | zas_ |
---|---|
date | Sat, 14 Mar 2009 11:26:43 +0000 |
parents | 249bf204004a |
children | cf4029d10d38 |
comparison
equal
deleted
inserted
replaced
1430:7718e351bc45 | 1431:7e180091e0b7 |
---|---|
99 if (imd->overlay_show_zoom) image_osd_update(imd); | 99 if (imd->overlay_show_zoom) image_osd_update(imd); |
100 | 100 |
101 image_update_util(imd); | 101 image_update_util(imd); |
102 } | 102 } |
103 | 103 |
104 static void image_complete_util(ImageWindow *imd, gint preload) | 104 static void image_complete_util(ImageWindow *imd, gboolean preload) |
105 { | 105 { |
106 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; | 106 if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return; |
107 | 107 |
108 DEBUG_1("%s image load completed \"%s\" (%s)", get_exec_time(), | 108 DEBUG_1("%s image load completed \"%s\" (%s)", get_exec_time(), |
109 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : | 109 (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : |
187 *------------------------------------------------------------------- | 187 *------------------------------------------------------------------- |
188 * rotation, flip, etc. | 188 * rotation, flip, etc. |
189 *------------------------------------------------------------------- | 189 *------------------------------------------------------------------- |
190 */ | 190 */ |
191 | 191 |
192 static gint image_post_process_color(ImageWindow *imd, gint start_row, gint run_in_bg) | 192 static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gboolean run_in_bg) |
193 { | 193 { |
194 ColorMan *cm; | 194 ColorMan *cm; |
195 ColorManProfileType input_type; | 195 ColorManProfileType input_type; |
196 ColorManProfileType screen_type; | 196 ColorManProfileType screen_type; |
197 const gchar *input_file; | 197 const gchar *input_file; |
627 g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); | 627 g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd); |
628 } | 628 } |
629 | 629 |
630 /* this read ahead is located here merely for the callbacks, above */ | 630 /* this read ahead is located here merely for the callbacks, above */ |
631 | 631 |
632 static gint image_read_ahead_check(ImageWindow *imd) | 632 static gboolean image_read_ahead_check(ImageWindow *imd) |
633 { | 633 { |
634 if (!imd->read_ahead_fd) return FALSE; | 634 if (!imd->read_ahead_fd) return FALSE; |
635 if (imd->il) return FALSE; | 635 if (imd->il) return FALSE; |
636 | 636 |
637 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) | 637 if (!imd->image_fd || imd->read_ahead_fd != imd->image_fd) |
674 | 674 |
675 image_read_ahead_cancel(imd); | 675 image_read_ahead_cancel(imd); |
676 return FALSE; | 676 return FALSE; |
677 } | 677 } |
678 | 678 |
679 static gint image_load_begin(ImageWindow *imd, FileData *fd) | 679 static gboolean image_load_begin(ImageWindow *imd, FileData *fd) |
680 { | 680 { |
681 DEBUG_1("%s image begin", get_exec_time()); | 681 DEBUG_1("%s image begin", get_exec_time()); |
682 | 682 |
683 if (imd->il) return FALSE; | 683 if (imd->il) return FALSE; |
684 | 684 |
760 *------------------------------------------------------------------- | 760 *------------------------------------------------------------------- |
761 * image changer | 761 * image changer |
762 *------------------------------------------------------------------- | 762 *------------------------------------------------------------------- |
763 */ | 763 */ |
764 | 764 |
765 static void image_change_complete(ImageWindow *imd, gdouble zoom, gint new) | 765 static void image_change_complete(ImageWindow *imd, gdouble zoom) |
766 { | 766 { |
767 image_reset(imd); | 767 image_reset(imd); |
768 imd->unknown = TRUE; | 768 imd->unknown = TRUE; |
769 | 769 |
770 if (!imd->image_fd) | 770 if (!imd->image_fd) |
812 | 812 |
813 file_data_unref(imd->image_fd); | 813 file_data_unref(imd->image_fd); |
814 imd->image_fd = file_data_ref(fd); | 814 imd->image_fd = file_data_ref(fd); |
815 | 815 |
816 | 816 |
817 image_change_complete(imd, zoom, TRUE); | 817 image_change_complete(imd, zoom); |
818 | 818 |
819 image_update_title(imd); | 819 image_update_title(imd); |
820 image_state_set(imd, IMAGE_STATE_IMAGE); | 820 image_state_set(imd, IMAGE_STATE_IMAGE); |
821 | 821 |
822 if (imd->auto_refresh && imd->image_fd) | 822 if (imd->auto_refresh && imd->image_fd) |
827 *------------------------------------------------------------------- | 827 *------------------------------------------------------------------- |
828 * focus stuff | 828 * focus stuff |
829 *------------------------------------------------------------------- | 829 *------------------------------------------------------------------- |
830 */ | 830 */ |
831 | 831 |
832 static void image_focus_paint(ImageWindow *imd, gint has_focus, GdkRectangle *area) | 832 static void image_focus_paint(ImageWindow *imd, gboolean has_focus, GdkRectangle *area) |
833 { | 833 { |
834 GtkWidget *widget; | 834 GtkWidget *widget; |
835 | 835 |
836 widget = imd->widget; | 836 widget = imd->widget; |
837 if (!widget->window) return; | 837 if (!widget->window) return; |
850 widget->allocation.x, widget->allocation.y, | 850 widget->allocation.x, widget->allocation.y, |
851 widget->allocation.width - 1, widget->allocation.height - 1); | 851 widget->allocation.width - 1, widget->allocation.height - 1); |
852 } | 852 } |
853 } | 853 } |
854 | 854 |
855 static gint image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) | 855 static gboolean image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data) |
856 { | 856 { |
857 ImageWindow *imd = data; | 857 ImageWindow *imd = data; |
858 | 858 |
859 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); | 859 image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area); |
860 return TRUE; | 860 return TRUE; |
861 } | 861 } |
862 | 862 |
863 static gint image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | 863 static gboolean image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) |
864 { | 864 { |
865 ImageWindow *imd = data; | 865 ImageWindow *imd = data; |
866 | 866 |
867 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); | 867 GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); |
868 image_focus_paint(imd, TRUE, NULL); | 868 image_focus_paint(imd, TRUE, NULL); |
869 | 869 |
870 return TRUE; | 870 return TRUE; |
871 } | 871 } |
872 | 872 |
873 static gint image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) | 873 static gboolean image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data) |
874 { | 874 { |
875 ImageWindow *imd = data; | 875 ImageWindow *imd = data; |
876 | 876 |
877 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); | 877 GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS); |
878 image_focus_paint(imd, FALSE, NULL); | 878 image_focus_paint(imd, FALSE, NULL); |
879 | 879 |
880 return TRUE; | 880 return TRUE; |
881 } | 881 } |
882 | 882 |
883 static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) | 883 static gboolean image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data) |
884 { | 884 { |
885 ImageWindow *imd = data; | 885 ImageWindow *imd = data; |
886 | 886 |
887 if (imd->func_scroll && | 887 if (imd->func_scroll && |
888 event && event->type == GDK_SCROLL) | 888 event && event->type == GDK_SCROLL) |
899 * public interface | 899 * public interface |
900 *------------------------------------------------------------------- | 900 *------------------------------------------------------------------- |
901 */ | 901 */ |
902 | 902 |
903 void image_attach_window(ImageWindow *imd, GtkWidget *window, | 903 void image_attach_window(ImageWindow *imd, GtkWidget *window, |
904 const gchar *title, const gchar *title_right, gint show_zoom) | 904 const gchar *title, const gchar *title_right, gboolean show_zoom) |
905 { | 905 { |
906 imd->top_window = window; | 906 imd->top_window = window; |
907 g_free(imd->title); | 907 g_free(imd->title); |
908 imd->title = g_strdup(title); | 908 imd->title = g_strdup(title); |
909 g_free(imd->title_right); | 909 g_free(imd->title_right); |
924 imd->func_update = func; | 924 imd->func_update = func; |
925 imd->data_update = data; | 925 imd->data_update = data; |
926 } | 926 } |
927 | 927 |
928 void image_set_complete_func(ImageWindow *imd, | 928 void image_set_complete_func(ImageWindow *imd, |
929 void (*func)(ImageWindow *imd, gint preload, gpointer data), | 929 void (*func)(ImageWindow *imd, gboolean preload, gpointer data), |
930 gpointer data) | 930 gpointer data) |
931 { | 931 { |
932 imd->func_complete = func; | 932 imd->func_complete = func; |
933 imd->data_complete = data; | 933 imd->data_complete = data; |
934 } | 934 } |
1016 if (imd->image_fd == fd) return; | 1016 if (imd->image_fd == fd) return; |
1017 | 1017 |
1018 image_change_real(imd, fd, NULL, NULL, zoom); | 1018 image_change_real(imd, fd, NULL, NULL, zoom); |
1019 } | 1019 } |
1020 | 1020 |
1021 gint image_get_image_size(ImageWindow *imd, gint *width, gint *height) | 1021 gboolean image_get_image_size(ImageWindow *imd, gint *width, gint *height) |
1022 { | 1022 { |
1023 return pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), width, height); | 1023 return pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), width, height); |
1024 } | 1024 } |
1025 | 1025 |
1026 GdkPixbuf *image_get_pixbuf(ImageWindow *imd) | 1026 GdkPixbuf *image_get_pixbuf(ImageWindow *imd) |
1027 { | 1027 { |
1028 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); | 1028 return pixbuf_renderer_get_pixbuf((PixbufRenderer *)imd->pr); |
1029 } | 1029 } |
1030 | 1030 |
1031 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gint lazy) | 1031 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy) |
1032 { | 1032 { |
1033 | 1033 |
1034 | 1034 |
1035 /* read_exif and similar functions can actually notice that the file has changed and triger a notification | 1035 /* read_exif and similar functions can actually notice that the file has changed and triger a notification |
1036 that removes the pixbuf from cache and unref it. Therefore we must ref it here before it is taken over by the renderer. */ | 1036 that removes the pixbuf from cache and unref it. Therefore we must ref it here before it is taken over by the renderer. */ |
1207 | 1207 |
1208 void image_reload(ImageWindow *imd) | 1208 void image_reload(ImageWindow *imd) |
1209 { | 1209 { |
1210 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; | 1210 if (pixbuf_renderer_get_tiles((PixbufRenderer *)imd->pr)) return; |
1211 | 1211 |
1212 image_change_complete(imd, image_zoom_get(imd), FALSE); | 1212 image_change_complete(imd, image_zoom_get(imd)); |
1213 } | 1213 } |
1214 | 1214 |
1215 void image_scroll(ImageWindow *imd, gint x, gint y) | 1215 void image_scroll(ImageWindow *imd, gint x, gint y) |
1216 { | 1216 { |
1217 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); | 1217 pixbuf_renderer_scroll((PixbufRenderer *)imd->pr, x, y); |
1394 file_data_register_real_time_monitor(imd->image_fd); | 1394 file_data_register_real_time_monitor(imd->image_fd); |
1395 | 1395 |
1396 imd->auto_refresh = enable; | 1396 imd->auto_refresh = enable; |
1397 } | 1397 } |
1398 | 1398 |
1399 void image_top_window_set_sync(ImageWindow *imd, gint allow_sync) | 1399 void image_top_window_set_sync(ImageWindow *imd, gboolean allow_sync) |
1400 { | 1400 { |
1401 imd->top_window_sync = allow_sync; | 1401 imd->top_window_sync = allow_sync; |
1402 | 1402 |
1403 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); | 1403 g_object_set(G_OBJECT(imd->pr), "window_fit", allow_sync, NULL); |
1404 } | 1404 } |
1408 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); | 1408 pixbuf_renderer_set_color((PixbufRenderer *)imd->pr, color); |
1409 } | 1409 } |
1410 | 1410 |
1411 void image_color_profile_set(ImageWindow *imd, | 1411 void image_color_profile_set(ImageWindow *imd, |
1412 gint input_type, gint screen_type, | 1412 gint input_type, gint screen_type, |
1413 gint use_image) | 1413 gboolean use_image) |
1414 { | 1414 { |
1415 if (!imd) return; | 1415 if (!imd) return; |
1416 | 1416 |
1417 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS || | 1417 if (input_type < 0 || input_type >= COLOR_PROFILE_FILE + COLOR_PROFILE_INPUTS || |
1418 screen_type < 0 || screen_type > 1) | 1418 screen_type < 0 || screen_type > 1) |
1423 imd->color_profile_input = input_type; | 1423 imd->color_profile_input = input_type; |
1424 imd->color_profile_screen = screen_type; | 1424 imd->color_profile_screen = screen_type; |
1425 imd->color_profile_use_image = use_image; | 1425 imd->color_profile_use_image = use_image; |
1426 } | 1426 } |
1427 | 1427 |
1428 gint image_color_profile_get(ImageWindow *imd, | 1428 gboolean image_color_profile_get(ImageWindow *imd, |
1429 gint *input_type, gint *screen_type, | 1429 gint *input_type, gint *screen_type, |
1430 gint *use_image) | 1430 gboolean *use_image) |
1431 { | 1431 { |
1432 if (!imd) return FALSE; | 1432 if (!imd) return FALSE; |
1433 | 1433 |
1434 if (input_type) *input_type = imd->color_profile_input; | 1434 if (input_type) *input_type = imd->color_profile_input; |
1435 if (screen_type) *screen_type = imd->color_profile_screen; | 1435 if (screen_type) *screen_type = imd->color_profile_screen; |
1436 if (use_image) *use_image = imd->color_profile_use_image; | 1436 if (use_image) *use_image = imd->color_profile_use_image; |
1437 | 1437 |
1438 return TRUE; | 1438 return TRUE; |
1439 } | 1439 } |
1440 | 1440 |
1441 void image_color_profile_set_use(ImageWindow *imd, gint enable) | 1441 void image_color_profile_set_use(ImageWindow *imd, gboolean enable) |
1442 { | 1442 { |
1443 if (!imd) return; | 1443 if (!imd) return; |
1444 | 1444 |
1445 if (imd->color_profile_enable == enable) return; | 1445 if (imd->color_profile_enable == enable) return; |
1446 | 1446 |
1447 imd->color_profile_enable = enable; | 1447 imd->color_profile_enable = enable; |
1448 } | 1448 } |
1449 | 1449 |
1450 gint image_color_profile_get_use(ImageWindow *imd) | 1450 gboolean image_color_profile_get_use(ImageWindow *imd) |
1451 { | 1451 { |
1452 if (!imd) return FALSE; | 1452 if (!imd) return FALSE; |
1453 | 1453 |
1454 return imd->color_profile_enable; | 1454 return imd->color_profile_enable; |
1455 } | 1455 } |
1456 | 1456 |
1457 gint image_color_profile_get_from_image(ImageWindow *imd) | 1457 gint image_color_profile_get_from_image(ImageWindow *imd) |
1458 { | 1458 { |
1459 if (!imd) return FALSE; | 1459 if (!imd) return COLOR_PROFILE_NONE; |
1460 | 1460 |
1461 return imd->color_profile_from_image; | 1461 return imd->color_profile_from_image; |
1462 } | 1462 } |
1463 | 1463 |
1464 void image_set_delay_flip(ImageWindow *imd, gint delay) | 1464 void image_set_delay_flip(ImageWindow *imd, gboolean delay) |
1465 { | 1465 { |
1466 if (!imd || | 1466 if (!imd || |
1467 imd->delay_flip == delay) return; | 1467 imd->delay_flip == delay) return; |
1468 | 1468 |
1469 imd->delay_flip = delay; | 1469 imd->delay_flip = delay; |
1480 | 1480 |
1481 image_load_pixbuf_ready(imd); | 1481 image_load_pixbuf_ready(imd); |
1482 } | 1482 } |
1483 } | 1483 } |
1484 | 1484 |
1485 void image_to_root_window(ImageWindow *imd, gint scaled) | 1485 void image_to_root_window(ImageWindow *imd, gboolean scaled) |
1486 { | 1486 { |
1487 GdkScreen *screen; | 1487 GdkScreen *screen; |
1488 GdkWindow *rootwindow; | 1488 GdkWindow *rootwindow; |
1489 GdkPixmap *pixmap; | 1489 GdkPixmap *pixmap; |
1490 GdkPixbuf *pixbuf; | 1490 GdkPixbuf *pixbuf; |
1703 gtk_widget_show(imd->pr); | 1703 gtk_widget_show(imd->pr); |
1704 | 1704 |
1705 imd->has_frame = frame; | 1705 imd->has_frame = frame; |
1706 } | 1706 } |
1707 | 1707 |
1708 ImageWindow *image_new(gint frame) | 1708 ImageWindow *image_new(gboolean frame) |
1709 { | 1709 { |
1710 ImageWindow *imd; | 1710 ImageWindow *imd; |
1711 | 1711 |
1712 imd = g_new0(ImageWindow, 1); | 1712 imd = g_new0(ImageWindow, 1); |
1713 | 1713 |