pre-size TimeAxisView controls_table to something more like the correct rows x cols
[ardour.git] / gtk2_ardour / export_filename_selector.cc
index 4f3a02a015747bb13b9d6c9342c4dba4a3abbe63..fd411719252ff0a19cac9488c9164931580c3853 100644 (file)
@@ -31,27 +31,30 @@ ExportFilenameSelector::ExportFilenameSelector () :
 
        label_label (_("Label:"), Gtk::ALIGN_LEFT),
        session_checkbox (_("Session Name")),
+       timespan_checkbox (_("Timespan Name")),
        revision_checkbox (_("Revision:")),
 
        path_label (_("Folder:"), Gtk::ALIGN_LEFT),
        browse_button (_("Browse")),
 
-       example_filename_label ("", Gtk::ALIGN_LEFT)
+       example_filename_label ("", Gtk::ALIGN_LEFT),
+       _require_timespan (false)
 {
-       include_label.set_markup (_("<i>Build filename(s) from these components:</i>"));
+       include_label.set_markup (_("Build filename(s) from these components:"));
 
        pack_start (path_hbox, false, false, 12);
        pack_start (include_label, false, false, 6);
        pack_start (include_hbox, false, false, 0);
        pack_start (example_filename_label, false, false, 12);
 
+       include_hbox.pack_start (session_checkbox, false, false, 3);
        include_hbox.pack_start (label_label, false, false, 3);
        include_hbox.pack_start (label_entry, false, false, 3);
-       include_hbox.pack_start (session_checkbox, false, false, 3);
-       include_hbox.pack_start (date_format_combo, false, false, 3);
-       include_hbox.pack_start (time_format_combo, false, false, 3);
        include_hbox.pack_start (revision_checkbox, false, false, 3);
        include_hbox.pack_start (revision_spinbutton, false, false, 3);
+       include_hbox.pack_start (timespan_checkbox, false, false, 3);
+       include_hbox.pack_start (date_format_combo, false, false, 3);
+       include_hbox.pack_start (time_format_combo, false, false, 3);
 
        label_entry.set_activates_default ();
 
@@ -61,10 +64,6 @@ ExportFilenameSelector::ExportFilenameSelector () :
 
        path_entry.set_activates_default ();
 
-       date_format_combo.set_name ("PaddedButton");
-       time_format_combo.set_name ("PaddedButton");
-       browse_button.set_name ("PaddedButton");
-
        label_sizegroup = Gtk::SizeGroup::create (Gtk::SIZE_GROUP_HORIZONTAL);
        label_sizegroup->add_widget (label_label);
        label_sizegroup->add_widget (path_label);
@@ -99,6 +98,7 @@ ExportFilenameSelector::ExportFilenameSelector () :
        path_entry.signal_activate().connect (sigc::mem_fun (*this, &ExportFilenameSelector::check_folder), false);
 
        session_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_session_selection));
+       timespan_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_timespan_selection));
 
        revision_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_revision_selection));
        revision_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFilenameSelector::change_revision_value));
@@ -120,6 +120,7 @@ ExportFilenameSelector::load_state ()
 
        label_entry.set_text (filename->include_label ? filename->get_label() : "");
        session_checkbox.set_active (filename->include_session);
+       timespan_checkbox.set_active (filename->include_timespan);
        revision_checkbox.set_active (filename->include_revision);
        revision_spinbutton.set_value (filename->get_revision());
        path_entry.set_text (filename->get_folder());
@@ -211,7 +212,7 @@ ExportFilenameSelector::set_example_filename (std::string filename)
        if (filename == "") {
                example_filename_label.set_markup (_("<small><i>Sorry, no example filename can be shown at the moment</i></small>"));
        } else {
-               example_filename_label.set_markup (string_compose(_("<small><i>Current (approximate) filename: \"%1\"</i></small>"), filename));
+               example_filename_label.set_markup (string_compose(_("<i>Current (approximate) filename</i>: \"%1\""), filename));
        }
 }
 
@@ -280,6 +281,55 @@ ExportFilenameSelector::change_time_format ()
        CriticalSelectionChanged();
 }
 
+void
+ExportFilenameSelector::require_timespan (bool r)
+{
+       _require_timespan = r;
+       update_timespan_sensitivity ();
+}
+
+void
+ExportFilenameSelector::update_timespan_sensitivity ()
+{
+       bool implicit = _require_timespan;
+
+       if (!implicit
+                       && !filename->include_session
+                       && !filename->include_label
+                       && !filename->include_revision
+                       && !filename->include_channel_config
+                       && !filename->include_channel
+                       && !filename->include_date
+                       && !filename->include_format_name) {
+               implicit = true;
+       }
+
+       // remember prev state, force enable if implicit active.
+       if (implicit && !timespan_checkbox.get_inconsistent()) {
+               timespan_checkbox.set_inconsistent (true);
+               filename->include_timespan = true;
+       }
+       else if (!implicit && timespan_checkbox.get_inconsistent()) {
+               filename->include_timespan = timespan_checkbox.get_active();
+               timespan_checkbox.set_inconsistent (false);
+       }
+
+}
+
+void
+ExportFilenameSelector::change_timespan_selection ()
+{
+       if (!filename) {
+               return;
+       }
+       if (timespan_checkbox.get_inconsistent()) {
+               return;
+       }
+
+       filename->include_timespan = timespan_checkbox.get_active();
+       CriticalSelectionChanged();
+}
+
 void
 ExportFilenameSelector::change_session_selection ()
 {
@@ -328,10 +378,10 @@ ExportFilenameSelector::open_browse_dialog ()
 
        while (true) {
                int result = dialog.run();
-               
+
                if (result == Gtk::RESPONSE_OK) {
                        std::string filename = dialog.get_filename();
-                       
+
                        if (!Glib::file_test (filename, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
                                Gtk::MessageDialog msg (string_compose (_("%1: this is only the directory/folder name, not the filename.\n\
 The filename will be chosen from the information just above the folder selector."), filename));
@@ -344,6 +394,7 @@ The filename will be chosen from the information just above the folder selector.
                                break;
                        }
                }
+               break;
        }
 
        CriticalSelectionChanged();