Changeset 10385 for trunk/gtk/favicon.c


Ignore:
Timestamp:
Mar 15, 2010, 3:07:23 PM (12 years ago)
Author:
charles
Message:

(trunk gtk) get the new filterbar working on older versions of GTK+

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/favicon.c

    r10382 r10385  
    6161
    6262static GdkPixbuf*
    63 favicon_load_from_data( const void * data, size_t len )
     63favicon_load_from_file( const char * host )
    6464{
    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 );
    7470    return pixbuf;
    7571}
     
    7874favicon_web_done_idle_cb( gpointer vfav )
    7975{
     76    GdkPixbuf * pixbuf = NULL;
    8077    struct favicon_data * fav = vfav;
    81     GdkPixbuf * pixbuf = favicon_load_from_data( fav->contents, fav->len );
    8278
    83     if( pixbuf != NULL )
     79    if( fav->len > 0 )
     80    {
    8481        favicon_save_cache_file( fav->host, fav->contents, fav->len );
     82        pixbuf = favicon_load_from_file( fav->host );
     83    }
    8584
    8685    fav->func( pixbuf, fav->data );
     
    104103
    105104    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;
    126105}
    127106   
Note: See TracChangeset for help on using the changeset viewer.