-
Notifications
You must be signed in to change notification settings - Fork 0
/
xfdesktop-4.10.0-cache.patch
110 lines (100 loc) · 3.49 KB
/
xfdesktop-4.10.0-cache.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
diff -crB xfdesktop-4.10.0/common/xfdesktop-common.c xfdesktop-4.10.0-cache/common/xfdesktop-common.c
*** xfdesktop-4.10.0/common/xfdesktop-common.c 2012-04-28 16:53:05.000000000 -0400
--- xfdesktop-4.10.0-cache/common/xfdesktop-common.c 2012-05-11 11:50:36.000000000 -0400
***************
*** 51,56 ****
--- 51,57 ----
#include <libxfce4util/libxfce4util.h>
#include "xfdesktop-common.h"
+ #include <sys/stat.h>
#ifndef O_BINARY
#define O_BINARY 0
***************
*** 277,282 ****
--- 278,291 ----
fd = open(filename, O_RDONLY|O_BINARY);
if(fd < 0)
return FALSE;
+
+ /* just because we can open you doesn't mean your a real image */
+ int status;
+ struct stat st_buf;
+ status = stat(filename, &st_buf);
+ if (S_ISDIR (st_buf.st_mode))
+ return FALSE;
+
loader = gdk_pixbuf_loader_new();
g_signal_connect(G_OBJECT(loader), "size-prepared",
diff -crB xfdesktop-4.10.0/settings/main.c xfdesktop-4.10.0-cache/settings/main.c
*** xfdesktop-4.10.0/settings/main.c 2012-04-28 16:53:07.000000000 -0400
--- xfdesktop-4.10.0-cache/settings/main.c 2012-05-11 11:48:30.000000000 -0400
***************
*** 139,144 ****
--- 139,159 ----
TARGET_TEXT_URI_LIST = 0,
};
+ 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 */
***************
*** 146,152 ****
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,
--- 161,168 ----
xfdesktop_settings_do_single_preview(GtkTreeModel *model,
GtkTreeIter *iter)
{
! //gchar *name = NULL, *new_name = NULL, *filename = NULL;
! gchar *name = NULL, *new_name = NULL, *filename = NULL, *cachefile = NULL;
GdkPixbuf *pix, *pix_scaled = NULL;
gtk_tree_model_get(model, iter,
***************
*** 154,159 ****
--- 170,183 ----
COL_FILENAME, &filename,
-1);
+ cachefile = replace_str(name,"<b>","");
+ cachefile = replace_str(cachefile,"</b>","");
+ cachefile = g_strdup_printf(_("%sthumb-%s"),xfce_resource_lookup(XFCE_RESOURCE_CACHE, "xfce4/"),cachefile);
+
+ if( access( cachefile, W_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) {
***************
*** 177,186 ****
--- 201,215 ----
height = PREVIEW_HEIGHT;
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);
+ }
if(new_name) {
gtk_list_store_set(GTK_LIST_STORE(model), iter,