Ignore:
Timestamp:
Feb 7, 2008, 8:27:15 PM (15 years ago)
Author:
charles
Message:

(gtk 1.0x) #376 again: add a fallback logo for platforms that don't support the freedesktop icon scheme

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0x/gtk/actions.c

    r4968 r4969  
    2020#include "tr_prefs.h"
    2121#include "lock.h"
     22#include "logo.h"
    2223
    2324#define UNUSED G_GNUC_UNUSED
     
    171172BuiltinIconInfo;
    172173
    173 const BuiltinIconInfo my_builtin_icons [] =
    174 {
     174const BuiltinIconInfo my_fallback_icons [] =
     175{
     176    { tr_icon_logo, "transmission" },
    175177    { tr_icon_lock, "transmission-lock" }
    176178};
     
    179181register_my_icons ( void )
    180182{
    181    int i;
    182    const int n = G_N_ELEMENTS( my_builtin_icons );
    183    GtkIconFactory * factory = gtk_icon_factory_new ();
    184    gtk_icon_factory_add_default( factory );
    185 
    186    for( i=0; i<n; ++i )
    187    {
    188        GdkPixbuf * p;
    189        int width;
    190        GtkIconSet * icon_set;
    191 
    192        p = gdk_pixbuf_new_from_inline( -1, my_builtin_icons[i].raw, FALSE, 0 );
    193        width = gdk_pixbuf_get_width( p );
    194        gtk_icon_theme_add_builtin_icon (my_builtin_icons[i].name, width, p );
    195 
    196        icon_set = gtk_icon_set_new_from_pixbuf( p );
    197        gtk_icon_factory_add( factory, my_builtin_icons[i].name, icon_set );
    198 
    199        g_object_unref( p );
    200        gdk_pixbuf_unref( p );
    201        gtk_icon_set_unref (icon_set);
     183    int i;
     184    const int n = G_N_ELEMENTS( my_fallback_icons );
     185    GtkIconFactory * factory = gtk_icon_factory_new( );
     186    GtkIconTheme * theme = gtk_icon_theme_get_default( );
     187    gtk_icon_factory_add_default( factory );
     188
     189    for( i=0; i<n; ++i )
     190    {
     191        const char * name = my_fallback_icons[i].name;
     192
     193        if( !gtk_icon_theme_has_icon( theme, name ) )
     194        {
     195            int width;
     196            GdkPixbuf * p;
     197            GtkIconSet * icon_set;
     198
     199            p = gdk_pixbuf_new_from_inline( -1, my_fallback_icons[i].raw, FALSE, 0 );
     200            width = gdk_pixbuf_get_width( p );
     201            icon_set = gtk_icon_set_new_from_pixbuf( p );
     202            gtk_icon_theme_add_builtin_icon( name, width, p );
     203            gtk_icon_factory_add( factory, name, icon_set );
     204
     205            g_object_unref( p );
     206            gtk_icon_set_unref( icon_set );
     207        }
    202208    }
    203209
Note: See TracChangeset for help on using the changeset viewer.