Changeset 10200


Ignore:
Timestamp:
Feb 14, 2010, 2:26:45 PM (13 years ago)
Author:
charles
Message:

(trunk gtk) #2900 "Indicator Application can only work with icon names, not rendered icons" -- patched for 1.90 in trunk. Thanks to qense for the patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-icon.c

    r10133 r10200  
    1919#include "tr-icon.h"
    2020#include "util.h"
     21
     22#define MY_NAME "transmission"
    2123
    2224#ifndef STATUS_ICON_SUPPORTED
     
    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
Note: See TracChangeset for help on using the changeset viewer.