Revision 1853 trunk/client/gui/queue.c

queue.c (revision 1853)
1219 1219
}
1220 1220

                
1221 1221
static void
1222
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state)
1222
file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining)
1223 1223
{
1224 1224
    GtkWidget *treeDownloadQueue;
1225 1225
    GtkTreeModel *store;
1226 1226
    GtkTreeIter iter, parent;
1227 1227
    int progress;
1228
    guint64 file_size;
1229
    guint64 file_size_remaining;
1230
    guint64 total_size;
1231
    guint64 total_size_remaining;
1232 1228
    char size[64];
1233 1229
    char size_remaining[64];
1234 1230

                
... ...
1241 1237
    switch(new_state) {
1242 1238
        case TASK_STATE_WAITING_FOR_DOWNLOAD:       // The file was restarted
1243 1239
            // Update the row itself
1244
            gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,    FIELD_FILESIZE, &file_size,
1245
                                                                FIELD_FILESIZE_REMAINING, &file_size_remaining, -1);
1246

                
1247 1240
            memset(size_remaining, 0, sizeof(size_remaining));
1248
            nntpgrab_utils_calculate_file_size(file_size, size_remaining, sizeof(size_remaining) - 1);
1241
            nntpgrab_utils_calculate_file_size(file_size_remaining, size_remaining, sizeof(size_remaining) - 1);
1249 1242

                
1250 1243
            gtk_tree_store_set(GTK_TREE_STORE(store), &iter,    FIELD_PARTS_DONE, (int) 0,
1251 1244
                                                                FIELD_PARTS_FAILED, (int) 0,
1252 1245
                                                                FIELD_PROGRESS, (int) 0,
1253 1246
                                                                FIELD_STATE_STR, NULL,
1254
                                                                FIELD_FILESIZE_REMAINING, file_size,
1247
                                                                FIELD_FILESIZE_REMAINING, file_size_remaining,
1255 1248
                                                                FIELD_FILESIZE_REMAINING_STR, size_remaining, -1);
1256 1249

                
1257 1250
            // Update the parent
1258
            gtk_tree_model_get(GTK_TREE_MODEL(store), &parent,  FIELD_FILESIZE, &total_size,
1259
                                                                FIELD_FILESIZE_REMAINING, &total_size_remaining, -1);
1260

                
1261
            if (old_state == TASK_STATE_SKIPPED) {
1262
                total_size += file_size - file_size_remaining;
1263
            }
1264

                
1265
            total_size_remaining += file_size - file_size_remaining;
1266 1251
            progress = calculate_progress(total_size, total_size_remaining);
1267 1252

                
1268 1253
            memset(size, 0, sizeof(size));
1269
            nntpgrab_utils_calculate_file_size(total_size_remaining, size, sizeof(size) - 1);
1254
            nntpgrab_utils_calculate_file_size(total_size, size, sizeof(size) - 1);
1270 1255

                
1271 1256
            memset(size_remaining, 0, sizeof(size_remaining));
1272 1257
            nntpgrab_utils_calculate_file_size(total_size_remaining, size_remaining, sizeof(size_remaining) - 1);
... ...
1316 1301
            break;
1317 1302

                
1318 1303
        case TASK_STATE_SKIPPED:
1319
            gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,    FIELD_FILESIZE, &file_size,
1320
                                                                FIELD_FILESIZE_REMAINING, &file_size_remaining, -1);
1321

                
1322 1304
            gtk_tree_store_set(GTK_TREE_STORE(store), &iter,    FIELD_STATE_STR, _("Skipped"),
1323 1305
                                                                FIELD_FILESIZE_REMAINING, (guint64) 0,
1324 1306
                                                                FIELD_FILESIZE_REMAINING_STR, NULL, -1);
1325 1307

                
1326 1308
            // Update the parent
1327
            gtk_tree_model_get(GTK_TREE_MODEL(store), &parent,  FIELD_FILESIZE, &total_size,
1328
                                                                FIELD_FILESIZE_REMAINING, &total_size_remaining, -1);
1329

                
1330
            total_size -= file_size_remaining;
1331
            total_size_remaining -= file_size_remaining;
1332 1309
            progress = calculate_progress(total_size, total_size_remaining);
1310

                
1311
            memset(size, 0, sizeof(size));
1312
            nntpgrab_utils_calculate_file_size(total_size, size, sizeof(size) - 1);
1313

                
1333 1314
            memset(size_remaining, 0, sizeof(size_remaining));
1334 1315
            nntpgrab_utils_calculate_file_size(total_size_remaining, size_remaining, sizeof(size_remaining) - 1);
1335 1316

                
1336 1317
            gtk_tree_store_set(GTK_TREE_STORE(store), &parent,  FIELD_PROGRESS, progress,
1318
                                                                FIELD_FILESIZE, total_size,
1319
                                                                FIELD_FILESIZE_REMAINING, size,
1337 1320
                                                                FIELD_FILESIZE_REMAINING, total_size_remaining,
1338 1321
                                                                FIELD_FILESIZE_REMAINING_STR, size_remaining, -1);
1339 1322

                

Also available in: Unified diff