Some fixes to the new session dialog.
authorNick Mainsbridge <beatroute@iprimus.com.au>
Wed, 10 May 2006 10:22:38 +0000 (10:22 +0000)
committerNick Mainsbridge <beatroute@iprimus.com.au>
Wed, 10 May 2006 10:22:38 +0000 (10:22 +0000)
git-svn-id: svn://localhost/trunk/ardour2@495 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/glade/new_session_dialog.glade
gtk2_ardour/new_session_dialog.cc
gtk2_ardour/new_session_dialog.h

index 169b150d70db835f31488e34b1b837e2cc690505..cb0881c620db888d1f8477cba8a139616e943cf2 100644 (file)
@@ -1706,14 +1706,20 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path)
        m_new_session_dialog->show_all();
        m_new_session_dialog->set_modal(true);
        m_new_session_dialog->set_name(predetermined_path);
+       m_new_session_dialog->reset_recent();
 
        int response = Gtk::RESPONSE_CANCEL;
 
        do {
                response = m_new_session_dialog->run ();
-               if(response == Gtk::RESPONSE_CANCEL) {
+               if(response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) {
                  quit();
                  return;
+
+               } else if (response == 0) {
+                 /* Clear was pressed */
+                 m_new_session_dialog->reset();
+
                } else if (response == Gtk::RESPONSE_YES) {
                  /* YES  == OPEN, but there's no enum for that */
                  std::string session_name = m_new_session_dialog->session_name();
@@ -1803,7 +1809,7 @@ ARDOUR_UI::new_session (bool startup, std::string predetermined_path)
                  }     
                }
                
-       } while(response == Gtk::RESPONSE_HELP);
+       } while (response == 0);
        m_new_session_dialog->hide_all();
        show();
 
index 5824ab4952895d29c6e004b518a7f0bba5ebc4bd..5ecee3b3864dfad2bef5cff2b37b7cea91fa82e3 100644 (file)
        <widget class="GtkHButtonBox" id="hbuttonbox2">
          <property name="layout_style">GTK_BUTTONBOX_DEFAULT_STYLE</property>
 
-         <child>
-           <widget class="GtkButton" id="HelpButton">
-             <property name="visible">True</property>
-             <property name="can_default">True</property>
-             <property name="can_focus">True</property>
-             <property name="label">gtk-help</property>
-             <property name="use_stock">True</property>
-             <property name="relief">GTK_RELIEF_NORMAL</property>
-             <property name="focus_on_click">True</property>
-             <property name="response_id">-11</property>
-           </widget>
-         </child>
-
          <child>
            <widget class="GtkButton" id="QuitButton">
              <property name="visible">True</property>
index 106fea73397629447390f2e3f710c952627fb3c0..533cd2aa96c5993c0fb26325313da640f71fde3d 100644 (file)
@@ -77,77 +77,17 @@ NewSessionDialog::NewSessionDialog(BaseObjectType* cobject,
        xml->get_widget(X_("TheTreeview"), m_treeview);
        xml->get_widget(X_("OkButton"), m_okbutton);
 
-
        if (m_treeview) {
-               /* Shamelessly ripped from ardour_ui.cc */
-               std::vector<string *> *sessions;
-               std::vector<string *>::iterator i;
-               RecentSessionsSorter cmp;
-               
                recent_model = Gtk::TreeStore::create (recent_columns);
                m_treeview->set_model (recent_model);
                m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
                m_treeview->set_headers_visible (false);
                m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
-               
-               recent_model->clear ();
-               
-               ARDOUR::RecentSessions rs;
-               ARDOUR::read_recent_sessions (rs);
-               
-               /* sort them alphabetically */
-               sort (rs.begin(), rs.end(), cmp);
-               sessions = new std::vector<std::string*>;
-               
-               for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
-                       sessions->push_back (new string ((*i).second));
-               }
-         
-               for (i = sessions->begin(); i != sessions->end(); ++i) {
-                 
-                 std::vector<std::string*>* states;
-                 std::vector<const gchar*> item;
-                 std::string fullpath = *(*i);
-                 
-                 /* remove any trailing / */
-                 
-                 if (fullpath[fullpath.length()-1] == '/') {
-                         fullpath = fullpath.substr (0, fullpath.length()-1);
-                 }
-           
-                 /* now get available states for this session */
-                 
-                 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
-                         /* no state file? */
-                         continue;
-                 }
-           
-                 Gtk::TreeModel::Row row = *(recent_model->append());
-                 
-                 row[recent_columns.visible_name] = PBD::basename (fullpath);
-                 row[recent_columns.fullpath] = fullpath;
-                 
-                 if (states->size() > 1) {
-                   
-                         /* add the children */
-                   
-                         for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
-                           
-                                 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
-                                 
-                                 child_row[recent_columns.visible_name] = **i2;
-                                 child_row[recent_columns.fullpath] = fullpath;
-                                 
-                                 delete *i2;
-                         }
-                 }
-                 
-                 delete states;
-               }
-               delete sessions;
+
        }
