~vcs-imports/transmission/trunk-old

« back to all changes in this revision

Viewing changes to gtk/add-dialog.c

  • Committer: charles
  • Date: 2010-02-02 07:51:45 UTC
  • Revision ID: vcs-imports@canonical.com-20100202075145-wavv46jdgipq6pbo
(trunk gtk) "Priority Selection in `Add' window" -- implemented for GTK+ client

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: add-dialog.c 9969 2010-01-20 17:20:35Z charles $
 
10
 * $Id: add-dialog.c 10079 2010-02-02 07:51:45Z charles $
11
11
 */
12
12
 
13
13
#include <glib/gi18n.h>
87
87
    GtkWidget *  list;
88
88
    GtkWidget *  run_check;
89
89
    GtkWidget *  trash_check;
 
90
    GtkWidget *  priority_combo;
90
91
    char *       filename;
91
92
    char *       downloadDir;
92
93
    TrTorrent *  gtor;
120
121
        }
121
122
        else
122
123
        {
 
124
            tr_torrent * tor = tr_torrent_handle( data->gtor );
 
125
 
 
126
            tr_torrentSetPriority( tor, gtr_priority_combo_get_value( data->priority_combo ) );
 
127
 
123
128
            if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( data->run_check ) ) )
124
 
                tr_torrentStart( tr_torrent_handle( data->gtor ) );
 
129
                tr_torrentStart( tor );
125
130
 
126
131
            tr_core_add_torrent( data->core, data->gtor, FALSE );
127
132
 
203
208
}
204
209
 
205
210
static void
206
 
verifyRequested( GtkButton * button UNUSED,
207
 
                 gpointer           gdata )
 
211
verifyRequested( GtkButton * button UNUSED, gpointer gdata )
208
212
{
209
213
    struct AddData * data = gdata;
210
214
 
253
257
****/
254
258
 
255
259
GtkWidget*
256
 
addSingleTorrentDialog( GtkWindow * parent,
257
 
                        TrCore *    core,
258
 
                        tr_ctor *   ctor )
 
260
addSingleTorrentDialog( GtkWindow * parent, TrCore * core, tr_ctor * ctor )
259
261
{
260
262
    int              row;
261
263
    int              col;
271
273
    GSList *         walk;
272
274
 
273
275
    /* make the dialog */
274
 
    d = gtk_dialog_new_with_buttons( _(
275
 
                                         "Torrent Options" ), parent,
 
276
    d = gtk_dialog_new_with_buttons( _( "Torrent Options" ), parent,
276
277
                                     GTK_DIALOG_DESTROY_WITH_PARENT |
277
278
                                     GTK_DIALOG_NO_SEPARATOR,
278
279
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
300
301
    str = _( "_Start when added" );
301
302
    data->run_check = gtk_check_button_new_with_mnemonic( str );
302
303
 
 
304
    data->priority_combo = gtr_priority_combo_new( );
 
305
    gtr_priority_combo_set_value( data->priority_combo, TR_PRI_NORMAL );
 
306
 
303
307
    g_signal_connect( G_OBJECT( d ), "response",
304
308
                      G_CALLBACK( addResponseCB ), data );
305
309
 
311
315
    row = col = 0;
312
316
    l = gtk_label_new_with_mnemonic( _( "_Torrent file:" ) );
313
317
    gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f );
314
 
    gtk_table_attach( GTK_TABLE(
315
 
                          t ), l, col, col + 1, row, row + 1, GTK_FILL, 0,
316
 
                      0, 0 );
 
318
    gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 );
317
319
    ++col;
318
320
    w = gtk_file_chooser_button_new( _( "Select Source File" ),
319
321
                                     GTK_FILE_CHOOSER_ACTION_OPEN );
320
322
    source_chooser = w;
321
 
    gtk_table_attach( GTK_TABLE(
322
 
                          t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 );
 
323
    gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 );
323
324
    gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w );
324
325
    addTorrentFilters( GTK_FILE_CHOOSER( w ) );
325
326
    g_signal_connect( w, "selection-changed",
329
330
    col = 0;
330
331
    l = gtk_label_new_with_mnemonic( _( "_Destination folder:" ) );
331
332
    gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f );
332
 
    gtk_table_attach( GTK_TABLE(
333
 
                          t ), l, col, col + 1, row, row + 1, GTK_FILL, 0,
334
 
                      0, 0 );
 
333
    gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 );
