diff --git a/gtk/actions.c b/gtk/actions.c index 6b881e225..49ff40912 100644 --- a/gtk/actions.c +++ b/gtk/actions.c @@ -47,8 +47,9 @@ static GtkRadioActionEntry sort_radio_entries[] = { "sort-by-activity", NULL, N_("Sort by _Activity"), NULL, NULL, 0 }, { "sort-by-name", NULL, N_("Sort by _Name"), NULL, NULL, 1 }, { "sort-by-progress", NULL, N_("Sort by _Progress"), NULL, NULL, 2 }, - { "sort-by-state", NULL, N_("Sort by _State"), NULL, NULL, 3 }, - { "sort-by-tracker", NULL, N_("Sort by _Tracker"), NULL, NULL, 4 } + { "sort-by-ratio", NULL, N_("Sort by _Ratio"), NULL, NULL, 3 }, + { "sort-by-state", NULL, N_("Sort by _State"), NULL, NULL, 4 }, + { "sort-by-tracker", NULL, N_("Sort by _Tracker"), NULL, NULL, 5 } }; static void diff --git a/gtk/makemeta-ui.c b/gtk/makemeta-ui.c index d1a2be650..2d724f038 100644 --- a/gtk/makemeta-ui.c +++ b/gtk/makemeta-ui.c @@ -114,7 +114,7 @@ refresh_cb ( gpointer user_data ) } case TR_MAKEMETA_IO_WRITE: { - char * tmp = g_strdup_printf( _( "Couldn't write \"%s\": %s" ), ui->builder->errfile, g_strerror( ui->builder->my_errno ) ); + char * tmp = g_strdup_printf( _( "Couldn't create \"%1$s\": %2$s" ), ui->builder->errfile, g_strerror( ui->builder->my_errno ) ); txt = g_strdup_printf( _( "Torrent creation failed: %s" ), tmp ); g_free( tmp ); break; diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 6800a1444..8e5aa2eae 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -166,6 +166,33 @@ compareDouble( double a, double b ) return 0; } +static int +compareRatio( double a, double b ) +{ + if( (int)a == TR_RATIO_INF && (int)b == TR_RATIO_INF ) return 0; + if( (int)a == TR_RATIO_INF ) return 1; + if( (int)b == TR_RATIO_INF ) return -1; + return compareDouble( a, b ); +} + +static int +compareByRatio( GtkTreeModel * model, + GtkTreeIter * a, + GtkTreeIter * b, + gpointer user_data UNUSED ) +{ + tr_torrent *ta, *tb; + const tr_stat *sa, *sb; + + gtk_tree_model_get( model, a, MC_TORRENT_RAW, &ta, -1 ); + gtk_tree_model_get( model, b, MC_TORRENT_RAW, &tb, -1 ); + + sa = tr_torrentStatCached( ta ); + sb = tr_torrentStatCached( tb ); + + return compareRatio( sa->ratio, sb->ratio ); +} + static int compareByActivity( GtkTreeModel * model, GtkTreeIter * a, @@ -223,7 +250,7 @@ compareByProgress( GtkTreeModel * model, sb = tr_torrentStatCached( tb ); ret = compareDouble( sa->percentDone, sb->percentDone ); if( !ret ) - ret = compareDouble( sa->ratio, sb->ratio ); + ret = compareRatio( sa->ratio, sb->ratio ); return ret; } @@ -263,24 +290,27 @@ compareByTracker( GtkTreeModel * model, static void setSort( TrCore * core, const char * mode, gboolean isReversed ) { - int col = MC_TORRENT_RAW; + const int col = MC_TORRENT_RAW; + GtkTreeIterCompareFunc sort_func; GtkSortType type = isReversed ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING; - GtkTreeModel * model = tr_core_model( core ); - GtkTreeSortable * sortable = GTK_TREE_SORTABLE( model ); + GtkTreeSortable * sortable = GTK_TREE_SORTABLE( tr_core_model( core ) ); if( !strcmp( mode, "sort-by-activity" ) ) - gtk_tree_sortable_set_sort_func( sortable, col, compareByActivity, NULL, NULL ); + sort_func = compareByActivity; else if( !strcmp( mode, "sort-by-progress" ) ) - gtk_tree_sortable_set_sort_func( sortable, col, compareByProgress, NULL, NULL ); + sort_func = compareByProgress; + else if( !strcmp( mode, "sort-by-ratio" ) ) + sort_func = compareByRatio; else if( !strcmp( mode, "sort-by-state" ) ) - gtk_tree_sortable_set_sort_func( sortable, col, compareByState, NULL, NULL ); + sort_func = compareByState; else if( !strcmp( mode, "sort-by-tracker" ) ) - gtk_tree_sortable_set_sort_func( sortable, col, compareByTracker, NULL, NULL ); + sort_func = compareByTracker; else { + sort_func = compareByName; type = isReversed ? GTK_SORT_DESCENDING : GTK_SORT_ASCENDING; - gtk_tree_sortable_set_sort_func( sortable, col, compareByName, NULL, NULL ); } - + + gtk_tree_sortable_set_sort_func( sortable, col, sort_func, NULL, NULL ); gtk_tree_sortable_set_sort_column_id( sortable, col, type ); } diff --git a/gtk/tr-prefs.c b/gtk/tr-prefs.c index c9e981711..e7eb4f4aa 100644 --- a/gtk/tr-prefs.c +++ b/gtk/tr-prefs.c @@ -461,7 +461,7 @@ peerPage( GObject * core ) target_cb( w, b ); hig_workarea_add_wide_control( t, &row, h ); - s = _("Ignore _unencrypted peers"); + s = _("_Ignore unencrypted peers"); w = new_check_button( s, PREF_KEY_ENCRYPTED_ONLY, core ); hig_workarea_add_wide_control( t, &row, w ); diff --git a/gtk/ui.h b/gtk/ui.h index b76c61b75..dffedf11b 100644 --- a/gtk/ui.h +++ b/gtk/ui.h @@ -32,6 +32,7 @@ const char * fallback_ui_file = " \n" " \n" " \n" +" \n" " \n" " \n" " \n"