Changeset 12578
- Timestamp:
- Jul 23, 2011, 5:23:12 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r12566 r12578 61 61 ## 62 62 ## 63 # play the XDG "download done" sound...64 CANBERRA_MINIMUM=0.1065 AC_SUBST(CANBERRA_MINIMUM)66 63 # inhibit hibernation when a torrent is active... 67 64 DBUS_GLIB_MINIMUM=0.70 … … 70 67 GIO_MINIMUM=2.15.5 71 68 AC_SUBST(GIO_MINIMUM) 72 # pop up a "download done" notice...73 LIBNOTIFY_MINIMUM=0.4.374 AC_SUBST(LIBNOTIFY_MINIMUM)75 69 # create the tray icon with AppIndicator 76 70 LIBAPPINDICATOR_MINIMUM=0.0.11 … … 261 255 use_gio=no 262 256 use_libappindicator=no 263 use_libnotify=no264 257 use_dbus_glib=no 265 use_canberra=no266 258 if test "x$want_gtk" = "xyes" ; then 267 259 if test "x$have_gtk" = "xyes"; then … … 281 273 if test "x$use_gio" = "xyes"; then 282 274 AC_DEFINE([HAVE_GIO], 1) 283 fi284 285 PKG_CHECK_MODULES([LIBNOTIFY],286 [libnotify >= $LIBNOTIFY_MINIMUM],287 [have_libnotify=yes],288 [have_libnotify=no])289 AC_ARG_ENABLE([libnotify],290 AS_HELP_STRING([--enable-libnotify],[enable notifications]),,291 [enable_libnotify=yes])292 use_libnotify=no293 if test "x$have_libnotify" = "xyes"; then294 if test "x$enable_libnotify" = "xyes" ; then295 use_libnotify=yes296 AC_DEFINE([HAVE_LIBNOTIFY], 1)297 else298 LIBNOTIFY_CFLAGS=299 LIBNOTIFY_LIBS=300 fi301 275 fi 302 276 … … 317 291 LIBAPPINDICATOR_CFLAGS= 318 292 LIBAPPINDICATOR_LIBS= 319 fi320 fi321 322 PKG_CHECK_MODULES([LIBCANBERRA],323 [libcanberra-gtk >= $CANBERRA_MINIMUM],324 [have_libcanberra=yes],325 [have_libcanberra=no])326 AC_ARG_ENABLE([libcanberra],327 AS_HELP_STRING([--enable-libcanberra],[enable sounds]),,328 [enable_libcanberra=yes])329 if test "x$have_libcanberra" = "xyes"; then330 if test "x$enable_libcanberra" = "xyes" ; then331 use_canberra=yes332 AC_DEFINE([HAVE_LIBCANBERRA], 1)333 else334 LIBCANBERRA_CFLAGS=335 LIBCANBERRA_LIBS=336 293 fi 337 294 fi … … 517 474 * dbus support: ${use_dbus_glib} 518 475 * gio for watchdir and mime-type support: ${use_gio} 519 * libnotify for 'download completed' popups: ${use_libnotify}520 * libcanberra for 'download completed' sounds: ${use_canberra}521 476 * libappindicator for an Ubuntu-style tray: ${use_libappindicator} 522 477 -
trunk/gtk/Makefile.am
r12562 r12578 16 16 @LIBAPPINDICATOR_CFLAGS@ \ 17 17 @LIBEVENT_CFLAGS@ \ 18 @LIBCANBERRA_CFLAGS@ \19 18 @GTK_CFLAGS@ \ 20 19 @LIBCURL_CFLAGS@ \ 21 20 @GIO_CFLAGS@ \ 22 @LIBNOTIFY_CFLAGS@ \23 21 @DBUS_GLIB_CFLAGS@ \ 24 22 @OPENSSL_CFLAGS@ \ … … 95 93 $(top_builddir)/third-party/miniupnp/libminiupnp.a \ 96 94 $(top_builddir)/third-party/libnatpmp/libnatpmp.a \ 97 @LIBCANBERRA_LIBS@ \98 95 @DHT_LIBS@ \ 99 96 @LIBUTP_LIBS@ \ … … 101 98 @GIO_LIBS@ \ 102 99 @LIBAPPINDICATOR_LIBS@ \ 103 @LIBNOTIFY_LIBS@ \104 100 @LIBEVENT_LIBS@ \ 105 101 @DBUS_GLIB_LIBS@ \ -
trunk/gtk/conf.c
r12223 r12578 158 158 if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP ); 159 159 if( !str ) str = tr_getDefaultDownloadDir( ); 160 tr_bencDictAddStr ( d, PREF_KEY_DIR_WATCH, str );160 tr_bencDictAddStr ( d, PREF_KEY_DIR_WATCH, str ); 161 161 tr_bencDictAddBool( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE ); 162 162 #endif … … 166 166 tr_bencDictAddBool( d, PREF_KEY_BLOCKLIST_UPDATES_ENABLED, TRUE ); 167 167 168 tr_bencDictAddStr ( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) );168 tr_bencDictAddStr ( d, PREF_KEY_OPEN_DIALOG_FOLDER, g_get_home_dir( ) ); 169 169 170 170 tr_bencDictAddBool( d, PREF_KEY_TOOLBAR, TRUE ); … … 172 172 tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE ); 173 173 tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE ); 174 tr_bencDictAddBool( d, PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND, TRUE );175 tr_bencDictAddBool( d, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, TRUE );176 174 tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE ); 177 175 tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_PEER_INFO, FALSE ); 178 176 tr_bencDictAddBool( d, PREF_KEY_SHOW_BACKUP_TRACKERS, FALSE ); 179 tr_bencDictAddStr( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" ); 177 tr_bencDictAddStr ( d, PREF_KEY_STATUSBAR_STATS, "total-ratio" ); 178 179 tr_bencDictAddStr ( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND, "notify-send -c transfer -i transmission '%s' '%s'" ); 180 tr_bencDictAddBool( d, PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED, true ); 181 tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND, "notify-send -c transfer.complete -i transmission '%s' '%s'" ); 182 tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED, true ); 183 tr_bencDictAddStr ( d, PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND, "canberra-gtk-play -i complete-download -d 'transmission torrent downloaded'" ); 184 tr_bencDictAddBool( d, PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED, true ); 180 185 181 186 tr_bencDictAddBool( d, PREF_KEY_OPTIONS_PROMPT, TRUE ); -
trunk/gtk/main.c
r12563 r12578 51 51 #include "makemeta-ui.h" 52 52 #include "msgwin.h" 53 #include "notify.h"54 53 #include "open-dialog.h" 55 54 #include "relocate.h" … … 666 665 configDir = (char*) tr_getDefaultConfigDir( MY_CONFIG_NAME ); 667 666 668 gtr_notify_init( );669 667 didinit = cf_init( configDir, NULL ); /* must come before actions_init */ 670 668 -
trunk/gtk/notify.c
r12223 r12578 11 11 */ 12 12 13 #include <string.h> /* strcmp() */14 15 #ifdef HAVE_LIBCANBERRA16 #include <canberra-gtk.h>17 #endif18 19 #ifdef HAVE_GIO20 #include <gio/gio.h>21 #endif22 23 13 #include <glib/gi18n.h> 24 #include "actions.h" /* NOTIFICATION_ICON */25 14 #include "conf.h" 26 15 #include "notify.h" … … 28 17 #include "util.h" 29 18 30 #ifndef HAVE_LIBNOTIFY31 32 void gtr_notify_init( void ) { }33 void gtr_notify_torrent_completed( TrCore * core UNUSED, int torrent_id UNUSED ) { }34 void gtr_notify_torrent_added( const char * name UNUSED ) { }35 36 #else37 #include <libnotify/notify.h>38 39 void40 gtr_notify_init( void )41 {42 notify_init( "Transmission" );43 }44 45 struct notify_callback_data46 {47 TrCore * core;48 int torrent_id;49 };50 51 static void52 notify_callback_data_free( gpointer gdata )53 {54 struct notify_callback_data * data = gdata;55 g_object_unref( G_OBJECT( data->core ) );56 g_free( data );57 }58 59 static struct notify_callback_data *60 notify_callback_data_new( TrCore * core, int torrent_id )61 {62 struct notify_callback_data * data = g_new( struct notify_callback_data, 1 );63 data->core = core;64 data->torrent_id = torrent_id;65 g_object_ref( G_OBJECT( data->core ) );66 return data;67 }68 69 static void70 notifyCallback( NotifyNotification * n UNUSED,71 const char * action,72 gpointer gdata )73 {74 struct notify_callback_data * data = gdata;75 tr_torrent * tor = gtr_core_find_torrent( data->core, data->torrent_id );76 77 if( tor != NULL )78 {79 if( !strcmp( action, "folder" ) )80 {81 gtr_core_open_folder( data->core, data->torrent_id );82 }83 else if( !strcmp( action, "file" ) )84 {85 const tr_info * inf = tr_torrentInfo( tor );86 const char * dir = tr_torrentGetDownloadDir( tor );87 char * path = g_build_filename( dir, inf->files[0].name, NULL );88 gtr_open_file( path );89 g_free( path );90 }91 }92 }93 94 static gboolean95 can_support_actions( void )96 {97 static gboolean supported;98 static gboolean have_checked = FALSE;99 100 if( !have_checked )101 {102 GList * c;103 GList * caps = notify_get_server_caps( );104 105 have_checked = TRUE;106 107 for( c=caps; c && !supported; c=c->next )108 supported = !strcmp( "actions", (char*)c->data );109 110 g_list_foreach( caps, (GFunc)g_free, NULL );111 g_list_free( caps );112 }113 114 return supported;115 }116 117 static void118 addIcon( NotifyNotification * notify )119 {120 int size = 32;121 GtkIconTheme * theme;122 GdkPixbuf * icon;123 124 gtk_icon_size_lookup( GTK_ICON_SIZE_DIALOG, &size, &size );125 theme = gtk_icon_theme_get_default( );126 icon = gtk_icon_theme_load_icon( theme, NOTIFICATION_ICON, size, 0, NULL );127 128 if( icon != NULL )129 {130 notify_notification_set_icon_from_pixbuf( notify, icon );131 g_object_unref( icon );132 }133 }134 135 static NotifyNotification *136 tr_notify_notification_new( const char * summary,137 const char * body,138 const char * icon )139 {140 NotifyNotification * n = notify_notification_new( summary, body, icon141 /* the fourth argument was removed in libnotify 0.7.0 */142 #if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)143 , NULL144 #endif145 );146 return n;147 }148 149 19 void 150 20 gtr_notify_torrent_completed( TrCore * core, int torrent_id ) 151 21 { 152 #ifdef HAVE_LIBCANBERRA 153 if( gtr_pref_flag_get( PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND ) ) 22 if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED ) ) 154 23 { 155 /* play the sound, using sounds from the naming spec */ 156 ca_context_play( ca_gtk_context_get (), 0, 157 CA_PROP_EVENT_ID, "complete-download", 158 CA_PROP_APPLICATION_NAME, g_get_application_name, 159 CA_PROP_EVENT_DESCRIPTION, _("Download complete"), 160 NULL); 24 const char * cmd = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND ); 25 g_spawn_command_line_async( cmd, NULL ); 161 26 } 162 #endif163 27 164 if( gtr_pref_flag_get( PREF_KEY_ SHOW_DESKTOP_NOTIFICATION) )28 if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED ) ) 165 29 { 166 NotifyNotification * n; 167 tr_torrent * tor = gtr_core_find_torrent( core, torrent_id ); 168 169 n = tr_notify_notification_new( _( "Torrent Complete" ), tr_torrentName( tor ), NULL ); 170 addIcon( n ); 171 172 if( can_support_actions( ) ) 173 { 174 const tr_info * inf = tr_torrentInfo( tor ); 175 if( inf->fileCount == 1 ) 176 notify_notification_add_action( 177 n, "file", _( "Open File" ), 178 NOTIFY_ACTION_CALLBACK( notifyCallback ), 179 notify_callback_data_new( core, torrent_id ), 180 notify_callback_data_free ); 181 182 notify_notification_add_action( 183 n, "folder", _( "Open Folder" ), 184 NOTIFY_ACTION_CALLBACK( notifyCallback ), 185 notify_callback_data_new( core, torrent_id ), 186 notify_callback_data_free ); 187 } 188 189 notify_notification_show( n, NULL ); 30 const tr_torrent * tor = gtr_core_find_torrent( core, torrent_id ); 31 const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND ); 32 char * cmd = g_strdup_printf( fmt, _( "Torrent Complete" ), ( tor ? tr_torrentName( tor ) : "" ) ); 33 g_spawn_command_line_async( cmd, NULL ); 34 g_free( cmd ); 190 35 } 191 36 } … … 194 39 gtr_notify_torrent_added( const char * name ) 195 40 { 196 if( gtr_pref_flag_get( PREF_KEY_ SHOW_DESKTOP_NOTIFICATION) )41 if( gtr_pref_flag_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED ) ) 197 42 { 198 NotifyNotification * n = tr_notify_notification_new( _( "Torrent Added" ), name, NULL);199 addIcon( n);200 notify_notification_set_timeout( n, NOTIFY_EXPIRES_DEFAULT);201 notify_notification_show( n, NULL);43 const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND ); 44 char * cmd = g_strdup_printf( fmt, _( "Torrent Added" ), name ); 45 g_spawn_command_line_async( cmd, NULL ); 46 g_free( cmd ); 202 47 } 203 48 } 204 205 #endif -
trunk/gtk/notify.h
r12068 r12578 16 16 #include "tr-core.h" 17 17 18 void gtr_notify_init( void );19 20 18 void gtr_notify_torrent_added ( const char * name ); 21 19 -
trunk/gtk/tr-prefs.c
r12550 r12578 344 344 desktopPage( GObject * core ) 345 345 { 346 int row = 0; 346 int row = 0; 347 GtkWidget * t; 348 GtkWidget * w; 347 349 const char * s; 348 GtkWidget * t;349 GtkWidget * w;350 350 351 351 t = hig_workarea_create( ); 352 352 hig_workarea_add_section_title( t, &row, _( "Desktop" ) ); 353 353 354 s = _( " Inhibit _hibernation when torrents are active" );354 s = _( "_Inhibit hibernation when torrents are active" ); 355 355 w = new_check_button( s, PREF_KEY_INHIBIT_HIBERNATION, core ); 356 356 hig_workarea_add_wide_control( t, &row, w ); … … 360 360 hig_workarea_add_wide_control( t, &row, w ); 361 361 362 s = _( "Show _popup notifications" ); 363 w = new_check_button( s, PREF_KEY_SHOW_DESKTOP_NOTIFICATION, core ); 364 hig_workarea_add_wide_control( t, &row, w ); 365 366 #ifdef HAVE_LIBCANBERRA 367 s = _( "Play _sound when downloads are complete" ); 368 w = new_check_button( s, PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND, core ); 369 hig_workarea_add_wide_control( t, &row, w ); 370 #endif 362 hig_workarea_add_section_divider( t, &row ); 363 hig_workarea_add_section_title ( t, &row, _( "Notification" ) ); 364 365 s = _( "Show a notification when torrents are a_dded" ); 366 w = new_check_button( s, PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED, core ); 367 hig_workarea_add_wide_control( t, &row, w ); 368 369 s = _( "Show a notification when torrents _finish" ); 370 w = new_check_button( s, PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED, core ); 371 hig_workarea_add_wide_control( t, &row, w ); 372 373 s = _( "Play a _sound when torrents finish" ); 374 w = new_check_button( s, PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED, core ); 375 hig_workarea_add_wide_control( t, &row, w ); 371 376 372 377 hig_workarea_finish( t, &row ); -
trunk/gtk/tr-prefs.h
r12068 r12578 21 21 * default in tr_prefs_init_defaults( void ) */ 22 22 23 #define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT "user-has-given-informed-consent" 24 #define PREF_KEY_OPTIONS_PROMPT "show-options-window" 25 #define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir" 26 #define PREF_KEY_INHIBIT_HIBERNATION "inhibit-desktop-hibernation" 27 #define PREF_KEY_DIR_WATCH "watch-dir" 28 #define PREF_KEY_DIR_WATCH_ENABLED "watch-dir-enabled" 29 #define PREF_KEY_SHOW_TRAY_ICON "show-notification-area-icon" 30 #define PREF_KEY_SHOW_DESKTOP_NOTIFICATION "show-desktop-notification" 31 #define PREF_KEY_PLAY_DOWNLOAD_COMPLETE_SOUND "play-download-complete-sound" 32 #define PREF_KEY_SHOW_MORE_TRACKER_INFO "show-tracker-scrapes" 33 #define PREF_KEY_SHOW_MORE_PEER_INFO "show-extra-peer-details" 34 #define PREF_KEY_SHOW_BACKUP_TRACKERS "show-backup-trackers" 35 #define PREF_KEY_SORT_MODE "sort-mode" 36 #define PREF_KEY_SORT_REVERSED "sort-reversed" 37 #define PREF_KEY_COMPACT_VIEW "compact-view" 38 #define PREF_KEY_FILTERBAR "show-filterbar" 39 #define PREF_KEY_STATUSBAR "show-statusbar" 40 #define PREF_KEY_STATUSBAR_STATS "statusbar-stats" 41 #define PREF_KEY_TOOLBAR "show-toolbar" 42 #define PREF_KEY_BLOCKLIST_UPDATES_ENABLED "blocklist-updates-enabled" 43 #define PREF_KEY_MAIN_WINDOW_HEIGHT "main-window-height" 44 #define PREF_KEY_MAIN_WINDOW_WIDTH "main-window-width" 45 #define PREF_KEY_MAIN_WINDOW_X "main-window-x" 46 #define PREF_KEY_MAIN_WINDOW_Y "main-window-y" 47 #define PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED "main-window-is-maximized" 23 #define PREF_KEY_BLOCKLIST_UPDATES_ENABLED "blocklist-updates-enabled" 24 #define PREF_KEY_COMPACT_VIEW "compact-view" 25 #define PREF_KEY_DIR_WATCH_ENABLED "watch-dir-enabled" 26 #define PREF_KEY_DIR_WATCH "watch-dir" 27 #define PREF_KEY_FILTERBAR "show-filterbar" 28 #define PREF_KEY_INHIBIT_HIBERNATION "inhibit-desktop-hibernation" 29 #define PREF_KEY_MAIN_WINDOW_HEIGHT "main-window-height" 30 #define PREF_KEY_MAIN_WINDOW_IS_MAXIMIZED "main-window-is-maximized" 31 #define PREF_KEY_MAIN_WINDOW_WIDTH "main-window-width" 32 #define PREF_KEY_MAIN_WINDOW_X "main-window-x" 33 #define PREF_KEY_MAIN_WINDOW_Y "main-window-y" 34 #define PREF_KEY_OPEN_DIALOG_FOLDER "open-dialog-dir" 35 #define PREF_KEY_OPTIONS_PROMPT "show-options-window" 36 #define PREF_KEY_SHOW_BACKUP_TRACKERS "show-backup-trackers" 37 #define PREF_KEY_SHOW_MORE_PEER_INFO "show-extra-peer-details" 38 #define PREF_KEY_SHOW_MORE_TRACKER_INFO "show-tracker-scrapes" 39 #define PREF_KEY_SHOW_TRAY_ICON "show-notification-area-icon" 40 #define PREF_KEY_SORT_MODE "sort-mode" 41 #define PREF_KEY_SORT_REVERSED "sort-reversed" 42 #define PREF_KEY_STATUSBAR "show-statusbar" 43 #define PREF_KEY_STATUSBAR_STATS "statusbar-stats" 44 #define PREF_KEY_TOOLBAR "show-toolbar" 45 #define PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND "torrent-added-notification-command" 46 #define PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED "torrent-added-notification-enabled" 47 #define PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND "torrent-complete-notification-command" 48 #define PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED "torrent-complete-notification-enabled" 49 #define PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND "torrent-complete-sound-command" 50 #define PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED "torrent-complete-sound-enabled" 51 #define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT "user-has-given-informed-consent" 48 52 49 53 enum -
trunk/transmission-gtk.spec.in
r12562 r12578 29 29 # OPTIONAL for the gtk+ client... see configure.ac for details 30 30 BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@ 31 BuildRequires: libcanberra-devel >= @CANBERRA_MINIMUM@32 BuildRequires: libnotify-devel >= @LIBNOTIFY_MINIMUM@33 31 Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@ 34 Requires: libcanberra >= @CANBERRA_MINIMUM@35 Requires: libnotify >= @LIBNOTIFY_MINIMUM@36 32 37 33 Provides: %{name}
Note: See TracChangeset
for help on using the changeset viewer.