Exemplo n.º 1
0
void 
mainwnd::file_open_dialog( void )
{
    FileSelection dialog( "Open..." );
    int result = dialog.run();
    
    //Handle the response:
    switch(result)
    {
        case(Gtk::RESPONSE_OK):
        {
            bool result = false;
            
            m_mainperf->clear_all();
            
            midifile f( dialog.get_filename() );
            result = f.parse( m_mainperf, 0 );

            if ( !result ){
                
                Gtk::MessageDialog errdialog(*this,
                                             "Error reading file.", false,
                                             Gtk::MESSAGE_ERROR,
                                             (Gtk::ButtonsType)(Gtk::BUTTONS_OK),
                                             true);
                errdialog.run();
            }

            global_filename = std::string(dialog.get_filename());
            set_window_title_filename( global_filename );
            
            m_main_wid->reset();
            m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad( m_mainperf->get_screenset() )); 
            m_adjust_bpm->set_value( m_mainperf->get_bpm() );

            
            break;
        }
        case(Gtk::RESPONSE_CANCEL):
        {
            break;
        }
        default:
        {
            break;
        }
    }
  
}
Exemplo n.º 2
0
void 
mainwnd::file_saveas_dialog( void )
{

    FileSelection dialog( "Save As..." );
    int result = dialog.run();
    
    //Handle the response:
    switch(result)
    {
        case(Gtk::RESPONSE_OK):
        {
            bool result = false;
            
            midifile f( dialog.get_filename() );
            result = f.write( m_mainperf );

            if ( !result ){
                
                Gtk::MessageDialog errdialog(*this,
                                              false,
                                             "Error writing file.",
                                             Gtk::MESSAGE_ERROR,
                                             (Gtk::ButtonsType)(Gtk::BUTTONS_OK),
                                             true );
                errdialog.run();
            }
            
            global_filename = std::string( dialog.get_filename());
            set_window_title_filename( global_filename );
            
            break;
        }
        case(Gtk::RESPONSE_CANCEL):
        {
            break;
        }
        default:
        {
            break;
        }
    }


}
Exemplo n.º 3
0
bool mainwnd::open_file(const Glib::ustring& fn, bool setlist_mode)
{
    bool result;

    stop_playing();

    /*We aren't using a playlist if we've opened a file*/
    set_wsetlist_mode(setlist_mode);

    m_mainperf->clear_all();

    midifile f(fn);
    result = f.parse(m_mainperf, 0);
    m_modified = !result;

    if (!result) {
    	if(setlist_mode){
    		//We don't want dialog boxes in setlist mode!
    		printf("Error reading file: %s\n",fn.data());
    	}
    	else{
		    Gtk::MessageDialog errdialog(*this,
		            "Error reading file: " + fn, false,
		            Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
		    errdialog.run();
        }
        return false;
    }

    last_used_dir = fn.substr(0, fn.rfind("/") + 1);
    global_filename = fn;
    update_window_title();

    m_main_wid->reset();
    m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad(
                m_mainperf->get_screenset()));
    m_adjust_bpm->set_value( m_mainperf->get_bpm());

    //Check what the max tick is
    m_mainperf->update_max_tick();

    return true;
}
Exemplo n.º 4
0
void 
mainwnd::file_save_dialog( void )
{
    bool result = false;
    
    midifile f( global_filename.c_str() );
    result = f.write( m_mainperf );

    if ( !result ){
        
        Gtk::MessageDialog errdialog(*this,
                                     "Error writing file.",
                                     false,
                                     Gtk::MESSAGE_ERROR,
                                     (Gtk::ButtonsType)(Gtk::BUTTONS_OK),
                                     true);
        errdialog.run();
    }
    
}
Exemplo n.º 5
0
bool mainwnd::save_file()
{
    bool result = false;

    if (global_filename == "") {
        file_save_as();
        return true;
    }

    midifile f(global_filename);
    result = f.write(m_mainperf);

    if (!result) {
        Gtk::MessageDialog errdialog(*this,
                "Error writing file.", false,
                Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        errdialog.run();
    }
    m_modified = !result;
    return result;
}
Exemplo n.º 6
0
void 
mainwnd::file_import_dialog( void )
{

   FileSelection dialog( "Import..." );


   HBox *abox = dialog.get_action_area(); 
   HBox hbox( false, 2 );
   
   m_adjust_load_offset = manage( new Adjustment( 0, -(c_max_sets - 1) , c_max_sets - 1, 1 ));
   m_spinbutton_load_offset = manage( new SpinButton( *m_adjust_load_offset ));
   m_spinbutton_load_offset->set_editable( false );
   m_spinbutton_load_offset->set_wrap( true );
   hbox.pack_end(*m_spinbutton_load_offset, false, false );
   hbox.pack_end(*(manage( new Label( "Screen Set Offset" ))), false, false, 4);
   
   abox->pack_end(hbox, false, false );  
   
   dialog.show_all_children();
   
   int result = dialog.run();
   
   //Handle the response:
   switch(result)
   {
       case(Gtk::RESPONSE_OK):
       {

           try{
               midifile f( dialog.get_filename() );
               f.parse( m_mainperf, (int) m_adjust_load_offset->get_value() );

           }
           catch(...){
               
               Gtk::MessageDialog errdialog(*this, 
                                            "Error reading file.", false,
                                            Gtk::MESSAGE_ERROR,
                                            (Gtk::ButtonsType)(Gtk::BUTTONS_OK),
                                            true);
                errdialog.run();
               
           }

           global_filename = std::string(dialog.get_filename());
           set_window_title_filename( global_filename );
           
           m_main_wid->reset();
           m_entry_notes->set_text( * m_mainperf->get_screen_set_notepad( m_mainperf->get_screenset() )); 
           m_adjust_bpm->set_value( m_mainperf->get_bpm() );

           break;
       }
       case(Gtk::RESPONSE_CANCEL):
       {
           break;
       }
       default:
       {
           break;
       }
   }

}
Exemplo n.º 7
0
void
mainwnd::file_import_dialog( void )
{
    Gtk::FileChooserDialog dialog("Import MIDI file",
            Gtk::FILE_CHOOSER_ACTION_OPEN);
    dialog.set_transient_for(*this);

    Gtk::FileFilter filter_midi;
    filter_midi.set_name("MIDI files");
    filter_midi.add_pattern("*.midi");
    filter_midi.add_pattern("*.mid");
    dialog.add_filter(filter_midi);

    Gtk::FileFilter filter_any;
    filter_any.set_name("Any files");
    filter_any.add_pattern("*");
    dialog.add_filter(filter_any);

    dialog.set_current_folder(last_used_dir);

    ButtonBox *btnbox = dialog.get_action_area();
    HBox hbox( false, 2 );

    m_adjust_load_offset = manage( new Adjustment( 0, -(c_max_sets - 1),
                c_max_sets - 1, 1 ));
    m_spinbutton_load_offset = manage( new SpinButton( *m_adjust_load_offset ));
    m_spinbutton_load_offset->set_editable( false );
    m_spinbutton_load_offset->set_wrap( true );
    hbox.pack_end(*m_spinbutton_load_offset, false, false );
    hbox.pack_end(*(manage( new Label("Screen Set Offset"))), false, false, 4);

    btnbox->pack_start(hbox, false, false );

    dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    dialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);

    dialog.show_all_children();

    int result = dialog.run();

    //Handle the response:
    switch(result)
    {
       case(Gtk::RESPONSE_OK):
       {
           try{
               midifile f( dialog.get_filename() );
               f.parse( m_mainperf, (int) m_adjust_load_offset->get_value() );
           }
           catch(...){
               Gtk::MessageDialog errdialog(*this,
                       "Error reading file.", false,
                       Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
                errdialog.run();
           }

           global_filename = std::string(dialog.get_filename());
           update_window_title();
           m_modified = true;

           m_main_wid->reset();
           m_entry_notes->set_text(*m_mainperf->get_screen_set_notepad(
                       m_mainperf->get_screenset() ));
           m_adjust_bpm->set_value( m_mainperf->get_bpm() );

           break;
       }

       case(Gtk::RESPONSE_CANCEL):
           break;

       default:
           break;

   }
}