/* ASE - Allegro Sprite Editor * Copyright (C) 2001-2009 David Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "config.h" #include "jinete/jalert.h" #include "jinete/jmutex.h" #include "jinete/jthread.h" #include "jinete/jwidget.h" #include "jinete/jwindow.h" #include "core/app.h" #include "core/job.h" #include "modules/gui.h" #include "widgets/statebar.h" Job::Job() { m_mutex = NULL; m_thread = NULL; m_progress = NULL; m_monitor = NULL; m_alert_window = NULL; m_last_progress = 0.0f; m_done_flag = false; m_canceled_flag = false; m_mutex = jmutex_new(); m_progress = progress_new(app_get_statusbar()); m_monitor = add_gui_monitor(&Job::monitor_proc, &Job::monitor_free, (void*)this); m_alert_window = jalert_new(PACKAGE "<on_job(); } catch (...) { // TODO handle this exception } self->done(); } /** * Procedure called from the GUI loop to monitoring each 100 milliseconds. * * [main thread] */ void Job::monitor_proc(void* data) { Job* self = (Job*)data; self->on_monitor_tick(); } /** * Function called when the GUI monitor is deleted. * * [main thread] */ void Job::monitor_free(void* data) { Job* self = (Job*)data; self->on_monitor_destroyed(); }