MainWindow: removed debug outputs and slight refactor

This commit is contained in:
zvon 2020-01-18 22:37:04 +01:00
parent 8b4a21fb53
commit d3d7ac801e
2 changed files with 51 additions and 64 deletions

View File

@ -29,19 +29,15 @@ void MainWindow::chooseFile() {
switch ( result ) { switch ( result ) {
case Gtk::RESPONSE_OK: case Gtk::RESPONSE_OK:
m_entry_dir->set_text( dialog.get_filename() ); m_entry_dir->set_text( dialog.get_filename() );
std::cout << dialog.get_filename() << std::endl;
break; break;
case Gtk::RESPONSE_CANCEL: case Gtk::RESPONSE_CANCEL:
std::cout << "Canceled" << std::endl;
break; break;
default: default:
std::cout << "Closed dialog" << std::endl;
break; break;
} }
} }
void MainWindow::quit() { void MainWindow::quit() {
std::cout << "Quitting" << std::endl;
hide(); hide();
} }
@ -159,9 +155,6 @@ void renameFiles(
&renamed ) { &renamed ) {
for ( auto renamed_it = renamed.begin(); renamed_it != renamed.end(); for ( auto renamed_it = renamed.begin(); renamed_it != renamed.end();
++renamed_it ) { ++renamed_it ) {
std::cout << renamed_it->first.second << "/" << renamed_it->second.first
<< " --> " << renamed_it->first.second << "/"
<< renamed_it->second.second << std::endl;
FSLib::rename( FSLib::rename(
renamed_it->first.second + "/" + renamed_it->second.first, renamed_it->first.second + "/" + renamed_it->second.first,
renamed_it->first.second + "/" + renamed_it->second.second ); renamed_it->first.second + "/" + renamed_it->second.second );
@ -174,10 +167,6 @@ void MainWindow::finishedSelection() {
auto iter = m_combo_possible->get_active(); auto iter = m_combo_possible->get_active();
// debug output
std::cout << ( *iter )[m_columns_show.m_col_show] << " " << language_code
<< std::endl;
std::string show_id = std::string show_id =
static_cast< Glib::ustring >( ( *iter )[m_columns_show.m_col_id] ); static_cast< Glib::ustring >( ( *iter )[m_columns_show.m_col_id] );
@ -185,8 +174,6 @@ void MainWindow::finishedSelection() {
if ( show_id.empty() ) if ( show_id.empty() )
return; return;
std::cout << "https://www.thetvdb.com/series/" << show_id << std::endl;
std::string input_pattern = m_entry_pattern->get_text(); std::string input_pattern = m_entry_pattern->get_text();
// store pattern to cache if it's different from default // store pattern to cache if it's different from default
@ -222,16 +209,16 @@ void MainWindow::finishedSelection() {
dialog->set_resizable( false ); dialog->set_resizable( false );
auto content = dialog->get_content_area(); auto content = dialog->get_content_area();
std::unique_ptr< Gtk::ScrolledWindow > sw( new Gtk::ScrolledWindow ); std::unique_ptr< Gtk::ScrolledWindow > sc_w( new Gtk::ScrolledWindow );
std::unique_ptr< Gtk::TextView > tx( new Gtk::TextView ); std::unique_ptr< Gtk::TextView > tx( new Gtk::TextView );
content->pack_start( *sw ); content->pack_start( *sc_w );
sw->add( *tx ); sc_w->add( *tx );
tx->set_editable( false ); tx->set_editable( false );
tx->set_cursor_visible( false ); tx->set_cursor_visible( false );
dialog->add_button( "_No", Gtk::RESPONSE_CANCEL ); dialog->add_button( "_No", Gtk::RESPONSE_CANCEL );
dialog->add_button( "_Yes", Gtk::RESPONSE_OK ); dialog->add_button( "_Yes", Gtk::RESPONSE_OK );
sw->show(); sc_w->show();
tx->show(); tx->show();
auto buff = tx->get_buffer(); auto buff = tx->get_buffer();
@ -271,7 +258,6 @@ MainWindow::~MainWindow() {
} }
index++; index++;
} }
std::cout << children.size() << std::endl;
for ( int i = max - 1; i >= 0; i-- ) { for ( int i = max - 1; i >= 0; i-- ) {
delete children[i]; delete children[i];
} }
@ -281,6 +267,17 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
: app( ptr ) { : app( ptr ) {
set_title( "TV Rename" ); set_title( "TV Rename" );
// create widgets
Gtk::Button *button_dir = new Gtk::Button();
Gtk::Button *button_quit = new Gtk::Button();
Gtk::Button *button_process = new Gtk::Button();
Gtk::Button *button_pattern = new Gtk::Button();
Gtk::Label *label_language = new Gtk::Label();
Gtk::Label *label_show = new Gtk::Label();
Gtk::Label *label_dir = new Gtk::Label();
Gtk::Label *label_pattern = new Gtk::Label();
set_default_size( 400, 345 ); set_default_size( 400, 345 );
set_resizable( false ); set_resizable( false );
@ -308,7 +305,7 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
box->pack_start( *m_label_possible, false, true ); box->pack_start( *m_label_possible, false, true );
box->pack_start( *m_combo_possible, false, true ); box->pack_start( *m_combo_possible, false, true );
box->pack_start( *buttons, false, true ); box->pack_start( *buttons, false, true );
box->pack_start( *m_button_quit, false, true ); box->pack_start( *button_quit, false, true );
auto *item = new Gtk::MenuItem(); auto *item = new Gtk::MenuItem();
auto *submenu = new Gtk::Menu(); auto *submenu = new Gtk::Menu();
@ -376,28 +373,28 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
submenu->append( *item ); submenu->append( *item );
std::vector< Gtk::Widget * > left_aligned_widgets = { std::vector< Gtk::Widget * > left_aligned_widgets = {
m_label_show, m_label_language, m_entry_show, m_combo_language, label_show, label_language, m_entry_show, m_combo_language,
m_label_dir, m_entry_dir, m_label_pattern, m_entry_pattern, label_dir, m_entry_dir, label_pattern, m_entry_pattern,
m_button_pattern, m_button_process, m_check_linux, m_check_trust, button_pattern, button_process, m_check_linux, m_check_trust,
m_check_dvd, m_label_possible, m_combo_possible, m_button_rename, m_check_dvd, m_label_possible, m_combo_possible, m_button_rename,
m_button_db_add, m_button_dir m_button_db_add, button_dir
}; };
// set widgets' position in boxes // set widgets' position in boxes
inputs->attach( *m_label_show, 0, 0, 1, 1 ); inputs->attach( *label_show, 0, 0, 1, 1 );
inputs->attach( *m_label_language, 1, 0, 1, 1 ); inputs->attach( *label_language, 1, 0, 1, 1 );
inputs->attach( *m_entry_show, 0, 1, 1, 1 ); inputs->attach( *m_entry_show, 0, 1, 1, 1 );
inputs->attach( *m_combo_language, 1, 1, 1, 1 ); inputs->attach( *m_combo_language, 1, 1, 1, 1 );
inputs->attach( *m_label_dir, 0, 2, 2, 1 ); inputs->attach( *label_dir, 0, 2, 2, 1 );
inputs->attach( *m_entry_dir, 0, 3, 1, 1 ); inputs->attach( *m_entry_dir, 0, 3, 1, 1 );
inputs->attach( *m_button_dir, 1, 3, 1, 1 ); inputs->attach( *button_dir, 1, 3, 1, 1 );
inputs->attach( *m_label_pattern, 0, 4, 2, 1 ); inputs->attach( *label_pattern, 0, 4, 2, 1 );
inputs->attach( *m_entry_pattern, 0, 5, 1, 1 ); inputs->attach( *m_entry_pattern, 0, 5, 1, 1 );
inputs->attach( *m_button_pattern, 1, 5, 1, 1 ); inputs->attach( *button_pattern, 1, 5, 1, 1 );
inputs->set_column_homogeneous( true ); inputs->set_column_homogeneous( true );
processing->attach( *m_button_process, 0, 0, 1, 2 ); processing->attach( *button_process, 0, 0, 1, 2 );
processing->attach( *m_check_linux, 1, 0, 1, 1 ); processing->attach( *m_check_linux, 1, 0, 1, 1 );
processing->attach( *m_check_trust, 1, 1, 1, 1 ); processing->attach( *m_check_trust, 1, 1, 1, 1 );
@ -416,36 +413,36 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
m_entry_dir->set_halign( Gtk::ALIGN_FILL ); m_entry_dir->set_halign( Gtk::ALIGN_FILL );
m_entry_pattern->set_halign( Gtk::ALIGN_FILL ); m_entry_pattern->set_halign( Gtk::ALIGN_FILL );
m_button_quit->set_halign( Gtk::ALIGN_END ); button_quit->set_halign( Gtk::ALIGN_END );
m_button_quit->set_valign( Gtk::ALIGN_CENTER ); button_quit->set_valign( Gtk::ALIGN_CENTER );
m_button_quit->set_margin_right( 5 ); button_quit->set_margin_right( 5 );
m_button_quit->set_margin_top( 5 ); button_quit->set_margin_top( 5 );
m_button_quit->set_margin_bottom( 5 ); button_quit->set_margin_bottom( 5 );
// set button texts // set button texts
m_button_process->set_label( "Process" ); button_process->set_label( "Process" );
button_quit->set_label( "Quit" );
button_dir->set_label( "Choose directory" );
button_pattern->set_label( "Pattern help" );
m_button_rename->set_label( "Rename" ); m_button_rename->set_label( "Rename" );
m_button_db_add->set_label( "Add to database" ); m_button_db_add->set_label( "Add to database" );
m_button_quit->set_label( "Quit" );
m_button_dir->set_label( "Choose directory" );
m_button_pattern->set_label( "Pattern help" );
m_check_linux->set_label( "Replace windows-illegal characters" ); m_check_linux->set_label( "Replace windows-illegal characters" );
m_check_trust->set_label( "Don't ask for rename confirmation" ); m_check_trust->set_label( "Don't ask for rename confirmation" );
m_check_dvd->set_label( "Use DVD ordering" ); m_check_dvd->set_label( "Use DVD ordering" );
// set label texts // set label texts
m_label_show->set_label( "Show:" ); label_show->set_label( "Show:" );
m_label_language->set_label( "Language:" ); label_language->set_label( "Language:" );
label_dir->set_label( "Directory:" );
label_pattern->set_label( "Pattern:" );
m_label_possible->set_label( "Possible shows:" ); m_label_possible->set_label( "Possible shows:" );
m_label_dir->set_label( "Directory:" );
m_label_pattern->set_label( "Pattern:" );
m_entry_show->set_size_request( 170, 30 ); m_entry_show->set_size_request( 170, 30 );
m_entry_dir->set_size_request( 170, 30 ); m_entry_dir->set_size_request( 170, 30 );
m_button_dir->set_size_request( 80, 30 ); button_dir->set_size_request( 80, 30 );
m_button_quit->set_size_request( 80, 30 ); button_quit->set_size_request( 80, 30 );
m_button_process->set_size_request( 80, 30 ); button_process->set_size_request( 80, 30 );
m_button_rename->set_size_request( 80, 30 ); m_button_rename->set_size_request( 80, 30 );
m_button_db_add->set_size_request( 80, 30 ); m_button_db_add->set_size_request( 80, 30 );
@ -475,12 +472,14 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
m_combo_possible->set_size_request( 200, 30 ); m_combo_possible->set_size_request( 200, 30 );
// set signals // set signals
m_button_dir->signal_clicked().connect( button_dir->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::chooseFile ) ); sigc::mem_fun( *this, &MainWindow::chooseFile ) );
m_button_quit->signal_clicked().connect( button_quit->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::quit ) ); sigc::mem_fun( *this, &MainWindow::quit ) );
m_button_process->signal_clicked().connect( button_process->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::process ) ); sigc::mem_fun( *this, &MainWindow::process ) );
button_pattern->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::patternHelp ) );
m_button_rename->signal_clicked().connect( m_button_rename->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::getNames ) ); sigc::mem_fun( *this, &MainWindow::getNames ) );
m_button_db_add->signal_clicked().connect( m_button_db_add->signal_clicked().connect(
@ -489,8 +488,6 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
sigc::mem_fun( *this, &MainWindow::process ) ); sigc::mem_fun( *this, &MainWindow::process ) );
m_entry_dir->signal_activate().connect( m_entry_dir->signal_activate().connect(
sigc::mem_fun( *this, &MainWindow::process ) ); sigc::mem_fun( *this, &MainWindow::process ) );
m_button_pattern->signal_clicked().connect(
sigc::mem_fun( *this, &MainWindow::patternHelp ) );
// show everything except possible shows and items related to them // show everything except possible shows and items related to them
show_all_children(); show_all_children();
@ -557,8 +554,6 @@ void MainWindow::dbAdd() {
std::string show_id = std::string show_id =
static_cast< Glib::ustring >( ( *iter )[m_columns_show.m_col_id] ); static_cast< Glib::ustring >( ( *iter )[m_columns_show.m_col_id] );
std::cout << show << " " << language_code << " " << show_id << std::endl;
auto *pw = new ProgressWindow; auto *pw = new ProgressWindow;
app->add_window( *pw ); app->add_window( *pw );
auto app_ptr = app; auto app_ptr = app;

View File

@ -38,12 +38,10 @@ private:
void dbPattern(); void dbPattern();
protected: protected:
Gtk::Button *m_button_dir = new Gtk::Button();
Gtk::Button *m_button_rename = new Gtk::Button(); Gtk::Button *m_button_rename = new Gtk::Button();
Gtk::Button *m_button_db_add = new Gtk::Button(); Gtk::Button *m_button_db_add = new Gtk::Button();
Gtk::Button *m_button_quit = new Gtk::Button();
Gtk::Button *m_button_process = new Gtk::Button(); Gtk::Label *m_label_possible = new Gtk::Label();
Gtk::Button *m_button_pattern = new Gtk::Button();
Gtk::CheckButton *m_check_linux = new Gtk::CheckButton(); Gtk::CheckButton *m_check_linux = new Gtk::CheckButton();
Gtk::CheckButton *m_check_trust = new Gtk::CheckButton(); Gtk::CheckButton *m_check_trust = new Gtk::CheckButton();
@ -56,12 +54,6 @@ protected:
Gtk::Entry *m_entry_dir = new Gtk::Entry(); Gtk::Entry *m_entry_dir = new Gtk::Entry();
Gtk::Entry *m_entry_pattern = new Gtk::Entry(); Gtk::Entry *m_entry_pattern = new Gtk::Entry();
Gtk::Label *m_label_language = new Gtk::Label();
Gtk::Label *m_label_possible = new Gtk::Label();
Gtk::Label *m_label_show = new Gtk::Label();
Gtk::Label *m_label_dir = new Gtk::Label();
Gtk::Label *m_label_pattern = new Gtk::Label();
class LanguageColumns : public Gtk::TreeModel::ColumnRecord { class LanguageColumns : public Gtk::TreeModel::ColumnRecord {
public: public:
LanguageColumns() { LanguageColumns() {