(trunk gtk) #1846: GTK client has no pause all / resume all buttons
This commit is contained in:
parent
b322fb2e54
commit
a129c452e5
|
@ -122,6 +122,7 @@ static GtkActionEntry entries[] =
|
|||
{ "verify-torrent", NULL, N_( "_Verify Local Data" ), NULL, NULL, G_CALLBACK( action_cb ) },
|
||||
{ "pause-torrent", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause" ), "<control>P", N_( "Pause torrent" ), G_CALLBACK( action_cb ) },
|
||||
{ "pause-all-torrents", GTK_STOCK_MEDIA_PAUSE, N_( "_Pause All" ), NULL, N_( "Pause all torrents" ), G_CALLBACK( action_cb ) },
|
||||
{ "start-all-torrents", GTK_STOCK_MEDIA_PLAY, N_( "_Start All" ), NULL, N_( "Start all torrents" ), G_CALLBACK( action_cb ) },
|
||||
{ "remove-torrent", GTK_STOCK_REMOVE, NULL, "Delete", N_( "Remove torrent" ), G_CALLBACK( action_cb ) },
|
||||
{ "delete-torrent", GTK_STOCK_DELETE, N_( "_Delete Files and Remove" ), "<shift>Delete", NULL, G_CALLBACK( action_cb ) },
|
||||
{ "new-torrent", GTK_STOCK_NEW, N_( "_New..." ), NULL, N_( "Create a torrent" ), G_CALLBACK( action_cb ) },
|
||||
|
|
22
gtk/main.c
22
gtk/main.c
|
@ -208,7 +208,7 @@ accumulateCanUpdateForeach( GtkTreeModel * model,
|
|||
static void
|
||||
refreshTorrentActions( struct cbdata * data )
|
||||
{
|
||||
int canUpdate;
|
||||
int canUpdate;
|
||||
struct counts_data counts;
|
||||
GtkTreeSelection * s = data->sel;
|
||||
|
||||
|
@ -231,15 +231,17 @@ refreshTorrentActions( struct cbdata * data )
|
|||
{
|
||||
GtkTreeView * view = gtk_tree_selection_get_tree_view( s );
|
||||
GtkTreeModel * model = gtk_tree_view_get_model( view );
|
||||
const int torrentCount = gtk_tree_model_iter_n_children( model, NULL ) != 0;
|
||||
const int torrentCount = gtk_tree_model_iter_n_children( model, NULL ) != 0;
|
||||
action_sensitize( "select-all", torrentCount != 0 );
|
||||
action_sensitize( "deselect-all", torrentCount != 0 );
|
||||
}
|
||||
|
||||
{
|
||||
tr_session * session = tr_core_session( data->core );
|
||||
int activeCount = tr_sessionGetActiveTorrentCount( session );
|
||||
action_sensitize( "pause-all-torrents", activeCount != 0 );
|
||||
const int active = tr_sessionGetActiveTorrentCount( session );
|
||||
const int total = tr_sessionCountTorrents( session );
|
||||
action_sensitize( "pause-all-torrents", active != 0 );
|
||||
action_sensitize( "start-all-torrents", active != total );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1385,6 +1387,14 @@ removeSelected( struct cbdata * data,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
startAllTorrents( struct cbdata * data )
|
||||
{
|
||||
tr_session * session = tr_core_session( data->core );
|
||||
const char * cmd = "{ \"method\": \"torrent-start\" }";
|
||||
tr_rpc_request_exec_json( session, cmd, strlen( cmd ), NULL, NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
pauseAllTorrents( struct cbdata * data )
|
||||
{
|
||||
|
@ -1419,6 +1429,10 @@ doAction( const char * action_name, gpointer user_data )
|
|||
{
|
||||
pauseAllTorrents( data );
|
||||
}
|
||||
else if( !strcmp( action_name, "start-all-torrents" ) )
|
||||
{
|
||||
startAllTorrents( data );
|
||||
}
|
||||
else if( !strcmp( action_name, "pause-torrent" ) )
|
||||
{
|
||||
GtkTreeSelection * s = tr_window_get_selection( data->wind );
|
||||
|
|
4
gtk/ui.h
4
gtk/ui.h
|
@ -15,6 +15,9 @@ static const char * fallback_ui_file =
|
|||
" <menuitem action='remove-torrent'/>\n"
|
||||
" <menuitem action='delete-torrent'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='start-all-torrents'/>\n"
|
||||
" <menuitem action='pause-all-torrents'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='quit'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='edit-menu'>\n"
|
||||
|
@ -79,6 +82,7 @@ static const char * fallback_ui_file =
|
|||
" <menuitem action='toggle-message-log'/>\n"
|
||||
" <menuitem action='show-about-dialog'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='start-all-torrents'/>\n"
|
||||
" <menuitem action='pause-all-torrents'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='quit'/>\n"
|
||||
|
|
Loading…
Reference in New Issue