From: John Ellis Date: Thu, 3 Mar 2005 06:32:53 +0000 (+0000) Subject: ##### Note: GQview CVS on sourceforge is not always up to date, please use ##### X-Git-Tag: v1.0.0~1789 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=4eac0c134508c7639cc85f951464b229c2bf727a ##### Note: GQview CVS on sourceforge is not always up to date, please use ##### ##### an offical release when making enhancements and translation updates. ##### Thu Mar 3 01:16:23 2005 John Ellis * pan-view.c: Add 'dots' image size option, fix up border size at edge of grid, and make drag and drop work to/from the window. Wed Mar 2 23:34:30 2005 John Ellis * globals.c, gqview.h, rcfile.c: Add thumbnail_fast option variable. * image-load.c, typedefs.h: Add shrunk flag to determine if an image was scaled down using image_loader_set_requested_size. * image.c: Make panning with mouse scroll more when holding shift key. * preferences.c: Add option for 'Fast jpeg thumbnailing' and disabled xvpics option in the gui - now a hidden option. * thumb.c, thumb_standard.c: Add support for thumbnail_fast option.. --- diff --git a/ChangeLog b/ChangeLog index 51140b47..3e12c69d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Thu Mar 3 01:16:23 2005 John Ellis + + * pan-view.c: Add 'dots' image size option, fix up border size at edge + of grid, and make drag and drop work to/from the window. + +Wed Mar 2 23:34:30 2005 John Ellis + + * globals.c, gqview.h, rcfile.c: Add thumbnail_fast option variable. + * image-load.c, typedefs.h: Add shrunk flag to determine if an image + was scaled down using image_loader_set_requested_size. + * image.c: Make panning with mouse scroll more when holding shift key. + * preferences.c: Add option for 'Fast jpeg thumbnailing' and disabled + xvpics option in the gui - now a hidden option. + * thumb.c, thumb_standard.c: Add support for thumbnail_fast option.. + Tue Mar 1 21:39:42 2005 John Ellis * image.[ch] (image_scroll_to_point): Add alignment for location of diff --git a/TODO b/TODO index 705612be..dbb50905 100644 --- a/TODO +++ b/TODO @@ -12,18 +12,18 @@ Major: > Fix slowness in image.c with huge grid size by changing use of pre-allocated tile array to on-demand tile allocation (can this be implemented like source tiles?). OR: use an array so that we do not need to walk a GList of pre-allocated tile containers - > Fix search scrolling to try to center image and info popup. + w> Fix search scrolling to try to center image and info popup. > Fix info popup location to opposing horizontal side when near edge of grid. > Find something to do with middle mouse clicks. - > Set drag and drop data to clicked image. - > Should the copy/move/rename/delete operations be available here? + d> Set drag and drop data to clicked image. + d> Should the copy/move/rename/delete operations be available here? > ^ and if so, should delete key actually work? > searching for same item more than once should step through all matches > search should highlight all matching images > should non-thumbnail images have a drop shadow? > time line view: - > searching by date should scroll to proper alignment with year/month/day boundaries. + d> searching by date should scroll to proper alignment with year/month/day boundaries. > grid view: > allow sorting by name, date, size, dimensions, etc. @@ -34,12 +34,16 @@ Major: > the info dialog is not set as a transient of the calling window, this causes it to be behind a full screen window when 'stay above other windows' is enabled. + > use doubles instead of floats wherever possible + ------------- > update translations: ( ) ( ) ( ) > document recent additions/changes: - (none currently) + > Added 'Fast jpeg thumbnailing'. + > xvpics is now hidden option. + > Holding down shift will now scroll more when panning with mouse. Minor (non blockers): diff --git a/src/globals.c b/src/globals.c index 46e6239d..caa40b9a 100644 --- a/src/globals.c +++ b/src/globals.c @@ -57,6 +57,7 @@ gint thumb_max_height = 72; gint enable_thumb_caching = TRUE; gint enable_thumb_dirs = FALSE; gint use_xvpics_thumbnails = TRUE; +gint thumbnail_fast = TRUE; gint thumbnail_spec_standard = TRUE; gint enable_metadata_dirs = FALSE; gint show_dot_files = FALSE; diff --git a/src/gqview.h b/src/gqview.h index bde3eedf..1d0e383e 100644 --- a/src/gqview.h +++ b/src/gqview.h @@ -133,6 +133,7 @@ extern gint thumb_max_width; extern gint thumb_max_height; extern gint enable_thumb_caching; extern gint enable_thumb_dirs; +extern gint thumbnail_fast; extern gint use_xvpics_thumbnails; extern gint thumbnail_spec_standard; extern gint enable_metadata_dirs; diff --git a/src/image-load.c b/src/image-load.c index 094ded46..fb8066bd 100644 --- a/src/image-load.c +++ b/src/image-load.c @@ -102,6 +102,7 @@ static void image_loader_size_cb(GdkPixbufLoader *loader, } gdk_pixbuf_loader_set_size(loader, nw, nh); + il->shrunk = TRUE; } } @@ -306,6 +307,8 @@ static gint image_loader_setup(ImageLoader *il) g_signal_connect(G_OBJECT(il->loader), "size_prepared", G_CALLBACK(image_loader_size_cb), il); + il->shrunk = FALSE; + return image_loader_begin(il); } @@ -333,6 +336,7 @@ ImageLoader *image_loader_new(const gchar *path) il->requested_width = 0; il->requested_height = 0; + il->shrunk = FALSE; return il; } diff --git a/src/image.c b/src/image.c index aad6af7a..3b27e48a 100644 --- a/src/image.c +++ b/src/image.c @@ -23,7 +23,10 @@ #include +/* size to use when breaking up image pane for rendering */ #define IMAGE_TILE_SIZE 512 + +/* default min and max zoom */ #define IMAGE_ZOOM_MIN -32.0 #define IMAGE_ZOOM_MAX 32.0 @@ -42,6 +45,9 @@ /* distance to drag mouse to disable image flip */ #define IMAGE_DRAG_SCROLL_THRESHHOLD 4 +/* increase pan rate when holding down shift */ +#define IMAGE_PAN_SHIFT_MULTIPLIER 6 + /* alpha channel checkerboard background (same as gimp) */ #define IMAGE_ALPHA_CHECK1 0x00999999 #define IMAGE_ALPHA_CHECK2 0x00666666 @@ -3001,6 +3007,7 @@ static void image_scroller_stop(ImageWindow *imd) static gint image_mouse_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { ImageWindow *imd = data; + gint accel; if (imd->scroller_id != -1) { @@ -3019,8 +3026,18 @@ static gint image_mouse_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpo widget_set_cursor (imd->image, GDK_FLEUR); } + if (bevent->state & GDK_SHIFT_MASK) + { + accel = IMAGE_PAN_SHIFT_MULTIPLIER; + } + else + { + accel = 1; + } + /* do the scroll */ - image_scroll_real(imd, imd->drag_last_x - bevent->x, imd->drag_last_y - bevent->y); + image_scroll_real(imd, (imd->drag_last_x - bevent->x) * accel, + (imd->drag_last_y - bevent->y) * accel); imd->drag_last_x = bevent->x; imd->drag_last_y = bevent->y; @@ -3078,13 +3095,16 @@ static gint image_mouse_release_cb(GtkWidget *widget, GdkEventButton *bevent, gp widget_set_cursor(imd->image, -1); } - if (bevent->button == 1 && (bevent->state & GDK_SHIFT_MASK)) - { - image_scroller_start(imd, bevent->x, bevent->y); - } - else if (bevent->button == 1 || bevent->button == 2) + if (imd->drag_moved < IMAGE_DRAG_SCROLL_THRESHHOLD) { - if (imd->drag_moved < IMAGE_DRAG_SCROLL_THRESHHOLD) image_button_do(imd, bevent); + if (bevent->button == 1 && (bevent->state & GDK_SHIFT_MASK)) + { + image_scroller_start(imd, bevent->x, bevent->y); + } + else if (bevent->button == 1 || bevent->button == 2) + { + image_button_do(imd, bevent); + } } imd->in_drag = FALSE; diff --git a/src/pan-view.c b/src/pan-view.c index aae7dee7..df036006 100644 --- a/src/pan-view.c +++ b/src/pan-view.c @@ -41,12 +41,14 @@ #define PAN_TILE_SIZE 512 +#define PAN_THUMB_SIZE_DOTS 4 #define PAN_THUMB_SIZE_NONE 24 #define PAN_THUMB_SIZE_SMALL 64 #define PAN_THUMB_SIZE_NORMAL 128 #define PAN_THUMB_SIZE_LARGE 256 #define PAN_THUMB_SIZE pw->thumb_size +#define PAN_THUMB_GAP_DOTS 2 #define PAN_THUMB_GAP_SMALL 14 #define PAN_THUMB_GAP_NORMAL 30 #define PAN_THUMB_GAP_LARGE 40 @@ -100,7 +102,8 @@ typedef enum { } LayoutType; typedef enum { - LAYOUT_SIZE_THUMB_NONE = 0, + LAYOUT_SIZE_THUMB_DOTS = 0, + LAYOUT_SIZE_THUMB_NONE, LAYOUT_SIZE_THUMB_SMALL, LAYOUT_SIZE_THUMB_NORMAL, LAYOUT_SIZE_THUMB_LARGE, @@ -1085,6 +1088,14 @@ static void pan_item_size_by_item(PanItem *pi, PanItem *child, gint border) pi->height = child->y + child->height + border - pi->y; } +static void pan_item_size_coordinates(PanItem *pi, gint border, gint *w, gint *h) +{ + if (!pi) return; + + if (*w < pi->x + pi->width + border) *w = pi->x + pi->width + border; + if (*h < pi->y + pi->height + border) *h = pi->y + pi->height + border; +} + static void pan_item_image_find_size(PanWindow *pw, PanItem *pi, gint w, gint h) { GList *work; @@ -1292,7 +1303,6 @@ static void pan_window_layout_compute_grid(PanWindow *pw, const gchar *path, gin GList *list; GList *work; gint x, y; - gint w, h; gint grid_size; gint next_y; @@ -1310,8 +1320,8 @@ static void pan_window_layout_compute_grid(PanWindow *pw, const gchar *path, gin next_y = 0; - w = PAN_THUMB_GAP * 2; - h = PAN_THUMB_GAP * 2; + *width = PAN_FOLDER_BOX_BORDER * 2; + *height = PAN_FOLDER_BOX_BORDER * 2; x = PAN_THUMB_GAP; y = PAN_THUMB_GAP; @@ -1347,14 +1357,9 @@ static void pan_window_layout_compute_grid(PanWindow *pw, const gchar *path, gin y += PAN_THUMB_SIZE + PAN_THUMB_GAP; } } - - if (w < pi->x + pi->width + PAN_THUMB_GAP) w = pi->x + pi->width + PAN_THUMB_GAP; - if (h < pi->y + pi->height + PAN_THUMB_GAP) h = pi->y + pi->height + PAN_THUMB_GAP; + pan_item_size_coordinates(pi, PAN_THUMB_GAP, width, height); } - if (width) *width = w; - if (height) *height = h; - g_list_free(list); } @@ -1696,7 +1701,7 @@ static void pan_window_layout_compute_folders_linear_path(PanWindow *pw, const g f = filelist_sort(f, SORT_NAME, TRUE); d = filelist_sort(d, SORT_NAME, TRUE); - *x = PAN_THUMB_GAP + ((*level) * (PAN_THUMB_GAP * 2)); + *x = PAN_FOLDER_BOX_BORDER + ((*level) * MAX(PAN_FOLDER_BOX_BORDER, PAN_THUMB_GAP)); pi_box = pan_item_new_text(pw, *x, *y, path, TEXT_ATTR_NONE, PAN_TEXT_COLOR, 255); @@ -1763,10 +1768,7 @@ static void pan_window_layout_compute_folders_linear_path(PanWindow *pw, const g if (*y < pi_box->y + pi_box->height + PAN_FOLDER_BOX_BORDER) *y = pi_box->y + pi_box->height + PAN_FOLDER_BOX_BORDER; - if (*width < pi_box->x + pi_box->width + PAN_FOLDER_BOX_BORDER) - *width = pi_box->x + pi_box->width + PAN_FOLDER_BOX_BORDER; - if (*height < pi_box->y + pi_box->height + PAN_FOLDER_BOX_BORDER) - *height = pi_box->y + pi_box->height + PAN_FOLDER_BOX_BORDER; + pan_item_size_coordinates(pi_box, PAN_FOLDER_BOX_BORDER, width, height); } static void pan_window_layout_compute_folders_linear(PanWindow *pw, const gchar *path, gint *width, gint *height) @@ -1792,7 +1794,6 @@ static void pan_window_layout_compute_timeline(PanWindow *pw, const gchar *path, GList *list; GList *work; gint x, y; - gint w, h; time_t tc; gint total; gint count; @@ -1808,8 +1809,8 @@ static void pan_window_layout_compute_timeline(PanWindow *pw, const gchar *path, list = pan_window_layout_list(path, SORT_NONE, TRUE); list = filelist_sort(list, SORT_TIME, TRUE); - w = PAN_FOLDER_BOX_BORDER * 2; - h = PAN_FOLDER_BOX_BORDER * 2; + *width = PAN_FOLDER_BOX_BORDER * 2; + *height = PAN_FOLDER_BOX_BORDER * 2; x = 0; y = 0; @@ -1921,23 +1922,6 @@ static void pan_window_layout_compute_timeline(PanWindow *pw, const gchar *path, pan_item_size_by_item(pi_day, pi, PAN_FOLDER_BOX_BORDER); pan_item_size_by_item(pi_month, pi_day, PAN_FOLDER_BOX_BORDER); -#if 0 - if (pi_day) - { - if (pi->x + pi->width + PAN_FOLDER_BOX_BORDER > pi_day->x + pi_day->width) - pi_day->width = pi->x + pi->width + PAN_FOLDER_BOX_BORDER - pi_day->x; - if (pi->y + pi->height + PAN_FOLDER_BOX_BORDER > pi_day->y + pi_day->height) - pi_day->height = pi->y + pi->height + PAN_FOLDER_BOX_BORDER - pi_day->y; - } - - if (pi_month && pi_day) - { - if (pi_day->x + pi_day->width + PAN_FOLDER_BOX_BORDER > pi_month->x + pi_month->width) - pi_month->width = pi_day->x + pi_day->width + PAN_FOLDER_BOX_BORDER - pi_month->x; - if (pi_day->y + pi_day->height + PAN_FOLDER_BOX_BORDER > pi_month->y + pi_month->height) - pi_month->height = pi_day->y + pi_day->height + PAN_FOLDER_BOX_BORDER - pi_month->y; - } -#endif total--; count++; @@ -1958,16 +1942,9 @@ static void pan_window_layout_compute_timeline(PanWindow *pw, const gchar *path, y = month_start; } - if (w < pi->x + pi->width + PAN_THUMB_GAP) w = pi->x + pi->width + PAN_THUMB_GAP; - if (h < pi->y + pi->height + PAN_THUMB_GAP) h = pi->y + pi->height + PAN_THUMB_GAP; + pan_item_size_coordinates(pi_month, PAN_FOLDER_BOX_BORDER, width, height); } - w += PAN_FOLDER_BOX_BORDER; - h += PAN_FOLDER_BOX_BORDER; - - if (width) *width = w; - if (height) *height = h; - g_list_free(list); } @@ -1979,6 +1956,10 @@ static void pan_window_layout_compute(PanWindow *pw, const gchar *path, switch (pw->size) { + case LAYOUT_SIZE_THUMB_DOTS: + pw->thumb_size = PAN_THUMB_SIZE_DOTS; + pw->thumb_gap = PAN_THUMB_GAP_DOTS; + break; case LAYOUT_SIZE_THUMB_NONE: pw->thumb_size = PAN_THUMB_SIZE_NONE; pw->thumb_gap = PAN_THUMB_GAP_SMALL; @@ -2240,7 +2221,7 @@ static gint pan_layout_queue_step(PanWindow *pw) static void pan_layout_queue(PanWindow *pw, PanItem *pi) { if (!pi || pi->queued || pi->pixbuf) return; - if (pw->size == LAYOUT_SIZE_THUMB_NONE) return; + if (pw->size <= LAYOUT_SIZE_THUMB_NONE) return; pi->queued = TRUE; pw->queue = g_list_prepend(pw->queue, pi); @@ -2405,7 +2386,7 @@ static gint pan_window_request_tile_cb(ImageWindow *imd, gint x, gint y, gint wi { gint d; - d = (pw->size == LAYOUT_SIZE_THUMB_NONE) ? 2 : 8; + d = (pw->size <= LAYOUT_SIZE_THUMB_NONE) ? 2 : 8; pixbuf_draw_rect_fill(pixbuf, rx - x, ry - y, rw, rh, PAN_SHADOW_COLOR, @@ -2708,6 +2689,7 @@ static void pan_window_zoom_limit(PanWindow *pw) switch (pw->size) { + case LAYOUT_SIZE_THUMB_DOTS: case LAYOUT_SIZE_THUMB_NONE: case LAYOUT_SIZE_THUMB_SMALL: case LAYOUT_SIZE_THUMB_NORMAL: @@ -3762,6 +3744,7 @@ void pan_window_new(const gchar *path) gtk_widget_show(combo); combo = gtk_combo_box_new_text(); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Dots")); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("No Images")); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Small Thumbnails")); gtk_combo_box_append_text(GTK_COMBO_BOX(combo), _("Normal Thumbnails")); @@ -3850,7 +3833,7 @@ void pan_window_new(const gchar *path) gtk_container_add(GTK_CONTAINER(frame), hbox); gtk_widget_show(hbox); - pref_spacer(hbox, PREF_PAD_SPACE); + pref_spacer(hbox, 0); pw->label_message = pref_label_new(hbox, ""); frame = gtk_frame_new(NULL); @@ -4078,9 +4061,9 @@ static GtkWidget *pan_popup_menu(PanWindow *pw) */ static void pan_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, guint info, - guint time, gpointer data) + gint x, gint y, + GtkSelectionData *selection_data, guint info, + guint time, gpointer data) { PanWindow *pw = data; ImageWindow *imd; @@ -4096,7 +4079,12 @@ static void pan_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, list = uri_list_from_text(selection_data->data, TRUE); if (list && isdir((gchar *)list->data)) { - printf("FIXME: change to this folder: %s\n", (gchar *)list->data); + gchar *path = list->data; + + g_free(pw->path); + pw->path = g_strdup(path); + + pan_window_layout_update_idle(pw); } path_list_free(list); @@ -4104,10 +4092,45 @@ static void pan_window_get_dnd_data(GtkWidget *widget, GdkDragContext *context, } static void pan_window_set_dnd_data(GtkWidget *widget, GdkDragContext *context, - GtkSelectionData *selection_data, guint info, - guint time, gpointer data) + GtkSelectionData *selection_data, guint info, + guint time, gpointer data) { - printf("FIXME: set dnd data\n"); + PanWindow *pw = data; + const gchar *path; + + path = pan_menu_click_path(pw); + if (path) + { + gchar *text = NULL; + gint len; + gint plain_text; + GList *list; + + switch (info) + { + case TARGET_URI_LIST: + plain_text = FALSE; + break; + case TARGET_TEXT_PLAIN: + default: + plain_text = TRUE; + break; + } + list = g_list_append(NULL, (gchar *)path); + text = uri_text_from_list(list, &len, plain_text); + g_list_free(list); + if (text) + { + gtk_selection_data_set (selection_data, selection_data->target, + 8, text, len); + g_free(text); + } + } + else + { + gtk_selection_data_set (selection_data, selection_data->target, + 8, NULL, 0); + } } static void pan_window_dnd_init(PanWindow *pw) diff --git a/src/preferences.c b/src/preferences.c index 8b1c083e..8a78eb71 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -87,7 +87,10 @@ static gint thumb_max_width_c; static gint thumb_max_height_c; static gint enable_thumb_caching_c; static gint enable_thumb_dirs_c; +static gint thumbnail_fast_c; +#if 0 static gint use_xvpics_thumbnails_c; +#endif static gint thumbnail_spec_standard_c; static gint enable_metadata_dirs_c; static gint show_dot_files_c; @@ -237,7 +240,10 @@ static void config_window_apply(void) thumb_max_height = thumb_max_height_c; enable_thumb_caching = enable_thumb_caching_c; enable_thumb_dirs = enable_thumb_dirs_c; + thumbnail_fast = thumbnail_fast_c; +#if 0 use_xvpics_thumbnails = use_xvpics_thumbnails_c; +#endif thumbnail_spec_standard = thumbnail_spec_standard_c; enable_metadata_dirs = enable_metadata_dirs_c; show_dot_files = show_dot_files_c; @@ -855,11 +861,16 @@ static void config_window_create(void) subgroup = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP); pref_checkbox_link_sensitivity_swap(button, subgroup); - button = pref_checkbox_new_int(subgroup, _("Cache thumbnails into .thumbnails"), - enable_thumb_dirs, &enable_thumb_dirs_c); + pref_checkbox_new_int(subgroup, _("Cache thumbnails into .thumbnails"), + enable_thumb_dirs, &enable_thumb_dirs_c); + +#if 0 + pref_checkbox_new_int(subgroup, _("Use xvpics thumbnails when found (read only)"), + use_xvpics_thumbnails, &use_xvpics_thumbnails_c); +#endif - button = pref_checkbox_new_int(subgroup, _("Use xvpics thumbnails when found (read only)"), - use_xvpics_thumbnails, &use_xvpics_thumbnails_c); + pref_checkbox_new_int(group, _("Faster jpeg thumbnailing (may reduce quality)"), + thumbnail_fast, &thumbnail_fast_c); group = pref_group_new(vbox, FALSE, _("Slide show"), GTK_ORIENTATION_VERTICAL); diff --git a/src/rcfile.c b/src/rcfile.c index 59ad96c1..83ea210b 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -238,6 +238,7 @@ void save_options(void) write_int_option(f, "thumbnail_height", thumb_max_height); write_bool_option(f, "cache_thumbnails", enable_thumb_caching); write_bool_option(f, "cache_thumbnails_into_dirs", enable_thumb_dirs); + write_bool_option(f, "thumbnail_fast", thumbnail_fast); write_bool_option(f, "use_xvpics_thumbnails", use_xvpics_thumbnails); write_bool_option(f, "thumbnail_spec_standard", thumbnail_spec_standard); fprintf(f,"\n"); @@ -450,6 +451,8 @@ void load_options(void) "cache_thumbnails", value, enable_thumb_caching); enable_thumb_dirs = read_bool_option(f, option, "cache_thumbnails_into_dirs", value, enable_thumb_dirs); + thumbnail_fast = read_bool_option(f, option, + "thumbnail_fast", value, thumbnail_fast); use_xvpics_thumbnails = read_bool_option(f, option, "use_xvpics_thumbnails", value, use_xvpics_thumbnails); thumbnail_spec_standard = read_bool_option(f, option, diff --git a/src/thumb.c b/src/thumb.c index 489ff2cd..0556d147 100644 --- a/src/thumb.c +++ b/src/thumb.c @@ -182,16 +182,16 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data) { gint w, h; - if (((float)tl->max_w / pw) < ((float)tl->max_h / ph)) + if (((double)tl->max_w / pw) < ((double)tl->max_h / ph)) { w = tl->max_w; - h = (float)w / pw * ph; + h = (double)w / pw * ph; if (h < 1) h = 1; } else { h = tl->max_h; - w = (float)h / ph * pw; + w = (double)h / ph * pw; if (w < 1) w = 1; } @@ -202,7 +202,7 @@ static void thumb_loader_done_cb(ImageLoader *il, gpointer data) { tl->pixbuf = pixbuf; gdk_pixbuf_ref(tl->pixbuf); - save = FALSE; + save = il->shrunk; } /* save it ? */ @@ -254,10 +254,11 @@ static void thumb_loader_setup(ThumbLoader *tl, gchar *path) image_loader_free(tl->il); tl->il = image_loader_new(path); -#if 0 - /* this will speed up jpegs by up to 3x in some cases */ - image_loader_set_requested_size(tl->max_w, tl->max_h); -#endif + if (thumbnail_fast) + { + /* this will speed up jpegs by up to 3x in some cases */ + image_loader_set_requested_size(tl->il, tl->max_w, tl->max_h); + } image_loader_set_error_func(tl->il, thumb_loader_error_cb, tl); if (tl->func_progress) image_loader_set_percent_func(tl->il, thumb_loader_percent_cb, tl); diff --git a/src/thumb_standard.c b/src/thumb_standard.c index edf021ef..3b1ee6a2 100644 --- a/src/thumb_standard.c +++ b/src/thumb_standard.c @@ -442,7 +442,7 @@ static gint thumb_loader_std_scale_aspect(gint req_w, gint req_h, gint old_w, gi return (*new_w != old_w || *new_h != old_h); } -static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf) +static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf, gint shrunk) { GdkPixbuf *pixbuf_thumb = NULL; GdkPixbuf *result; @@ -452,7 +452,7 @@ static GdkPixbuf *thumb_loader_std_finish(ThumbLoaderStd *tl, GdkPixbuf *pixbuf) sh = gdk_pixbuf_get_height(pixbuf); if (tl->cache_enable && !tl->cache_hit && - (sw >= THUMB_SIZE_NORMAL || sh >= THUMB_SIZE_NORMAL)) + (sw >= THUMB_SIZE_NORMAL || sh >= THUMB_SIZE_NORMAL || shrunk)) { gint cache_w, cache_h; gint thumb_w, thumb_h; @@ -595,7 +595,7 @@ static void thumb_loader_std_done_cb(ImageLoader *il, gpointer data) tl->cache_hit = (tl->thumb_path != NULL); - tl->pixbuf = thumb_loader_std_finish(tl, pixbuf); + tl->pixbuf = thumb_loader_std_finish(tl, pixbuf, il->shrunk); if (tl->func_done) tl->func_done(tl, tl->data); } @@ -635,18 +635,19 @@ static gint thumb_loader_std_setup(ThumbLoaderStd *tl, const gchar *path) { tl->il = image_loader_new(path); -#if 0 - /* this will speed up jpegs by up to 3x in some cases */ - if (tl->requested_width <= THUMB_SIZE_NORMAL && - tl->requested_height <= THUMB_SIZE_NORMAL) + if (thumbnail_fast) { - image_loader_set_requested_size(tl->il, THUMB_SIZE_NORMAL, THUMB_SIZE_NORMAL); - } - else - { - image_loader_set_requested_size(tl->il, THUMB_SIZE_LARGE, THUMB_SIZE_LARGE); + /* this will speed up jpegs by up to 3x in some cases */ + if (tl->requested_width <= THUMB_SIZE_NORMAL && + tl->requested_height <= THUMB_SIZE_NORMAL) + { + image_loader_set_requested_size(tl->il, THUMB_SIZE_NORMAL, THUMB_SIZE_NORMAL); + } + else + { + image_loader_set_requested_size(tl->il, THUMB_SIZE_LARGE, THUMB_SIZE_LARGE); + } } -#endif image_loader_set_error_func(tl->il, thumb_loader_std_error_cb, tl); if (tl->func_progress) diff --git a/src/typedefs.h b/src/typedefs.h index d1ae8d83..5e05533a 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -77,6 +77,7 @@ struct _ImageLoader gint requested_width; gint requested_height; + gint shrunk; gint done; gint idle_id;