mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Separate interthread progress window out into its own class and HIG-ify it a bit. Make the import progress bar report on the whole import rather than individual files.
git-svn-id: svn://localhost/ardour2/branches/3.0@6894 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
8783fc35f2
commit
3d3e889dd6
8 changed files with 174 additions and 130 deletions
94
gtk2_ardour/interthread_progress_window.cc
Normal file
94
gtk2_ardour/interthread_progress_window.cc
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
Copyright (C) 2010 Paul Davis
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <glibmm/main.h>
|
||||
#include <gtkmm/stock.h>
|
||||
#include "ardour/import_status.h"
|
||||
#include "interthread_progress_window.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Gtk;
|
||||
|
||||
/** @param i Status information.
|
||||
* @param t Window title.
|
||||
* @param c Label to use for Cancel button.
|
||||
*/
|
||||
InterthreadProgressWindow::InterthreadProgressWindow (ARDOUR::InterThreadInfo* i, string const & t, string const & c)
|
||||
: ArdourDialog (t, true)
|
||||
, _interthread_info (i)
|
||||
{
|
||||
_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
|
||||
|
||||
set_border_width (12);
|
||||
get_vbox()->set_spacing (6);
|
||||
|
||||
get_vbox()->pack_start (_bar, false, false);
|
||||
|
||||
Button* b = add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||
b->signal_clicked().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::cancel_clicked));
|
||||
|
||||
_cancel_label.set_text (c);
|
||||
_cancel_button.add (_cancel_label);
|
||||
|
||||
set_default_size (200, 100);
|
||||
show_all ();
|
||||
|
||||
Glib::signal_timeout().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::update), 100);
|
||||
}
|
||||
|
||||
void
|
||||
InterthreadProgressWindow::cancel_clicked ()
|
||||
{
|
||||
_interthread_info->cancel = true;
|
||||
}
|
||||
|
||||
bool
|
||||
InterthreadProgressWindow::update ()
|
||||
{
|
||||
_bar.set_fraction (_interthread_info->progress);
|
||||
return !(_interthread_info->done || _interthread_info->cancel);
|
||||
}
|
||||
|
||||
/** @param i Status information.
|
||||
* @param t Window title.
|
||||
* @param c Label to use for Cancel button.
|
||||
*/
|
||||
ImportProgressWindow::ImportProgressWindow (ARDOUR::ImportStatus* s, string const & t, string const & c)
|
||||
: InterthreadProgressWindow (s, t, c)
|
||||
, _import_status (s)
|
||||
{
|
||||
_label.set_alignment (0, 0.5);
|
||||
_label.set_use_markup (true);
|
||||
|
||||
get_vbox()->pack_start (_label, false, false);
|
||||
|
||||
_label.show ();
|
||||
}
|
||||
|
||||
bool
|
||||
ImportProgressWindow::update ()
|
||||
{
|
||||
_cancel_button.set_sensitive (!_import_status->freeze);
|
||||
_label.set_markup ("<i>" + _import_status->doing_what + "</i>");
|
||||
|
||||
/* use overall progress for the bar, rather than that for individual files */
|
||||
_bar.set_fraction ((_import_status->current - 1 + _import_status->progress) / _import_status->total);
|
||||
|
||||
return !(_import_status->done || _import_status->cancel);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue