Changeset 8003


Ignore:
Timestamp:
Mar 3, 2009, 5:58:25 PM (14 years ago)
Author:
charles
Message:

(trunk gtk) #628: tweak r7996 a little bit to play nicer on older versions of gtk+

Location:
trunk/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/icons.c

    r7999 r8003  
    44 */
    55
     6#include <string.h> /* strcmp */
    67#include <glib.h>
    78#include <gtk/gtk.h>
     
    910
    1011#ifdef HAVE_GIO
    11 
    12 #include <gio/gio.h>
     12 #include <gio/gio.h>
     13#endif
    1314
    1415#define VOID_PIXBUF_KEY "void-pixbuf"
     
    9798}
    9899
     100#ifdef HAVE_GIO
    99101static const char *
    100102_icon_cache_get_icon_key( GIcon * icon )
     
    218220    return pixbuf;
    219221}
     222
     223#else /* HAVE_GIO */
     224
     225static GdkPixbuf *
     226icon_cache_get_mime_type_icon( IconCache  * icon_cache,
     227                               const char * mime_type )
     228{
     229    GdkPixbuf  * pixbuf;
     230    const char * stock_name;
     231
     232    if( !strcmp( mime_type, DIRECTORY_MIME_TYPE ) )
     233        stock_name = GTK_STOCK_DIRECTORY;
     234    else
     235        stock_name = GTK_STOCK_FILE;
     236
     237    pixbuf = g_hash_table_lookup( icon_cache->cache, stock_name );
     238
     239    if( pixbuf != NULL )
     240    {
     241        g_object_ref( pixbuf );
     242        return pixbuf;
     243    }
     244
     245    pixbuf = gtk_icon_theme_load_icon( icon_cache->icon_theme,
     246                                       stock_name,
     247                                       icon_cache->icon_size,
     248                                       0, NULL );
     249    g_hash_table_insert( icon_cache->cache, (gpointer) stock_name, g_object_ref( pixbuf ));
     250    return pixbuf;
     251}
     252
     253#endif
    220254
    221255
     
    245279
    246280const char *
    247 get_mime_type_from_filename( const char *file )
    248 {
     281get_mime_type_from_filename( const char * file G_GNUC_UNUSED )
     282{
     283#ifdef HAVE_GIO
    249284    return get_static_string( g_content_type_guess( file, NULL, 0, NULL ));
    250 }
    251 
    252285#else
    253 
    254 GdkPixbuf *
    255 get_mime_type_icon( const char   * mime_type,
    256                     GtkIconSize    icon_size,
    257                     GtkWidget    * for_widget )
    258 {
    259     return NULL;
    260 }                   
    261 
    262 
    263 const char *
    264 get_mime_type_from_filename( const char *file )
    265 {
    266286    return "uncertain";
    267 }
    268 
    269287#endif
     288}
  • trunk/gtk/torrent-cell-renderer.c

    r7996 r8003  
    1212
    1313#include "assert.h"
     14#include <string.h> /* strcmp */
    1415#include <gtk/gtk.h>
    1516#include <glib/gi18n.h>
     
    365366    /* cleanup */
    366367    g_free( status );
     368    g_object_unref( icon );
    367369}
    368370
     
    427429    g_free( status );
    428430    g_free( progress );
     431    g_object_unref( icon );
    429432}
    430433
     
    556559    /* cleanup */
    557560    g_free( status );
     561    g_object_unref( icon );
    558562}
    559563
     
    664668    g_free( status );
    665669    g_free( progress );
     670    g_object_unref( icon );
    666671}
    667672
Note: See TracChangeset for help on using the changeset viewer.