Esempio n. 1
0
/**
 * gva_main_analyze_roms:
 * @error: return location for a #GError, or %NULL
 *
 * Executes the lengthy process of analyzing all available ROM and sample
 * sets for correctness and then updating the games database with the new
 * status information.  The function updates the main window's progress bar
 * to help track the analysis.  The function is synchronous; it blocks until
 * the analysis is complete or aborted.
 *
 * Returns: %TRUE if the analysis completed successfully,
 *          %FALSE if the analysis failed or was aborted
 **/
gboolean
gva_main_analyze_roms (GError **error)
{
        GvaProcess *process;
        GvaProcess *process2 = NULL;
        guint context_id;
        gboolean main_loop_quit = FALSE;
        gboolean success = FALSE;
        guint timeout_id = 0;

        context_id = gva_main_statusbar_get_context_id (G_STRFUNC);

        process = gva_audit_roms (error);
        if (process == NULL)
                goto exit;

        process2 = gva_audit_samples (error);
        if (process2 == NULL)
                goto exit;

        gva_main_progress_bar_show ();
        gva_main_progress_bar_set_fraction (0.0);
        gva_main_statusbar_push (context_id, _("Analyzing ROM files…"));

        timeout_id = g_timeout_add (
                PROGRESS_BAR_PULSE_INTERVAL_MS,
                main_progress_bar_pulse_cb,
                GVA_WIDGET_MAIN_PROGRESS_BAR);

        while (!gva_process_has_exited (process, NULL))
                main_loop_quit = gtk_main_iteration ();

        if (main_loop_quit)
                goto exit;

        while (!gva_process_has_exited (process2, NULL))
                main_loop_quit = gtk_main_iteration ();

        if (main_loop_quit)
                goto exit;

        success = TRUE;

        gva_main_statusbar_pop (context_id);
        gva_main_progress_bar_hide ();

exit:
        if (timeout_id > 0)
                g_source_remove (timeout_id);

        if (process != NULL)
                g_object_unref (process);

        if (process2 != NULL)
                g_object_unref (process2);

        return success;
}
Esempio n. 2
0
/**
 * gva_main_analyze_roms:
 * @error: return location for a #GError, or %NULL
 *
 * Executes the lengthy process of analyzing all available ROM and sample
 * sets for correctness and then updating the games database with the new
 * status information.  The function updates the main window's progress bar
 * to help track the analysis.  The function is synchronous; it blocks until
 * the analysis is complete or aborted.
 *
 * Returns: %TRUE if the analysis completed successfully,
 *          %FALSE if the analysis failed or was aborted
 **/
gboolean
gva_main_analyze_roms (GError **error)
{
        GvaProcess *process;
        GvaProcess *process2 = NULL;
        guint context_id;
        guint total_supported;
        gboolean main_loop_quit = FALSE;
        gboolean success = FALSE;

        context_id = gva_main_statusbar_get_context_id (G_STRFUNC);
        total_supported = gva_mame_get_total_supported (NULL);

        process = gva_audit_roms (error);
        if (process == NULL)
                goto exit;

        process2 = gva_audit_samples (error);
        if (process2 == NULL)
                goto exit;

        gva_main_statusbar_push (context_id, _("Analyzing ROM files..."));

        g_signal_connect (
                process, "notify::progress",
                G_CALLBACK (main_build_database_progress_cb),
                GUINT_TO_POINTER (total_supported));

        while (!gva_process_has_exited (process, NULL))
                main_loop_quit = gtk_main_iteration ();

        if (main_loop_quit)
                goto exit;

        while (!gva_process_has_exited (process2, NULL))
                main_loop_quit = gtk_main_iteration ();

        if (main_loop_quit)
                goto exit;

        success = TRUE;

        gva_main_statusbar_pop (context_id);

exit:
        if (process != NULL)
                g_object_unref (process);

        if (process2 != NULL)
                g_object_unref (process2);

        return success;
}