Work around tooltips in treeviews selection issue #7678
[ardour.git] / gtk2_ardour / session_dialog.cc
index 0164366f746e34dcaf2e2c8d97bf23b955df5a2b..489e52fac62153e0fecec629a8f1394039567f9d 100644 (file)
@@ -99,10 +99,10 @@ SessionDialog::SessionDialog (bool require_new, const std::string& session_name,
         * and invisible most of the time.
         */
 
-       info_sample.set_shadow_type(SHADOW_ETCHED_OUT);
-       info_sample.set_no_show_all (true);
-       info_sample.set_border_width (12);
-       get_vbox()->pack_start (info_sample, false, false);
+       info_frame.set_shadow_type(SHADOW_ETCHED_OUT);
+       info_frame.set_no_show_all (true);
+       info_frame.set_border_width (12);
+       get_vbox()->pack_start (info_frame, false, false);
 
        setup_new_session_page ();
 
@@ -375,7 +375,7 @@ SessionDialog::setup_recent_sessions ()
        recent_session_display.append_column (_("Session Name"), recent_session_columns.visible_name);
        recent_session_display.append_column (_("Sample Rate"), recent_session_columns.sample_rate);
 #ifdef MIXBUS
-       recent_session_display.append_column (_("Created With"), recent_session_columns.created_with);
+       recent_session_display.append_column (_("Modified With"), recent_session_columns.modified_with);
 #else
        recent_session_display.append_column (_("File Resolution"), recent_session_columns.disk_format);
 #endif
@@ -453,9 +453,9 @@ SessionDialog::setup_initial_choice_box ()
 
                info_box->pack_start (*updates_button, false, false);
 
-               info_sample.add (*info_box);
+               info_frame.add (*info_box);
                info_box->show_all ();
-               info_sample.show ();
+               info_frame.show ();
        }
 
        /* recent session scroller */
@@ -481,7 +481,7 @@ SessionDialog::setup_initial_choice_box ()
        existing_session_chooser.add_filter (session_filter);
 
        FileFilter archive_filter;
-       archive_filter.add_pattern (X_("*.tar.xz"));
+       archive_filter.add_pattern (string_compose(X_("*%1"), ARDOUR::session_archive_suffix));
        archive_filter.set_name (_("Session Archives"));
        existing_session_chooser.add_filter (archive_filter);
 
@@ -564,6 +564,14 @@ SessionDialog::open_button_pressed (GdkEventButton* ev)
        return true;
 }
 
