~ubuntu-branches/ubuntu/precise/transmission/precise

« back to all changes in this revision

Viewing changes to gtk/file-list.c

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Bicha
  • Date: 2011-07-19 10:35:40 UTC
  • mfrom: (2.1.28 experimental)
  • Revision ID: james.westby@ubuntu.com-20110719103540-rhollwusry5x0r5t
Tags: 2.32-1ubuntu1
* Merge with Debian experimental (LP: #715046), remaining changes:
* debian/control:
  - Build-depend on liblaunchpad-integration-dev & libappindicator-dev
  - Keep libcanberra-gtk-dev build-depends
  - Add Vcs-Bzr link
* debian/rules:
  - Don't disable libcanberra
* debian/patches/0102-lpi.patch: Refreshed
* debian/patches/0103-add_X_Ubuntu_specific_desktop_keys.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * This file Copyright (C) 2007-2010 Mnemosyne LLC
 
2
 * This file Copyright (C) Mnemosyne LLC
3
3
 *
4
 
 * This file is licensed by the GPL version 2.  Works owned by the
 
4
 * This file is licensed by the GPL version 2. Works owned by the
5
5
 * Transmission project are granted a special exemption to clause 2(b)
6
6
 * so that the bulk of its code can remain under the MIT license.
7
7
 * This exemption does not extend to derived works not owned by
8
8
 * the Transmission project.
9
9
 *
10
 
 * $Id: file-list.c 11217 2010-09-17 13:23:20Z charles $
 
10
 * $Id: file-list.c 12356 2011-04-13 22:00:55Z jordan $
11
11
 */
12
12
 
13
13
#include <stddef.h>
14
14
#include <stdio.h>
15
 
#include <stdlib.h>
16
15
#include <string.h>
17
16
#include <glib/gi18n.h>
18
17
#include <gtk/gtk.h>
19
18
 
20
19
#include <libtransmission/transmission.h>
 
20
#include <libtransmission/utils.h>
21
21
 
22
22
#include "file-list.h"
23
23
#include "hig.h"
24
24
#include "icons.h"
25
25
#include "tr-prefs.h"
 
26
#include "util.h"
 
27
 
 
28
#define TR_DOWNLOAD_KEY  "tr-download-key"
 
29
#define TR_COLUMN_ID_KEY "tr-model-column-id-key"
 
30
#define TR_PRIORITY_KEY  "tr-priority-key"
26
31
 
27
32
enum
28
33
{
39
44
    FC_PROG,
40
45
    FC_INDEX,
41
46
    FC_SIZE,
 
47
    FC_SIZE_STR,
42
48
    FC_HAVE,
43
49
    FC_PRIORITY,
44
50
    FC_ENABLED,
126
132
        if( (priority!=old_priority) || (enabled!=old_enabled) || (have!=old_have) || (prog!=old_prog) )
127
133
        {
128
134
            /* Changing a value in the sort column can trigger a resort
129
 
             * which breaks this foreach() call.  (See #3529)
 
135
             * which breaks this foreach() call. (See #3529)
130
136
             * As a workaround: if that's about to happen, temporarily disable
131
137
             * sorting until we finish walking the tree. */
132
138
            if( !refresh_data->resort_needed )
194
200
                             || (priority!=old_priority)
195
201
                             || (enabled!=old_enabled)
196
202
                             || (prog!=old_prog) )
 
203
        {
 
204
            char size_str[64];
 
205
            tr_strlsize( size_str, sub_size, sizeof size_str );
197
206
            gtk_tree_store_set( data->store, iter, FC_SIZE, sub_size,
 
207
                                                   FC_SIZE_STR, size_str,
198
208
                                                   FC_HAVE, have,
199
209
                                                   FC_PRIORITY, priority,
200
210
                                                   FC_ENABLED, enabled,
201
211
                                                   FC_PROG, prog,
202
212
                                                   -1 );
 
213
        }
203
214
    }
204
215
 
205
216
    return FALSE; /* keep walking */
225
236
                                  gpointer                  data )
