mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
(trunk gtk) #4399 "Add option to disable 'trash can' feature" -- done.
This commit is contained in:
parent
6315db10f2
commit
a7a9c2b12e
3 changed files with 22 additions and 14 deletions
|
@ -86,6 +86,7 @@ tr_prefs_init_defaults( tr_benc * d )
|
|||
tr_bencDictAddBool( d, PREF_KEY_TOOLBAR, TRUE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_FILTERBAR, TRUE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_TRASH_CAN_ENABLED, TRUE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE );
|
||||
tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_PEER_INFO, FALSE );
|
||||
|
|
|
@ -48,6 +48,7 @@ GtkWidget * gtr_prefs_dialog_new( GtkWindow * parent, GObject * core );
|
|||
#define PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED "torrent-complete-notification-enabled"
|
||||
#define PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND "torrent-complete-sound-command"
|
||||
#define PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED "torrent-complete-sound-enabled"
|
||||
#define PREF_KEY_TRASH_CAN_ENABLED "trash-can-enabled"
|
||||
#define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT "user-has-given-informed-consent"
|
||||
|
||||
enum
|
||||
|
|
34
gtk/util.c
34
gtk/util.c
|
@ -25,7 +25,9 @@
|
|||
#include <libtransmission/web.h> /* tr_webResponseStr() */
|
||||
#include <libtransmission/version.h> /* SHORT_VERSION_STRING */
|
||||
|
||||
#include "conf.h"
|
||||
#include "hig.h"
|
||||
#include "tr-prefs.h"
|
||||
#include "util.h"
|
||||
|
||||
/***
|
||||
|
@ -297,24 +299,28 @@ on_tree_view_button_released( GtkWidget * view,
|
|||
int
|
||||
gtr_file_trash_or_remove( const char * filename )
|
||||
{
|
||||
if( filename && g_file_test( filename, G_FILE_TEST_EXISTS ) )
|
||||
{
|
||||
gboolean trashed = FALSE;
|
||||
GError * err = NULL;
|
||||
GFile * file = g_file_new_for_path( filename );
|
||||
trashed = g_file_trash( file, NULL, &err );
|
||||
if( err )
|
||||
g_message( "Unable to trash file \"%s\": %s", filename, err->message );
|
||||
g_clear_error( &err );
|
||||
g_object_unref( G_OBJECT( file ) );
|
||||
gboolean trashed = FALSE;
|
||||
GFile * file = g_file_new_for_path( filename );
|
||||
|
||||
if( !trashed && g_remove( filename ) )
|
||||
{
|
||||
const int err = errno;
|
||||
g_message( "Unable to remove file \"%s\": %s", filename, g_strerror( err ) );
|
||||
if( gtr_pref_flag_get( PREF_KEY_TRASH_CAN_ENABLED ) ) {
|
||||
GError * err = NULL;
|
||||
trashed = g_file_trash( file, NULL, &err );
|
||||
if( err ) {
|
||||
g_message( "Unable to trash file \"%s\": %s", filename, err->message );
|
||||
g_clear_error( &err );
|
||||
}
|
||||
}
|
||||
|
||||
if( !trashed ) {
|
||||
GError * err = NULL;
|
||||
trashed = g_file_delete( file, NULL, &err );
|
||||
if( err ) {
|
||||
g_message( "Unable to delete file \"%s\": %s", filename, err->message );
|
||||
g_clear_error( &err );
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref( G_OBJECT( file ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue