Changeset 6285


Ignore:
Timestamp:
Jul 2, 2008, 6:49:07 PM (13 years ago)
Author:
charles
Message:

(gtk) #1063: don't inhibit power management when torrents are paused

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r6165 r6285  
    4646#include "util.h"
    4747
    48 static void tr_core_set_hibernation_allowed( TrCore * core, gboolean allowed );
     48static void maybeInhibitHibernation( TrCore * core );
    4949
    5050static gboolean our_instance_adds_remote_torrents = FALSE;
     
    502502    else if( !strcmp( key, PREF_KEY_ALLOW_HIBERNATION ) )
    503503    {
    504         tr_core_set_hibernation_allowed( core, pref_flag_get( key ) );
     504        maybeInhibitHibernation( core );
    505505    }
    506506#ifdef HAVE_GIO
     
    907907    /* resume sorting */
    908908    gtk_tree_sortable_set_sort_column_id( sortable, column, order );
     909
     910    /* maybe inhibit hibernation */
     911    maybeInhibitHibernation( self );
    909912}
    910913
     
    994997#endif
    995998
    996 
    997 void
     999static void
    9981000tr_core_set_hibernation_allowed( TrCore * core, gboolean allowed )
    9991001{
     
    10171019}
    10181020
     1021static void
     1022maybeInhibitHibernation( TrCore * core )
     1023{
     1024    gboolean allowHibernation;
     1025    tr_handle * session = tr_core_handle( core );
     1026
     1027    /* allow hibernation unless we have active torrents */
     1028    allowHibernation = TRUE;
     1029    tr_torrent * tor = NULL;
     1030    while(( tor = tr_torrentNext( session, tor ))) {
     1031        if( tr_torrentGetStatus( tor ) != TR_STATUS_STOPPED ) {
     1032            allowHibernation = FALSE;
     1033            break;
     1034        }
     1035    }
     1036
     1037    /* even if we do have active torrents,
     1038     * maybe allow hibernation anyway... */
     1039    if( !allowHibernation )
     1040        allowHibernation = pref_flag_get( PREF_KEY_ALLOW_HIBERNATION );
     1041
     1042    tr_core_set_hibernation_allowed( core, allowHibernation );
     1043}
     1044
    10191045/**
    10201046***  Prefs
  • trunk/gtk/tr-prefs.c

    r6162 r6285  
    5353
    5454    pref_int_set_default    ( PREF_KEY_PEER_SOCKET_TOS, TR_DEFAULT_PEER_SOCKET_TOS );
    55     pref_flag_set_default   ( PREF_KEY_ALLOW_HIBERNATION, TRUE );
     55    pref_flag_set_default   ( PREF_KEY_ALLOW_HIBERNATION, FALSE );
    5656    pref_flag_set_default   ( PREF_KEY_BLOCKLIST_ENABLED, TR_DEFAULT_BLOCKLIST_ENABLED );
    5757
  • trunk/gtk/tr-prefs.h

    r6166 r6285  
    2828#define PREF_KEY_DOWNLOAD_DIR           "download-dir"
    2929#define PREF_KEY_OPEN_DIALOG_FOLDER     "open-dialog-dir"
    30 #define PREF_KEY_ALLOW_HIBERNATION      "allow-hibernation"
     30#define PREF_KEY_ALLOW_HIBERNATION      "allow-hibernation-even-when-torrents-are-active"
    3131#define PREF_KEY_DIR_WATCH              "watch-dir"
    3232#define PREF_KEY_DIR_WATCH_ENABLED      "watch-dir-enabled"
Note: See TracChangeset for help on using the changeset viewer.