]> granicus.if.org Git - transmission/commitdiff
(trunk gtk) get the new filterbar working on older versions of GTK+
authorCharles Kerr <charles@transmissionbt.com>
Mon, 15 Mar 2010 15:07:23 +0000 (15:07 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Mon, 15 Mar 2010 15:07:23 +0000 (15:07 +0000)
gtk/favicon.c
gtk/filter.c

index 680ccf7f19ce8bc092a19f4c1e5a2d66223e04a3..99bec5da37bba531ad74f7b7dc86b42364f83174 100644 (file)
@@ -60,28 +60,27 @@ favicon_save_cache_file( const char * host, const void * data, size_t len )
 }
 
 static GdkPixbuf*
-favicon_load_from_data( const void * data, size_t len )
+favicon_load_from_file( const char * host )
 {
-    GdkPixbuf * pixbuf = NULL;
-
-    if( len > 0 )
-    {
-        GInputStream * i = g_memory_input_stream_new_from_data( data, len, NULL );
-        pixbuf = gdk_pixbuf_new_from_stream_at_scale( i, 16, 16, TRUE, NULL, NULL );
-        g_object_unref( i );
-    }
-
+    char * filename = favicon_get_cache_filename( host );
+    GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file_at_size( filename, 16, 16, NULL );
+    if( pixbuf == NULL ) /* bad file */
+        g_remove( filename );
+    g_free( filename );
     return pixbuf;
 }
 
 static gboolean
 favicon_web_done_idle_cb( gpointer vfav )
 {
+    GdkPixbuf * pixbuf = NULL;
     struct favicon_data * fav = vfav;
-    GdkPixbuf * pixbuf = favicon_load_from_data( fav->contents, fav->len );
 
-    if( pixbuf != NULL )
+    if( fav->len > 0 )
+    {
         favicon_save_cache_file( fav->host, fav->contents, fav->len );
+        pixbuf = favicon_load_from_file( fav->host );
+    }
 
     fav->func( pixbuf, fav->data );
 
@@ -105,26 +104,6 @@ favicon_web_done_cb( tr_session    * session UNUSED,
     gtr_idle_add( favicon_web_done_idle_cb, fav );
 }
     
-static GdkPixbuf*
-favicon_load_from_file( const char * host )
-{
-    gsize len;
-    char * data;
-    char * path = favicon_get_cache_filename( host );
-    GdkPixbuf * pixbuf = NULL;
-
-    if( g_file_get_contents( path, &data, &len, NULL ) )
-    {
-        pixbuf = favicon_load_from_data( data, len );
-        if( pixbuf == NULL ) /* bad file... delete it from the cache */
-            g_remove( path );
-        g_free( data );
-    }
-
-    g_free( path );
-    return pixbuf;
-}
-    
 void
 gtr_get_favicon( tr_session  * session,
                  const char  * host, 
index 2890cf2e5bcda9223798f6b8abcd379c0542a0ef..6b2bfacdb414cbf6c5a5634512fe269ec931ffba 100644 (file)
@@ -320,7 +320,7 @@ category_filter_model_update( GtkTreeStore * store )
     }
     
     /* cleanup */
-    g_ptr_array_unref( hosts );
+    g_ptr_array_free( hosts, TRUE );
     g_hash_table_unref( hosts_hash );
     g_ptr_array_foreach( hosts, (GFunc)g_free, NULL );
     return FALSE;