Changeset 2519


Ignore:
Timestamp:
Jul 27, 2007, 11:09:09 PM (15 years ago)
Author:
charles
Message:

lots of work on getting basic functionality up and running.

Location:
trunk/wx
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wx/Makefile.am

    r2469 r2519  
    66
    77Xmission_SOURCES = \
    8     xmission.cc \
     8    speed-stats.cc \
    99    torrent-filter.cc \
    10     torrent-list.cc
     10    torrent-list.cc \
     11    torrent-stats.cc \
     12    xmission.cc
    1113
    1214Xmission_LDADD = ../libtransmission/libtransmission.a @WX_LIBS@ $(PTHREAD_LIBS) -lm
  • trunk/wx/torrent-list.cc

    r2504 r2519  
    2020    {
    2121        COL_POSITION,
    22         COL_DONE,
     22        COL_PERCENT_DONE,
    2323        COL_DOWNLOAD_SPEED,
    2424        COL_ETA,
     
    6868        {
    6969            columns[_T("position")]        = COL_POSITION;
    70             columns[_T("done")]            = COL_DONE;
     70            columns[_T("done")]            = COL_PERCENT_DONE;
    7171            columns[_T("download-speed")]  = COL_DOWNLOAD_SPEED;
    7272            columns[_T("eta")]             = COL_ETA;
     
    133133        int i;
    134134        static const char *sizestrs[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
    135         for ( i=0; size>>10; ++i ) size = size>>10;
     135        for ( i=0; size>>10; ++i )
     136            size = size >> 10;
    136137        char buf[512];
    137138        snprintf( buf, sizeof(buf), "%.*f %s", bestDecimal(size), (double)size, sizestrs[i] );
     
    144145    }
    145146
    146     wxString getReadableSpeed( float f )
    147     {
    148         wxString xstr = getReadableSize(f);
     147    wxString getReadableSpeed( float kib_sec )
     148    {
     149        wxString xstr = getReadableSize(1024*kib_sec);
    149150        xstr += _T("/s");
    150151        return xstr;
     
    176177                                    const wxPoint     & pos,
    177178                                    const wxSize      & size):
    178     wxListCtrl( parent, TORRENT_LIST_CTRL, pos, size, wxLC_REPORT ),
     179    wxListCtrl( parent, TORRENT_LIST_CTRL, pos, size, wxLC_REPORT|wxLC_HRULES ),
    179180    myHandle( handle ),
    180181    myConfig( config )
     
    217218                break;
    218219
    219             case COL_DONE:
     220            case COL_PERCENT_DONE:
    220221                snprintf( buf, sizeof(buf), "%d%%", (int)(s->percentDone*100.0) );
    221222                xstr = toWxStr( buf );
    222223                break;
    223224
    224             case COL_DOWNLOAD_SPEED: break;
     225            case COL_DOWNLOAD_SPEED:
    225226                if( s->rateDownload > 0.01 )
    226227                    xstr = getReadableSpeed( s->rateDownload );
     
    248249            case COL_PEERS:
    249250                /* FIXME: this is all peers, not just leechers */
    250                 snprintf( buf, sizeof(buf), "%d (%d)", s->peersTotal, s->peersConnected );
    251                 xstr = toWxStr( buf );
     251                xstr = wxString::Format( _("%d of %d"), s->peersConnected, s->peersTotal );
    252252                break;
    253253
     
    284284                    case TR_STATUS_STOPPING:    xstr = _("Stopping"); break;
    285285                    case TR_STATUS_STOPPED:     xstr = _("Stopped"); break;
    286                     case TR_STATUS_CHECK:       xstr = _("Checking Files"); break;
     286                    case TR_STATUS_CHECK:       xstr = wxString::Format ( _("Checking Files (%.0f)"), s->recheckProgress ); break;
    287287                    case TR_STATUS_CHECK_WAIT:  xstr = _("Waiting to Check"); break;
    288288                    case TR_STATUS_DOWNLOAD:    xstr = _("Downloading"); break;
     
    389389            break;
    390390
    391         case COL_DONE:
     391        case COL_PERCENT_DONE:
    392392            if( sa->percentDone < sb->percentDone )
    393393                ret = -1;
     
    582582        {
    583583            case COL_POSITION:        h = _("#"); format = wxLIST_FORMAT_CENTRE; break;
    584             case COL_DONE:            h = _("Done"); format = wxLIST_FORMAT_RIGHT; break;
    585             case COL_DOWNLOAD_SPEED:  h = _("Down"); width = 50; format = wxLIST_FORMAT_RIGHT; break;
     584            case COL_PERCENT_DONE:    h = _("Done"); width = 50; format = wxLIST_FORMAT_RIGHT; break;
     585            case COL_DOWNLOAD_SPEED:  h = _("Down"); width = 80; format = wxLIST_FORMAT_RIGHT; break;
    586586            case COL_ETA:             h = _("ETA"); format = wxLIST_FORMAT_RIGHT; break;
    587             case COL_HASH:            h = _("SHA1 Hash"); break;
     587            case COL_HASH:            h = _("Checksum"); break;
    588588            case COL_NAME:            h = _("Name"); width = 500; break;
    589589            case COL_PEERS:           h = _("Peers"); format = wxLIST_FORMAT_RIGHT; break;
     
    597597            case COL_STATUS:          h = _("Status"); width = 120; break;
    598598            case COL_TOTAL:           h = _("Total"); break;
    599             case COL_UPLOAD_SPEED:    h = _("Up"); width = 50; format = wxLIST_FORMAT_RIGHT;break;
     599            case COL_UPLOAD_SPEED:    h = _("Up"); width = 80; format = wxLIST_FORMAT_RIGHT;break;
    600600            default:                  h = _("Error"); break;
    601601        }
     
    677677    return ts.stat;
    678678}
     679
     680/***
     681****
     682***/
     683
     684void
     685TorrentListCtrl :: SelectAll( )
     686{
     687    for( int i=0, n=GetItemCount(); i<n; ++i )
     688        SetItemState( i, ~0, wxLIST_STATE_SELECTED );
     689}
     690
     691void
     692TorrentListCtrl :: DeselectAll( )
     693{
     694    for( int i=0, n=GetItemCount(); i<n; ++i )
     695        SetItemState( i, 0, wxLIST_STATE_SELECTED );
     696}
     697
  • trunk/wx/torrent-list.h

    r2502 r2519  
    7575        void Repopulate ();
    7676        void Refresh ();
     77        void SelectAll ();
     78        void DeselectAll ();
    7779
    7880    public:
  • trunk/wx/xmission.cc

    r2504 r2519  
    1414#include <vector>
    1515#include <iostream>
     16
    1617#include <stdint.h>
     18
    1719#include <wx/artprov.h>
    1820#include <wx/bitmap.h>
     21#include <wx/cmdline.h>
     22#include <wx/config.h>
     23#include <wx/dcmemory.h>
    1924#include <wx/defs.h>
    20 #include <wx/config.h>
     25#include <wx/filename.h>
    2126#include <wx/image.h>
    2227#include <wx/intl.h>
    2328#include <wx/listctrl.h>
    2429#include <wx/notebook.h>
     30#include <wx/snglinst.h>
    2531#include <wx/splitter.h>
    2632#include <wx/taskbar.h>
     
    4551}
    4652
     53#include "foreach.h"
     54#include "speed-stats.h"
    4755#include "torrent-filter.h"
    4856#include "torrent-list.h"
     57#include "torrent-stats.h"
    4958
    5059/***
     
    8594    }
    8695
    87     wxString getReadableSpeed( float f )
    88     {
    89         wxString xstr = getReadableSize(f);
     96    wxString getReadableSpeed( float kib_sec )
     97    {
     98        wxString xstr = getReadableSize(1024*kib_sec);
    9099        xstr += _T("/s");
    91100        return xstr;
    92101    }
     102}
     103
     104namespace
     105{
     106    const wxCmdLineEntryDesc cmdLineDesc[] =
     107    {
     108        { wxCMD_LINE_SWITCH, _T("p"), _("pause"), _("pauses all the torrents on startup"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
     109        { wxCMD_LINE_NONE, NULL, NULL, NULL, wxCMD_LINE_VAL_STRING, 0 }
     110    };
    93111}
    94112
     
    100118{
    101119    virtual bool OnInit();
     120    virtual ~MyApp();
     121    wxSingleInstanceChecker * myChecker;
    102122};
    103123
    104124namespace
    105125{
    106     const char * destination = "/home/charles/torrents"; /*FIXME*/
    107 
    108126    tr_handle_t * handle = NULL;
    109127
     
    114132{
    115133public:
    116     MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
     134    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, bool paused);
    117135    virtual ~MyFrame();
    118136
     
    121139    void OnAbout( wxCommandEvent& );
    122140    void OnOpen( wxCommandEvent& );
     141    void OnFilterSelected( wxListEvent& );
     142
     143    void OnStart( wxCommandEvent& );
     144    void OnStartUpdate( wxUpdateUIEvent& );
     145
     146    void OnStop( wxCommandEvent& );
     147    void OnStopUpdate( wxUpdateUIEvent& );
     148
     149    void OnRemove( wxCommandEvent& );
     150    void OnRemoveUpdate( wxUpdateUIEvent& );
     151
    123152    void OnRecheck( wxCommandEvent& );
    124     void OnTimer( wxTimerEvent& );
    125     void OnFilterSelected( wxListEvent& );
    126     void OnStartUpdate( wxUpdateUIEvent& );
    127     void OnStopUpdate( wxUpdateUIEvent& );
    128     void OnRemoveUpdate( wxUpdateUIEvent& );
    129     void OnRefreshUpdate( wxUpdateUIEvent& );
     153    void OnRecheckUpdate( wxUpdateUIEvent& );
     154
     155    void OnInfo( wxCommandEvent& );
    130156    void OnInfoUpdate( wxUpdateUIEvent& );
     157
     158    void OnSelectAll( wxCommandEvent& );
     159    void OnSelectAllUpdate( wxUpdateUIEvent& );
     160    void OnDeselectAll( wxCommandEvent& );
     161    void OnDeselectAllUpdate( wxUpdateUIEvent& );
     162
     163    void OnPulse( wxTimerEvent& );
     164
    131165    virtual void OnTorrentListSelectionChanged( TorrentListCtrl*, const std::set<tr_torrent_t*>& );
    132166
     
    141175private:
    142176    TorrentListCtrl * myTorrentList;
     177    TorrentStats * myTorrentStats;
    143178    wxListCtrl * myFilters;
    144179    wxTaskBarIcon myTrayIcon;
    145180    wxIcon myLogoIcon;
    146181    wxIcon myTrayIconIcon;
     182    SpeedStats * mySpeedStats;
    147183    torrents_v myTorrents;
    148184    torrents_v mySelectedTorrents;
    149185    int myFilter;
     186    std::string mySavePath;
     187    time_t myExitTime;
    150188
    151189private:
     
    156194{
    157195    ID_START,
     196    ID_DESELECTALL,
    158197    ID_EDIT_PREFS,
    159198    ID_SHOW_DEBUG_WINDOW,
     
    163202
    164203BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     204    EVT_MENU     ( wxID_ABOUT, MyFrame::OnAbout )
     205    EVT_TIMER    ( ID_Pulse, MyFrame::OnPulse )
    165206    EVT_LIST_ITEM_SELECTED( ID_Filter, MyFrame::OnFilterSelected )
    166     EVT_MENU( wxID_REFRESH, MyFrame::OnRecheck )
     207    EVT_MENU     ( wxID_EXIT, MyFrame::OnExit )
     208    EVT_MENU     ( wxID_OPEN, MyFrame::OnOpen )
     209    EVT_MENU     ( ID_START, MyFrame::OnStart )
    167210    EVT_UPDATE_UI( ID_START, MyFrame::OnStartUpdate )
     211    EVT_MENU     ( wxID_STOP, MyFrame::OnStop )
    168212    EVT_UPDATE_UI( wxID_STOP, MyFrame::OnStopUpdate )
     213    EVT_MENU     ( wxID_REFRESH, MyFrame::OnRecheck )
     214    EVT_UPDATE_UI( wxID_REFRESH, MyFrame::OnRecheckUpdate )
     215    EVT_MENU     ( wxID_REMOVE, MyFrame::OnRemove )
    169216    EVT_UPDATE_UI( wxID_REMOVE, MyFrame::OnRemoveUpdate )
    170     EVT_UPDATE_UI( wxID_REFRESH, MyFrame::OnRefreshUpdate )
     217    EVT_MENU     ( wxID_PROPERTIES, MyFrame::OnInfo )
    171218    EVT_UPDATE_UI( wxID_PROPERTIES, MyFrame::OnInfoUpdate )
     219    EVT_MENU     ( wxID_SELECTALL, MyFrame::OnSelectAll )
     220    EVT_UPDATE_UI( wxID_SELECTALL, MyFrame::OnSelectAllUpdate )
     221    EVT_MENU     ( ID_DESELECTALL, MyFrame::OnDeselectAll )
     222    EVT_UPDATE_UI( ID_DESELECTALL, MyFrame::OnDeselectAllUpdate )
    172223END_EVENT_TABLE()
    173224
    174225IMPLEMENT_APP(MyApp)
    175226
     227
     228void
     229MyFrame :: OnSelectAll( wxCommandEvent& )
     230{
     231    myTorrentList->SelectAll( );
     232}
     233
     234void
     235MyFrame :: OnSelectAllUpdate( wxUpdateUIEvent& event )
     236{
     237    event.Enable( mySelectedTorrents.size() < myTorrents.size() );
     238}
     239
     240void
     241MyFrame :: OnDeselectAll( wxCommandEvent& )
     242{
     243    myTorrentList->DeselectAll ( );
     244}
     245
     246void
     247MyFrame :: OnDeselectAllUpdate( wxUpdateUIEvent& event )
     248{
     249    event.Enable( !mySelectedTorrents.empty() );
     250}
     251
     252/**
     253**/
     254
    176255void
    177256MyFrame :: OnStartUpdate( wxUpdateUIEvent& event )
    178257{
    179258    unsigned long l = 0;
    180     for( torrents_v::iterator it(mySelectedTorrents.begin()),
    181                              end(mySelectedTorrents.end()); it!=end; ++it )
     259    foreach( torrents_v, mySelectedTorrents, it )
    182260        l |= tr_torrentStat(*it)->status; /* FIXME: expensive */
    183261    event.Enable( (l & TR_STATUS_INACTIVE)!=0 );
    184262}
     263void
     264MyFrame :: OnStart( wxCommandEvent& WXUNUSED(unused) )
     265{
     266    foreach( torrents_v, mySelectedTorrents, it )
     267        if( tr_torrentStat(*it)->status & TR_STATUS_INACTIVE )
     268            tr_torrentStart( *it );
     269}
     270
     271/**
     272**/
    185273
    186274void
     
    188276{
    189277    unsigned long l = 0;
    190     for( torrents_v::iterator it(mySelectedTorrents.begin()),
    191                              end(mySelectedTorrents.end()); it!=end; ++it )
     278    foreach( torrents_v, mySelectedTorrents, it )
    192279        l |= tr_torrentStat(*it)->status; /* FIXME: expensive */
    193280    event.Enable( (l & TR_STATUS_ACTIVE)!=0 );
    194281}
     282void
     283MyFrame :: OnStop( wxCommandEvent& WXUNUSED(unused) )
     284{
     285    foreach( torrents_v, mySelectedTorrents, it )
     286        if( tr_torrentStat(*it)->status & TR_STATUS_ACTIVE )
     287            tr_torrentStop( *it );
     288}
     289
     290/**
     291**/
    195292
    196293void
    197294MyFrame :: OnRemoveUpdate( wxUpdateUIEvent& event )
    198295{
     296    event.Enable( !mySelectedTorrents.empty() );
     297}
     298void
     299MyFrame :: OnRemove( wxCommandEvent& WXUNUSED(unused) )
     300{
     301    foreach( torrents_v, mySelectedTorrents, it ) {
     302        tr_torrentRemoveSaved( *it );
     303        tr_torrentClose( *it );
     304    }
     305}
     306
     307/**
     308**/
     309
     310void
     311MyFrame :: OnRecheckUpdate( wxUpdateUIEvent& event )
     312{
    199313   event.Enable( !mySelectedTorrents.empty() );
    200314}
    201315void
    202 MyFrame :: OnRefreshUpdate( wxUpdateUIEvent& event )
     316MyFrame :: OnRecheck( wxCommandEvent& WXUNUSED(unused) )
     317{
     318    foreach( torrents_v, mySelectedTorrents, it )
     319        tr_torrentRecheck( *it );
     320}
     321
     322/**
     323**/
     324
     325void
     326MyFrame :: OnInfoUpdate( wxUpdateUIEvent& event )
    203327{
    204328   event.Enable( !mySelectedTorrents.empty() );
    205329}
    206330void
    207 MyFrame :: OnInfoUpdate( wxUpdateUIEvent& event )
    208 {
    209    event.Enable( !mySelectedTorrents.empty() );
    210 }
     331MyFrame :: OnInfo( wxCommandEvent& WXUNUSED(unused) )
     332{
     333    std::cerr << "FIXME: info" << std::endl;
     334}
     335
     336/**
     337**/
    211338
    212339void MyFrame :: OnOpen( wxCommandEvent& WXUNUSED(event) )
     
    231358            tr_torrent_t * tor = tr_torrentInit( handle,
    232359                                                 filename.c_str(),
    233                                                  destination,
     360                                                 mySavePath.c_str(),
    234361                                                 0, NULL );
    235362            if( tor )
     
    249376    handle = tr_init( "wx" );
    250377
     378    wxCmdLineParser cmdParser( cmdLineDesc, argc, argv );
     379    if( cmdParser.Parse ( ) )
     380        return false;
     381
     382    const wxString name = wxString::Format( _T("MyApp-%s"), wxGetUserId().c_str());
     383    myChecker = new wxSingleInstanceChecker( name );
     384    if ( myChecker->IsAnotherRunning() ) {
     385        wxLogError(_("An instance of Transmission is already running."));
     386        return false;
     387    }
     388
     389    const bool paused = cmdParser.Found( _("p") );
     390
    251391    MyFrame * frame = new MyFrame( _T("Xmission"),
    252392                                   wxPoint(50,50),
    253                                    wxSize(900,600));
    254 
    255     frame->Connect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnOpen );
    256     frame->Connect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnAbout );
    257     frame->Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnExit );
    258     frame->Connect( ID_Pulse, wxEVT_TIMER, (wxObjectEventFunction) &MyFrame::OnTimer );
     393                                   wxSize(900,600),
     394                                   paused);
    259395
    260396    frame->Show( true );
    261397    SetTopWindow( frame );
    262398    return true;
     399}
     400
     401MyApp :: ~MyApp()
     402{
     403    delete myChecker;
    263404}
    264405
     
    295436}
    296437
    297 void
    298 MyFrame :: OnRecheck( wxCommandEvent& WXUNUSED(unused) )
    299 {
    300     for( torrents_v::iterator it(mySelectedTorrents.begin()),
    301                              end(mySelectedTorrents.end()); it!=end; ++it )
    302         tr_torrentRecheck( *it );
    303 }
    304438
    305439void
     
    312446
    313447void
    314 MyFrame :: OnTimer(wxTimerEvent& WXUNUSED(event) )
    315 {
     448MyFrame :: OnPulse(wxTimerEvent& WXUNUSED(event) )
     449{
     450    if( myExitTime ) {
     451        std::cerr << __FILE__ << ':' << __LINE__ << ' ' << tr_torrentCount(handle) << " torrents left" << std::endl;
     452        if ( !tr_torrentCount(handle) ||  myExitTime<time(0) ) {
     453            Destroy( );
     454            return;
     455        }
     456    }
     457
    316458    RefreshFilterCounts( );
    317459
     460    mySpeedStats->Update( handle );
     461
     462    float down, up;
     463    tr_torrentRates( handle, &down, &up );
     464    wxString xstr = _("Total DL: ");
     465    xstr += getReadableSpeed( down );
     466    SetStatusText( xstr, 1 );
     467    xstr = _("Total UL: ");
     468    xstr += getReadableSpeed( up );
     469    SetStatusText( xstr, 2 );
     470
     471    xstr = _("Download: ");
     472    xstr += getReadableSpeed( down );
     473    xstr += _T("\n");
     474    xstr +=_("Upload: ");
     475    xstr +=  getReadableSpeed( up );
     476    myTrayIcon.SetIcon( myTrayIconIcon, xstr );
     477
    318478    myTorrentList->Refresh ( );
    319 
    320     float dl, ul;
    321     tr_torrentRates( handle, &dl, &ul );
    322     wxString s = _("Download: ");
    323     s += getReadableSpeed( dl );
    324     s += _T("\n");
    325     s +=_("Upload: ");
    326     s +=  getReadableSpeed( ul );
    327     myTrayIcon.SetIcon( myTrayIconIcon, s );
    328479}
    329480
     
    336487}
    337488
    338 MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size):
     489MyFrame :: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, bool paused):
    339490    wxFrame((wxFrame*)NULL,-1,title,pos,size),
    340491    myConfig( new wxConfig( _T("xmission") ) ),
     
    342493    myLogoIcon( transmission_xpm ),
    343494    myTrayIconIcon( systray_xpm ),
    344     myFilter( TorrentFilter::SHOW_ALL )
     495    myFilter( TorrentFilter::SHOW_ALL ),
     496    myExitTime( 0 )
    345497{
    346498    SetIcon( myLogoIcon );
     499
     500    long port;
     501    wxString key = _T("port");
     502    if( !myConfig->Read( key, &port, 9090 ) )
     503        myConfig->Write( key, port );
     504    tr_setBindPort( handle, port );
     505
     506    key = _T("save-path");
     507    wxString wxstr;
     508    if( !myConfig->Read( key, &wxstr, wxFileName::GetHomeDir() ) )
     509        myConfig->Write( key, wxstr );
     510    mySavePath = toStr( wxstr );
     511    std::cerr << __FILE__ << ':' << __LINE__ << " save-path is [" << mySavePath << ']' << std::endl;
    347512
    348513    /**
     
    366531
    367532    m = new wxMenu;
     533    m->Append( wxID_SELECTALL, _T("Select &All") );
     534    m->Append( ID_DESELECTALL, _T("&Deselect All") );
     535    m->AppendSeparator();
    368536    m->Append( wxID_PROPERTIES, _T("Torrent &Info") );
    369537    m->Append( wxID_PREFERENCES, _T("Edit &Preferences") );
     
    434602
    435603    wxNotebook * notebook = new wxNotebook( hsplit, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
    436     wxButton * tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
    437     notebook->AddPage( tmp, _T("General"), false );
     604    myTorrentStats = new TorrentStats( notebook );
     605    notebook->AddPage( myTorrentStats, _T("General"), false );
     606    wxButton * tmp = new wxButton( notebook, wxID_ANY, _T("Hello &World"));
     607    notebook->AddPage( tmp, _T("Peers") );
     608    tmp = new wxButton( notebook, wxID_ANY, _T("&Hello World"));
     609    notebook->AddPage( tmp, _T("Pieces") );
    438610    tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
    439     notebook->AddPage( tmp, _T("Peers"), false );
     611    notebook->AddPage( tmp, _T("Files") );
     612    mySpeedStats = new SpeedStats( notebook, wxID_ANY );
     613    notebook->AddPage( mySpeedStats, _T("Speed"), true );
    440614    tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
    441     notebook->AddPage( tmp, _T("Pieces"), false );
    442     tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
    443     notebook->AddPage( tmp, _T("Files"), false );
    444     tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
    445     notebook->AddPage( tmp, _T("Logger"), false );
     615    notebook->AddPage( tmp, _T("Logger") );
    446616
    447617    hsplit->SplitHorizontally( row1, notebook );
     
    451621    **/
    452622
    453     CreateStatusBar();
    454     SetStatusText(_T("Welcome to Xmission!"));
     623    const int widths[] = { -1, 150, 150 };
     624    wxStatusBar * statusBar = CreateStatusBar( WXSIZEOF(widths) );
     625    SetStatusWidths( WXSIZEOF(widths), widths );
     626    const int styles[] = { wxSB_FLAT, wxSB_NORMAL, wxSB_NORMAL };
     627    statusBar->SetStatusStyles(  WXSIZEOF(widths), styles );
    455628
    456629    /**
     
    464637    **/
    465638
    466     const int flags = TR_FLAG_PAUSED;
     639    int flags = 0;
     640    if( paused )
     641        flags |= TR_FLAG_PAUSED;
    467642    int count = 0;
    468     tr_torrent_t ** torrents = tr_loadTorrents ( handle, destination, flags, &count );
     643    tr_torrent_t ** torrents = tr_loadTorrents ( handle, mySavePath.c_str(), flags, &count );
    469644    myTorrents.insert( myTorrents.end(), torrents, torrents+count );
    470645    myTorrentList->Add( myTorrents );
     
    472647
    473648    wxTimerEvent dummy;
    474     OnTimer( dummy );
     649    OnPulse( dummy );
    475650}
    476651
    477652void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
    478653{
    479     Destroy( );
     654    Enable( false );
     655
     656    foreach( torrents_v, myTorrents, it )
     657        tr_torrentClose( *it );
     658
     659    myTorrents.clear ();
     660    mySelectedTorrents.clear ();
     661
     662    ApplyCurrentFilter ();
     663
     664    /* give the connections a max of 10 seconds to shut themselves down */
     665    myExitTime = time(0) + 10;
    480666}
    481667
Note: See TracChangeset for help on using the changeset viewer.