2007-07-19 20:35:01 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
|
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2007-07-19 14:06:50 +00:00
|
|
|
#include <iostream>
|
2007-07-22 02:24:13 +00:00
|
|
|
#include <stdint.h>
|
2007-07-19 14:06:50 +00:00
|
|
|
#include <wx/artprov.h>
|
2007-07-23 17:36:34 +00:00
|
|
|
#include <wx/bitmap.h>
|
2007-07-19 14:06:50 +00:00
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/config.h>
|
2007-07-23 17:36:34 +00:00
|
|
|
#include <wx/image.h>
|
2007-07-23 21:01:26 +00:00
|
|
|
#include <wx/intl.h>
|
2007-07-23 02:43:25 +00:00
|
|
|
#include <wx/listctrl.h>
|
2007-07-23 17:36:34 +00:00
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/splitter.h>
|
2007-07-23 05:43:16 +00:00
|
|
|
#include <wx/taskbar.h>
|
2007-07-19 14:06:50 +00:00
|
|
|
#include <wx/toolbar.h>
|
|
|
|
#include <wx/wx.h>
|
2007-07-20 02:12:07 +00:00
|
|
|
#if wxCHECK_VERSION(2,8,0)
|
|
|
|
#include <wx/aboutdlg.h>
|
|
|
|
#endif
|
2007-07-23 17:12:38 +00:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2007-07-19 14:06:50 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
2007-07-22 02:24:13 +00:00
|
|
|
#include <libtransmission/utils.h>
|
2007-07-23 17:12:38 +00:00
|
|
|
|
|
|
|
#include <images/exec.xpm>
|
|
|
|
#include <images/fileopen.xpm>
|
|
|
|
#include <images/gtk-properties.xpm>
|
|
|
|
#include <images/gtk-remove.xpm>
|
|
|
|
#include <images/stop.xpm>
|
|
|
|
#include <images/transmission.xpm>
|
2007-07-19 14:06:50 +00:00
|
|
|
}
|
2007-07-23 17:12:38 +00:00
|
|
|
|
2007-07-23 21:01:26 +00:00
|
|
|
#include "torrent-filter.h"
|
2007-07-23 15:20:47 +00:00
|
|
|
#include "torrent-list.h"
|
2007-07-19 14:06:50 +00:00
|
|
|
|
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
|
|
|
virtual bool OnInit();
|
|
|
|
};
|
|
|
|
|
2007-07-23 15:20:47 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
tr_handle_t * handle = NULL;
|
|
|
|
|
2007-07-23 21:01:26 +00:00
|
|
|
typedef std::vector<tr_torrent_t*> torrents_v;
|
2007-07-23 15:20:47 +00:00
|
|
|
}
|
2007-07-19 14:06:50 +00:00
|
|
|
|
2007-07-24 04:36:36 +00:00
|
|
|
class MyFrame : public wxFrame, public TorrentListCtrl::Listener
|
2007-07-19 14:06:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
|
|
|
virtual ~MyFrame();
|
2007-07-23 21:01:26 +00:00
|
|
|
|
|
|
|
public:
|
2007-07-23 15:20:47 +00:00
|
|
|
void OnQuit( wxCommandEvent& );
|
|
|
|
void OnAbout( wxCommandEvent& );
|
|
|
|
void OnOpen( wxCommandEvent& );
|
2007-07-24 04:36:36 +00:00
|
|
|
void OnRecheck( wxCommandEvent& );
|
2007-07-23 15:20:47 +00:00
|
|
|
void OnTimer( wxTimerEvent& );
|
2007-07-23 23:59:13 +00:00
|
|
|
void OnItemSelected( wxListEvent& );
|
2007-07-24 04:36:36 +00:00
|
|
|
virtual void OnTorrentListSelectionChanged( TorrentListCtrl*, const std::set<tr_torrent_t*>& );
|
2007-07-19 14:06:50 +00:00
|
|
|
|
2007-07-23 21:01:26 +00:00
|
|
|
private:
|
|
|
|
void RefreshFilterCounts( );
|
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
protected:
|
|
|
|
wxConfig * myConfig;
|
2007-07-22 19:37:43 +00:00
|
|
|
wxTimer myPulseTimer;
|
2007-07-19 20:35:01 +00:00
|
|
|
|
|
|
|
private:
|
2007-07-23 15:20:47 +00:00
|
|
|
TorrentListCtrl * myTorrentList;
|
2007-07-23 21:01:26 +00:00
|
|
|
wxListCtrl * myFilters;
|
2007-07-23 05:43:16 +00:00
|
|
|
wxTaskBarIcon * myTaskBarIcon;
|
|
|
|
wxIcon * myLogoIcon;
|
|
|
|
wxIcon * myTrayLogo;
|
2007-07-23 21:01:26 +00:00
|
|
|
torrents_v myTorrents;
|
2007-07-24 04:36:36 +00:00
|
|
|
torrents_v mySelectedTorrents;
|
2007-07-23 23:59:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-07-19 14:06:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_START,
|
|
|
|
ID_STOP,
|
|
|
|
ID_REMOVE,
|
|
|
|
ID_QUIT,
|
|
|
|
ID_TORRENT_INFO,
|
|
|
|
ID_EDIT_PREFS,
|
|
|
|
ID_SHOW_DEBUG_WINDOW,
|
|
|
|
ID_ABOUT,
|
2007-07-22 19:37:43 +00:00
|
|
|
ID_Pulse,
|
2007-07-23 23:59:13 +00:00
|
|
|
ID_Filter,
|
2007-07-19 14:06:50 +00:00
|
|
|
N_IDS
|
|
|
|
};
|
|
|
|
|
2007-07-23 23:59:13 +00:00
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
|
|
EVT_LIST_ITEM_SELECTED( ID_Filter, MyFrame::OnItemSelected )
|
2007-07-24 04:36:36 +00:00
|
|
|
EVT_MENU( wxID_REFRESH, MyFrame::OnRecheck )
|
2007-07-23 23:59:13 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
void MyFrame :: OnOpen( wxCommandEvent& event )
|
|
|
|
{
|
2007-07-23 15:33:04 +00:00
|
|
|
const wxString key = _T("prev-directory");
|
2007-07-19 14:06:50 +00:00
|
|
|
wxString directory;
|
|
|
|
myConfig->Read( key, &directory );
|
|
|
|
wxFileDialog * w = new wxFileDialog( this, _T("message"),
|
|
|
|
directory,
|
|
|
|
_T(""), /* default file */
|
|
|
|
_T("Torrent files|*.torrent"),
|
|
|
|
wxOPEN|wxMULTIPLE );
|
|
|
|
|
|
|
|
if( w->ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
wxArrayString paths;
|
|
|
|
w->GetPaths( paths );
|
|
|
|
size_t nPaths = paths.GetCount();
|
|
|
|
for( size_t i=0; i<nPaths; ++i )
|
|
|
|
{
|
|
|
|
const wxString& w = paths[i];
|
|
|
|
std::cerr << w.ToAscii() << std::endl;
|
|
|
|
}
|
|
|
|
myConfig->Write( key, w->GetDirectory() );
|
|
|
|
}
|
|
|
|
|
|
|
|
delete w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
|
|
|
handle = tr_init( "wx" );
|
|
|
|
|
2007-07-19 14:50:42 +00:00
|
|
|
MyFrame * frame = new MyFrame( _T("Xmission"),
|
2007-07-19 14:06:50 +00:00
|
|
|
wxPoint(50,50),
|
2007-07-23 15:20:47 +00:00
|
|
|
wxSize(900,600));
|
2007-07-19 14:06:50 +00:00
|
|
|
|
|
|
|
frame->Connect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnOpen );
|
|
|
|
frame->Connect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnAbout );
|
2007-07-23 05:43:16 +00:00
|
|
|
frame->Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) &MyFrame::OnQuit );
|
2007-07-22 19:37:43 +00:00
|
|
|
frame->Connect( ID_Pulse, wxEVT_TIMER, (wxObjectEventFunction) &MyFrame::OnTimer );
|
2007-07-19 14:06:50 +00:00
|
|
|
|
|
|
|
frame->Show( true );
|
|
|
|
SetTopWindow( frame );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
2007-07-19 20:35:01 +00:00
|
|
|
namespace
|
|
|
|
{
|
2007-07-22 02:24:13 +00:00
|
|
|
int bestDecimal( double num ) {
|
|
|
|
if ( num < 10 ) return 2;
|
|
|
|
if ( num < 100 ) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-23 05:43:16 +00:00
|
|
|
wxString toWxStr( const char * s )
|
|
|
|
{
|
|
|
|
return wxString( s, wxConvUTF8 );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString getReadableSize( uint64_t size )
|
2007-07-22 02:24:13 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
static const char *sizestrs[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
|
2007-07-23 05:43:16 +00:00
|
|
|
for ( i=0; size>>10; ++i ) size = size>>10;
|
2007-07-22 02:24:13 +00:00
|
|
|
char buf[512];
|
|
|
|
snprintf( buf, sizeof(buf), "%.*f %s", bestDecimal(size), (double)size, sizestrs[i] );
|
2007-07-23 05:43:16 +00:00
|
|
|
return toWxStr( buf );
|
2007-07-22 02:24:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 05:43:16 +00:00
|
|
|
wxString getReadableSize( float f )
|
2007-07-22 02:24:13 +00:00
|
|
|
{
|
2007-07-23 05:43:16 +00:00
|
|
|
return getReadableSize( (uint64_t)f );
|
2007-07-22 02:24:13 +00:00
|
|
|
}
|
|
|
|
|
2007-07-23 05:43:16 +00:00
|
|
|
wxString getReadableSpeed( float f )
|
2007-07-22 02:24:13 +00:00
|
|
|
{
|
2007-07-23 05:43:16 +00:00
|
|
|
wxString xstr = getReadableSize(f);
|
|
|
|
xstr += _T("/s");
|
|
|
|
return xstr;
|
2007-07-22 02:24:13 +00:00
|
|
|
}
|
2007-07-22 19:37:43 +00:00
|
|
|
}
|
2007-07-22 02:24:13 +00:00
|
|
|
|
2007-07-23 21:01:26 +00:00
|
|
|
void
|
|
|
|
MyFrame :: RefreshFilterCounts( )
|
|
|
|
{
|
|
|
|
for( int i=0; i<TorrentFilter::N_FILTERS; ++i )
|
|
|
|
{
|
|
|
|
wxString xstr = TorrentFilter::getFilterName( i );
|
|
|
|
const int count = TorrentFilter::CountHits( i, myTorrents );
|
|
|
|
if( count )
|
|
|
|
xstr += wxString::Format(_T(" (%d)"), count );
|
|
|
|
myFilters->SetItem( i, 0, xstr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-23 23:59:13 +00:00
|
|
|
void
|
|
|
|
MyFrame :: OnItemSelected( wxListEvent& event )
|
|
|
|
{
|
|
|
|
const int item = event.GetIndex ();
|
|
|
|
torrents_v tmp( myTorrents );
|
|
|
|
TorrentFilter :: RemoveFailures( item, tmp );
|
|
|
|
myTorrentList->Assign( tmp );
|
|
|
|
}
|
|
|
|
|
2007-07-24 04:36:36 +00:00
|
|
|
void
|
|
|
|
MyFrame :: OnRecheck( wxCommandEvent& unused )
|
|
|
|
{
|
|
|
|
for( torrents_v::iterator it(mySelectedTorrents.begin()),
|
|
|
|
end(mySelectedTorrents.end()); it!=end; ++it )
|
|
|
|
tr_torrentRecheck( *it );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MyFrame :: OnTorrentListSelectionChanged( TorrentListCtrl* list,
|
|
|
|
const std::set<tr_torrent_t*>& torrents )
|
|
|
|
{
|
|
|
|
assert( list == myTorrentList );
|
|
|
|
mySelectedTorrents.assign( torrents.begin(), torrents.end() );
|
|
|
|
}
|
|
|
|
|
2007-07-22 19:37:43 +00:00
|
|
|
void
|
|
|
|
MyFrame :: OnTimer(wxTimerEvent& event)
|
|
|
|
{
|
2007-07-23 21:01:26 +00:00
|
|
|
RefreshFilterCounts( );
|
|
|
|
|
|
|
|
myTorrentList->Refresh ( );
|
2007-07-23 05:43:16 +00:00
|
|
|
|
|
|
|
float dl, ul;
|
|
|
|
tr_torrentRates( handle, &dl, &ul );
|
|
|
|
wxString s = _("Download: ");
|
|
|
|
s += getReadableSpeed( dl );
|
|
|
|
s += _T("\n");
|
|
|
|
s +=_("Upload: ");
|
|
|
|
s += getReadableSpeed( ul );
|
|
|
|
myTaskBarIcon->SetIcon( *myTrayLogo, s );
|
2007-07-22 19:37:43 +00:00
|
|
|
}
|
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
MyFrame::~MyFrame()
|
|
|
|
{
|
2007-07-24 04:36:36 +00:00
|
|
|
myTorrentList->RemoveListener( this );
|
|
|
|
delete myTorrentList;
|
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
delete myConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size):
|
|
|
|
wxFrame((wxFrame*)NULL,-1,title,pos,size),
|
2007-07-22 19:37:43 +00:00
|
|
|
myConfig( new wxConfig( _T("xmission") ) ),
|
|
|
|
myPulseTimer( this, ID_Pulse )
|
2007-07-19 14:06:50 +00:00
|
|
|
{
|
2007-07-23 17:36:34 +00:00
|
|
|
myLogoIcon = new wxIcon( transmission_xpm );
|
2007-07-23 05:43:16 +00:00
|
|
|
SetIcon( *myLogoIcon );
|
2007-07-23 17:36:34 +00:00
|
|
|
|
|
|
|
/*#if wxCHECK_VERSION(2,8,0)
|
2007-07-23 05:43:16 +00:00
|
|
|
transmission_logo.Rescale( 24, 24, wxIMAGE_QUALITY_HIGH );
|
|
|
|
#else
|
|
|
|
transmission_logo.Rescale( 24, 24 );
|
|
|
|
#endif
|
|
|
|
myTrayLogo = new wxIcon;
|
2007-07-23 17:36:34 +00:00
|
|
|
myTrayLogo->CopyFromBitmap( wxBitmap( transmission_logo ) );*/
|
|
|
|
myTrayLogo = myLogoIcon;
|
2007-07-19 14:06:50 +00:00
|
|
|
|
2007-07-22 02:24:13 +00:00
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
/**
|
|
|
|
*** Menu
|
|
|
|
**/
|
|
|
|
|
|
|
|
wxMenuBar *menuBar = new wxMenuBar;
|
|
|
|
|
|
|
|
wxMenu * m = new wxMenu;
|
|
|
|
m->Append( wxID_OPEN, _T("&Open") );
|
|
|
|
m->Append( ID_START, _T("&Start") );
|
|
|
|
m->Append( wxID_STOP, _T("Sto&p") ) ;
|
|
|
|
m->Append( wxID_REFRESH, _T("Re&check") );
|
|
|
|
m->Append( wxID_REMOVE, _T("&Remove") );
|
|
|
|
m->AppendSeparator();
|
|
|
|
m->Append( wxID_NEW, _T("Create &New Torrent") );
|
|
|
|
m->AppendSeparator();
|
|
|
|
m->Append( wxID_CLOSE, _T("&Close") );
|
|
|
|
m->Append( wxID_EXIT, _T("&Exit") );
|
|
|
|
menuBar->Append( m, _T("&File") );
|
|
|
|
|
|
|
|
m = new wxMenu;
|
|
|
|
m->Append( ID_TORRENT_INFO, _T("Torrent &Info") );
|
|
|
|
m->Append( wxID_PREFERENCES, _T("Edit &Preferences") );
|
|
|
|
menuBar->Append( m, _T("&Edit") );
|
|
|
|
|
|
|
|
m = new wxMenu;
|
|
|
|
m->Append( ID_SHOW_DEBUG_WINDOW, _T("Show &Debug Window") );
|
|
|
|
m->AppendSeparator();
|
2007-07-19 14:50:42 +00:00
|
|
|
m->Append( wxID_ABOUT, _T("&About Xmission") );
|
2007-07-19 14:06:50 +00:00
|
|
|
menuBar->Append( m, _T("&Help") );
|
|
|
|
|
|
|
|
SetMenuBar(menuBar);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*** Toolbar
|
|
|
|
**/
|
|
|
|
|
2007-07-23 17:36:34 +00:00
|
|
|
wxIcon open_icon( fileopen_xpm );
|
|
|
|
wxIcon exec_icon( exec_xpm );
|
|
|
|
wxIcon stop_icon( stop_xpm );
|
|
|
|
wxIcon drop_icon( gtk_remove_xpm );
|
|
|
|
wxIcon info_icon( gtk_properties_xpm );
|
|
|
|
wxBitmap bitmap;
|
2007-07-19 14:50:42 +00:00
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
wxToolBar* toolbar = CreateToolBar( wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT | wxTB_TEXT );
|
|
|
|
toolbar->SetToolBitmapSize( wxSize( 16, 16 ) );
|
2007-07-23 17:36:34 +00:00
|
|
|
bitmap.CopyFromIcon( open_icon );
|
|
|
|
toolbar->AddTool( wxID_OPEN, _T("Open"), bitmap );
|
|
|
|
bitmap.CopyFromIcon( exec_icon );
|
|
|
|
toolbar->AddTool( ID_START, _T("Start"), bitmap );
|
|
|
|
bitmap.CopyFromIcon( stop_icon );
|
|
|
|
toolbar->AddTool( wxID_STOP, _T("Stop"), bitmap );
|
|
|
|
bitmap.CopyFromIcon( drop_icon );
|
|
|
|
toolbar->AddTool( wxID_REMOVE, _T("Remove"), bitmap );
|
2007-07-19 14:06:50 +00:00
|
|
|
toolbar->AddSeparator();
|
2007-07-23 17:36:34 +00:00
|
|
|
bitmap.CopyFromIcon( info_icon );
|
|
|
|
toolbar->AddTool( ID_TORRENT_INFO, _("Torrent Info"), bitmap );
|
2007-07-19 14:06:50 +00:00
|
|
|
toolbar->Realize();
|
|
|
|
|
|
|
|
/**
|
2007-07-19 19:05:55 +00:00
|
|
|
*** Row 1
|
|
|
|
**/
|
|
|
|
|
|
|
|
wxSplitterWindow * hsplit = new wxSplitterWindow( this );
|
2007-07-23 00:56:51 +00:00
|
|
|
hsplit->SetSashGravity( 0.8 );
|
2007-07-19 19:05:55 +00:00
|
|
|
|
|
|
|
wxPanel * row1 = new wxPanel( hsplit, wxID_ANY );
|
|
|
|
|
2007-07-23 00:56:51 +00:00
|
|
|
/* Filters */
|
2007-07-19 19:05:55 +00:00
|
|
|
|
2007-07-23 23:59:13 +00:00
|
|
|
myFilters = new wxListCtrl( row1, ID_Filter, wxDefaultPosition, wxSize(120,-1),
|
2007-07-23 21:01:26 +00:00
|
|
|
wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_NO_HEADER );
|
|
|
|
myFilters->InsertColumn( wxLIST_FORMAT_LEFT, _("Filters"), wxLIST_FORMAT_LEFT, 120 );
|
|
|
|
for( int i=0; i<TorrentFilter::N_FILTERS; ++i )
|
|
|
|
myFilters->InsertItem( i, TorrentFilter::getFilterName(i) );
|
2007-07-19 19:05:55 +00:00
|
|
|
|
2007-07-23 00:56:51 +00:00
|
|
|
/* Torrent List */
|
2007-07-19 19:05:55 +00:00
|
|
|
|
2007-07-23 15:20:47 +00:00
|
|
|
myTorrentList = new TorrentListCtrl( handle, myConfig, row1 );
|
2007-07-24 04:36:36 +00:00
|
|
|
myTorrentList->AddListener( this );
|
2007-07-19 19:05:55 +00:00
|
|
|
|
2007-07-23 00:56:51 +00:00
|
|
|
wxBoxSizer * boxSizer = new wxBoxSizer( wxHORIZONTAL );
|
2007-07-23 21:01:26 +00:00
|
|
|
boxSizer->Add( myFilters, 0, wxEXPAND|wxRIGHT, 5 );
|
2007-07-23 00:56:51 +00:00
|
|
|
boxSizer->Add( myTorrentList, 1, wxEXPAND, 0 );
|
|
|
|
row1->SetSizer( boxSizer );
|
2007-07-23 21:01:26 +00:00
|
|
|
//boxSizer->SetSizeHints( row1 );
|
2007-07-19 19:05:55 +00:00
|
|
|
|
|
|
|
|
2007-07-23 00:56:51 +00:00
|
|
|
wxNotebook * notebook = new wxNotebook( hsplit, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
|
2007-07-19 19:05:55 +00:00
|
|
|
wxButton * tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
|
|
|
|
notebook->AddPage( tmp, _T("General"), false );
|
|
|
|
tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
|
|
|
|
notebook->AddPage( tmp, _T("Peers"), false );
|
|
|
|
tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
|
|
|
|
notebook->AddPage( tmp, _T("Pieces"), false );
|
|
|
|
tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
|
|
|
|
notebook->AddPage( tmp, _T("Files"), false );
|
|
|
|
tmp = new wxButton( notebook, wxID_ANY, _T("Hello World"));
|
|
|
|
notebook->AddPage( tmp, _T("Logger"), false );
|
|
|
|
|
|
|
|
hsplit->SplitHorizontally( row1, notebook );
|
|
|
|
|
|
|
|
/**
|
|
|
|
*** Statusbar
|
2007-07-19 14:06:50 +00:00
|
|
|
**/
|
|
|
|
|
|
|
|
CreateStatusBar();
|
2007-07-19 14:50:42 +00:00
|
|
|
SetStatusText(_T("Welcome to Xmission!"));
|
2007-07-22 19:37:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** Refresh
|
|
|
|
**/
|
|
|
|
|
|
|
|
myPulseTimer.Start( 1500 );
|
2007-07-23 05:43:16 +00:00
|
|
|
|
|
|
|
myTaskBarIcon = new wxTaskBarIcon( );
|
2007-07-23 15:20:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*** Load the torrents
|
|
|
|
**/
|
|
|
|
|
|
|
|
const int flags = TR_FLAG_PAUSED;
|
|
|
|
const char * destination = "/home/charles/torrents";
|
|
|
|
int count = 0;
|
|
|
|
tr_torrent_t ** torrents = tr_loadTorrents ( handle, destination, flags, &count );
|
2007-07-23 21:01:26 +00:00
|
|
|
myTorrents.insert( myTorrents.end(), torrents, torrents+count );
|
|
|
|
myTorrentList->Add( myTorrents );
|
2007-07-23 15:20:47 +00:00
|
|
|
tr_free( torrents );
|
2007-07-23 23:59:13 +00:00
|
|
|
|
|
|
|
wxTimerEvent dummy;
|
|
|
|
OnTimer( dummy );
|
2007-07-19 14:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2007-07-23 05:43:16 +00:00
|
|
|
Close( true );
|
2007-07-19 14:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2007-07-23 17:36:34 +00:00
|
|
|
wxIcon ico( transmission_xpm );
|
2007-07-19 14:50:42 +00:00
|
|
|
|
2007-07-20 02:12:07 +00:00
|
|
|
#if wxCHECK_VERSION(2,8,0)
|
2007-07-19 14:06:50 +00:00
|
|
|
wxAboutDialogInfo info;
|
2007-07-19 14:50:42 +00:00
|
|
|
info.SetName(_T("Xmission"));
|
2007-07-19 14:06:50 +00:00
|
|
|
info.SetVersion(_T(LONG_VERSION_STRING));
|
|
|
|
info.SetCopyright(_T("Copyright 2005-2007 The Transmission Project"));
|
|
|
|
info.SetDescription(_T("A fast, lightweight bittorrent client"));
|
|
|
|
info.SetWebSite( _T( "http://transmission.m0k.org/" ) );
|
2007-07-19 14:50:42 +00:00
|
|
|
info.SetIcon( ico );
|
2007-07-23 02:43:25 +00:00
|
|
|
info.AddDeveloper( _T("Josh Elsasser (Back-end; GTK+)") );
|
|
|
|
info.AddDeveloper( _T("Charles Kerr (Back-end, GTK+, wxWidgets)") );
|
|
|
|
info.AddDeveloper( _T("Mitchell Livingston (Back-end; OS X)") );
|
|
|
|
info.AddDeveloper( _T("Eric Petit (Back-end; OS X)") );
|
|
|
|
info.AddDeveloper( _T("Bryan Varner (BeOS)") );
|
2007-07-19 14:06:50 +00:00
|
|
|
wxAboutBox( info );
|
2007-07-20 02:12:07 +00:00
|
|
|
#else
|
|
|
|
wxMessageBox(_T("Xmission " LONG_VERSION_STRING "\n"
|
|
|
|
"Copyright 2005-2007 The Transmission Project"),
|
|
|
|
_T("About Xmission"),
|
|
|
|
wxOK|wxICON_INFORMATION, this);
|
|
|
|
#endif
|
|
|
|
|
2007-07-19 14:06:50 +00:00
|
|
|
}
|