*** xfdesktop-4.6.2/settings/main.c Fri May 21 13:01:34 2010 --- xfdesktop-4.6.2-mine/settings/main.c Fri Jul 2 15:30:33 2010 *************** *** 128,152 **** N_ICON_COLS, }; /* assumes gdk lock is held on function enter, and should be held * on function exit */ static void xfdesktop_settings_do_single_preview(GtkTreeModel *model, GtkTreeIter *iter) { ! gchar *name = NULL, *new_name = NULL, *filename = NULL; GdkPixbuf *pix, *pix_scaled = NULL; gtk_tree_model_get(model, iter, COL_NAME, &name, COL_FILENAME, &filename, -1); - gdk_threads_leave(); pix = gdk_pixbuf_new_from_file(filename, NULL); g_free(filename); if(pix) { gint width, height; gdouble aspect; --- 128,174 ---- N_ICON_COLS, }; + static char *replace_str(char *str, char *orig, char *rep) + { + static char buffer[4096]; + char *p; + + if(!(p = strstr(str, orig))) // Is 'orig' even in 'str'? + return str; + + strncpy(buffer, str, p-str); // Copy characters from 'str' start to 'orig' st$ + buffer[p-str] = '\0'; + sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig)); + + return buffer; + } /* assumes gdk lock is held on function enter, and should be held * on function exit */ static void xfdesktop_settings_do_single_preview(GtkTreeModel *model, GtkTreeIter *iter) { ! gchar *name = NULL, *new_name = NULL, *filename = NULL, *cachefile = NULL; GdkPixbuf *pix, *pix_scaled = NULL; gtk_tree_model_get(model, iter, COL_NAME, &name, COL_FILENAME, &filename, -1); gdk_threads_leave(); + cachefile = replace_str(name,"",""); + cachefile = replace_str(cachefile,"",""); + cachefile = g_strdup_printf(_("%sthumb-%s"),xfce_resource_lookup(XFCE_RESOURCE_CACHE, "xfce4/"),cachefile); + + if(_access( cachefile, F_OK ) != -1 ) { + g_free(filename); + pix_scaled = gdk_pixbuf_new_from_file(cachefile,NULL); + } else { pix = gdk_pixbuf_new_from_file(filename, NULL); g_free(filename); + if(pix) { gint width, height; gdouble aspect; *************** *** 163,171 **** --- 185,199 ---- pix_scaled = gdk_pixbuf_scale_simple(pix, width, height, GDK_INTERP_BILINEAR); + /* save thumb on hd */ + gdk_pixbuf_save(pix_scaled, cachefile, "jpeg", NULL, "quality", "75", NULL); + g_object_unref(G_OBJECT(pix)); } + } + g_free(name); + g_free(cachefile); gdk_threads_enter();