Ticket #2900: icon_fallback_maybe_without_typo.patch

File icon_fallback_maybe_without_typo.patch, 1.9 KB (added by qense, 12 years ago)
  • gtk/tr-icon.c

     
    1919#include "tr-icon.h"
    2020#include "util.h"
    2121
     22#define MY_NAME "transmission"
     23
    2224#ifndef STATUS_ICON_SUPPORTED
    2325
    2426gpointer
     
    122124gpointer
    123125tr_icon_new( TrCore * core)
    124126{
    125         const char * icon_name = TRAY_ICON;
    126         AppIndicator * indicator = app_indicator_new ( "transmission",
    127                                                                                                         icon_name,
    128                                                                                                         APP_INDICATOR_CATEGORY_SYSTEM_SERVICES );
     127    GtkWidget * w;
     128    const char * icon_name;
     129    AppIndicator * indicator;
     130    GtkIconTheme * theme = gtk_icon_theme_get_default( );
    129131
    130         GtkWidget * indicator_menu = action_get_widget( "/icon-popup" );
     132    /* if the tray's icon is a 48x48 file, use it;
     133     * otherwise, use the fallback builtin icon */
     134    if( !gtk_icon_theme_has_icon( theme, TRAY_ICON ) )
     135        icon_name = MY_NAME;
     136    else {
     137        GtkIconInfo * icon_info = gtk_icon_theme_lookup_icon( theme, TRAY_ICON, 48, GTK_ICON_LOOKUP_USE_BUILTIN );
     138        const gboolean icon_is_builtin = gtk_icon_info_get_filename ( icon_info ) == NULL;
     139        gtk_icon_info_free ( icon_info );
     140        icon_name = icon_is_builtin ? MY_NAME : TRAY_ICON;
     141    }
     142   
     143    indicator = app_indicator_new( MY_NAME, icon_name, APP_INDICATOR_CATEGORY_SYSTEM_SERVICES );
     144    app_indicator_set_status( indicator, APP_INDICATOR_STATUS_ACTIVE );
     145    w = action_get_widget( "/icon-popup" );
     146    app_indicator_set_menu( indicator, GTK_MENU ( w ) );
    131147
    132         app_indicator_set_status ( indicator, APP_INDICATOR_STATUS_ACTIVE );
    133         app_indicator_set_menu ( indicator, GTK_MENU (indicator_menu) );
    134 
    135         g_object_set_data( G_OBJECT( indicator ), "tr-core", core );
    136         return indicator;
     148    g_object_set_data( G_OBJECT( indicator ), "tr-core", core );
     149   
     150    return indicator;
    137151}                       
    138152#else
    139153gpointer