Changeset 10385 for trunk/gtk/favicon.c
- Timestamp:
- Mar 15, 2010, 3:07:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/favicon.c
r10382 r10385 61 61 62 62 static GdkPixbuf* 63 favicon_load_from_ data( const void * data, size_t len)63 favicon_load_from_file( const char * host ) 64 64 { 65 GdkPixbuf * pixbuf = NULL; 66 67 if( len > 0 ) 68 { 69 GInputStream * i = g_memory_input_stream_new_from_data( data, len, NULL ); 70 pixbuf = gdk_pixbuf_new_from_stream_at_scale( i, 16, 16, TRUE, NULL, NULL ); 71 g_object_unref( i ); 72 } 73 65 char * filename = favicon_get_cache_filename( host ); 66 GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size( filename, 16, 16, NULL ); 67 if( pixbuf == NULL ) /* bad file */ 68 g_remove( filename ); 69 g_free( filename ); 74 70 return pixbuf; 75 71 } … … 78 74 favicon_web_done_idle_cb( gpointer vfav ) 79 75 { 76 GdkPixbuf * pixbuf = NULL; 80 77 struct favicon_data * fav = vfav; 81 GdkPixbuf * pixbuf = favicon_load_from_data( fav->contents, fav->len );82 78 83 if( pixbuf != NULL ) 79 if( fav->len > 0 ) 80 { 84 81 favicon_save_cache_file( fav->host, fav->contents, fav->len ); 82 pixbuf = favicon_load_from_file( fav->host ); 83 } 85 84 86 85 fav->func( pixbuf, fav->data ); … … 104 103 105 104 gtr_idle_add( favicon_web_done_idle_cb, fav ); 106 }107 108 static GdkPixbuf*109 favicon_load_from_file( const char * host )110 {111 gsize len;112 char * data;113 char * path = favicon_get_cache_filename( host );114 GdkPixbuf * pixbuf = NULL;115 116 if( g_file_get_contents( path, &data, &len, NULL ) )117 {118 pixbuf = favicon_load_from_data( data, len );119 if( pixbuf == NULL ) /* bad file... delete it from the cache */120 g_remove( path );121 g_free( data );122 }123 124 g_free( path );125 return pixbuf;126 105 } 127 106
Note: See TracChangeset
for help on using the changeset viewer.