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:
parent
91940d1c07
commit
130cb762d9
1 changed files with 34 additions and 8 deletions
42
gtk/notify.c
42
gtk/notify.c
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue