Beispiel #1
0
/**
 * gva_main_progress_bar_show:
 *
 * Shows the progress bar in the main window's status bar and sets the
 * mouse cursor to busy.  Generally useful before starting a long-running
 * foreground task.
 **/
void
gva_main_progress_bar_show (void)
{
        gva_main_progress_bar_set_fraction (0.0);
        gtk_widget_show (GVA_WIDGET_MAIN_PROGRESS_BAR);
        gva_main_cursor_busy ();
}
Beispiel #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;
        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;
}
Beispiel #3
0
/**
 * gva_main_progress_bar_show:
 *
 * Shows the progress bar in the main window's status bar and sets the
 * mouse cursor to busy.  Generally useful before starting a long-running
 * foreground task.
 **/
void
gva_main_progress_bar_show (void)
{
        GtkWindow *window;

        window = GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW);
        gtk_window_set_has_resize_grip (window, FALSE);

        gva_main_progress_bar_set_fraction (0.0);
        gtk_widget_show (GVA_WIDGET_MAIN_PROGRESS_BAR);
        gva_main_cursor_busy ();
}
Beispiel #4
0
/**
 * gva_main_build_database:
 * @error: return location for a #GError, or %NULL
 *
 * Executes the lengthy process of constructing the games database.
 * The function updates the main window's progress bar to help track
 * the database construction.  The function is synchronous; it blocks
 * until database construction is complete or aborted.
 *
 * Returns: %TRUE if the database construction was successful,
 *          %FALSE if construction failed or was aborted
 **/
gboolean
gva_main_build_database (GError **error)
{
        GvaProcess *process;
        guint context_id;
        guint total_supported;
        gboolean main_loop_quit = FALSE;
        gboolean success = FALSE;

        /* XXX Comment this code! */

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

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

        gva_main_progress_bar_show ();
        gva_main_progress_bar_set_fraction (0.0);
        gva_main_statusbar_push (context_id, _("Building game database…"));

        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;

        success = TRUE;

        gva_main_statusbar_pop (context_id);
        gva_main_progress_bar_hide ();

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

        return success;
}
Beispiel #5
0
static void
main_build_database_progress_cb (GvaProcess *process,
                                 GParamSpec *pspec,
                                 gpointer user_data)
{
        guint total_supported = GPOINTER_TO_UINT (user_data);
        gdouble fraction = 0.0;

        if (total_supported != 0)
        {
                guint progress;

                progress = gva_process_get_progress (process);
                fraction = (gdouble) progress / (gdouble) total_supported;
                fraction = CLAMP (fraction, 0.0, 1.0);
        }

        gva_main_progress_bar_set_fraction (fraction);
}