~jblount/libubuntuone/classy-error-pages

« back to all changes in this revision

Viewing changes to libubuntuone/u1-music-store.c

  • Committer: Tarmac
  • Author(s): Rodrigo Moya
  • Date: 2010-03-02 10:16:37 UTC
  • mfrom: (46.1.4 calculate-percent)
  • Revision ID: rodrigo@megeve-20100302101637-99d5rxsysopafdal
Fixed percentage calculation and use a 5 seconds timeout for polling

Show diffs side-by-side

added added

removed removed

Lines of Context:
314
314
                                        escaped_prop = g_string_append_c (escaped_prop, prop[i]);
315
315
                        }
316
316
 
317
 
                        g_print ("Escaped prop = %s", escaped_prop->str);
 
317
                        g_debug ("Escaped prop = %s", escaped_prop->str);
318
318
 
319
319
                        full_path = g_build_filename (g_get_home_dir (),
320
320
                                                      ".ubuntuone/Purchased from Ubuntu One",
323
323
 
324
324
                        download = g_hash_table_lookup (current_downloads, full_path);
325
325
                        if (download != NULL) {
326
 
                                gfloat percent;
 
326
                                gdouble percent;
327
327
 
328
328
                                if (download->deflated_size != 0)
329
 
                                        percent = download->n_bytes_read / download->deflated_size;
 
329
                                        percent = (gdouble) download->n_bytes_read / (gdouble) download->deflated_size;
330
330
                                else
331
331
                                        percent = 0.0;
332
332
                                script = g_strdup_printf ("setProgressBar('%s', %.2f, '%d of %d bytes read');",
334
334
                        } else {
335
335
                                /* If the file exists, the download is done */
336
336
                                if (g_file_test (full_path, G_FILE_TEST_EXISTS))
337
 
                                        script = g_strdup_printf ("setProgressBar('%s', 1.0, 'Completed', true);", escaped_prop->str);
 
337
                                        script = g_strdup_printf ("setProgressBar('%s', 1.0, 'Completed', false);", escaped_prop->str);
338
338
                                else
339
339
                                        script = g_strdup_printf ("setProgressBar('%s', 0.0, 'Transferring to your Ubuntu One storage');", escaped_prop->str);
340
340
                        }
473
473
                execute_script (web_view, "u1-songs-clickable.js", NULL);
474
474
 
475
475
                /* Poll syncdaemon for downloads while the page is loaded */
476
 
                music_store->priv->watch_id = g_timeout_add (10000, (GSourceFunc) poll_downloads_cb, music_store);
 
476
                music_store->priv->watch_id = g_timeout_add (5000, (GSourceFunc) poll_downloads_cb, music_store);
477
477
        }
478
478
 
479
479
        g_free (tmp_url);