226
237
{
227
238
    GtkTreeIter iter;
228
 
    if( gtk_tree_model_get_iter_first( model, &iter ) ) do
 
239
    if( gtk_tree_model_iter_nth_child( model, &iter, NULL, 0 ) ) do
229
240
        gtr_tree_model_foreach_postorder_subtree( model, &iter, func, data );
230
241
    while( gtk_tree_model_iter_next( model, &iter ) );
231
242
}
233
244
static void
234
245
refresh( FileData * data )
235
246
{
236
 
    tr_torrent * tor = NULL;
237
 
    tr_session * session = tr_core_session( data->core );
238
 
 
239
 
    if( session != NULL )
240
 
        tor = tr_torrentFindFromId( session, data->torrentId );
 
247
    tr_torrent * tor = gtr_core_find_torrent( data->core, data->torrentId );
241
248
 
242
249
    if( tor == NULL )
243
250
    {
244
 
        file_list_clear( data->top );
 
251
        gtr_file_list_clear( data->top );
245
252
    }
246
253
    else
247
254
    {
255
262
        refresh_data.sort_column_id = sort_column_id;
256
263
        refresh_data.resort_needed = FALSE;
257
264
        refresh_data.refresh_file_stat = tr_torrentFiles( tor, &fileCount );
258
 
        refresh_data.tor = tr_torrentFindFromId( session, data->torrentId );
 
265
        refresh_data.tor = tor;
259
266
        refresh_data.file_data = data;
260
267
 
261
268
        gtr_tree_model_foreach_postorder( data->model, refreshFilesForeach, &refresh_data );
295
302
    if( is_file )
296
303
    {
297
304
        struct ActiveData * data = gdata;
298
 
    
 
305
 
299
306
        /* active means: if it's selected or any ancestor is selected */
300
307
 
301
308
        gboolean is_active = gtk_tree_selection_iter_is_selected( data->sel, iter );
322
329
    return FALSE; /* keep walking */
323
330
}
324
331
 
325
 
static void
326
 
getSelectedFilesAndDescendants( GtkTreeView * view, GArray * indices )
 
332
static GArray*
 
333
getSelectedFilesAndDescendants( GtkTreeView * view )
327
334
{
328
335
    struct ActiveData data;
329
336
 
330
337
    data.sel = gtk_tree_view_get_selection( view );
331
 
    data.array  = indices;
 
338
    data.array = g_array_new( FALSE, FALSE, sizeof( tr_file_index_t ) );
332
339
    gtk_tree_model_foreach( gtk_tree_view_get_model( view ),
333
340
                            getSelectedFilesForeach, &data );
 
341
    return data.array;
334
342
}
335
343
 
336
344
struct SubtreeForeachData
378
386
static GArray*
379
387
getActiveFilesForPath( GtkTreeView * view, GtkTreePath * path )
380
388
{
 
389
    GArray * indices;
381
390
    GtkTreeSelection * sel = gtk_tree_view_get_selection( view );
382
 
    GArray * indices = g_array_new( FALSE, FALSE, sizeof( tr_file_index_t ) );
383
391
 
384
392
    if( gtk_tree_selection_path_is_selected( sel, path ) )
385
393
    {
386
394
        /* clicked in a selected row... use the current selection */
387
 
        getSelectedFilesAndDescendants( view, indices );
 
395
        indices = getSelectedFilesAndDescendants( view );
388
396
    }
389
397
    else
390
398
    {
391
399
        /* clicked OUTSIDE of the selected row... just use the clicked row */
 
400
        indices = g_array_new( FALSE, FALSE, sizeof( tr_file_index_t ) );
392
401
        getSubtree( view, path, indices );
393
402
    }
394
403
 
400
409
***/
401
410
 
402
411
void
403
 
file_list_clear( GtkWidget * w )
 
412
gtr_file_list_clear( GtkWidget * w )
404
413
{
405
 
    file_list_set_torrent( w, -1 );
 
414
    gtr_file_list_set_torrent( w, -1 );
406
415
}
407
416
 
408
417
struct build_data
423
432
static void
424
433
buildTree( GNode * node, gpointer gdata )
425
434
{
 
435
    char size_str[64];
426
436
    GtkTreeIter child_iter;
427
437
    struct build_data * build = gdata;
428
438
    struct row_struct *child_data = node->data;
429
439
    const gboolean isLeaf = node->children == NULL;
430
440
 
431
 
    const char * mime_type = isLeaf ? get_mime_type_from_filename( child_data->name ) : DIRECTORY_MIME_TYPE;
432
 
    GdkPixbuf * icon = get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w );
 
441
    const char * mime_type = isLeaf ? gtr_get_mime_type_from_filename( child_data->name ) : DIRECTORY_MIME_TYPE;
 
442
    GdkPixbuf * icon = gtr_get_mime_type_icon( mime_type, GTK_ICON_SIZE_MENU, build->w );
433
443
    const tr_info * inf = tr_torrentInfo( build->tor );
434
444
    const int priority = isLeaf ? inf->files[ child_data->index ].priority : 0;
435
445
    const gboolean enabled = isLeaf ? !inf->files[ child_data->index ].dnd : TRUE;
 
446
 
 
447
    tr_strlsize( size_str, child_data->length, sizeof size_str );
 
448
 
436
449
#if GTK_CHECK_VERSION(2,10,0)
437
450
    gtk_tree_store_insert_with_values( build->store, &child_iter, build->iter, INT_MAX,
438
451
                                       FC_INDEX, child_data->index,
439
452
                                       FC_LABEL, child_data->name,
440
453
                                       FC_SIZE, child_data->length,
 
454
                                       FC_SIZE_STR, size_str,
441
455
                                       FC_ICON, icon,
442
456
                                       FC_PRIORITY, priority,
443
457
                                       FC_ENABLED, enabled,
448
462
                        FC_INDEX, child_data->index,
449
463
                        FC_LABEL, child_data->name,
450
464
                        FC_SIZE, child_data->length,
 
465
                        FC_SIZE_STR, size_str,
451
466
                        FC_ICON, icon,
452
467
                        FC_PRIORITY, priority,
453
468
                        FC_ENABLED, enabled,
482
497
}
483
498
 
484
499
void
485
 
file_list_set_torrent( GtkWidget * w, int torrentId )
 
500
gtr_file_list_set_torrent( GtkWidget * w, int torrentId )
486
501
{
487
502
    GtkTreeStore * store;
488
503
    FileData * data = g_object_get_data( G_OBJECT( w ), "file-data" );
497
512
                                 G_TYPE_INT,       /* prog [0..100] */
498
513
                                 G_TYPE_UINT,      /* index */
499
514
                                 G_TYPE_UINT64,    /* size */
 
515
                                 G_TYPE_STRING,    /* size str */
500
516
                                 G_TYPE_UINT64,    /* have */
501
517
                                 G_TYPE_INT,       /* priority */
502
518
                                 G_TYPE_INT );     /* dl enabled */
508
524
    /* populate the model */
509
525
    if( torrentId > 0 )
510
526
    {
511
 
        tr_session * session = tr_core_session( data->core );
512
 
        tr_torrent * tor = tr_torrentFindFromId( session, torrentId );
 
527
        tr_torrent * tor = gtr_core_find_torrent( data->core, torrentId );
513
528
        if( tor != NULL )
514
529
        {
515
530
            tr_file_index_t i;
520
535
 
521
536
            /* build a GNode tree of the files */
522
537
            root_data = g_new0( struct row_struct, 1 );
523
 
            root_data->name = g_strdup( inf->name );
 
538
            root_data->name = g_strdup( tr_torrentName( tor ) );
524
539
            root_data->index = -1;
525
540
            root_data->length = 0;
526
541
            root = g_node_new( root_data );
565
580
 
566
581
    gtk_tree_view_set_model( GTK_TREE_VIEW( data->view ), data->model );
567
582
    gtk_tree_view_expand_all( GTK_TREE_VIEW( data->view ) );
 
583
    g_object_unref( data->model );
568
584
}
569
585
 
570
586
/***
572
588
***/
573
589
 
574
590
static void
575
 
renderFilename( GtkTreeViewColumn  * column UNUSED,
576
 
                GtkCellRenderer    * renderer,
577
 
                GtkTreeModel       * model,
578
 
                GtkTreeIter        * iter,
579
 
                gpointer             data UNUSED )
580
 
{
581
 
    char *   filename;
582
 
    char *   str;
583
 
    int64_t  size;
584
 
    char     buf[64];
585
 
 
586
 
    gtk_tree_model_get( model, iter, FC_LABEL, &filename,
587
 
                                     FC_SIZE, &size,
588
 
                                     -1 );
589
 
    tr_strlsize( buf, size, sizeof( buf ) );
590
 
    str = g_markup_printf_escaped( "<small>%s (%s)</small>", filename, buf );
591
 
    g_object_set( renderer, "markup", str, NULL );
592
 
    g_free( str );
593
 
    g_free( filename );
594
 
}
595
 
 
596
 
static void
597
591
renderDownload( GtkTreeViewColumn  * column UNUSED,
598
592
                GtkCellRenderer    * renderer,
599
593
                GtkTreeModel       * model,
652
646
{
653
647
    gboolean handled = FALSE;
654
648
    FileData * data = gdata;
655
 
    tr_torrent * tor = tr_torrentFindFromId( tr_core_session( data->core ), data->torrentId );
 
649
    tr_torrent * tor = gtr_core_find_torrent( data->core, data->torrentId );
656
650
 
657
651
    if( tor != NULL )
658
652
    {
683
677
    return handled;
684
678
}
685
679
 
 
680
static gboolean
 
681
onViewPathToggled( GtkTreeView       * view,
 
682
                   GtkTreeViewColumn * col,
 
683
                   GtkTreePath       * path,
 
684
                   FileData          * data )
 
685
{
 
686
    int cid;
 
687
    tr_torrent * tor;
 
688
    gboolean handled = FALSE;
 
689
 
 
690
    if( !col || !path )
 
691
        return FALSE;
 
692
 
 
693
    cid = GPOINTER_TO_INT( g_object_get_data( G_OBJECT( col ), TR_COLUMN_ID_KEY ) );
 
694
    tor = gtr_core_find_torrent( data->core, data->torrentId );
 
695
    if( ( tor != NULL ) && ( ( cid == FC_PRIORITY ) || ( cid == FC_ENABLED ) ) )
 
696
    {
 
697
        GtkTreeIter iter;
 
698
        GArray * indices = getActiveFilesForPath( view, path );
 
699
        GtkTreeModel * model = data->model;
 
700
 
 
701
        gtk_tree_model_get_iter( model, &iter, path );
 
702
 
 
703
        if( cid == FC_PRIORITY )
 
704
        {
 
705
            int priority;
 
706
            gtk_tree_model_get( model, &iter, FC_PRIORITY, &priority, -1 );
 
707
            switch( priority ) {
 
708
                case TR_PRI_NORMAL: priority = TR_PRI_HIGH; break;
 
709
                case TR_PRI_HIGH:   priority = TR_PRI_LOW; break;
 
710
                default:            priority = TR_PRI_NORMAL; break;
 
711
            }
 
712
            tr_torrentSetFilePriorities( tor,
 
713
                                         (tr_file_index_t *) indices->data,
 
714
                                         (tr_file_index_t) indices->len,
 
715
                                         priority );
 
716
        }
 
717
        else
 
718
        {
 
719
            int enabled;
 
720
            gtk_tree_model_get( model, &iter, FC_ENABLED, &enabled, -1 );
 
721
            enabled = !enabled;
 
722
 
 
723
            tr_torrentSetFileDLs( tor,
 
724
                                  (tr_file_index_t *) indices->data,
 
725
                                  (tr_file_index_t) indices->len,
 
726
                                  enabled );
 
727
        }
 
728
 
 
729
        refresh( data );
 
730
        g_array_free( indices, TRUE );
 
731
        handled = TRUE;
 
732
    }
 
733
 
 
734
    return handled;
 
735
}
 
736
 
 
737
/**
 
738
 * @note 'col' and 'path' are assumed not to be NULL.
 
739
 */
 
740
static gboolean
 
741
getAndSelectEventPath( GtkTreeView        * treeview,
 
742
                       GdkEventButton     * event,
 
743
                       GtkTreeViewColumn ** col,
 
744
                       GtkTreePath       ** path )
 
745
{
 
746
    GtkTreeSelection * sel;
 
747
 
 
748
    if( gtk_tree_view_get_path_at_pos( treeview,
 
749
                                       event->x, event->y,
 
750
                                       path, col, NULL, NULL ) )
 
751
    {
 
752
        sel = gtk_tree_view_get_selection( treeview );
 
753
        if( !gtk_tree_selection_path_is_selected( sel, *path ) )
 
754
        {
 
755
            gtk_tree_selection_unselect_all( sel );
 
756
            gtk_tree_selection_select_path( sel, *path );
 
757
        }
 
758
        return TRUE;
 
759
    }
 
760
 
 
761
    return FALSE;
 
762
}
686
763
 
687
764
static gboolean
688
765
onViewButtonPressed( GtkWidget * w, GdkEventButton * event, gpointer gdata )
689
766
{
 
767
    GtkTreeViewColumn * col;
 
768
    GtkTreePath * path = NULL;
 
769
    gboolean handled = FALSE;
 
770
    GtkTreeView * treeview = GTK_TREE_VIEW( w );
690
771
    FileData * data = gdata;
691
 
    gboolean   handled = FALSE;
692
 
    tr_torrent * tor = tr_torrentFindFromId( tr_core_session( data->core ), data->torrentId );
693
 
 
694
 
    if( tor == NULL )
695
 
        return handled;
696
 
 
697
 
    if( ( event->type == GDK_BUTTON_PRESS ) && ( event->button == 1 )
698
 
      && !( event->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) )
 
772
 
 
773
    if( ( event->type == GDK_BUTTON_PRESS )
 
774
         && ( event->button == 1 )
 
775
         && !( event->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) )
 
776
         && getAndSelectEventPath( treeview, event, &col, &path ) )
699
777
    {
700
 
        GtkTreeView *       view = GTK_TREE_VIEW( w );
701
 
        GtkTreePath *       path;
702
 
        GtkTreeViewColumn * column;
703
 
        int                 cell_x;
704
 
        int                 cell_y;
705
 
        if( gtk_tree_view_get_path_at_pos( view, event->x, event->y,
706
 
                                           &path, &column, &cell_x, &cell_y ) )
707
 
        {
708
 
            const char * column_title = gtk_tree_view_column_get_title( column );
709
 
            const gboolean downloadColumn = !strcmp( column_title, _( "Download" ) );
710
 
            const gboolean priorityColumn = !strcmp( column_title, _( "Priority" ) );
711
 
            if( downloadColumn || priorityColumn )
712
 
            {
713
 
                GArray * a = getActiveFilesForPath( view, path );
714
 
                GtkTreeSelection * sel = gtk_tree_view_get_selection( view );
715
 
                const gboolean isSelected = gtk_tree_selection_path_is_selected( sel, path );
716
 
                GtkTreeModel * model = data->model;
717
 
                GtkTreeIter iter;
718
 
 
719
 
                gtk_tree_model_get_iter( model, &iter, path );
720
 
 
721
 
                if( priorityColumn )
722
 
                {
723
 
                    int priority;
724
 
 
725
 
                    /* get the `priority' state of the clicked row */
726
 
                    gtk_tree_model_get( model, &iter, FC_PRIORITY, &priority, -1 );
727
 
 
728
 
                    /* twiddle it to the next state */
729
 
                    switch( priority ) {
730
 
                        case TR_PRI_NORMAL: priority = TR_PRI_HIGH; break;
731
 
                        case TR_PRI_HIGH:   priority = TR_PRI_LOW; break;
732
 
                        default:            priority = TR_PRI_NORMAL; break;
733
 
                    }
734
 
 
735
 
                    /* apply that new state to the active files */
736
 
                    tr_torrentSetFilePriorities( tor,
737
 
                                                 (tr_file_index_t*)a->data,
738
 
                                                 (tr_file_index_t)a->len,
739
 
                                                 priority );
740
 
                }
741
 
                else if( downloadColumn )
742
 
                {
743
 
                    int enabled;
744
 
 
745
 
                    /* get the `enabled' state of the clicked row */
746
 
                    gtk_tree_model_get( model, &iter, FC_ENABLED, &enabled, -1 );
747
 
 
748
 
                    /* twiddle it to the next state */
749
 
                    enabled = !enabled;
750
 
 
751
 
                    /* apply that new state to the active files */
752
 
                    tr_torrentSetFileDLs( tor,
753
 
                                          (tr_file_index_t*)a->data,
754
 
                                          (tr_file_index_t)a->len,
755
 
                                          enabled );
756
 
                }
757
 
 
758
 
                refresh( data );
759
 
 
760
 
                /* the click was meant to change the priority or enabled state,
761
 
                   not to alter which rows were selected, so don't pass this
762
 
                   event on to the other handlers. */
763
 
                handled = isSelected;
764
 
 
765
 
                /* cleanup */
766
 
                g_array_free( a, TRUE );
767
 
            }
768
 
 
 
778
        handled = onViewPathToggled( treeview, col, path, data );
 
779
 
 
780
        if( path != NULL )
769
781
            gtk_tree_path_free( path );
770
 
        }
771
782
    }
772
783
 
773
784
    return handled;
774
785
}
775
786
 
776
787
GtkWidget *
777
 
file_list_new( TrCore * core, int torrentId )
 
788
gtr_file_list_new( TrCore * core, int torrentId )
778
789
{
 
790
    int size;
779
791
    int width;
780
792
    GtkWidget * ret;
781
793
    GtkWidget * view;
786
798
    GtkTreeView * tree_view;
787
799
    const char * title;
788
800
    PangoLayout * pango_layout;
 
801
    PangoContext * pango_context;
 
802
    PangoFontDescription * pango_font_description;
789
803
    FileData * data = g_new0( FileData, 1 );
790
804
 
791
805
    data->core = core;
803
817
                      G_CALLBACK( on_tree_view_button_released ), NULL );
804
818
 
805
819
 
 
820
    pango_context = gtk_widget_create_pango_context( view );
 
821
    pango_font_description = pango_font_description_copy( pango_context_get_font_description( pango_context ) );
 
822
    size = pango_font_description_get_size( pango_font_description );
 
823
    pango_font_description_set_size( pango_font_description, size * 0.8 );
 
824
    g_object_unref( G_OBJECT( pango_context ) );
 
825
 
806
826
    /* set up view */
807
827
    sel = gtk_tree_view_get_selection( tree_view );
808
828
    gtk_tree_selection_set_mode( sel, GTK_SELECTION_MULTIPLE );
810
830
    gtk_tree_view_set_search_column( tree_view, FC_LABEL );
811
831
 
812
832
    /* add file column */
813
 
 
814
833
    col = GTK_TREE_VIEW_COLUMN ( g_object_new ( GTK_TYPE_TREE_VIEW_COLUMN,
815
834
                                                "expand", TRUE,
816
 
                                                "title", _( "File" ),
 
835
                                                "title", _( "Name" ),
817
836
                                                NULL ) );
818
837
    gtk_tree_view_column_set_resizable( col, TRUE );
819
838
    rend = gtk_cell_renderer_pixbuf_new( );
821
840
    gtk_tree_view_column_add_attribute( col, rend, "pixbuf", FC_ICON );
822
841
    /* add text renderer */
823
842
    rend = gtk_cell_renderer_text_new( );
824
 
    g_object_set( rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL );
 
843
    g_object_set( rend, "ellipsize", PANGO_ELLIPSIZE_END, "font-desc", pango_font_description, NULL );
825
844
    gtk_tree_view_column_pack_start( col, rend, TRUE );
826
 
    gtk_tree_view_column_set_cell_data_func( col, rend, renderFilename, NULL, NULL );
 
845
    gtk_tree_view_column_set_attributes( col, rend, "text", FC_LABEL, NULL );
827
846
    gtk_tree_view_column_set_sort_column_id( col, FC_LABEL );
828
847
    gtk_tree_view_append_column( tree_view, col );
829
848
 
 
849
    /* add "size" column */
 
850
    title = _( "Size" );
 
851
    rend = gtk_cell_renderer_text_new( );
 
852
    g_object_set( rend, "alignment", PANGO_ALIGN_RIGHT,
 
853
                        "font-desc", pango_font_description,
 
854
                        "xpad", GUI_PAD,
 
855
                        "xalign", 1.0f,
 
856
                        "yalign", 0.5f,
 
857
                        NULL );
 
858
    col = gtk_tree_view_column_new_with_attributes( title, rend, NULL );
 
859
    gtk_tree_view_column_set_sizing( col, GTK_TREE_VIEW_COLUMN_GROW_ONLY );
 
860
    gtk_tree_view_column_set_sort_column_id( col, FC_SIZE );
 
861
    gtk_tree_view_column_set_attributes( col, rend, "text", FC_SIZE_STR, NULL );
 
862
    gtk_tree_view_append_column( tree_view, col );
 
863
 
830
864
    /* add "progress" column */
831
 
    title = _( "Progress" );
 
865
    title = _( "Have" );
832
866
    pango_layout = gtk_widget_create_pango_layout( view, title );
833
867
    pango_layout_get_pixel_size( pango_layout, &width, NULL );
834
868
    width += 30; /* room for the sort indicator */
848
882
    g_object_unref( G_OBJECT( pango_layout ) );
849
883
    rend = gtk_cell_renderer_toggle_new( );
850
884
    col = gtk_tree_view_column_new_with_attributes( title, rend, NULL );
 
885
    g_object_set_data( G_OBJECT( col ), TR_COLUMN_ID_KEY,
 
886
                       GINT_TO_POINTER( FC_ENABLED ) );
851
887
    gtk_tree_view_column_set_fixed_width( col, width );
852
888
    gtk_tree_view_column_set_sizing( col, GTK_TREE_VIEW_COLUMN_FIXED );
853
889
    gtk_tree_view_column_set_cell_data_func( col, rend, renderDownload, NULL, NULL );
863
899
    rend = gtk_cell_renderer_text_new( );
864
900
    g_object_set( rend, "xalign", (gfloat)0.5, "yalign", (gfloat)0.5, NULL );
865
901
    col = gtk_tree_view_column_new_with_attributes( title, rend, NULL );
 
902
    g_object_set_data( G_OBJECT( col ), TR_COLUMN_ID_KEY,
 
903
                       GINT_TO_POINTER( FC_PRIORITY ) );
866
904
    gtk_tree_view_column_set_fixed_width( col, width );
867
905
    gtk_tree_view_column_set_sizing( col, GTK_TREE_VIEW_COLUMN_FIXED );
868
906
    gtk_tree_view_column_set_sort_column_id( col, FC_PRIORITY );
883
921
    data->view = view;
884
922
    data->top = scroll;
885
923
    g_object_set_data_full( G_OBJECT( ret ), "file-data", data, freeData );
886
 
    file_list_set_torrent( ret, torrentId );
 
924
    gtr_file_list_set_torrent( ret, torrentId );
887
925
 
 
926
    pango_font_description_free( pango_font_description );
888
927
    return ret;
889
928
}