support for glade and new new session dialog
authorsolido <solido@dummy.example.com>
Mon, 14 Nov 2005 08:38:16 +0000 (08:38 +0000)
committersolido <solido@dummy.example.com>
Mon, 14 Nov 2005 08:38:16 +0000 (08:38 +0000)
git-svn-id: svn://localhost/trunk/ardour2@88 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/SConscript
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/audio_time_axis.cc
gtk2_ardour/glade_factory.cc [new file with mode: 0644]
gtk2_ardour/glade_factory.h [new file with mode: 0644]
gtk2_ardour/glade_path.cc [new file with mode: 0644]
gtk2_ardour/glade_path.h [new file with mode: 0644]
gtk2_ardour/new_session_dialog.cc
gtk2_ardour/new_session_dialog.h
gtk2_ardour/po/SConscript [new file with mode: 0644]

index 752e3360139038a111cbdb871f3a63ae6cc76180..23368ad910cd8265c6c1fd0a2f025e0c8ef33e57 100644 (file)
@@ -43,7 +43,8 @@ gtkardour.Merge ([
     libraries['xml'],
     libraries['soundtouch'],
     libraries['samplerate'],
-    libraries['jack']
+    libraries['jack'],
+    libraries['libglademm']
 ])
 
 if gtkardour['VST']:
@@ -110,6 +111,8 @@ export_dialog.cc
 gain_automation_time_axis.cc
 gain_meter.cc
 ghostregion.cc
+glade_path.cc
+glade_factory.cc
 grouped_buttons.cc
 gtk-custom-hruler.c
 gtk-custom-ruler.c
