Changeset 7943


Ignore:
Timestamp:
Feb 25, 2009, 5:48:45 PM (13 years ago)
Author:
charles
Message:

(trunk gtk) #1865: Notifications should check notification server for capabilities before using actions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/notify.c

    r7707 r7943  
    6060}
    6161
     62static gboolean
     63can_support_actions( void )
     64{
     65    static gboolean supported;
     66    static gboolean have_checked = FALSE;
     67
     68    if( !have_checked )
     69    {
     70        GList * c;
     71        GList * caps = notify_get_server_caps( );
     72
     73        have_checked = TRUE;
     74
     75        for( c=caps; c && !supported; c=c->next )
     76            supported = !strcmp( "actions", (char*)c->data );
     77
     78        g_list_foreach( caps, (GFunc)g_free, NULL );
     79        g_list_free( caps );
     80    }
     81
     82    return supported;
     83}
     84
    6285void
    6386tr_notify_send( TrTorrent *tor )
     
    7295                                     "transmission", NULL );
    7396
    74         if( info->fileCount == 1 )
     97        if( can_support_actions( ) )
     98        {
     99            if( info->fileCount == 1 )
     100                notify_notification_add_action(
     101                    n, "file", _( "Open File" ),
     102                    NOTIFY_ACTION_CALLBACK( notifyCallback ), tor,
     103                    NULL );
     104
    75105            notify_notification_add_action(
    76                 n, "file", _( "Open File" ),
    77                 NOTIFY_ACTION_CALLBACK( notifyCallback ), tor,
    78                 NULL );
    79 
    80         notify_notification_add_action(
    81             n, "folder", _( "Open Folder" ),
    82             NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, NULL );
     106                n, "folder", _( "Open Folder" ),
     107                NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, NULL );
     108        }
    83109
    84110        notify_notification_show( n, NULL );
Note: See TracChangeset for help on using the changeset viewer.