13
0

L: ensure the sensitivity of the Open button is correct for the open tab

This commit is contained in:
Ben Loftis 2024-05-19 21:32:17 -05:00
parent e88711624a
commit c81faa8f9e

View File

@ -166,13 +166,11 @@ SessionDialog::SessionDialog (DialogTab initial_tab, const std::string& session_
existing_session_chooser.show_all();
_tabs.show_all();
_tabs.set_current_page(0);
cancel_button = add_button ((cancel_not_quit ? Stock::CANCEL : Stock::QUIT), RESPONSE_CANCEL);
open_button = add_button (Stock::OPEN, RESPONSE_ACCEPT);
open_button->signal_button_press_event().connect (sigc::mem_fun (*this, &SessionDialog::open_button_pressed), false);
open_button->set_sensitive (false);
if (!template_name.empty()) {
load_template_override = template_name;
@ -204,9 +202,9 @@ SessionDialog::SessionDialog (DialogTab initial_tab, const std::string& session_
}
_tabs.signal_switch_page().connect (sigc::mem_fun (*this, &SessionDialog::tab_page_switched));
_tabs.set_current_page(3); //this will enforce a page-change, so correct widgets get sensitized
if (initial_tab==New) {
_tabs.set_current_page(0);
new_button.set_active_state (Gtkmm2ext::ExplicitActive);
} else if (initial_tab==Open) {
_tabs.set_current_page(2);
} else {
@ -227,6 +225,14 @@ SessionDialog::tab_page_switched(GtkNotebookPage*, guint page_number)
recent_button.set_active_state ( page_number==1 ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
existing_button.set_active_state (page_number==2 ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
prefs_button.set_active_state ( page_number==3 ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off);
//check the status of each tab and sensitize the 'open' button appropriately
open_button->set_sensitive(false);
switch (page_number) {
case 0: new_name_changed(); break;
case 1: recent_session_row_selected(); break;
case 2: existing_file_selected(); break;
}
}
uint32_t
@ -480,6 +486,11 @@ SessionDialog::setup_existing_box ()
void
SessionDialog::existing_file_selected ()
{
if (_tabs.get_current_page()!=2) {
//gtk filechooser is threaded; don't allow it to mess with open_button sensitivity when it's not actually visible
return;
}
open_button->set_sensitive(false);
float sr;
@ -534,8 +545,6 @@ SessionDialog::new_button_pressed (GdkEventButton*)
{
_tabs.set_current_page(0);
new_name_changed(); //checks for a valid name and (maybe) sensitizes the button
return true;
}
@ -544,8 +553,6 @@ SessionDialog::recent_button_pressed (GdkEventButton*)
{
_tabs.set_current_page(1);
recent_session_row_selected(); //checks for a selection and (maybe) sensitizes the open button
return true;
}
@ -554,8 +561,6 @@ SessionDialog::existing_button_pressed (GdkEventButton*)
{
_tabs.set_current_page(2);
existing_file_selected(); //checks for a selection and (maybe) sensitizes the open button
return true;
}