~dobey/libubuntuone/just-load-already

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Rodney Dawes
  • Date: 2012-03-06 20:50:46 UTC
  • mfrom: (146.1.1 u1ms-load-fixes)
  • Revision ID: tarmac-20120306205046-vxafldxcz652o5v9
Add a delay to the initial main store page loading, to avoid a race
Move progress bar creation, and notify signal connect, to avoid racing
Avoid an unneeded second call to get the URI from webkit in nav request

Show diffs side-by-side

added added

removed removed

Lines of Context:
544
544
                music_store->priv->watched_downloads = NULL;
545
545
        }
546
546
 
 
547
        network_uri = webkit_network_request_get_uri (request);
 
548
 
547
549
        /* Capture URLs we're interested in */
548
 
        parsed_uri = soup_uri_new (webkit_network_request_get_uri (request));
 
550
        parsed_uri = soup_uri_new (network_uri);
549
551
        if (parsed_uri == NULL)
550
552
                return FALSE;
551
553
 
552
 
        network_uri = webkit_network_request_get_uri (request);
553
554
        if (network_uri != NULL && g_str_has_prefix (network_uri, U1_NOT_REGISTERED_URL)) {
554
555
                fire_authentication (music_store, request, policy_decision);
555
556
        } else if (g_str_has_prefix (parsed_uri->path, "/auth/login") &&
561
562
                fire_authentication (music_store, request, policy_decision);
562
563
        } else if (g_strrstr (parsed_uri->path, "library.aspx") != NULL ||
563
564
                 g_str_has_prefix (parsed_uri->path, "/music/store/library")) {
564
 
                //g_str_has_prefix (webkit_network_request_get_uri (request), "https://one.ubuntu.com/music/store/library")) {
565
565
                const gchar *library_override;
566
566
 
567
567
                /* If the URL being loaded is the 7d library page, and we have a library
1222
1222
        folder_info = syncdaemon_daemon_get_folder_info (music_store->priv->syncdaemon, u1_music_store_get_library_location (music_store));
1223
1223
        music_store->priv->folder_subscribed = syncdaemon_folder_info_get_subscribed (folder_info);
1224
1224
 
1225
 
        g_signal_connect (G_OBJECT (music_store->priv->web_viewer), "notify",
1226
 
                          G_CALLBACK (viewer_property_changed_cb), music_store);
1227
 
 
1228
1225
        /* Rescan the purchased music folder */
1229
1226
        _u1_music_store_rescan_purchased_folder (music_store);
1230
1227
 
1266
1263
 
1267
1264
        music_store->priv->base_url = g_strdup (url_to_use);
1268
1265
 
 
1266
        /* Create a hidden progress bar */
 
1267
        music_store->priv->progress = gtk_progress_bar_new ();
 
1268
        
1269
1269
        /* Create web viewer object */
1270
1270
        music_store->priv->scroll = gtk_scrolled_window_new (NULL, NULL);
1271
1271
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (music_store->priv->scroll),
1303
1303
        g_signal_connect (G_OBJECT (music_store->priv->web_viewer), "load-error",
1304
1304
                          G_CALLBACK (load_error_cb), music_store);
1305
1305
 
 
1306
        g_signal_connect (G_OBJECT (music_store->priv->web_viewer), "notify",
 
1307
                          G_CALLBACK (viewer_property_changed_cb), music_store);
 
1308
 
1306
1309
        /* Show a temp view when loading the initial store page */
1307
1310
        load_internal_html_page (WEBKIT_WEB_VIEW (music_store->priv->web_viewer), 
1308
1311
                                 U1_CONNECTING_PAGE, NULL);
1344
1347
        g_signal_connect (G_OBJECT (music_store->priv->subscribe_btn), "clicked",
1345
1348
                          G_CALLBACK (subscribe_purchased_folder), music_store);
1346
1349
 
1347
 
        /* Create a hidden progress bar */
1348
 
        music_store->priv->progress = gtk_progress_bar_new ();
1349
 
        
1350
1350
        gtk_box_pack_start (GTK_BOX (music_store), music_store->priv->alertbar, FALSE, FALSE, 6);
1351
1351
        gtk_box_pack_start (GTK_BOX (music_store), music_store->priv->scroll, TRUE, TRUE, 0);
1352
1352
        gtk_box_pack_end (GTK_BOX (music_store), music_store->priv->progress, FALSE, FALSE, 0);
1356
1356
                              music_store);
1357
1357
 
1358
1358
        /* And load the real store in the background */
1359
 
        music_store->priv->idle_cb = g_idle_add ((GSourceFunc) load_real_store_cb, music_store);
 
1359
        music_store->priv->idle_cb = g_timeout_add_seconds (2, (GSourceFunc) load_real_store_cb, music_store);
1360
1360
 
1361
1361
}
1362
1362
 
1416
1416
        g_return_if_fail (U1_IS_MUSIC_STORE (music_store));
1417
1417
        g_return_if_fail (url != NULL);
1418
1418
 
1419
 
        /* Stop any currently pending or active page loads first */
1420
 
        webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (music_store->priv->web_viewer));
1421
 
 
1422
1419
        /* If the load_real_store callback is set up, disable it first */
1423
1420
        if (music_store->priv->idle_cb > 0) {
1424
1421
                g_source_remove (music_store->priv->idle_cb);
1425
1422
                music_store->priv->idle_cb = 0;
1426
1423
        }
1427
1424
 
 
1425
        /* Stop any currently pending or active page loads first */
 
1426
        webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (music_store->priv->web_viewer));
 
1427
 
1428
1428
        quoted_url = g_uri_escape_string (url, NULL, FALSE);
1429
1429
        real_url = g_strdup_printf ("%s%s?forward_on_to_url=%s",
1430
1430
                                    music_store->priv->base_url,