(gtk) #826: Transmission doesn't open torrents via web browser
This commit is contained in:
parent
12a10f514f
commit
50dcfb2ba0
|
@ -139,34 +139,52 @@ updateTorrent( struct AddData * o )
|
||||||
file_list_set_torrent( o->list, o->gtor );
|
file_list_set_torrent( o->list, o->gtor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the source .torrent file is deleted
|
||||||
|
* (such as, if it was a temp file that a web browser passed to us),
|
||||||
|
* gtk invokes this callback and `filename' will be NULL.
|
||||||
|
* The `filename' tests here are to prevent us from losing the current
|
||||||
|
* metadata when that happens.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
sourceChanged( GtkFileChooserButton * b, gpointer gdata )
|
sourceChanged( GtkFileChooserButton * b, gpointer gdata )
|
||||||
{
|
{
|
||||||
struct AddData * data = gdata;
|
struct AddData * data = gdata;
|
||||||
|
char * filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );
|
||||||
removeOldTorrent( data );
|
|
||||||
|
|
||||||
g_free( data->filename );
|
|
||||||
data->filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );
|
|
||||||
|
|
||||||
/* maybe instantiate a torrent */
|
/* maybe instantiate a torrent */
|
||||||
if( data->filename ) {
|
if( data->filename || !data->gtor )
|
||||||
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
int new_file = 0;
|
||||||
tr_torrent * torrent;
|
tr_torrent * torrent;
|
||||||
tr_handle * handle = tr_core_handle( data->core );
|
tr_handle * handle = tr_core_handle( data->core );
|
||||||
|
|
||||||
|
if( filename && ( !data->filename || strcmp( filename, data->filename ) ) )
|
||||||
|
{
|
||||||
|
g_free( data->filename );
|
||||||
|
data->filename = g_strdup( filename );
|
||||||
tr_ctorSetMetainfoFromFile( data->ctor, data->filename );
|
tr_ctorSetMetainfoFromFile( data->ctor, data->filename );
|
||||||
|
new_file = 1;
|
||||||
|
}
|
||||||
|
|
||||||
tr_ctorSetDownloadDir( data->ctor, TR_FORCE, data->downloadDir );
|
tr_ctorSetDownloadDir( data->ctor, TR_FORCE, data->downloadDir );
|
||||||
tr_ctorSetPaused( data->ctor, TR_FORCE, TRUE );
|
tr_ctorSetPaused( data->ctor, TR_FORCE, TRUE );
|
||||||
tr_ctorSetDeleteSource( data->ctor, FALSE );
|
tr_ctorSetDeleteSource( data->ctor, FALSE );
|
||||||
if(( torrent = tr_torrentNew( handle, data->ctor, &err )))
|
|
||||||
|
if(( torrent = tr_torrentNew( handle, data->ctor, &err ))) {
|
||||||
|
removeOldTorrent( data );
|
||||||
data->gtor = tr_torrent_new_preexisting( torrent );
|
data->gtor = tr_torrent_new_preexisting( torrent );
|
||||||
else
|
} else if( new_file ) {
|
||||||
addTorrentErrorDialog( GTK_WIDGET(b), err, data->filename );
|
addTorrentErrorDialog( GTK_WIDGET(b), err, data->filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTorrent( data );
|
updateTorrent( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free( filename );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
verifyRequested( GtkButton * button UNUSED, gpointer gdata )
|
verifyRequested( GtkButton * button UNUSED, gpointer gdata )
|
||||||
{
|
{
|
||||||
|
@ -179,15 +197,18 @@ static void
|
||||||
downloadDirChanged( GtkFileChooserButton * b, gpointer gdata )
|
downloadDirChanged( GtkFileChooserButton * b, gpointer gdata )
|
||||||
{
|
{
|
||||||
char * fname = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );
|
char * fname = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );
|
||||||
if( fname )
|
|
||||||
{
|
|
||||||
struct AddData * data = gdata;
|
struct AddData * data = gdata;
|
||||||
|
|
||||||
|
if( fname && ( !data->downloadDir || strcmp( fname, data->downloadDir ) ) )
|
||||||
|
{
|
||||||
g_free( data->downloadDir );
|
g_free( data->downloadDir );
|
||||||
data->downloadDir = fname;
|
data->downloadDir = g_strdup( fname );
|
||||||
|
|
||||||
updateTorrent( data );
|
updateTorrent( data );
|
||||||
verifyRequested( NULL, data );
|
verifyRequested( NULL, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free( fname );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue