summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor.cc1
-rw-r--r--gtk2_ardour/editor.h13
-rw-r--r--gtk2_ardour/editor_audio_import.cc54
-rw-r--r--gtk2_ardour/editor_ops.cc58
-rw-r--r--gtk2_ardour/interthread_progress_window.cc94
-rw-r--r--gtk2_ardour/interthread_progress_window.h69
-rw-r--r--gtk2_ardour/wscript1
-rw-r--r--libs/ardour/import.cc14
8 files changed, 174 insertions, 130 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 70a3c047b8..715800550e 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -304,7 +304,6 @@ Editor::Editor ()
last_autoscroll_y = 0;
autoscroll_active = false;
autoscroll_timeout_tag = -1;
- interthread_progress_window = 0;
logo_item = 0;
analysis_window = 0;
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index ca7d7766ee..15cee99dde 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1174,17 +1174,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
boost::shared_ptr<ARDOUR::AudioTrack> get_nth_selected_audio_track (int nth) const;
boost::shared_ptr<ARDOUR::MidiTrack> get_nth_selected_midi_track (int nth) const;
- /* generic interthread progress window */
-
- ArdourDialog* interthread_progress_window;
- Gtk::Label interthread_progress_label;
- Gtk::VBox interthread_progress_vbox;
- Gtk::ProgressBar interthread_progress_bar;
- Gtk::Button interthread_cancel_button;
- Gtk::Label interthread_cancel_label;
- sigc::connection interthread_progress_connection;
- void interthread_cancel_clicked ();
- void build_interthread_progress_window ();
ARDOUR::InterThreadInfo* current_interthread_info;
AnalysisWindow* analysis_window;
@@ -1201,7 +1190,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
};
EditorImportStatus import_status;
- gint import_progress_timeout (void *);
static void *_import_thread (void *);
void* import_thread ();
void finish_import ();
@@ -1795,7 +1783,6 @@ public:
/* freeze operations */
ARDOUR::InterThreadInfo freeze_status;
- gint freeze_progress_timeout (void *);
static void* _freeze_thread (void*);
void* freeze_thread ();
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 65ddb12e30..e7572ce8c1 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -58,6 +58,7 @@
#include "session_import_dialog.h"
#include "utils.h"
#include "gui_thread.h"
+#include "interthread_progress_window.h"
#include "i18n.h"
@@ -330,15 +331,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
import_status.current = 1;
import_status.total = paths.size ();
- if (interthread_progress_window == 0) {
- build_interthread_progress_window ();
- }
-
- interthread_progress_window->set_title (_("Import"));
- interthread_progress_bar.set_fraction (0.0f);
- interthread_cancel_label.set_text (_("Cancel Import"));
- interthread_progress_connection = Glib::signal_timeout().connect
- (sigc::bind (sigc::mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 500);
+ ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
if (chns == Editing::ImportMergeFiles) {
@@ -419,9 +412,6 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
}
}
}
-
- interthread_progress_window->hide_all ();
- interthread_progress_connection.disconnect ();
}
void
@@ -937,43 +927,3 @@ Editor::import_thread ()
/*NOTREACHED*/
return 0;
}
-
-gint
-Editor::import_progress_timeout (void */*arg*/)
-{
- bool reset = false;
-
- if (!interthread_progress_window->is_visible()) {
- interthread_progress_window->show_all ();
- reset = true;
- }
-
- interthread_progress_label.set_markup (import_status.doing_what);
-
- if (import_status.freeze) {
- interthread_cancel_button.set_sensitive(false);
- } else {
- interthread_cancel_button.set_sensitive(true);
- }
-
- if (import_status.doing_what == "building peak files") {
- interthread_progress_bar.pulse ();
- return FALSE;
- } else {
- float val = import_status.progress;
- interthread_progress_bar.set_fraction (min (max (0.0f, val), 1.0f));
- }
-
- if (reset) {
-
- /* the window is now visible, speed up the updates */
-
- interthread_progress_connection.disconnect ();
- interthread_progress_connection = Glib::signal_timeout().connect
- (sigc::bind (sigc::mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 100);
- return false;
- } else {
- return !(import_status.done || import_status.cancel);
- }
-}
-
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 0535b31d3b..a38998ba73 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -79,6 +79,7 @@
#include "editor_routes.h"
#include "editor_regions.h"
#include "quantize_dialog.h"
+#include "interthread_progress_window.h"
#include "i18n.h"
@@ -2603,40 +2604,6 @@ Editor::audition_playlist_region_standalone (boost::shared_ptr<Region> region)
}
void
-Editor::build_interthread_progress_window ()
-{
- interthread_progress_window = new ArdourDialog (X_("interthread progress"), true);
-
- interthread_progress_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
-
- interthread_progress_window->set_border_width (12);
- interthread_progress_window->get_vbox()->set_spacing (6);
-
- interthread_progress_label.set_alignment (0, 0.5);
- interthread_progress_label.set_use_markup (true);
-
- interthread_progress_window->get_vbox()->pack_start (interthread_progress_label, false, false);
- interthread_progress_window->get_vbox()->pack_start (interthread_progress_bar,false, false);
-
- // GTK2FIX: this button needs a modifiable label
-
- Button* b = interthread_progress_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
- b->signal_clicked().connect (sigc::mem_fun(*this, &Editor::interthread_cancel_clicked));
-
- interthread_cancel_button.add (interthread_cancel_label);
-
- interthread_progress_window->set_default_size (200, 100);
-}
-
-void
-Editor::interthread_cancel_clicked ()
-{
- if (current_interthread_info) {
- current_interthread_info->cancel = true;
- }
-}
-
-void
Editor::region_from_selection ()
{
if (clicked_axisview == 0) {
@@ -3640,13 +3607,6 @@ Editor::freeze_thread ()
return 0;
}
-gint
-Editor::freeze_progress_timeout (void */*arg*/)
-{
- interthread_progress_bar.set_fraction (current_interthread_info->progress);
- return !(current_interthread_info->done || current_interthread_info->cancel);
-}
-
void
Editor::freeze_route ()
{
@@ -3655,21 +3615,9 @@ Editor::freeze_route ()
}
InterThreadInfo itt;
-
- if (interthread_progress_window == 0) {
- build_interthread_progress_window ();
- }
-
- interthread_progress_window->set_title (_("Freeze"));
- interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
- interthread_progress_window->show_all ();
- interthread_progress_bar.set_fraction (0.0f);
- interthread_progress_label.set_text ("");
- interthread_cancel_label.set_text (_("Cancel Freeze"));
current_interthread_info = &itt;
- interthread_progress_connection =
- Glib::signal_timeout().connect (sigc::bind (sigc::mem_fun(*this, &Editor::freeze_progress_timeout), (gpointer) 0), 100);
+ InterthreadProgressWindow ipw (current_interthread_info, _("Freeze"), _("Cancel Freeze"));
itt.done = false;
itt.cancel = false;
@@ -3683,8 +3631,6 @@ Editor::freeze_route ()
gtk_main_iteration ();
}
- interthread_progress_connection.disconnect ();
- interthread_progress_window->hide_all ();
current_interthread_info = 0;
track_canvas->get_window()->set_cursor (*current_canvas_cursor);
}
diff --git a/gtk2_ardour/interthread_progress_window.cc b/gtk2_ardour/interthread_progress_window.cc
new file mode 100644
index 0000000000..28308ee74f
--- /dev/null
+++ b/gtk2_ardour/interthread_progress_window.cc
@@ -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);
+}
diff --git a/gtk2_ardour/interthread_progress_window.h b/gtk2_ardour/interthread_progress_window.h
new file mode 100644
index 0000000000..6c7f0f5bd5
--- /dev/null
+++ b/gtk2_ardour/interthread_progress_window.h
@@ -0,0 +1,69 @@
+/*
+ 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.
+
+*/
+
+#ifndef __ardour_interthread_progress_window_h__
+#define __ardour_interthread_progress_window_h__
+
+#include <gtkmm/label.h>
+#include <gtkmm/progressbar.h>
+#include "ardour_dialog.h"
+
+namespace ARDOUR {
+ class InterThreadInfo;
+ class ImportStatus;
+}
+
+/** A progress dialogue which gets its status from an
+ * ARDOUR::InterThreadInfo struct. Displays a progress bar, which is
+ * automagically updated using a Glib timer, and a cancel button.
+ */
+
+class InterthreadProgressWindow : public ArdourDialog
+{
+public:
+ InterthreadProgressWindow (ARDOUR::InterThreadInfo *, std::string const &, std::string const &);
+
+protected:
+
+ virtual bool update ();
+
+ Gtk::Button _cancel_button;
+ Gtk::Label _cancel_label;
+ Gtk::ProgressBar _bar;
+
+private:
+ void cancel_clicked ();
+
+ ARDOUR::InterThreadInfo* _interthread_info;
+};
+
+/** Progress dialogue for importing sound files */
+class ImportProgressWindow : public InterthreadProgressWindow
+{
+public:
+ ImportProgressWindow (ARDOUR::ImportStatus *, std::string const &, std::string const &);
+
+private:
+ bool update ();
+
+ Gtk::Label _label;
+ ARDOUR::ImportStatus* _import_status;
+};
+
+#endif
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index 6a71c7718b..7ec88b3751 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -116,6 +116,7 @@ gtk2_ardour_sources = [
'group_tabs.cc',
'gtk-custom-hruler.c',
'gtk-custom-ruler.c',
+ 'interthread_progress_window.cc',
'io_selector.cc',
'keyboard.cc',
'keyeditor.cc',
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc
index 64eadbb973..0f57ea0144 100644
--- a/libs/ardour/import.cc
+++ b/libs/ardour/import.cc
@@ -250,16 +250,13 @@ compose_status_message (const string& path,
uint total_files)
{
if (file_samplerate != session_samplerate) {
- return string_compose (_("<b>Resampling</b> from %1kHz to %2kHz.\n<i>%3</i>\n(%4 of %5)"),
- file_samplerate/1000.0f,
- session_samplerate/1000.0f,
+ return string_compose (_("Resampling %1 from %2kHz to %3kHz"),
Glib::path_get_basename (path),
- current_file, total_files);
+ file_samplerate/1000.0f,
+ session_samplerate/1000.0f);
}
-
- return string_compose (_("<b>Copying</b>\n<i>%1</i>\n(%2 of %3)"),
- Glib::path_get_basename (path),
- current_file, total_files);
+
+ return string_compose (_("Copying %1"), Glib::path_get_basename (path));
}
static void
@@ -517,6 +514,7 @@ Session::import_audiofiles (ImportStatus& status)
}
++status.current;
+ status.progress = 0;
}
if (!status.cancel) {