[Summary] Embed (DRAG-nDROPped) file with different sample rate DIALOG

[Feature reviewed] Mykhailo Kosharnyy
[Reviewed] YPozdnyakov
This commit is contained in:
Nikolay 2015-01-15 18:23:12 +02:00
parent 0f1ad3ef6f
commit 86f858c82b
5 changed files with 60 additions and 63 deletions

View file

@ -272,7 +272,7 @@ Editor::do_import (vector<string> paths, ImportDisposition disposition, ImportMo
import_status.total = paths.size (); import_status.total = paths.size ();
import_status.all_done = false; import_status.all_done = false;
ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import")); ImportProgressWindow ipw (&import_status);
bool ok = true; bool ok = true;

View file

@ -3731,7 +3731,7 @@ Editor::freeze_route ()
InterThreadInfo itt; InterThreadInfo itt;
current_interthread_info = &itt; current_interthread_info = &itt;
InterthreadProgressWindow ipw (current_interthread_info, _("Freeze"), _("Cancel Freeze")); InterthreadProgressWindow ipw (current_interthread_info);
pthread_create_and_store (X_("freezer"), &itt.thread, _freeze_thread, this); pthread_create_and_store (X_("freezer"), &itt.thread, _freeze_thread, this);

View file

@ -89,8 +89,7 @@ Editor::embed_audio_from_video (std::string path, framepos_t n, bool lock_positi
import_status.total = paths.size (); import_status.total = paths.size ();
import_status.all_done = false; import_status.all_done = false;
ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import")); ImportProgressWindow ipw (&import_status);
ipw.show ();
boost::shared_ptr<ARDOUR::Track> track; boost::shared_ptr<ARDOUR::Track> track;
bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0); bool ok = (import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, n, 1, 1, track, false) == 0);

View file

@ -22,85 +22,80 @@
#include "ardour/import_status.h" #include "ardour/import_status.h"
#include "interthread_progress_window.h" #include "interthread_progress_window.h"
#include "i18n.h" #include "i18n.h"
#include "progress_dialog.h"
#include "gtkmm2ext/gui_thread.h"
using namespace std; using namespace std;
using namespace Gtk; using namespace Gtk;
/** @param i Status information. /** @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) InterthreadProgressWindow::InterthreadProgressWindow (ARDOUR::InterThreadInfo* i)
, _interthread_info (i) : _interthread_info (i)
{ {
_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT); _timeout_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::update), 100);
_progress_dialog.CancelClicked.connect (_cancel_connection, MISSING_INVALIDATOR, boost::bind (&InterthreadProgressWindow::cancel_clicked, this), gui_context());
}
set_border_width (12); InterthreadProgressWindow::~InterthreadProgressWindow ()
get_vbox()->set_spacing (6); {
_timeout_connection.disconnect ();
get_vbox()->pack_start (_bar, false, false); _cancel_connection.disconnect ();
_progress_dialog.hide_cancel_button ();
Button* b = add_button ("CANCEL", RESPONSE_CANCEL); _progress_dialog.hide_pd ();
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 ();
hide ();
Glib::signal_timeout().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::update), 100);
} }
void void
InterthreadProgressWindow::cancel_clicked () InterthreadProgressWindow::cancel_clicked ()
{ {
_interthread_info->cancel = true; _interthread_info->cancel = true;
}
void
InterthreadProgressWindow::show ()
{
_progress_dialog.show_pd ();
_progress_dialog.show_cancel_button ();
} }
bool bool
InterthreadProgressWindow::update () InterthreadProgressWindow::update ()
{ {
_bar.set_fraction (_interthread_info->progress); _progress_dialog.set_progress (_interthread_info->progress);
return !(_interthread_info->done || _interthread_info->cancel); return !(_interthread_info->done || _interthread_info->cancel);
} }
/** @param i Status information. /** @param s Status information.
* @param t Window title. */
* @param c Label to use for Cancel button.
*/ ImportProgressWindow::ImportProgressWindow (ARDOUR::ImportStatus* s)
ImportProgressWindow::ImportProgressWindow (ARDOUR::ImportStatus* s, string const & t, string const & c) : InterthreadProgressWindow (s)
: InterthreadProgressWindow (s, t, c) , _import_status (s)
, _import_status (s)
{ {
_label.set_alignment (0, 0.5);
_label.set_use_markup (true);
get_vbox()->pack_start (_label, false, false);
_label.show ();
} }
bool bool
ImportProgressWindow::update () ImportProgressWindow::update ()
{ {
_cancel_button.set_sensitive (!_import_status->freeze); _progress_dialog.set_cancel_button_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 */ /* 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); double fraction = (_import_status->current - 1 + _import_status->progress) / _import_status->total;
/* some of the code which sets up _import_status->current may briefly increment it too far
at the end of an import, so check for that to avoid a visual glitch */
/* some of the code which sets up _import_status->current may briefly increment it too far uint32_t c = _import_status->current;
at the end of an import, so check for that to avoid a visual glitch
*/
uint32_t c = _import_status->current;
if (c > _import_status->total) { if (c > _import_status->total) {
c = _import_status->total; c = _import_status->total;
} }
_bar.set_text (string_compose (_("Importing file: %1 of %2"), c, _import_status->total)); _progress_dialog.update_info ( fraction,
_("Importing files"),
return !(_import_status->all_done || _import_status->cancel); (string_compose (_("Importing file: %1 of %2"), c, _import_status->total)).c_str(),
(_import_status->doing_what).c_str() );
return !(_import_status->all_done || _import_status->cancel);
} }

View file

@ -22,7 +22,10 @@
#include <gtkmm/label.h> #include <gtkmm/label.h>
#include <gtkmm/progressbar.h> #include <gtkmm/progressbar.h>
#include "pbd/signals.h"
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "waves_button.h"
#include "progress_dialog.h"
namespace ARDOUR { namespace ARDOUR {
class InterThreadInfo; class InterThreadInfo;
@ -34,35 +37,35 @@ namespace ARDOUR {
* automagically updated using a Glib timer, and a cancel button. * automagically updated using a Glib timer, and a cancel button.
*/ */
class InterthreadProgressWindow : public ArdourDialog class InterthreadProgressWindow
{ {
public: public:
InterthreadProgressWindow (ARDOUR::InterThreadInfo *, std::string const &, std::string const &); InterthreadProgressWindow (ARDOUR::InterThreadInfo *);
virtual ~InterthreadProgressWindow ();
void show ();
protected: protected:
virtual bool update (); virtual bool update ();
ProgressDialog _progress_dialog;
Gtk::Button _cancel_button;
Gtk::Label _cancel_label;
Gtk::ProgressBar _bar;
private: private:
void cancel_clicked (); void cancel_clicked ();
ARDOUR::InterThreadInfo* _interthread_info; ARDOUR::InterThreadInfo* _interthread_info;
PBD::ScopedConnection _cancel_connection;
sigc::connection _timeout_connection;
}; };
/** Progress dialogue for importing sound files */ /** Progress dialogue for importing sound files */
class ImportProgressWindow : public InterthreadProgressWindow class ImportProgressWindow : public InterthreadProgressWindow
{ {
public: public:
ImportProgressWindow (ARDOUR::ImportStatus *, std::string const &, std::string const &); ImportProgressWindow (ARDOUR::ImportStatus *);
private: private:
bool update (); bool update ();
Gtk::Label _label;
ARDOUR::ImportStatus* _import_status; ARDOUR::ImportStatus* _import_status;
}; };