summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-01-14 17:54:26 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-01-14 17:54:26 -0500
commit4a72145d1dde826bf6e84bc0141861fc5b396fa1 (patch)
tree1970e7797bbab326c16022905ad7a5a8e971144b /gtk2_ardour
parent140778641cfa6ad208bdc2e5beca72b00c2501c9 (diff)
unfinished save-as dialog, to serve as example/guide/framework for full implementation
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc47
-rw-r--r--gtk2_ardour/ardour_ui.h5
2 files changed, 51 insertions, 1 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index f582f23ba8..894ba52789 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -2282,6 +2282,25 @@ ARDOUR_UI::stop_clocking ()
clock_signal_connection.disconnect ();
}
+bool
+ARDOUR_UI::save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar)
+{
+ char buf[256];
+
+ snprintf (buf, sizeof (buf), _("Copied %" PRId64 " of %" PRId64), cnt, total);
+
+ label->set_text (buf);
+ bar->set_fraction (fraction);
+
+ /* process events, redraws, etc. */
+
+ while (gtk_events_pending()) {
+ gtk_main_iteration ();
+ }
+
+ return true; /* continue with save-as */
+}
+
void
ARDOUR_UI::save_session_as ()
{
@@ -2289,6 +2308,15 @@ ARDOUR_UI::save_session_as ()
return;
}
+ ArdourDialog save_as_dialog (_("Save As"), true);
+ Gtk::Label label;
+ Gtk::ProgressBar progress_bar;
+
+ save_as_dialog.get_vbox()->pack_start (label);
+ save_as_dialog.get_vbox()->pack_start (progress_bar);
+ label.show ();
+ progress_bar.show ();
+
Session::SaveAs sa;
sa.new_parent_folder = "/tmp";
sa.new_name = "foobar";
@@ -2296,7 +2324,24 @@ ARDOUR_UI::save_session_as ()
sa.copy_media = true;
sa.copy_external = false;
- _session->save_as (sa);
+ /* this signal will be emitted from within this, the calling thread,
+ * after every file is copied. It provides information on percentage
+ * complete (in terms of total data to copy), the number of files
+ * copied so far, and the total number to copy.
+ */
+
+ ScopedConnection c;
+
+ sa.Progress.connect_same_thread (c, boost::bind (&ARDOUR_UI::save_as_progress_update, this, _1, _2, _3, &label, &progress_bar));
+
+ save_as_dialog.show_all ();
+ save_as_dialog.present ();
+
+ if (_session->save_as (sa)) {
+ /* ERROR MESSAGE */
+ MessageDialog msg (string_compose (_("Save As failed: %1"), sa.failure_message));
+ msg.run ();
+ }
}
/** Ask the user for the name of a new snapshot and then take it.
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 8a4e04a290..f5e8972a70 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -125,6 +125,10 @@ namespace Gtkmm2ext {
class TearOff;
}
+namespace Gtk {
+ class ProgressBar;
+}
+
class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
{
private:
@@ -605,6 +609,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
guint32 last_key_press_time;
void snapshot_session (bool switch_to_it);
+ bool save_as_progress_update (float fraction, int64_t cnt, int64_t total, Gtk::Label* label, Gtk::ProgressBar* bar);
void save_session_as ();
void rename_session ();
void setup_order_hint ();