@@ -166,6 +169,10 @@ visual_time_axis.cc
 waveview.cc
 """)
 
+glade_files=glob.glob('glade/*.glade')
+
+intl_files = gtkardour_files + glade_files + glob.glob('*.h')
+
 mtest_files=Split("""
 mtest.cc
 """)
@@ -180,9 +187,12 @@ vst_files = [ 'vst_pluginui.cc' ]
 if env['VST']:
    extra_sources += vst_files
 
+intl_files += extra_sources
+
 gtkardour.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
 gtkardour.Append(CXXFLAGS="-DDATA_DIR=\\\""+final_prefix+"/share\\\"")
 gtkardour.Append(CXXFLAGS="-DLOCALEDIR=\\\""+final_prefix+"/share/locale\\\"")
+gtkardour.Append(CXXFLAGS="-DGLADEPATH=\\\""+final_prefix+"/share/ardour/glade\\\"")
 
 versionflag = '-DVERSIONSTRING=\\\"' + env['VERSION'] + '\\\"'
 
@@ -202,14 +212,16 @@ if env['VERSIONED']:
     Default (env.VersionedExecutable ('tagged_executable', ardour))
 
 if env['NLS']:
-    i18n (gtkardour, gtkardour_files + extra_sources, env)
-
+    Export('gtkardour', 'intl_files')
+    SConscript ('po/SConscript')
+    
 #install
 
 
 env.Alias('install', env.InstallAs(os.path.join(install_prefix, 'bin')+'/ardour', ardour))
 env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour'), 'ardour_ui.rc'))
 env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour'), 'splash.ppm'))
+env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour/glade'), glade_files))
 
 #dist
 env.Alias ('tarball', env.Distribute (env['DISTTREE'],
@@ -218,7 +230,7 @@ env.Alias ('tarball', env.Distribute (env['DISTTREE'],
                                         'editor_xpms', 'misc_xpms', 'transport_xpms',
                                         'ardour_ui.rc', 'splash.ppm'
                                         ] +
-                                      gtkardour_files + vst_files +
+                                      gtkardour_files + vst_files + glade_files +
                                       glob.glob('po/*.po') + glob.glob('*.h')))
 
 # generate a prototype full-featured ardour_ui.rc file
index f45243bb1b739ce30d7fedad91cf1cf81ed959de..f66b6ff0d1d817d3230cbd408337663b7f814466 100644 (file)
@@ -781,7 +781,7 @@ vector<string> channel_combo_strings;
 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
 
        : Gtkmm2ext::UI ("ardour", argcp, argvp, rcfile),
-
+         
          primary_clock (X_("TransportClockDisplay"), true, false, true),
          secondary_clock (X_("SecondaryClockDisplay"), true, false, true),
          preroll_clock (X_("PreRollClock"), true, true),
@@ -830,7 +830,11 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        if (theArdourUI == 0) {
                theArdourUI = this;
        }
-
+       
+       m_new_session_dialog = 0;
+       m_new_session_dialog_ref = NewSessionDialogFactory::create();
+       m_new_session_dialog_ref->get_widget_derived(NewSessionDialogFactory::top_level_widget_name(),
+                                                    m_new_session_dialog);
        editor = 0;
        mixer = 0;
        session = 0;
@@ -844,7 +848,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        meter_bridge = 0;
        option_editor = 0;
        location_ui = 0;
-       new_session_window = 0;
        open_session_selector = 0;
        have_configure_timeout = false;
        have_disk_overrun_displayed = false;
@@ -852,6 +855,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        _will_create_new_session_automatically = false;
        session_loaded = false;
 
+
        last_configure_time.tv_sec = 0;
        last_configure_time.tv_usec = 0;
 
@@ -1778,21 +1782,6 @@ ARDOUR_UI::open_recent_session ()
 
 }
 
-void
-ARDOUR_UI::fs_cancel_clicked (Gtk::FileSelection* fs)
-{
-       fs->hide_all();
-       fs->get_selection_entry()->set_text("");
-       allow_focus (false);
-}
-
-gint 
-ARDOUR_UI::fs_delete_event (GdkEventAny* ev, Gtk::FileSelection* fs)
-{
-       fs_cancel_clicked (fs);
-       return 1;
-}
-
 bool
 ARDOUR_UI::filter_ardour_session_dirs (const FileFilter::Info& info) 
 {
@@ -2697,87 +2686,81 @@ ARDOUR_UI::save_template ()
 }
 
 void
-ARDOUR_UI::new_session (bool startup, string predetermined_path)
+ARDOUR_UI::new_session (bool startup, std::string predetermined_path)
 {
-       if (new_session_window == 0){
-               new_session_window = new NewSessionDialog (*engine, startup, predetermined_path);
-               editor->ensure_float (*new_session_window);
-       }
+       m_new_session_dialog->show_all();
+       m_new_session_dialog->set_transient_for(*editor);
+       m_new_session_dialog->set_name(predetermined_path);
 
-       new_session_window->run ();
+       int response = Gtk::RESPONSE_CANCEL;
 
-#if 0
-       // GTK2FIX
+       do {
+               response = m_new_session_dialog->run ();
        
-       /* write favorites either way */
-       Session::FavoriteDirs favs;
-       new_session_window->file_selector.get_favorites (favs);
-       Session::write_favorite_dirs (favs);
-
-       if (new_session_window->run_status()) {
-               return;
-       }
-#endif
-
-       string session_path = new_session_window->file_selector.get_filename ();
-       string session_name = PBD::basename (session_path);
-
-       // Check that it doesn't already exist.
-       access(session_path.c_str(), R_OK); 
-       if (errno != ENOENT){
-               error << string_compose(_("Session %1 already exists at %2"), session_name, session_path) << endmsg;
-               return;
-       }
-
-       _session_is_new = true;
-
-       if (session_path[session_path.length()-1] != '/') {
-
-               string template_name = new_session_window->get_template_name ();
-
-               if (template_name.length()) {
-
-                       load_session (session_path, session_name, &template_name);
-
-               } else {
+               if(response == Gtk::RESPONSE_OK) {
 
-                       uint32_t cchns;
-                       uint32_t mchns;
-                       Session::AutoConnectOption iconnect;
-                       Session::AutoConnectOption oconnect;
-
-                       if (new_session_window->use_control_button.get_active()) {
-                               cchns = (uint32_t) channel_combo_get_channel_count (new_session_window->control_out_channel_combo);
-                       } else {
-                               cchns = 0;
-                       }
-                       if (new_session_window->use_master_button.get_active()) {
-                               mchns = (uint32_t) channel_combo_get_channel_count (new_session_window->master_out_channel_combo);
-                       } else {
-                               mchns = 0;
-                       }
-
-                       if (new_session_window->connect_to_physical_inputs_button.get_active()) {
-                               iconnect = Session::AutoConnectPhysical;
-                       } else {
-                               iconnect = Session::AutoConnectOption (0);
-                       }
-
-                       if (new_session_window->connect_to_master_button.get_active ()) {
-                               oconnect = Session::AutoConnectMaster;
-                       } else if (new_session_window->connect_to_physical_outputs_button.get_active ()) {
-                               oconnect = Session::AutoConnectPhysical;
+                       _session_is_new = true;
+                       
+                       std::string session_name = m_new_session_dialog->session_name();
+                       std::string session_path = m_new_session_dialog->session_folder();
+                       std::string template_name = m_new_session_dialog->session_template_name();
+                       
+                       if (m_new_session_dialog->use_session_template()) {
+                               
+                               load_session (session_path, session_name, &template_name);
+                               
                        } else {
-                               oconnect = Session::AutoConnectOption (0);
-                       } 
-
-                       uint32_t nphysin = (uint32_t) new_session_window->in_count_adjustment.get_value();
-                       uint32_t nphysout = (uint32_t) new_session_window->out_count_adjustment.get_value();
-
-                       build_session (session_path, session_name, cchns, mchns, iconnect, oconnect, nphysin, nphysout, 
-                                      engine->frame_rate() * 60 * 5);
+                               
+                               uint32_t cchns;
+                               uint32_t mchns;
+                               Session::AutoConnectOption iconnect;
+                               Session::AutoConnectOption oconnect;
+                               
+                               if (m_new_session_dialog->create_control_track()) {
+                                       cchns = (uint32_t) m_new_session_dialog->control_channel_count();
+                               } else {
+                                       cchns = 0;
+                               }
+                               
+                               if (m_new_session_dialog->create_master_track()) {
+                                       mchns = (uint32_t) m_new_session_dialog->master_channel_count();
+                               } else {
+                                       mchns = 0;
+                               }
+                               
+                               if (m_new_session_dialog->connect_inputs()) {
+                                       iconnect = Session::AutoConnectPhysical;
+                               } else {
+                                       iconnect = Session::AutoConnectOption (0);
+                               }
+                               
+                               /// @todo some minor tweaks.
+
+                               if (m_new_session_dialog->connect_outs_to_master()) {
+                                       oconnect = Session::AutoConnectMaster;
+                               } else if (m_new_session_dialog->connect_outs_to_physical()) {
+                                       oconnect = Session::AutoConnectPhysical;
+                               } else {
+                                       oconnect = Session::AutoConnectOption (0);
+                               } 
+                               
+                               uint32_t nphysin = (uint32_t) m_new_session_dialog->input_limit_count();
+                               uint32_t nphysout = (uint32_t) m_new_session_dialog->output_limit_count();
+                               
+                               build_session (session_path,
+                                              session_name,
+                                              cchns,
+                                              mchns,
+                                              iconnect,
+                                              oconnect,
+                                              nphysin,
+                                              nphysout, 
+                                              engine->frame_rate() * 60 * 5);
+                       }               
                }
-       }
+
+       } while(response == Gtk::RESPONSE_HELP);
+       m_new_session_dialog->hide_all();
 }
 
 int
@@ -2875,12 +2858,6 @@ ARDOUR_UI::build_session (string path, string snap_name,
        return 0;
 }
 
-void
-ARDOUR_UI::hide_dialog (ArdourDialog *dialog)
-{
-       dialog->hide_all();
-}
-
 void
 ARDOUR_UI::show ()
 {
index c835303de7cc662ca3f42c3b766969c3b08306cc..b5ed3b4e3aa265cb51469ea085d00f18667df215 100644 (file)
@@ -61,6 +61,7 @@
 #include "audio_clock.h"
 #include "ardour_dialog.h"
 #include "editing.h"
+#include "glade_factory.h"
 
 class AudioClock;
 class PublicEditor;
@@ -127,7 +128,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
                _will_create_new_session_automatically = yn;
        }
 
-       void new_session (bool startup = false, std::string path = string());
+       void new_session(bool startup = false, std::string path = string());
        gint cmdline_new_session (std::string path);
        int  unload_session ();
        void close_session() { unload_session(); }
@@ -548,16 +549,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI
 
        bool _will_create_new_session_automatically;
 
-       NewSessionDialog* new_session_window;
-       string template_name;
-
-       void new_session_ok_clicked ();
-       void new_session_template_choice (Gtk::TreeView&, Glib::RefPtr<Gtk::TreeSelection>);
-       void hide_dialog (ArdourDialog *dialog);
-
-       void fs_cancel_clicked (Gtk::FileSelection*);
-       gint fs_delete_event (GdkEventAny*, Gtk::FileSelection*);
-
+       GladeRef m_new_session_dialog_ref;
+       NewSessionDialog* m_new_session_dialog;
+       
        void open_session ();
        void open_recent_session ();
        void open_ok_clicked ();
index 5f9c020025c14a834d30551c08678d7048241e12..af98f55d686e1c74b67f5e15ce3b6050eb5c97cd 100644 (file)
@@ -1199,14 +1199,21 @@ AudioTimeAxisView::add_gain_automation_child ()
        XMLProperty* prop;
        AutomationLine* line;
 
-       gain_track = new GainAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, _("gain"),
+       gain_track = new GainAutomationTimeAxisView (_session,
+                                                    _route,
+                                                    editor,
+                                                    *this,
+                                                    parent_canvas,
+                                                    _("gain"),
                                                     _route.gain_automation_curve());
        
 
        sigc::slot<bool,GdkEvent*,ControlPoint*> cslot = mem_fun (editor, &PublicEditor::canvas_control_point_event);
        sigc::slot<bool,GdkEvent*,AutomationLine*> lslot = mem_fun (editor, &PublicEditor::canvas_line_event);
        
-       line = new AutomationGainLine ("automation gain", _session, *gain_track,
+       line = new AutomationGainLine ("automation gain",
+                                      _session,
+                                      *gain_track,
                                       *gain_track->canvas_display,
                                       _route.gain_automation_curve(), cslot, lslot);
 
diff --git a/gtk2_ardour/glade_factory.cc b/gtk2_ardour/glade_factory.cc
new file mode 100644 (file)
index 0000000..b92f36b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2005 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    $Id$
+*/
+
+#include <iostream>
+
+#include "glade_factory.h"
+
+Glib::RefPtr<Gnome::Glade::Xml>
+GladeFactory::create(const std::string& full_path_to_file,
+                    const Glib::ustring& toplevel_widget)
+{
+       try {
+               return Gnome::Glade::Xml::create(full_path_to_file,
+                                                toplevel_widget,
+                                                PACKAGE );
+       } catch(const Gnome::Glade::XmlError& ex) {
+               std::cerr << ex.what() << std::endl;
+               throw ex;
+       }
+}
diff --git a/gtk2_ardour/glade_factory.h b/gtk2_ardour/glade_factory.h
new file mode 100644 (file)
index 0000000..2fff3bd
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+    Copyright (C) 2005 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    $Id$
+*/
+
+// -*- c++ -*-
+
+#ifndef GLADE_FACTORY_H
+#define GLADE_FACTORY_H
+
+#include <string>
+#include <libglademm/xml.h>
+
+typedef Glib::RefPtr<Gnome::Glade::Xml> GladeRef;
+
+/**
+   This is the base class for all glade 
+   factories so that the same domain is
+   used.
+*/
+class GladeFactory {
+       
+protected:
+       static GladeRef
+       create(const std::string& full_path,
+              const Glib::ustring& toplevel_widget = Glib::ustring());
+};
+
+
+#endif // GLADE_FACTORY_H
diff --git a/gtk2_ardour/glade_path.cc b/gtk2_ardour/glade_path.cc
new file mode 100644 (file)
index 0000000..e922ec2
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+    Copyright (C) 2005 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    $Id$
+*/
+
+#include <glibmm/fileutils.h>
+#include <glibmm/miscutils.h>
+
+#include "i18n.h"
+#include "glade_path.h"
+
+#include <iostream>
+
+std::string
+GladePath::path(const std::string& glade_file)
+{
+       std::string user_glade_dir = Glib::getenv(X_("ARDOUR_GLADE_PATH"));
+       std::string full_path;
+       
+       if(user_glade_dir != "") {
+               full_path = Glib::build_filename(user_glade_dir, glade_file);
+               if(Glib::file_test(full_path, Glib::FILE_TEST_EXISTS)) return full_path;
+       }
+       
+       // check if file ~/.ardour/glade/glade_file exists.
+       std::vector<std::string> path;
+       path.push_back(Glib::get_home_dir());
+       path.push_back(X_(".ardour")); // define as a constant somewhere?
+       path.push_back(X_("glade"));
+       path.push_back(glade_file);
+       full_path = Glib::build_filename(path);
+       
+       // temporary debugging
+       std::cout << "Path to glade file" << full_path << std::endl;
+       
+       if(Glib::file_test(full_path, Glib::FILE_TEST_EXISTS)) return full_path;
+       
+       /*
+         If for some wierd reason the system wide glade file
+         doesn't exist libglademm will throw an exception 
+         so don't bother testing if it exists etc.
+       */
+       return Glib::build_filename(GLADEPATH, glade_file);
+}
diff --git a/gtk2_ardour/glade_path.h b/gtk2_ardour/glade_path.h
new file mode 100644 (file)
index 0000000..a651b5f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+    Copyright (C) 2005 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    $Id$
+*/
+
+#ifndef GLADE_PATH_H
+#define GLADE_PATH_H
+
+#include <string>
+
+struct GladePath {
+
+       /**
+          @return Path to glade file.
+          
+          XXX subject to change upon discussion.
+
+          glade files are currently looked for in
+          three possible directories in this order.
+
+          In the directory defined in the environment
+          variable ARDOUR_GLADE_PATH
+
+          In the users .ardour/glade directory.
+          
+          In the system defined glade path.
+       */
+       static std::string
+       path(const std::string& glade_filename);
+
+};
+
+#endif // GLADE_PATH_H
+
index 854e702232b23a7acb8193f6811df258ad651281..428facdfbad1587aab9b3be9618b1fe0c774a504 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 1999-2002 Paul Davis 
+    Copyright (C) 2005 Paul Davis 
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     $Id$
 */
 
-#include <list>
-#include <string>
-#include <ardour/session.h>
-#include <ardour/audioengine.h>
-
-#include "prompter.h"
+#include "i18n.h"
 #include "new_session_dialog.h"
+#include "glade_path.h"
 
-using namespace Gtkmm2ext;
-using namespace Gtk;
-using namespace ARDOUR;
+const char* NewSessionDialogFactory::s_m_top_level_widget_name = X_("new_session_dialog");
 
-#include "i18n.h"
 
-extern std::vector<string> channel_combo_strings;
-
-NewSessionDialog::NewSessionDialog (ARDOUR::AudioEngine& engine, bool startup, string given_path)
-       : ArdourDialog ("new session dialog"),
-         file_selector (_("Session name:"), _("Create")),
-         use_control_button (_("use control outs")),
-         use_master_button (_("use master outs")),
-         connect_to_physical_inputs_button (_("automatically connect track inputs to physical ports")),
-         connect_to_master_button (_("automatically connect track outputs to master outs")),
-         connect_to_physical_outputs_button (_("automatically connect track outputs to physical ports")),
-         manual_connect_outputs_button (_("manually connect track outputs")),
-         in_count_adjustment (2, 1, 1000, 1, 2),
-         out_count_adjustment (2, 1, 1000, 1, 2),
-         output_label (_("Output Connections")),
-         input_label (_("Input Connections")),
-         expansion_button (_("Advanced...")),
-         out_table (2, 2),
-         show_again (_("show again")),
-         in_count_spinner (in_count_adjustment),
-         out_count_spinner (out_count_adjustment),
-         in_count_label (_("Hardware Inputs: use")),
-         out_count_label (_("Hardware Outputs: use"))
-       
+Glib::RefPtr<Gnome::Glade::Xml>
+NewSessionDialogFactory::create()
 {
-       using namespace Notebook_Helpers;
-
-       set_name ("NewSessionDialog");
-       set_title (_("new session setup"));
-       set_wmclass (_("ardour_new_session"), "Ardour");
-       set_position (Gtk::WIN_POS_MOUSE);
-       set_keyboard_input (true);
-       // GTK2FIX
-       // set_policy (false, true, false);
-       set_modal (true);
-
-       /* sample rate */
-
-       sr_label1.set_text (string_compose 
-                          (_("This session will playback and record at %1 Hz"),
-                           engine.frame_rate()));
-       sr_label2.set_text (_("This rate is set by JACK and cannot be changed.\n"
-                             "If you want to use a different sample rate\n"
-                             "please exit and restart JACK"));
-       sr_box.set_spacing (12);
-       sr_box.set_border_width (12);
-       sr_box.pack_start (sr_label1, false, false);
-       sr_box.pack_start (sr_label2, false, false);
-       sr_frame.add (sr_box);
-
-       /* input */
-
-       connect_to_physical_inputs_button.set_active (true);
-       connect_to_physical_inputs_button.set_name ("NewSessionDialogButton");
-       
-       HBox* input_limit_box = manage (new HBox);
-       input_limit_box->set_spacing (7);
-       input_limit_box->pack_start (in_count_label, false, false);
-       input_limit_box->pack_start (in_count_spinner, false, false);
-
-       input_label.set_alignment (0.1, 0.5);
-       input_vbox.pack_start (input_label, false, false, 7);
-       input_vbox.pack_start (connect_to_physical_inputs_button, false, false);
+       return GladeFactory::create(GladePath::path(X_("new_session_dialog.glade")));
+}
 
-       if (engine.n_physical_inputs() > 2) {
-               input_vbox.pack_start (*input_limit_box, false, false);
-       }
 
-       /* output */
+NewSessionDialog::NewSessionDialog(BaseObjectType* cobject,
+                                  const Glib::RefPtr<Gnome::Glade::Xml>& xml)
+       : Gtk::Dialog(cobject)    
+{
+       // look up the widgets we care about.
 
-       use_master_button.set_active (true);
-       use_master_button.set_name ("NewSessionDialogButton");
-       
-       connect_to_physical_outputs_button.set_group (connect_to_master_button.get_group());
-       manual_connect_outputs_button.set_group (connect_to_master_button.get_group());
-       connect_to_master_button.set_active (true);
+       xml->get_widget(X_("SessionName"), m_name);
+       xml->get_widget(X_("SessionFolder"), m_folder);
+       xml->get_widget(X_("SessionTemplate"), m_template);
        
-       connect_to_physical_outputs_button.set_name ("NewSessionDialogButton");
-       manual_connect_outputs_button.set_name ("NewSessionDialogButton");
-       connect_to_master_button.set_name ("NewSessionDialogButton");
-       use_control_button.set_name ("NewSessionDialogButton");
+       xml->get_widget(X_("CreateMasterTrack"), m_create_master_track);
+       xml->get_widget(X_("MasterChannelCount"), m_master_track_channel_count);
        
-       out_count_adjustment.set_value (engine.n_physical_outputs());
-       in_count_adjustment.set_value (engine.n_physical_inputs());
+       xml->get_widget(X_("CreateControlTrack"), m_create_control_track);
+       xml->get_widget(X_("ControlChannelCount"), m_control_track_channel_count);
 
-       set_popdown_strings (control_out_channel_combo, channel_combo_strings);
-       control_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
-       // use stereo as default
-       control_out_channel_combo.set_active_text (channel_combo_strings.front());
+       xml->get_widget(X_("ConnectInputs"), m_connect_inputs);
+       xml->get_widget(X_("LimitInputPorts"), m_limit_input_ports);
+       xml->get_widget(X_("InputLimitCount"), m_input_limit_count);
 
-       set_popdown_strings (master_out_channel_combo, channel_combo_strings);
-       master_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
-       // use stereo as default
-       master_out_channel_combo.set_active_text (channel_combo_strings.front());
+       xml->get_widget(X_("ConnectOutputs"), m_connect_outputs);
+       xml->get_widget(X_("LimitOutputPorts"), m_limit_output_ports);
+       xml->get_widget(X_("OutputLimitCount"), m_output_limit_count);  
+       xml->get_widget(X_("ConnectOutsToMaster"), m_connect_outputs_to_master);
+       xml->get_widget(X_("ConnectOutsToPhysical"), m_connect_outputs_to_physical);
 
-       
-       out_table.set_col_spacings (7);
-       out_table.set_row_spacings (7);
-       if (engine.n_physical_outputs() > 2) {
-               out_table.attach (out_count_label, 0, 1, 0, 1, 0, 0);   
-               out_table.attach (out_count_spinner, 1, 2, 0, 1, 0, 0);
-       }
-       out_table.attach (use_control_button, 0, 1, 1, 2, 0, 0);
-       out_table.attach (control_out_channel_combo, 1, 2, 1, 2, 0, 0);
-       out_table.attach (use_master_button, 0, 1, 2, 3, 0, 0);
-       out_table.attach (master_out_channel_combo, 1, 2, 2, 3, 0, 0);
-       
-       output_label.set_alignment (0.1, 0.5);
-       output_vbox.pack_start (output_label, true, true, 7);
-       output_vbox.pack_start (out_table, false, false, 5);
-       output_vbox.pack_start (connect_to_master_button, false);
-       output_vbox.pack_start (connect_to_physical_outputs_button, false);
-       output_vbox.pack_start (manual_connect_outputs_button, false);
-       
-       input_hbox.pack_start (input_vbox, false, false);
-       output_hbox.pack_start (output_vbox, false, false);
+       ///@ todo connect some signals
 
-       VBox* template_vbox = manage (new VBox);
-       Label* template_label = manage (new Label (_("Session template")));
-       
-       template_label->set_alignment (0.1, 0.5);
-       template_vbox->pack_start (*template_label, true, true, 7);
-       template_vbox->pack_start (template_combo, false, false);
+}
 
-       io_box.set_border_width (12);
-       io_box.set_spacing (7);
-       io_box.pack_start (*template_vbox);
+void
+NewSessionDialog::set_session_name(const Glib::ustring& name)
+{
+       m_name->set_text(name);
+}
 
-       io_box.pack_start (input_hbox);
-       io_box.pack_start (output_hbox);
+std::string
+NewSessionDialog::session_name() const
+{
+       return Glib::filename_from_utf8(m_name->get_text());
+}
 
-       reset_templates();
+std::string
+NewSessionDialog::session_folder() const
+{
+       return Glib::filename_from_utf8(m_folder->get_current_folder());
+}
 
-       option_hbox.set_spacing (7);
-       option_hbox.pack_start (io_box);
+bool
+NewSessionDialog::use_session_template() const
+{
+       if(m_template->get_filename().empty()) return false;
+       return true;
+}
 
-       fsbox.set_border_width (12);
-       fsbox.set_spacing (7);
-       fsbox.pack_start (file_selector.table, false, false);
+std::string
+NewSessionDialog::session_template_name() const
+{
+       return Glib::filename_from_utf8(m_template->get_filename());
+}
 
-       notebook.pages().push_back (TabElem (fsbox, _("Location")));
-       notebook.pages().push_back (TabElem (option_hbox, _("Configuration")));
+bool
+NewSessionDialog::create_master_track() const
+{
+       return m_create_master_track->get_active();
+}
 
-       if (startup) {
-               show_again.set_active(true);
-               show_again.toggled.connect (mem_fun(*this, &NewSessionDialog::show_again_toggled));
-               file_selector.button_box.pack_end(show_again, false, false);
-       }
+int
+NewSessionDialog::master_channel_count() const
+{
+       return m_master_track_channel_count->get_value_as_int();
+}
 
-       main_vbox.set_border_width (12);
-       main_vbox.set_border_width (12);
-       main_vbox.set_spacing (7);
-       main_vbox.pack_start (sr_frame, false, false);
-       main_vbox.pack_start (notebook, false, false);
-       main_vbox.pack_start (file_selector.button_box, false, false);
-       
-       add (main_vbox);
-
-//     template_selector.shift_made.connect (
-//             mem_fun(*this, &NewSessionDialog::mix_template_shift));
-//     template_selector.control_made.connect (
-//             mem_fun(*this, &NewSessionDialog::mix_template_control));
-
-       file_selector.cancel_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), -1));
-       file_selector.op_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 0));
-       file_selector.Expanded.connect (mem_fun(*this, &NewSessionDialog::file_selector_expansion));
-
-       delete_event.connect (mem_fun(*this, &ArdourDialog::wm_close_event));
-       show.connect (mem_fun(*this, &NewSessionDialog::fixup_at_show));
-
-       file_selector.entry_label.set_name ("NewSessionMainLabel");
-       file_selector.where_label.set_name ("NewSessionMainLabel");
-       template_label->set_name ("NewSessionIOLabel");
-       input_label.set_name ("NewSessionIOLabel");
-       output_label.set_name ("NewSessionIOLabel");
-       sr_label1.set_name ("NewSessionSR1Label");
-       sr_label2.set_name ("NewSessionSR2Label");
-
-       if (given_path.empty()) {
-               Session::FavoriteDirs favs;
-               Session::read_favorite_dirs (favs);
-               file_selector.set_favorites (favs);
-       } else {
-               file_selector.set_path (given_path, true);
-               notebook.set_page (-1);
-               notebook.show.connect (bind (mem_fun (notebook, &Notebook::set_page), -1));
-       }
-       set_default_size(531, 358);
+bool
+NewSessionDialog::create_control_track() const
+{
+       return m_create_control_track->get_active();
 }
 
-void
-NewSessionDialog::file_selector_expansion (bool expanded)
+int
+NewSessionDialog::control_channel_count() const
 {
-       if (expanded) {
-               fsbox.pack_start (file_selector.expansion_vbox);
-               fsbox.reorder_child (file_selector.expansion_vbox, 2);
-       } else {
-               fsbox.remove (file_selector.expansion_vbox);
-       }
+       return m_control_track_channel_count->get_value_as_int();
 }
 
-void
-NewSessionDialog::fixup_at_show ()
+bool
+NewSessionDialog::connect_inputs() const
 {
-//     if (template_selector.clist().rows().size() == 0) {
-//             use_template_button.set_sensitive (false);
-//     }
+       return m_connect_inputs->get_active();
+}
 
-       Session::FavoriteDirs favs;
-       Session::read_favorite_dirs (favs);
-       file_selector.set_favorites (favs);
+bool
+NewSessionDialog::limit_inputs_used_for_connection() const
+{
+       return m_limit_input_ports->get_active();
+}
 
-       file_selector.entry.grab_focus ();
+int
+NewSessionDialog::input_limit_count() const
+{
+       return m_input_limit_count->get_value_as_int();
 }
 
-void
-NewSessionDialog::_mix_template_refiller (CList &clist, void *arg)
+bool
+NewSessionDialog::connect_outputs() const
+{
+       return m_connect_outputs->get_active();
+}
 
+bool
+NewSessionDialog::limit_outputs_used_for_connection() const
 {
-       ((NewSessionDialog*) arg)->mix_template_refiller (clist);
+       return m_limit_output_ports->get_active();
 }
 
-void
-NewSessionDialog::mix_template_refiller (CList &clist)
+int
+NewSessionDialog::output_limit_count() const
 {
-       const gchar *rowdata[2];
-       list<string> templates;
-       list<string>::iterator i;
-       
-       Session::get_template_list(templates);
-       
-       rowdata[0] = _("blank");
-       clist.insert_row (0, rowdata);
-
-       guint row;
-       for (row=1, i=templates.begin(); i != templates.end(); ++row, ++i) {
-               rowdata[0] = (*i).c_str();
-               clist.insert_row (row, rowdata);
-       }
+       return m_output_limit_count->get_value_as_int();
 }
 
-void
-NewSessionDialog::mix_template_shift (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
+bool
+NewSessionDialog::connect_outs_to_master() const
 {
-       if (res && res->text){
-               Session::delete_template(*res->text);
-               // template_selector.rescan();
-       }
+       return m_connect_outputs_to_master->get_active();
 }
 
-void
-NewSessionDialog::mix_template_control (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
+bool
+NewSessionDialog::connect_outs_to_physical() const
 {
-#if 0
-       if (res && res->text) {
-               ArdourPrompter prompter (true);
-               prompter.set_prompt(_("Name for mix template:"));
-
-               string old_name = *(res->text);
-               prompter.set_initial_text (old_name);
-               prompter.done.connect (Gtk::Main::quit.slot());
-               prompter.show_all();
-               
-               Gtk::Main::run();
-               
-               if (prompter.status == Gtkmm2ext::Prompter::entered) {
-                       string name;
-
-                       prompter.get_result (name);
-
-                       if (name.length() && name != old_name) {
-                               Session::rename_template(old_name, name);
-                               template_selector.rescan();
-                       }
-               }
-       }
-#endif
+       return m_connect_outputs_to_physical->get_active();
 }
 
+
 void
-NewSessionDialog::show_again_toggled ()
+NewSessionDialog::reset_name()
 {
-       Config->set_no_new_session_dialog(!show_again.get_active());
-       Config->save_state();
+       m_name->set_text(Glib::ustring());
+       
 }
 
+/// @todo
 void
-NewSessionDialog::reset_template()
+NewSessionDialog::reset_template()
 {
-       templates.clear ();
-       templates.push_back (_("No template - create tracks/busses manually"));
-       Session::get_template_list (templates);
-       set_popdown_strings (template_combo, templates);
+
 }
 
-string
-NewSessionDialog::get_template_name()
+void
+NewSessionDialog::reset()
 {
-       string str = template_combo.get_entry()->get_text();
-       if (str.substr (0, 11) == _("No template")) {
-               return "";
-       } else {
-               return str;
-       }
+       reset_name();
+       reset_template();
 }
index ba79598c8f22b089811e319a204d4c9a26bafd20..79e7000ee73b81d53c09e2cbbcf79ce8b56cc4f4 100644 (file)
-#ifndef __gtk_ardour_new_session_dialog_h__
-#define __gtk_ardour_new_session_dialog_h__
-
-#include <gtkmm/adjustment.h>
-#include <gtkmm/radiobutton.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/filechooserwidget.h>
-#include <gtkmm/box.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/comboboxtext.h>
-
-namespace Gtk {
-       class CList;
-}
-
-namespace ARDOUR {
-       class AudioEngine;
-}
-
-#include <gtkmm2ext/click_box.h>
-#include <gtkmm2ext/selector.h>
-#include "ardour_dialog.h"
-
-class NewSessionDialog : public ArdourDialog
+/*
+    Copyright (C) 2005 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+    $Id$
+*/
+
+// -*- c++ -*-
+
+#ifndef NEW_SESSION_DIALOG_H
+#define NEW_SESSION_DIALOG_H
+
+#include <string>
+#include <gtkmm.h>
+
+#include "glade_factory.h"
+
+struct NewSessionDialogFactory : public GladeFactory
 {
-  public:
-       NewSessionDialog (ARDOUR::AudioEngine&, bool startup, std::string path);
+       static GladeRef create();
+
+       static const char* top_level_widget_name();
+
+private:
+
+       static const char* s_m_top_level_widget_name;
        
-       Gtk::FileChooserWidget file_selector;
-       Gtk::ComboBoxText control_out_channel_combo;
-       Gtk::ComboBoxText master_out_channel_combo;
-       Gtk::CheckButton use_control_button;
-       Gtk::CheckButton use_master_button;
-       Gtk::CheckButton connect_to_physical_inputs_button;
-
-       Gtk::RadioButton connect_to_master_button;
-       Gtk::RadioButton connect_to_physical_outputs_button;
-       Gtk::RadioButton manual_connect_outputs_button;
-
-       Gtk::VBox input_vbox;
-       Gtk::VBox manual_vbox;
-       Gtk::VBox output_vbox;
-       Gtk::VBox vbox;
-
-       Gtk::Adjustment in_count_adjustment;
-       Gtk::Adjustment out_count_adjustment;
-
-       string get_template_name ();
-
-  private:
-       Gtk::Notebook notebook;
-       Gtk::VBox     main_vbox;
-       Gtk::VBox     fsbox;
-
-       Gtk::Frame control_out_config_frame;
-       Gtk::Frame master_out_config_frame;
-       Gtk::Label output_label;
-       Gtk::Label input_label;
-       Gtk::Frame sr_frame;
-       Gtk::Frame template_frame;
-       Gtk::Frame manual_frame;
-       Gtk::HBox control_hbox;
-       Gtk::HBox master_hbox;
-       Gtk::Table io_table;
-       Gtk::VBox template_box;
-       Gtk::HBox output_hbox;
-       Gtk::HBox input_hbox;
-       Gtk::HBox option_hbox;
-       Gtk::VBox io_box;
-       Gtk::Label sr_label2;
-       Gtk::Label sr_label1;
-       Gtk::VBox  sr_box;
-       Gtk::Button expansion_button;
-       Gtk::Table out_table;
-       Gtk::CheckButton show_again;
-       Gtk::ComboBoxText template_combo;
-       list<string> templates;
-       Gtk::SpinButton in_count_spinner;
-       Gtk::SpinButton out_count_spinner;
-       Gtk::Label      in_count_label;
-       Gtk::Label      out_count_label;
-
-       void reset_templates ();
+};
+
+class NewSessionDialog : public Gtk::Dialog
+{
+public:
+               
+       NewSessionDialog(BaseObjectType* cobject,
+                        const Glib::RefPtr<Gnome::Glade::Xml>& xml);
+
+       void set_session_name(const Glib::ustring& name);
+
+       std::string session_name() const;
+       std::string session_folder() const;
        
-       static void _mix_template_refiller (Gtk::CList &clist, void *);
-       void mix_template_refiller (Gtk::CList &clist);
+       bool use_session_template() const;
+       std::string session_template_name() const;
+
+       // advanced.
+
+       bool create_master_track() const;
+               int master_channel_count() const;
+
+       bool create_control_track() const;
+       int control_channel_count() const;
+
+       bool connect_inputs() const;
+       bool limit_inputs_used_for_connection() const;
+       int input_limit_count() const;
 
-       void mix_template_shift (Gtkmm2ext::Selector *, Gtkmm2ext::Selector::Result*);
-       void mix_template_control (Gtkmm2ext::Selector *, Gtkmm2ext::Selector::Result*);
+       bool connect_outputs() const;
+       bool limit_outputs_used_for_connection() const;
+       int output_limit_count() const;
 
-       void fixup_at_realize ();
-       void fixup_at_show ();
-       void toggle_expansion ();
-       void file_selector_expansion (bool);
+       bool connect_outs_to_master() const;
+       bool connect_outs_to_physical() const ;
 
-       void show_again_toggled ();
+protected:
+
+       void reset_name();
+       void reset_template();
+       
+       // reset everything to default values.
+       void reset();
+
+       // references to widgets we care about.
+
+       Gtk::Entry*  m_name;
+       Gtk::FileChooserButton* m_folder;
+       Gtk::FileChooserButton* m_template;
+       
+       Gtk::CheckButton* m_create_master_track;
+       Gtk::SpinButton* m_master_track_channel_count;
+               
+       Gtk::CheckButton* m_create_control_track;
+       Gtk::SpinButton* m_control_track_channel_count;
+
+       Gtk::CheckButton* m_connect_inputs;
+       Gtk::CheckButton* m_limit_input_ports;
+       Gtk::SpinButton* m_input_limit_count;
+
+       Gtk::CheckButton* m_connect_outputs;    
+       Gtk::CheckButton* m_limit_output_ports;
+       Gtk::SpinButton* m_output_limit_count;
+
+       Gtk::RadioButton* m_connect_outputs_to_master;
+       Gtk::RadioButton* m_connect_outputs_to_physical;
+       
 };
 
-#endif // __gtk_ardour_new_session_dialog_h__ */
+#endif // NEW_SESSION_DIALOG_H
diff --git a/gtk2_ardour/po/SConscript b/gtk2_ardour/po/SConscript
new file mode 100644 (file)
index 0000000..55a4642
--- /dev/null
@@ -0,0 +1,47 @@
+# -*- python -*-
+import os
+import os.path
+import glob
+
+Import ('env gtkardour install_prefix intl_files')
+
+potfiles_in = open('POTFILES.in', 'w')
+
+intl_files.sort()
+
+print "Generating POTFILES.in in gtk_ardour/po"
+
+potfiles_in.write("""# This file was automatically generated by a configuration script.
+# Contains a list of source files containing translatable
+# strings sorted alphabetically.
+[encoding: UTF-8]
+""")
+
+for f in intl_files[:]:
+    potfiles_in.write(f + '\n')
+
+potfiles_in.close()
+
+print "Updating pot file: "
+
+domain = gtkardour['DOMAIN']
+potfile = gtkardour['POTFILE']
+
+poaction = Action('intltool-update -p -g=' + domain)
+
+Execute(poaction)
+
+# this should probably be merged with the i18n builder somehow
+
+p_oze = [ os.path.basename (po) for po in glob.glob ('*.po') ]
+languages = [ po.replace ('.po', '') for po in p_oze ]
+m_oze = [ po.replace (".po", ".mo") for po in p_oze ]
+    
+for mo in m_oze[:]:
+    po = mo.replace (".mo", ".po")
+    env.Alias ('install', gtkardour.MoBuild (mo, [ po, potfile ]))
+        
+for lang in languages[:]:
+    modir = (os.path.join (install_prefix, 'share/locale/' + lang + '/LC_MESSAGES/'))
+    moname = domain + '.mo'
+    env.Alias('install', env.InstallAs (os.path.join (modir, moname), lang + '.mo'))