Changeset 12682


Ignore:
Timestamp:
Aug 13, 2011, 10:58:49 PM (10 years ago)
Author:
jordan
Message:

(trunk gtk) #4399 "Add option to disable 'trash can' feature" -- done.

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/conf.c

    r12656 r12682  
    8787    tr_bencDictAddBool( d, PREF_KEY_FILTERBAR, TRUE );
    8888    tr_bencDictAddBool( d, PREF_KEY_STATUSBAR, TRUE );
     89    tr_bencDictAddBool( d, PREF_KEY_TRASH_CAN_ENABLED, TRUE );
    8990    tr_bencDictAddBool( d, PREF_KEY_SHOW_TRAY_ICON, FALSE );
    9091    tr_bencDictAddBool( d, PREF_KEY_SHOW_MORE_TRACKER_INFO, FALSE );
  • trunk/gtk/tr-prefs.h

    r12578 r12682  
    4949#define PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND          "torrent-complete-sound-command"
    5050#define PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED          "torrent-complete-sound-enabled"
     51#define PREF_KEY_TRASH_CAN_ENABLED                       "trash-can-enabled"
    5152#define PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT         "user-has-given-informed-consent"
    5253
  • trunk/gtk/util.c

    r12676 r12682  
    2626#include <libtransmission/version.h> /* SHORT_VERSION_STRING */
    2727
     28#include "conf.h"
    2829#include "hig.h"
     30#include "tr-prefs.h"
    2931#include "util.h"
    3032
     
    298300gtr_file_trash_or_remove( const char * filename )
    299301{
    300     if( filename && g_file_test( filename, G_FILE_TEST_EXISTS ) )
    301     {
    302         gboolean trashed = FALSE;
     302    gboolean trashed = FALSE;
     303    GFile * file = g_file_new_for_path( filename );
     304
     305    if( gtr_pref_flag_get( PREF_KEY_TRASH_CAN_ENABLED ) ) {
    303306        GError * err = NULL;
    304         GFile *  file = g_file_new_for_path( filename );
    305307        trashed = g_file_trash( file, NULL, &err );
    306         if( err )
     308        if( err ) {
    307309            g_message( "Unable to trash file \"%s\": %s", filename, err->message );
    308         g_clear_error( &err );
    309         g_object_unref( G_OBJECT( file ) );
    310 
    311         if( !trashed && g_remove( filename ) )
    312         {
    313             const int err = errno;
    314             g_message( "Unable to remove file \"%s\": %s", filename, g_strerror( err ) );
     310            g_clear_error( &err );
    315311        }
    316312    }
    317313
     314    if( !trashed ) {
     315        GError * err = NULL;
     316        trashed = g_file_delete( file, NULL, &err );
     317        if( err ) {
     318            g_message( "Unable to delete file \"%s\": %s", filename, err->message );
     319            g_clear_error( &err );
     320        }
     321    }
     322
     323    g_object_unref( G_OBJECT( file ) );
    318324    return 0;
    319325}
Note: See TracChangeset for help on using the changeset viewer.