source: trunk/gtk/notify.c @ 6620

Last change on this file since 6620 was 6620, checked in by charles, 13 years ago

fix #include warning

  • Property svn:keywords set to Date Rev Author Id
File size: 1.9 KB
Line 
1/*
2 * This file Copyright (C) 2008 Charles Kerr <charles@rebelbase.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: notify.c 6620 2008-08-22 01:05:38Z charles $
11 */
12
13#include <string.h>
14#ifdef HAVE_GIO
15#include <gio/gio.h>
16#endif
17#include <glib/gi18n.h>
18#include "notify.h"
19#include "util.h"
20
21#ifndef HAVE_LIBNOTIFY
22
23void tr_notify_init( void ) { }
24void tr_notify_send( TrTorrent * tor UNUSED ) { }
25
26#else
27#include <libnotify/notify.h>
28
29void
30tr_notify_init( void )
31{
32    notify_init( "Transmission" );
33}
34
35static void
36notifyCallback( NotifyNotification * n UNUSED,
37                const char         * action,
38                gpointer             gdata )
39{
40    TrTorrent * gtor = TR_TORRENT( gdata );
41
42    if( !strcmp( action, "folder" ) )
43    {
44        tr_torrent_open_folder( gtor );
45    }
46    else if( !strcmp( action, "file" ) )
47    {
48        tr_torrent * tor = tr_torrent_handle( gtor );
49        const tr_info * info = tr_torrent_info( gtor );
50        char * path = g_build_filename( tr_torrentGetDownloadDir(tor), info->files[0].name, NULL );
51        gtr_open_file( path );
52        g_free( path );
53    }
54}
55
56void
57tr_notify_send(TrTorrent *tor) 
58{ 
59    const tr_info * info = tr_torrent_info( tor ); 
60    NotifyNotification * n = notify_notification_new( _( "Torrent Complete" ), info->name, "transmission", NULL ); 
61 
62    if (info->fileCount == 1) 
63        notify_notification_add_action( n, "file", _( "Open File" ),
64                                        NOTIFY_ACTION_CALLBACK(notifyCallback), tor, NULL); 
65    notify_notification_add_action( n, "folder", _( "Open Folder" ),
66                                    NOTIFY_ACTION_CALLBACK(notifyCallback), tor, NULL );
67    notify_notification_show( n, NULL ); 
68}
69
70#endif
Note: See TracBrowser for help on using the repository browser.