1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 00:04:06 +00:00

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

This commit is contained in:
Charles Kerr 2009-02-25 17:48:45 +00:00
parent 91940d1c07
commit 130cb762d9

View file

@ -59,6 +59,29 @@ notifyCallback( NotifyNotification * n UNUSED,
}
}
static gboolean
can_support_actions( void )
{
static gboolean supported;
static gboolean have_checked = FALSE;
if( !have_checked )
{
GList * c;
GList * caps = notify_get_server_caps( );
have_checked = TRUE;
for( c=caps; c && !supported; c=c->next )
supported = !strcmp( "actions", (char*)c->data );
g_list_foreach( caps, (GFunc)g_free, NULL );
g_list_free( caps );
}
return supported;
}
void
tr_notify_send( TrTorrent *tor )
{
@ -71,15 +94,18 @@ tr_notify_send( TrTorrent *tor )
info->name,
"transmission", NULL );
if( info->fileCount == 1 )
notify_notification_add_action(
n, "file", _( "Open File" ),
NOTIFY_ACTION_CALLBACK( notifyCallback ), tor,
NULL );
if( can_support_actions( ) )
{
if( info->fileCount == 1 )
notify_notification_add_action(
n, "file", _( "Open File" ),
NOTIFY_ACTION_CALLBACK( notifyCallback ), tor,
NULL );
notify_notification_add_action(
n, "folder", _( "Open Folder" ),
NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, NULL );
notify_notification_add_action(
n, "folder", _( "Open Folder" ),
NOTIFY_ACTION_CALLBACK( notifyCallback ), tor, NULL );
}
notify_notification_show( n, NULL );
}