From: Charles Kerr Date: Wed, 2 Jul 2008 00:17:27 +0000 (+0000) Subject: (gtk) #1043: Include recent folders in the destination folder chooser X-Git-Tag: 1.31~161 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=435cbaf6b457bc043b6f59b8c7bcfe988b363fbf;p=transmission (gtk) #1043: Include recent folders in the destination folder chooser --- diff --git a/gtk/add-dialog.c b/gtk/add-dialog.c index 7301a5893..69953c32f 100644 --- a/gtk/add-dialog.c +++ b/gtk/add-dialog.c @@ -18,6 +18,67 @@ #include "hig.h" #include "tr-prefs.h" +/**** +***** +****/ + +#define N_RECENT 4 + +static GSList* +get_recent_destinations( void ) +{ + int i; + GSList * list = NULL; + for( i=0; inext ) + l->data = g_strdup( l->data ); + + /* save the first N_RECENT directories */ + for( l=list, i=0; l && (inext ) { + char key[64]; + g_snprintf( key, sizeof(key), "recent-download-dir-%d", i+1 ); + pref_string_set( key, l->data ); + } + pref_save( ); + + /* cleanup */ + g_slist_foreach( list, (GFunc)g_free, NULL ); + g_slist_free( list ); +} + +/**** +***** +****/ + struct AddData { TrCore * core; @@ -58,6 +119,7 @@ addResponseCB( GtkDialog * dialog, gint response, gpointer gdata ) tr_core_add_torrent( data->core, data->gtor ); if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->trash_check ) ) ) tr_file_trash_or_unlink( data->filename ); + save_recent_destination( data->downloadDir ); } } @@ -160,6 +222,8 @@ addSingleTorrentDialog( GtkWindow * parent, GtkWidget * l; struct AddData * data; uint8_t flag; + GSList * list; + GSList * walk; /* make the dialog */ d = gtk_dialog_new_with_buttons( _( "Torrent Options" ), parent, @@ -220,6 +284,10 @@ addSingleTorrentDialog( GtkWindow * parent, w = gtk_file_chooser_button_new( _( "Select Destination Folder" ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); if( !gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ), data->downloadDir ) ) g_warning( "couldn't select '%s'", data->downloadDir ); + list = get_recent_destinations( ); + for( walk=list; walk; walk=walk->next ) + gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( w ), walk->data, NULL ); + g_slist_free( list ); gtk_table_attach( GTK_TABLE( t ), w, col, col+1, row, row+1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w ); g_signal_connect( w, "selection-changed", G_CALLBACK( downloadDirChanged ), data );