2013-10-07 09:44:35 -04:00
|
|
|
/* soundcloud_export_selector.cpp ***************************************************
|
|
|
|
|
|
|
|
Adapted for Ardour by Ben Loftis, March 2012
|
|
|
|
|
|
|
|
Licence GPL:
|
|
|
|
|
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
|
|
*************************************************************************************/
|
2014-05-27 06:23:47 -04:00
|
|
|
#include "ardour/debug.h"
|
2013-10-07 09:44:35 -04:00
|
|
|
#include "ardour/soundcloud_upload.h"
|
|
|
|
#include "soundcloud_export_selector.h"
|
|
|
|
|
|
|
|
#include <pbd/error.h>
|
|
|
|
#include "pbd/openuri.h"
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <iostream>
|
2015-10-05 16:10:58 -04:00
|
|
|
#include "pbd/gstdio_compat.h"
|
2013-10-07 09:44:35 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2013-10-07 09:44:35 -04:00
|
|
|
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
#include "ardour/session_metadata.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2014-05-27 06:23:47 -04:00
|
|
|
SoundcloudExportSelector::SoundcloudExportSelector () :
|
2013-10-07 09:44:35 -04:00
|
|
|
sc_table (4, 3),
|
|
|
|
soundcloud_username_label (_("User Email"), 1.0, 0.5),
|
|
|
|
soundcloud_password_label (_("Password"), 1.0, 0.5),
|
2014-05-23 13:45:40 -04:00
|
|
|
soundcloud_public_checkbox (_("Make files public")),
|
2013-10-07 09:44:35 -04:00
|
|
|
soundcloud_open_checkbox (_("Open uploaded files in browser")),
|
2014-05-23 13:45:40 -04:00
|
|
|
soundcloud_download_checkbox (_("Make files downloadable")),
|
2013-10-07 09:44:35 -04:00
|
|
|
progress_bar()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
soundcloud_public_checkbox.set_name ("ExportCheckbox");
|
2014-05-23 13:45:40 -04:00
|
|
|
soundcloud_download_checkbox.set_name ("ExportCheckbox");
|
2013-10-07 09:44:35 -04:00
|
|
|
soundcloud_username_label.set_name ("ExportFormatLabel");
|
|
|
|
soundcloud_username_entry.set_name ("ExportFormatDisplay");
|
|
|
|
soundcloud_password_label.set_name ("ExportFormatLabel");
|
|
|
|
soundcloud_password_entry.set_name ("ExportFormatDisplay");
|
|
|
|
|
|
|
|
soundcloud_username_entry.set_text (ARDOUR::SessionMetadata::Metadata()->user_email());
|
2014-05-27 06:23:47 -04:00
|
|
|
soundcloud_password_entry.set_visibility (false);
|
2013-10-07 09:44:35 -04:00
|
|
|
|
2014-05-27 06:23:47 -04:00
|
|
|
Gtk::Frame *sc_frame = manage (new Gtk::Frame);
|
|
|
|
sc_frame->set_border_width (4);
|
|
|
|
sc_frame->set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
|
|
|
|
sc_frame->set_name ("soundcloud_export_box");
|
|
|
|
pack_start (*sc_frame, false, false);
|
2013-10-07 09:44:35 -04:00
|
|
|
|
2014-05-23 13:45:40 -04:00
|
|
|
sc_table.set_border_width (4);
|
2013-10-07 09:44:35 -04:00
|
|
|
sc_table.set_col_spacings (5);
|
|
|
|
sc_table.set_row_spacings (5);
|
|
|
|
sc_frame->add (sc_table);
|
|
|
|
|
2014-06-25 15:27:37 -04:00
|
|
|
sc_table.attach ( *(Gtk::manage (new Gtk::Image (ARDOUR_UI_UTILS::get_icon (X_("soundcloud"))))) , 0, 1, 0, 2);
|
2013-10-07 09:44:35 -04:00
|
|
|
|
2014-05-23 13:45:40 -04:00
|
|
|
sc_table.attach (soundcloud_username_label, 0, 1, 1, 2);
|
|
|
|
sc_table.attach (soundcloud_username_entry, 1, 3, 1, 2);
|
|
|
|
sc_table.attach (soundcloud_password_label, 0, 1, 2, 3);
|
|
|
|
sc_table.attach (soundcloud_password_entry, 1, 3, 2, 3);
|
|
|
|
sc_table.attach (soundcloud_public_checkbox, 2, 3, 3, 4);
|
|
|
|
sc_table.attach (soundcloud_open_checkbox, 2, 3, 4, 5);
|
|
|
|
sc_table.attach (soundcloud_download_checkbox, 2, 3, 5, 6);
|
2013-10-07 09:44:35 -04:00
|
|
|
|
2014-05-27 06:23:47 -04:00
|
|
|
pack_end (progress_bar, false, false);
|
|
|
|
sc_frame->show_all ();
|
2013-10-07 09:44:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2014-05-27 06:23:47 -04:00
|
|
|
SoundcloudExportSelector::do_progress_callback (double ultotal, double ulnow, const std::string &filename)
|
2013-10-07 09:44:35 -04:00
|
|
|
{
|
2014-05-27 06:23:47 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Soundcloud, string_compose ("SoundcloudExportSelector::do_progress_callback(%1, %2, %3)", ultotal, ulnow, filename));
|
2013-10-07 09:44:35 -04:00
|
|
|
if (soundcloud_cancel) {
|
|
|
|
progress_bar.set_fraction (0);
|
|
|
|
// cancel_button.set_label ("");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
double fraction = 0.0;
|
|
|
|
if (ultotal != 0) {
|
|
|
|
fraction = ulnow / ultotal;
|
|
|
|
}
|
|
|
|
|
|
|
|
progress_bar.set_fraction ( fraction );
|
|
|
|
|
|
|
|
std::string prog;
|
|
|
|
prog = string_compose (_("%1: %2 of %3 bytes uploaded"), filename, ulnow, ultotal);
|
2014-05-27 06:23:47 -04:00
|
|
|
progress_bar.set_text (prog);
|
2013-10-07 09:44:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|