source: trunk/gtk/notify.c @ 5843

Last change on this file since 5843 was 5843, checked in by charles, 14 years ago

RPC/IPC redesign

  • 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 5843 2008-05-18 16:44:30Z charles $
11 */
12
13#ifdef HAVE_GIO
14#include <gio/gio.h>
15#endif
16#include <glib/gi18n.h>
17#include "notify.h"
18#include "util.h"
19
20#ifndef HAVE_LIBNOTIFY
21
22void tr_notify_init( void ) { }
23void tr_notify_send( TrTorrent * tor UNUSED ) { }
24
25#else
26#include <libnotify/notify.h>
27
28void
29tr_notify_init( void )
30{
31    notify_init( "Transmission" );
32}
33
34static void
35notifyCallback( NotifyNotification * n UNUSED,
36                const char         * action,
37                gpointer             gdata )
38{
39    TrTorrent * gtor = TR_TORRENT( gdata );
40
41    if( !strcmp( action, "folder" ) )
42    {
43        tr_torrent_open_folder( gtor );
44    }
45    else if( !strcmp( action, "file" ) )
46    {
47        tr_torrent * tor = tr_torrent_handle( gtor );
48        const tr_info * info = tr_torrent_info( gtor );
49        char * path = g_build_filename( tr_torrentGetDownloadDir(tor), info->files[0].name, NULL );
50        gtr_open_file( path );
51        g_free( path );
52    }
53}
54
55void
56tr_notify_send(TrTorrent *tor) 
57{ 
58    const tr_info * info = tr_torrent_info( tor ); 
59    NotifyNotification * n = notify_notification_new( _( "Torrent Complete" ), info->name, "transmission", NULL ); 
60 
61    if (info->fileCount == 1) 
62        notify_notification_add_action( n, "file", _( "Open File" ),
63                                        NOTIFY_ACTION_CALLBACK(notifyCallback), tor, NULL); 
64    notify_notification_add_action( n, "folder", _( "Open Folder" ),
65                                    NOTIFY_ACTION_CALLBACK(notifyCallback), tor, NULL );
66    notify_notification_show( n, NULL ); 
67}
68
69#endif
Note: See TracBrowser for help on using the repository browser.