6b52775e58
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
37 lines
681 B
C
37 lines
681 B
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/idle.h>
|
|
#include <gui/builder.h>
|
|
#include <gtk/gtk.h>
|
|
|
|
static guint idle_id = 0;
|
|
|
|
static gboolean __on_idle(gpointer data)
|
|
{
|
|
GtkProgressBar *progress = GTK_PROGRESS_BAR(data);
|
|
|
|
if (idle_run_task()) {
|
|
gtk_progress_bar_set_fraction(progress, idle_progress());
|
|
return G_SOURCE_CONTINUE;
|
|
} else {
|
|
gtk_widget_hide(GTK_WIDGET(progress));
|
|
idle_id = 0;
|
|
return G_SOURCE_REMOVE;
|
|
}
|
|
}
|
|
|
|
void gui_idle_enable()
|
|
{
|
|
GtkWidget *progress = gui_builder_widget("o_idle_progress");
|
|
|
|
gtk_widget_show(progress);
|
|
idle_id = g_idle_add(__on_idle, progress);
|
|
}
|
|
|
|
void gui_idle_disable()
|
|
{
|
|
if (idle_id)
|
|
g_source_remove(idle_id);
|
|
}
|