diff --git a/gtk/tr-icon.c b/gtk/tr-icon.c index 96dff2fde..126840ec6 100644 --- a/gtk/tr-icon.c +++ b/gtk/tr-icon.c @@ -19,6 +19,8 @@ #include "tr-icon.h" #include "util.h" +#define MY_NAME "transmission" + #ifndef STATUS_ICON_SUPPORTED gpointer @@ -122,18 +124,30 @@ tr_icon_refresh( gpointer vicon ) gpointer tr_icon_new( TrCore * core) { - const char * icon_name = TRAY_ICON; - AppIndicator * indicator = app_indicator_new ( "transmission", - icon_name, - APP_INDICATOR_CATEGORY_SYSTEM_SERVICES ); + GtkWidget * w; + const char * icon_name; + AppIndicator * indicator; + GtkIconTheme * theme = gtk_icon_theme_get_default( ); - GtkWidget * indicator_menu = action_get_widget( "/icon-popup" ); + /* if the tray's icon is a 48x48 file, use it; + * otherwise, use the fallback builtin icon */ + if( !gtk_icon_theme_has_icon( theme, TRAY_ICON ) ) + icon_name = MY_NAME; + else { + GtkIconInfo * icon_info = gtk_icon_theme_lookup_icon( theme, TRAY_ICON, 48, GTK_ICON_LOOKUP_USE_BUILTIN ); + const gboolean icon_is_builtin = gtk_icon_info_get_filename ( icon_info ) == NULL; + gtk_icon_info_free ( icon_info ); + icon_name = icon_is_builtin ? MY_NAME : TRAY_ICON; + } + + indicator = app_indicator_new( MY_NAME, icon_name, APP_INDICATOR_CATEGORY_SYSTEM_SERVICES ); + app_indicator_set_status( indicator, APP_INDICATOR_STATUS_ACTIVE ); + w = action_get_widget( "/icon-popup" ); + app_indicator_set_menu( indicator, GTK_MENU ( w ) ); - app_indicator_set_status ( indicator, APP_INDICATOR_STATUS_ACTIVE ); - app_indicator_set_menu ( indicator, GTK_MENU (indicator_menu) ); - - g_object_set_data( G_OBJECT( indicator ), "tr-core", core ); - return indicator; + g_object_set_data( G_OBJECT( indicator ), "tr-core", core ); + + return indicator; } #else gpointer