Changeset 6834
- Timestamp:
- Oct 2, 2008, 4:42:35 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/main.c
r6825 r6834 310 310 } 311 311 312 struct rpc_data 313 { 314 int type; 315 int torrentId; 316 tr_torrent * tor; 317 struct cbdata * cbdata; 318 }; 319 320 static int 321 onRPCIdle( void * vdata ) 322 { 323 struct rpc_data * data = vdata; 324 325 switch( data->type ) 312 static tr_rpc_callback_status 313 onRPCChanged( tr_handle * handle UNUSED, 314 tr_rpc_callback_type type, 315 struct tr_torrent * tor, 316 void * gdata ) 317 { 318 struct cbdata * cbdata = gdata; 319 gdk_threads_enter( ); 320 321 switch( type ) 326 322 { 327 323 case TR_RPC_TORRENT_ADDED: 328 tr_core_add_torrent( data->cbdata->core, 329 tr_torrent_new_preexisting( 330 data->tor ) ); 324 tr_core_add_torrent( cbdata->core, 325 tr_torrent_new_preexisting( tor ) ); 331 326 break; 332 327 … … 340 335 341 336 case TR_RPC_TORRENT_REMOVING: 342 tr_core_torrent_destroyed( data->cbdata->core, data->torrentId);337 tr_core_torrent_destroyed( cbdata->core, tr_torrentId( tor ) ); 343 338 break; 344 339 … … 348 343 break; 349 344 } 350 g_free( data ); 351 return FALSE; 352 } 353 354 static tr_rpc_callback_status 355 onRPCChanged( tr_handle * handle UNUSED, 356 tr_rpc_callback_type type, 357 struct tr_torrent * tor, 358 void * cbdata ) 359 { 360 /* this callback is being invoked from the libtransmission thread, 361 * so let's push the information over to the gtk+ thread where 362 * it's safe to update the gui */ 363 struct rpc_data * data = g_new0( struct rpc_data, 1 ); 364 365 data->type = type; 366 data->torrentId = tor ? tr_torrentId( tor ) : -1; 367 data->tor = type == TR_RPC_TORRENT_REMOVING ? NULL : tor; 368 data->cbdata = cbdata; 369 g_idle_add( onRPCIdle, data ); 345 346 gdk_threads_leave( ); 370 347 return TR_RPC_OK; 371 348 }
Note: See TracChangeset
for help on using the changeset viewer.