335
334
    ++col;
336
 
    w = gtk_file_chooser_button_new( _(
337
 
                                         "Select Destination Folder" ),
 
335
    w = gtk_file_chooser_button_new( _( "Select Destination Folder" ),
338
336
                                     GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );
339
337
    if( !gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ),
340
338
                                        data->downloadDir ) )
341
339
        g_warning( "couldn't select '%s'", data->downloadDir );
342
340
    list = get_recent_destinations( );
343
341
    for( walk = list; walk; walk = walk->next )
344
 
        gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER(
345
 
                                                  w ), walk->data, NULL );
 
342
        gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( w ), walk->data, NULL );
346
343
    g_slist_free( list );
347
 
    gtk_table_attach( GTK_TABLE(
348
 
                          t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 );
 
344
    gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 );
349
345
    gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w );
350
346
    g_signal_connect( w, "selection-changed",
351
347
                      G_CALLBACK( downloadDirChanged ), data );
354
350
    col = 0;
355
351
    w = data->list;
356
352
    gtk_widget_set_size_request ( w, 466u, 300u );
357
 
    gtk_table_attach_defaults( GTK_TABLE(
358
 
                                   t ), w, col, col + 2, row, row + 1 );
 
353
    gtk_table_attach_defaults( GTK_TABLE( t ), w, col, col + 2, row, row + 1 );
359
354
 
360
355
    ++row;
361
356
    col = 0;
362
 
    w = gtk_button_new_with_mnemonic( _( "_Verify Local Data" ) );
363
 
    gtk_table_attach( GTK_TABLE(
364
 
                          t ), w, col, col + 1, row, row + 1, GTK_FILL, 0,
365
 
                      0, 0 );
366
 
    g_signal_connect( w, "clicked", G_CALLBACK( verifyRequested ), data );
 
357
    w = gtk_label_new_with_mnemonic( _( "Torrent _priority:" ) );
 
358
    gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.5f );
 
359
    gtk_table_attach_defaults( GTK_TABLE( t ), w, col, col + 1, row, row + 1 );
 
360
    ++col;
 
361
    gtk_table_attach_defaults( GTK_TABLE( t ), data->priority_combo, col, col + 1, row, row + 1 );
 
362
    gtk_label_set_mnemonic_widget( GTK_LABEL( w ), data->priority_combo );
367
363
 
368
364
    ++row;
369
365
    col = 0;
371
367
    if( tr_ctorGetPaused( ctor, TR_FORCE, &flag ) )
372
368
        g_assert_not_reached( );
373
369
    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), !flag );
374
 
    gtk_table_attach( GTK_TABLE(
375
 
                          t ), w, col, col + 2, row, row + 1, GTK_FILL, 0,
376
 
                      0, 0 );
 
370
    gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 );
377
371
 
378
372
    ++row;
379
373
    col = 0;
381
375
    if( tr_ctorGetDeleteSource( ctor, &flag ) )
382
376
        g_assert_not_reached( );
383
377
    gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), flag );
384
 
    gtk_table_attach( GTK_TABLE(
385
 
                          t ), w, col, col + 2, row, row + 1, GTK_FILL, 0,
386
 
                      0, 0 );
 
378
    gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 );
 
379
 
 
380
    ++row;
 
381
    col = 0;
 
382
    w = data->priority_combo;
387
383
 
388
384
    /* trigger sourceChanged, either directly or indirectly,
389
385
     * so that it creates the tor/gtor objects */