+struct LuaScriptListSorter
+{
+       bool operator() (LuaScriptInfoPtr const a, LuaScriptInfoPtr const b) const {
+               return ARDOUR::cmp_nocase_utf8 (a->name, b->name) < 0;
+       }
+};
+
+
 void
 SessionDialog::populate_session_templates ()
 {
@@ -573,32 +581,29 @@ SessionDialog::populate_session_templates ()
 
        template_model->clear ();
 
-       /* Add Lua Scripts dedicated to session-setup */
-       LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::SessionInit));
-       for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
-               TreeModel::Row row = *(template_model->append ());
-               row[session_template_columns.name] = (*s)->name;
-               row[session_template_columns.path] = "urn:ardour:" + (*s)->path;
-               row[session_template_columns.description] = (*s)->description;
-               row[session_template_columns.created_with_short] = _("{Factory Template}");
-               row[session_template_columns.created_with_long] = _("{Factory Template}");
-       }
+       /* Get Lua Scripts dedicated to session-setup */
+       LuaScriptList scripts (LuaScripting::instance ().scripts (LuaScriptInfo::SessionInit));
 
        /* Add Lua Action Scripts which can also be used for session-setup */
        LuaScriptList& as (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
        for (LuaScriptList::const_iterator s = as.begin(); s != as.end(); ++s) {
-               if (!((*s)->subtype & LuaScriptInfo::SessionSetup)) {
-                       continue;
+               if ((*s)->subtype & LuaScriptInfo::SessionSetup) {
+                       scripts.push_back (*s);
                }
+       }
+
+       LuaScriptListSorter cmp;
+       std::sort (scripts.begin(), scripts.end(), cmp);
+
+       for (LuaScriptList::const_iterator s = scripts.begin(); s != scripts.end(); ++s) {
                TreeModel::Row row = *(template_model->append ());
                row[session_template_columns.name] = (*s)->name;
                row[session_template_columns.path] = "urn:ardour:" + (*s)->path;
                row[session_template_columns.description] = (*s)->description;
-               row[session_template_columns.created_with_short] = _("{Factory Template}");
-               row[session_template_columns.created_with_long] = _("{Factory Template}");
+               row[session_template_columns.modified_with_short] = _("{Factory Template}");
+               row[session_template_columns.modified_with_long] = _("{Factory Template}");
        }
 
-
        //Add any "template sessions" found in the user's preferences folder
        for (vector<TemplateInfo>::iterator x = templates.begin(); x != templates.end(); ++x) {
                TreeModel::Row row;
@@ -608,8 +613,8 @@ SessionDialog::populate_session_templates ()
                row[session_template_columns.name] = (*x).name;
                row[session_template_columns.path] = (*x).path;
                row[session_template_columns.description] = (*x).description;
-               row[session_template_columns.created_with_long] = (*x).created_with;
-               row[session_template_columns.created_with_short] = (*x).created_with.substr(0, (*x).created_with.find(" "));
+               row[session_template_columns.modified_with_long] = (*x).modified_with;
+               row[session_template_columns.modified_with_short] = (*x).modified_with.substr(0, (*x).modified_with.find(" "));
        }
 
        //Add an explicit 'Empty Template' item
@@ -617,8 +622,8 @@ SessionDialog::populate_session_templates ()
        row[session_template_columns.name] = (_("Empty Template"));
        row[session_template_columns.path] = string();
        row[session_template_columns.description] = _("An empty session with factory default settings.");
-       row[session_template_columns.created_with_short] = _("");
-       row[session_template_columns.created_with_long] = _("");
+       row[session_template_columns.modified_with_short] = _("");
+       row[session_template_columns.modified_with_long] = _("");
 
        //auto-select the first item in the list
        Gtk::TreeModel::Row first = template_model->children()[0];
@@ -698,9 +703,9 @@ SessionDialog::setup_new_session_page ()
 
                template_hbox->pack_start (*template_scroller, true, true);
 
-               template_desc_sample.set_name (X_("TextHighlightFrame"));
-               template_desc_sample.add (*desc_scroller);
-               template_hbox->pack_start (template_desc_sample, true, true);
+               template_desc_frame.set_name (X_("TextHighlightFrame"));
+               template_desc_frame.add (*desc_scroller);
+               template_hbox->pack_start (template_desc_frame, true, true);
        }
 
        //template_desc is the textview that displays the currently selected template's description
@@ -715,13 +720,15 @@ SessionDialog::setup_new_session_page ()
        template_chooser.set_model (template_model);
        template_chooser.append_column (_("Template"), session_template_columns.name);
 #ifdef MIXBUS
-       template_chooser.append_column (_("Created With"), session_template_columns.created_with_short);
+       template_chooser.append_column (_("Modified With"), session_template_columns.modified_with_short);
 #endif
-       template_chooser.set_tooltip_column(4); // created_with_long
        template_chooser.set_headers_visible (true);
        template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
        template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &SessionDialog::template_row_selected));
        template_chooser.set_sensitive (true);
+       if (UIConfiguration::instance().get_use_tooltips()) {
+               template_chooser.set_tooltip_column(4); // modified_with_long
+       }
 
        session_new_vbox.pack_start (*template_hbox, true, true);
        session_new_vbox.pack_start (*folder_box, false, true);
@@ -867,7 +874,7 @@ SessionDialog::redisplay_recent_sessions ()
                        row[recent_session_columns.tip] = Gtkmm2ext::markup_escape_text (dirname);
                } else {
                        row[recent_session_columns.tip] = Gtkmm2ext::markup_escape_text (dirname + "\n" + string_compose (_("Last modified with: %1"), program_version));
-                       row[recent_session_columns.created_with] = program_version;
+                       row[recent_session_columns.modified_with] = program_version;
                }
 
                ++session_snapshot_count;
@@ -947,7 +954,9 @@ SessionDialog::redisplay_recent_sessions ()
                row[recent_session_columns.time_formatted] = gdt.format ("%F %H:%M");
        }
 
-       recent_session_display.set_tooltip_column(1); // recent_session_columns.tip
+       if (UIConfiguration::instance().get_use_tooltips()) {
+               recent_session_display.set_tooltip_column(1); // recent_session_columns.tip
+       }
        recent_session_display.set_model (recent_session_model);
 
        // custom sort