mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
(trunk gtk) #1963: Use tooltip to notify user of added torrent
This commit is contained in:
parent
c2dd366154
commit
ebfd93fe7b
7 changed files with 54 additions and 31 deletions
|
@ -123,7 +123,7 @@ addResponseCB( GtkDialog * dialog,
|
|||
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->run_check ) ) )
|
||||
tr_torrentStart( tr_torrent_handle( data->gtor ) );
|
||||
|
||||
tr_core_add_torrent( data->core, data->gtor );
|
||||
tr_core_add_torrent( data->core, data->gtor, FALSE );
|
||||
|
||||
if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->trash_check ) ) )
|
||||
|
||||
|
@ -426,7 +426,7 @@ onAddDialogResponse( GtkDialog * dialog,
|
|||
: PREF_FLAG_FALSE;
|
||||
GSList * l = gtk_file_chooser_get_filenames( chooser );
|
||||
|
||||
tr_core_add_list( core, l, start, prompt );
|
||||
tr_core_add_list( core, l, start, prompt, FALSE );
|
||||
}
|
||||
|
||||
gtk_widget_destroy( GTK_WIDGET( dialog ) );
|
||||
|
|
|
@ -300,8 +300,7 @@ onRPCChanged( tr_session * session UNUSED,
|
|||
switch( type )
|
||||
{
|
||||
case TR_RPC_TORRENT_ADDED:
|
||||
tr_core_add_torrent( cbdata->core,
|
||||
tr_torrent_new_preexisting( tor ) );
|
||||
tr_core_add_torrent( cbdata->core, tr_torrent_new_preexisting( tor ), TRUE );
|
||||
break;
|
||||
|
||||
case TR_RPC_TORRENT_STARTED:
|
||||
|
@ -517,7 +516,7 @@ appsetup( TrWindow * wind,
|
|||
|
||||
/* add torrents from command-line and saved state */
|
||||
tr_core_load( cbdata->core, forcepause );
|
||||
tr_core_add_list( cbdata->core, torrentFiles, start, prompt );
|
||||
tr_core_add_list( cbdata->core, torrentFiles, start, prompt, TRUE );
|
||||
torrentFiles = NULL;
|
||||
tr_core_torrents_added( cbdata->core );
|
||||
|
||||
|
@ -793,7 +792,7 @@ gotdrag( GtkWidget * widget UNUSED,
|
|||
if( paths )
|
||||
{
|
||||
paths = g_slist_reverse( paths );
|
||||
tr_core_add_list_defaults( data->core, paths );
|
||||
tr_core_add_list_defaults( data->core, paths, TRUE );
|
||||
tr_core_torrents_added( data->core );
|
||||
}
|
||||
|
||||
|
|
19
gtk/notify.c
19
gtk/notify.c
|
@ -22,10 +22,9 @@
|
|||
|
||||
#ifndef HAVE_LIBNOTIFY
|
||||
|
||||
void
|
||||
tr_notify_init( void ) { }
|
||||
void
|
||||
tr_notify_send( TrTorrent * tor UNUSED ) { }
|
||||
void tr_notify_init( void ) { }
|
||||
void tr_notify_send( TrTorrent * tor UNUSED ) { }
|
||||
void tr_notify_added( const char * name UNUSED ) { }
|
||||
|
||||
#else
|
||||
#include <libnotify/notify.h>
|
||||
|
@ -113,4 +112,16 @@ tr_notify_send( TrTorrent *tor )
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tr_notify_added( const char * name )
|
||||
{
|
||||
if( pref_flag_get( PREF_KEY_SHOW_DESKTOP_NOTIFICATION ) )
|
||||
{
|
||||
NotifyNotification * n = notify_notification_new(
|
||||
_( "Torrent Added" ), name, "transmission", NULL );
|
||||
notify_notification_set_timeout( n, NOTIFY_EXPIRES_DEFAULT );
|
||||
notify_notification_show( n, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,4 +19,6 @@ void tr_notify_init( void );
|
|||
|
||||
void tr_notify_send( TrTorrent * tor );
|
||||
|
||||
void tr_notify_added( const char * name );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <libtransmission/utils.h> /* tr_free */
|
||||
|
||||
#include "conf.h"
|
||||
#include "notify.h"
|
||||
#include "tr-core.h"
|
||||
#ifdef HAVE_DBUS_GLIB
|
||||
#include "tr-core-dbus.h"
|
||||
|
@ -469,7 +470,7 @@ watchFolderIdle( gpointer gcore )
|
|||
TrCore * core = TR_CORE( gcore );
|
||||
|
||||
core->priv->adding_from_watch_dir = TRUE;
|
||||
tr_core_add_list_defaults( core, core->priv->monitor_files );
|
||||
tr_core_add_list_defaults( core, core->priv->monitor_files, TRUE );
|
||||
core->priv->adding_from_watch_dir = FALSE;
|
||||
|
||||
/* cleanup */
|
||||
|
@ -784,8 +785,9 @@ doCollate( const char * in )
|
|||
}
|
||||
|
||||
void
|
||||
tr_core_add_torrent( TrCore * self,
|
||||
TrTorrent * gtor )
|
||||
tr_core_add_torrent( TrCore * self,
|
||||
TrTorrent * gtor,
|
||||
gboolean doNotify )
|
||||
{
|
||||
const tr_info * inf = tr_torrent_info( gtor );
|
||||
const tr_stat * torStat = tr_torrent_stat( gtor );
|
||||
|
@ -802,6 +804,9 @@ tr_core_add_torrent( TrCore * self,
|
|||
MC_ACTIVITY, torStat->activity,
|
||||
-1 );
|
||||
|
||||
if( doNotify )
|
||||
tr_notify_added( inf->name );
|
||||
|
||||
/* cleanup */
|
||||
g_object_unref( G_OBJECT( gtor ) );
|
||||
g_free( collated );
|
||||
|
@ -824,7 +829,7 @@ tr_core_load( TrCore * self,
|
|||
|
||||
torrents = tr_sessionLoadTorrents ( tr_core_session( self ), ctor, &count );
|
||||
for( i = 0; i < count; ++i )
|
||||
tr_core_add_torrent( self, tr_torrent_new_preexisting( torrents[i] ) );
|
||||
tr_core_add_torrent( self, tr_torrent_new_preexisting( torrents[i] ), FALSE );
|
||||
|
||||
tr_free( torrents );
|
||||
tr_ctorFree( ctor );
|
||||
|
@ -853,7 +858,7 @@ tr_core_errsig( TrCore * core,
|
|||
}
|
||||
|
||||
static int
|
||||
add_ctor( TrCore * core, tr_ctor * ctor, gboolean doPrompt )
|
||||
add_ctor( TrCore * core, tr_ctor * ctor, gboolean doPrompt, gboolean doNotify )
|
||||
{
|
||||
tr_info inf;
|
||||
int err = tr_torrentParse( ctor, &inf );
|
||||
|
@ -879,9 +884,8 @@ add_ctor( TrCore * core, tr_ctor * ctor, gboolean doPrompt )
|
|||
else {
|
||||
tr_session * session = tr_core_session( core );
|
||||
TrTorrent * gtor = tr_torrent_new_ctor( session, ctor, &err );
|
||||
g_message( "creating a gtorrent" );
|
||||
if( !err )
|
||||
tr_core_add_torrent( core, gtor );
|
||||
tr_core_add_torrent( core, gtor, doNotify );
|
||||
}
|
||||
tr_metainfoFree( &inf );
|
||||
break;
|
||||
|
@ -918,7 +922,7 @@ tr_core_add_metainfo( TrCore * core,
|
|||
err = tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
|
||||
|
||||
if( !err )
|
||||
err = add_ctor( core, ctor, do_prompt );
|
||||
err = add_ctor( core, ctor, do_prompt, TRUE );
|
||||
|
||||
tr_free( file_contents );
|
||||
tr_core_torrents_added( core );
|
||||
|
@ -932,7 +936,8 @@ static void
|
|||
add_filename( TrCore * core,
|
||||
const char * filename,
|
||||
gboolean doStart,
|
||||
gboolean doPrompt )
|
||||
gboolean doPrompt,
|
||||
gboolean doNotify )
|
||||
{
|
||||
tr_session * session = tr_core_session( core );
|
||||
if( filename && session )
|
||||
|
@ -943,7 +948,7 @@ add_filename( TrCore * core,
|
|||
tr_ctorSetPaused( ctor, TR_FORCE, !doStart );
|
||||
tr_ctorSetMetainfoFromFile( ctor, filename );
|
||||
|
||||
err = add_ctor( core, ctor, doPrompt );
|
||||
err = add_ctor( core, ctor, doPrompt, doNotify );
|
||||
if( err == TR_EINVALID )
|
||||
tr_core_errsig( core, TR_EINVALID, filename );
|
||||
}
|
||||
|
@ -960,17 +965,18 @@ tr_core_present_window( TrCore * core UNUSED,
|
|||
}
|
||||
|
||||
void
|
||||
tr_core_add_list( TrCore * core,
|
||||
GSList * torrentFiles,
|
||||
pref_flag_t start,
|
||||
pref_flag_t prompt )
|
||||
tr_core_add_list( TrCore * core,
|
||||
GSList * torrentFiles,
|
||||
pref_flag_t start,
|
||||
pref_flag_t prompt,
|
||||
gboolean doNotify )
|
||||
{
|
||||
const gboolean doStart = pref_flag_eval( start, PREF_KEY_START );
|
||||
const gboolean doPrompt = pref_flag_eval( prompt, PREF_KEY_OPTIONS_PROMPT );
|
||||
GSList * l;
|
||||
|
||||
for( l = torrentFiles; l != NULL; l = l->next )
|
||||
add_filename( core, l->data, doStart, doPrompt );
|
||||
add_filename( core, l->data, doStart, doPrompt, doNotify );
|
||||
|
||||
tr_core_torrents_added( core );
|
||||
freestrlist( torrentFiles );
|
||||
|
|
|
@ -134,10 +134,11 @@ int tr_core_load( TrCore * self,
|
|||
void tr_core_add_list( TrCore * self,
|
||||
GSList * torrentFiles,
|
||||
pref_flag_t start,
|
||||
pref_flag_t prompt );
|
||||
pref_flag_t prompt,
|
||||
gboolean doNotify );
|
||||
|
||||
#define tr_core_add_list_defaults( c, l ) \
|
||||
tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT )
|
||||
#define tr_core_add_list_defaults( c, l, doNotify ) \
|
||||
tr_core_add_list( c, l, PREF_FLAG_DEFAULT, PREF_FLAG_DEFAULT, doNotify )
|
||||
|
||||
|
||||
/** @brief Add a torrent. */
|
||||
|
@ -147,7 +148,7 @@ gboolean tr_core_add_metainfo( TrCore * core,
|
|||
GError ** err );
|
||||
|
||||
/** Add a torrent. */
|
||||
void tr_core_add_torrent( TrCore*, TrTorrent* );
|
||||
void tr_core_add_torrent( TrCore*, TrTorrent*, gboolean doNotify );
|
||||
|
||||
/** Present the main window */
|
||||
gboolean tr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );
|
||||
|
|
|
@ -538,12 +538,16 @@ peerPage( GObject * core )
|
|||
w = new_encryption_combo( core, "encryption" );
|
||||
hig_workarea_add_row( t, &row, s, w, NULL );
|
||||
|
||||
s = _( "Use peer e_xchange (PEX)" );
|
||||
s = _( "Use PE_X to find more peers" );
|
||||
w = new_check_button( s, TR_PREFS_KEY_PEX_ENABLED, core );
|
||||
s = _( "PEX is a tool for exchanging peer lists with the peers you're connected to." );
|
||||
gtr_widget_set_tooltip_text( w, s );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
|
||||
s = _( "Use _distributed hash table (DHT)" );
|
||||
s = _( "Use _DHT to find more peers" );
|
||||
w = new_check_button( s, TR_PREFS_KEY_DHT_ENABLED, core );
|
||||
s = _( "DHT is a tool for finding peers without a tracker." );
|
||||
gtr_widget_set_tooltip_text( w, s );
|
||||
hig_workarea_add_wide_control( t, &row, w );
|
||||
|
||||
hig_workarea_finish( t, &row );
|
||||
|
|
Loading…
Add table
Reference in a new issue