# HG changeset patch # User zas_ # Date 1216126322 0 # Node ID ad420f2eb789e71282a976930fb9999d836b0a7c # Parent ff16ed0d2c8a10d552eca48407cfbdab8a34e487 Use a specific enum for image.zoom_mode values (ZoomMode) and simplify calls to image_zoom_get_default(), dropping last parameter which was always options->image.zoom_mode. diff -r ff16ed0d2c8a -r ad420f2eb789 src/image.c --- a/src/image.c Sun Jul 13 14:50:07 2008 +0000 +++ b/src/image.c Tue Jul 15 12:52:02 2008 +0000 @@ -1312,29 +1312,21 @@ return g_strdup_printf("%.*f :%s%.*f", pl, l, approx, pr, r); } -gdouble image_zoom_get_default(ImageWindow *imd, gint mode) +gdouble image_zoom_get_default(ImageWindow *imd) { - gdouble zoom; + gdouble zoom = 1.0; - if (mode == ZOOM_RESET_ORIGINAL) - { - zoom = 1.0; - } - else if (mode == ZOOM_RESET_FIT_WINDOW) - { + switch (options->image.zoom_mode) + { + case ZOOM_RESET_ORIGINAL: + break; + case ZOOM_RESET_FIT_WINDOW: zoom = 0.0; - } - else - { - if (imd) - { - zoom = image_zoom_get(imd); - } - else - { - zoom = 1.0; - } - } + break; + case ZOOM_RESET_NONE: + if (imd) zoom = image_zoom_get(imd); + break; + } return zoom; } diff -r ff16ed0d2c8a -r ad420f2eb789 src/image.h --- a/src/image.h Sun Jul 13 14:50:07 2008 +0000 +++ b/src/image.h Tue Jul 15 12:52:02 2008 +0000 @@ -83,7 +83,7 @@ gdouble image_zoom_get(ImageWindow *imd); gdouble image_zoom_get_real(ImageWindow *imd); gchar *image_zoom_get_as_text(ImageWindow *imd); -gdouble image_zoom_get_default(ImageWindow *imd, gint mode); +gdouble image_zoom_get_default(ImageWindow *imd); /* read ahead, pass NULL to cancel */ void image_prebuffer_set(ImageWindow *imd, FileData *fd); diff -r ff16ed0d2c8a -r ad420f2eb789 src/img-view.c --- a/src/img-view.c Sun Jul 13 14:50:07 2008 +0000 +++ b/src/img-view.c Tue Jul 15 12:52:02 2008 +0000 @@ -135,7 +135,7 @@ if (info) { - image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_from_collection(imd, cd, info, image_zoom_get_default(imd)); if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->fd); } @@ -166,7 +166,7 @@ if (info) { - image_change_from_collection(imd, cd, info, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_from_collection(imd, cd, info, image_zoom_get_default(imd)); if (read_ahead_info) image_prebuffer_set(imd, read_ahead_info->fd); } } @@ -226,7 +226,7 @@ vw->list_pointer = work; fd = work->data; - image_change_fd(imd, fd, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_fd(imd, fd, image_zoom_get_default(imd)); if (options->image.enable_read_ahead && work_ahead) { @@ -257,7 +257,7 @@ vw->list_pointer = work; fd = work->data; - image_change_fd(imd, fd, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_fd(imd, fd, image_zoom_get_default(imd)); if (options->image.enable_read_ahead && work_ahead) { @@ -872,7 +872,7 @@ G_CALLBACK(view_window_key_press_cb), vw); if (cd && info) { - image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL, options->image.zoom_mode)); + image_change_from_collection(vw->imd, cd, info, image_zoom_get_default(NULL)); if (options->image.enable_read_ahead) { CollectInfo * r_info = collection_next_by_info(cd, info); @@ -884,7 +884,7 @@ { view_window_set_list(vw, list); vw->list_pointer = vw->list; - image_change_fd(vw->imd, (FileData *)vw->list->data, image_zoom_get_default(NULL, options->image.zoom_mode)); + image_change_fd(vw->imd, (FileData *)vw->list->data, image_zoom_get_default(NULL)); if (options->image.enable_read_ahead) { @@ -894,7 +894,7 @@ } else { - image_change_fd(vw->imd, fd, image_zoom_get_default(NULL, options->image.zoom_mode)); + image_change_fd(vw->imd, fd, image_zoom_get_default(NULL)); } if (image_zoom_get(vw->imd) == 0.0) @@ -1386,7 +1386,7 @@ vw->list_pointer = vw->list; fd = vw->list->data; - image_change_fd(vw->imd, fd, image_zoom_get_default(vw->imd, options->image.zoom_mode)); + image_change_fd(vw->imd, fd, image_zoom_get_default(vw->imd)); work = vw->list->next; if (options->image.enable_read_ahead && work) @@ -1397,7 +1397,7 @@ } else { - image_change_fd(vw->imd, NULL, image_zoom_get_default(vw->imd, options->image.zoom_mode)); + image_change_fd(vw->imd, NULL, image_zoom_get_default(vw->imd)); } } @@ -1516,7 +1516,7 @@ if (source && info_list) { - image_change_from_collection(imd, source, info_list->data, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_from_collection(imd, source, info_list->data, image_zoom_get_default(imd)); } else { @@ -1527,7 +1527,7 @@ vw->list_pointer = vw->list; } - image_change_fd(imd, fd, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_fd(imd, fd, image_zoom_get_default(imd)); } } } @@ -1633,7 +1633,7 @@ } if (image_get_fd(imd) == image_fd) { - image_change_fd(imd, NULL, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_fd(imd, NULL, image_zoom_get_default(imd)); } } @@ -1679,7 +1679,7 @@ fd = NULL; } - image_change_fd(imd, fd, image_zoom_get_default(imd, options->image.zoom_mode)); + image_change_fd(imd, fd, image_zoom_get_default(imd)); } } diff -r ff16ed0d2c8a -r ad420f2eb789 src/layout_image.c --- a/src/layout_image.c Sun Jul 13 14:50:07 2008 +0000 +++ b/src/layout_image.c Tue Jul 15 12:52:02 2008 +0000 @@ -1181,7 +1181,7 @@ image_get_scroll_center(lw->image, &sx, &sy); - image_change_fd(lw->image, fd, image_zoom_get_default(lw->image, options->image.zoom_mode)); + image_change_fd(lw->image, fd, image_zoom_get_default(lw->image)); image_set_scroll_center(lw->image, sx, sy); @@ -1273,7 +1273,7 @@ { if (!layout_valid(&lw)) return; - image_change_from_collection(lw->image, cd, info, image_zoom_get_default(lw->image, options->image.zoom_mode)); + image_change_from_collection(lw->image, cd, info, image_zoom_get_default(lw->image)); if (options->image.enable_read_ahead) { CollectInfo *r_info; diff -r ff16ed0d2c8a -r ad420f2eb789 src/main.h --- a/src/main.h Sun Jul 13 14:50:07 2008 +0000 +++ b/src/main.h Tue Jul 15 12:52:02 2008 +0000 @@ -82,10 +82,6 @@ #define GQ_COLLECTION_EXT ".gqv" -#define ZOOM_RESET_ORIGINAL 0 -#define ZOOM_RESET_FIT_WINDOW 1 -#define ZOOM_RESET_NONE 2 - #define SCROLL_RESET_TOPLEFT 0 #define SCROLL_RESET_CENTER 1 #define SCROLL_RESET_NOCHANGE 2 diff -r ff16ed0d2c8a -r ad420f2eb789 src/options.h --- a/src/options.h Sun Jul 13 14:50:07 2008 +0000 +++ b/src/options.h Tue Jul 15 12:52:02 2008 +0000 @@ -71,7 +71,7 @@ guint dither_quality; gboolean enable_read_ahead; - gint zoom_mode; + ZoomMode zoom_mode; gboolean zoom_2pass; gboolean zoom_to_fit_allow_expand; guint zoom_quality; diff -r ff16ed0d2c8a -r ad420f2eb789 src/rcfile.c --- a/src/rcfile.c Sun Jul 13 14:50:07 2008 +0000 +++ b/src/rcfile.c Tue Jul 15 12:52:02 2008 +0000 @@ -442,12 +442,12 @@ "# fit\n" "# dont_change\n"); secure_fprintf(ssi, "image.zoom_mode: "); - if (options->image.zoom_mode == ZOOM_RESET_ORIGINAL) - secure_fprintf(ssi, "original\n"); - else if (options->image.zoom_mode == ZOOM_RESET_FIT_WINDOW) - secure_fprintf(ssi, "fit\n"); - else if (options->image.zoom_mode == ZOOM_RESET_NONE) - secure_fprintf(ssi, "dont_change\n"); + switch (options->image.zoom_mode) + { + case ZOOM_RESET_ORIGINAL: secure_fprintf(ssi, "original\n"); break; + case ZOOM_RESET_FIT_WINDOW: secure_fprintf(ssi, "fit\n"); break; + case ZOOM_RESET_NONE: secure_fprintf(ssi, "dont_change\n"); break; + } WRITE_SEPARATOR(); WRITE_BOOL(image.zoom_2pass); WRITE_BOOL(image.zoom_to_fit_allow_expand); diff -r ff16ed0d2c8a -r ad420f2eb789 src/slideshow.c --- a/src/slideshow.c Sun Jul 13 14:50:07 2008 +0000 +++ b/src/slideshow.c Tue Jul 15 12:52:02 2008 +0000 @@ -183,7 +183,7 @@ if (ss->filelist) { ss->slide_fd = file_data_ref((FileData *)g_list_nth_data(ss->filelist, row)); - image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd, options->image.zoom_mode)); + image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); } else if (ss->cd) { @@ -192,7 +192,7 @@ info = g_list_nth_data(ss->cd->list, row); ss->slide_fd = file_data_ref(info->fd); - image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd, options->image.zoom_mode)); + image_change_from_collection(ss->imd, ss->cd, info, image_zoom_get_default(ss->imd)); } else { @@ -200,7 +200,7 @@ if (ss->from_selection) { - image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd, options->image.zoom_mode)); + image_change_fd(ss->imd, ss->slide_fd, image_zoom_get_default(ss->imd)); layout_status_update_info(ss->layout, NULL); } else diff -r ff16ed0d2c8a -r ad420f2eb789 src/typedefs.h --- a/src/typedefs.h Sun Jul 13 14:50:07 2008 +0000 +++ b/src/typedefs.h Tue Jul 15 12:52:02 2008 +0000 @@ -15,6 +15,12 @@ #define TYPEDEFS_H typedef enum { + ZOOM_RESET_ORIGINAL = 0, + ZOOM_RESET_FIT_WINDOW = 1, + ZOOM_RESET_NONE = 2 +} ZoomMode; + +typedef enum { MOUSE_BUTTON_LEFT = 1, MOUSE_BUTTON_MIDDLE = 2, MOUSE_BUTTON_RIGHT = 3,