-       
+
        m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false);
+       m_new_session_dialog->set_response_sensitive (0, false);
        m_new_session_dialog->set_default_response (Gtk::RESPONSE_OK);
        m_notebook->show_all_children();
        m_notebook->set_current_page(0);
@@ -321,6 +261,7 @@ NewSessionDialog::entry_key_release (GdkEventKey* ev)
 {
         if (m_name->get_text() != "") {
                m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true);
+               m_new_session_dialog->set_response_sensitive (0, true);
        } else {
                m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, false);
        }
@@ -331,6 +272,7 @@ void
 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
 {
         if (pagenum == 1) {
+               m_new_session_dialog->set_response_sensitive (0, false);
                m_okbutton->set_label(_("Open"));
                m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
                if (m_treeview->get_selection()->count_selected_rows() == 0) {
@@ -339,6 +281,9 @@ NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
                        m_new_session_dialog->set_response_sensitive (Gtk::RESPONSE_OK, true);
                }
        } else {
+               if (m_name->get_text() != "") {
+                       m_new_session_dialog->set_response_sensitive (0, true);
+               }
                m_okbutton->set_label(_("New"));
                m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
                if (m_name->get_text() == "") {
@@ -386,6 +331,71 @@ NewSessionDialog::reset_template()
 
 }
 
+void
+NewSessionDialog::reset_recent()
+{
+               /* Shamelessly ripped from ardour_ui.cc */
+               std::vector<string *> *sessions;
+               std::vector<string *>::iterator i;
+               RecentSessionsSorter cmp;
+               
+               recent_model->clear ();
+               
+               ARDOUR::RecentSessions rs;
+               ARDOUR::read_recent_sessions (rs);
+               
+               /* sort them alphabetically */
+               sort (rs.begin(), rs.end(), cmp);
+               sessions = new std::vector<std::string*>;
+               
+               for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
+                       sessions->push_back (new string ((*i).second));
+               }
+         
+               for (i = sessions->begin(); i != sessions->end(); ++i) {
+                 
+                 std::vector<std::string*>* states;
+                 std::vector<const gchar*> item;
+                 std::string fullpath = *(*i);
+                 
+                 /* remove any trailing / */
+                 
+                 if (fullpath[fullpath.length()-1] == '/') {
+                         fullpath = fullpath.substr (0, fullpath.length()-1);
+                 }
+           
+                 /* now get available states for this session */
+                 
+                 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
+                         /* no state file? */
+                         continue;
+                 }
+           
+                 Gtk::TreeModel::Row row = *(recent_model->append());
+                 
+                 row[recent_columns.visible_name] = PBD::basename (fullpath);
+                 row[recent_columns.fullpath] = fullpath;
+                 
+                 if (states->size() > 1) {
+                   
+                         /* add the children */
+                   
+                         for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
+                           
+                                 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
+                                 
+                                 child_row[recent_columns.visible_name] = **i2;
+                                 child_row[recent_columns.fullpath] = fullpath;
+                                 
+                                 delete *i2;
+                         }
+                 }
+                 
+                 delete states;
+               }
+               delete sessions;
+}
+
 void
 NewSessionDialog::reset()
 {
index 5e5e9723dd7d070e78f4d581b4a3e38f97929670..8ee4a93969b920703afe7c8c4ea951a3ffdaad21 100644 (file)
@@ -93,15 +93,16 @@ public:
        bool connect_outs_to_master() const;
        bool connect_outs_to_physical() const ;
        int get_current_page();
+       void reset_recent();
+
+       // reset everything to default values.
+       void reset();
 
 protected:
 
        void reset_name();
        void reset_template();
        
-       // reset everything to default values.
-       void reset();
-
        // references to widgets we care about.
        Gtk::Dialog* m_new_session_dialog;
        Gtk::Entry*  m_name;