Added comment explaining new Gtk::Dialog idiom.
[ardour.git] / gtk2_ardour / ardour_ui.h
index 34f3422e50e502ebf35fc44bbe3a1d109cff7213..d9ba85bb70e7b36d98a44ef01f4f694a21689504 100644 (file)
 
 #include <cmath>
 
-#include <gtk-canvas.h>
+#include <libgnomecanvasmm/canvas.h>
 
 #include <pbd/xml++.h>
-#include <gtkmmext/gtk_ui.h>
-#include <gtkmmext/pix.h>
-#include <gtkmmext/spinner.h>
-#include <gtkmmext/pixmap_button.h>
-#include <gtkmmext/popup_selector.h>
-#include <gtkmmext/click_box.h>
-#include <gtkmmext/selector.h>
+#include <gtkmm/box.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
+#include <gtkmm/fixed.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/eventbox.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/menuitem.h>
+#include <gtkmm/button.h>
+#include <gtkmm/togglebutton.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/menubar.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm2ext/gtk_ui.h>
+#include <gtkmm2ext/pix.h>
+#include <gtkmm2ext/click_box.h>
 #include <ardour/ardour.h>
 #include <ardour/session.h>
 
 #include "audio_clock.h"
 #include "ardour_dialog.h"
 #include "editing.h"
+#include "glade_factory.h"
 
 class AudioClock;
 class PublicEditor;
@@ -60,13 +71,13 @@ class OptionEditor;
 class Mixer_UI;
 class ConnectionEditor;
 class RouteParams_UI;
-class SoundFileSelector;
+class SoundFileChooser;
 class About;
 class AddRouteDialog;
 class NewSessionDialog;
 class LocationUI;
 
-namespace Gtkmmext {
+namespace Gtkmm2ext {
        class TearOff;
 };
 
@@ -83,7 +94,7 @@ namespace ALSA {
 
 #define FRAME_NAME "BaseFrame"
 
-class ARDOUR_UI : public Gtkmmext::UI
+class ARDOUR_UI : public Gtkmm2ext::UI
 {
   public:
        ARDOUR_UI (int *argcp, char **argvp[], string rcfile);
@@ -117,7 +128,7 @@ class ARDOUR_UI : public Gtkmmext::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(); }
@@ -134,28 +145,20 @@ class ARDOUR_UI : public Gtkmmext::UI
        PublicEditor&     the_editor(){return *editor;}
        Mixer_UI* the_mixer() { return mixer; }
        
-       void allow_focus (bool yn);
-
-       static gint generic_focus_in_event (GdkEventFocus *);
-       static gint generic_focus_out_event (GdkEventFocus *);
-
        void toggle_location_window ();
        void toggle_big_clock_window ();
        void toggle_connection_editor ();
        void toggle_route_params_window ();
        void toggle_tempo_window ();
-       void toggle_sfdb_window ();
-
-       SoundFileSelector& get_sfdb_window();
 
        gint32 select_diskstream (GdkEventButton *ev);
 
        Gtk::Tooltips& tooltips() { return _tooltips; }
 
-       static SigC::Signal1<void,bool> Blink;
-       static SigC::Signal0<void>      RapidScreenUpdate;
-       static SigC::Signal0<void>      SuperRapidScreenUpdate;
-       static SigC::Signal1<void,jack_nframes_t> Clock;
+       static sigc::signal<void,bool> Blink;
+       static sigc::signal<void>      RapidScreenUpdate;
+       static sigc::signal<void>      SuperRapidScreenUpdate;
+       static sigc::signal<void,jack_nframes_t> Clock;
 
        /* this is a helper function to centralize the (complex) logic for
           blinking rec-enable buttons.
@@ -202,7 +205,6 @@ class ARDOUR_UI : public Gtkmmext::UI
   protected:
        friend class PublicEditor;
 
-       void toggle_metering ();
        void toggle_clocking ();
        void toggle_auto_play ();
        void toggle_auto_input ();
@@ -219,7 +221,7 @@ class ARDOUR_UI : public Gtkmmext::UI
 
   private:
        struct GlobalClickBox : public Gtk::VBox {
-           Gtkmmext::ClickBox  *box;
+           Gtkmm2ext::ClickBox  *box;
            Gtk::Frame      frame;
            Gtk::Label      label;
            vector<string> &strings;
@@ -230,11 +232,11 @@ class ARDOUR_UI : public Gtkmmext::UI
            GlobalClickBox (const string &str, vector<string> &vs)
                    : strings (vs),
                      adjustment (0, 0, vs.size() - 1, 1, 1, 0) {
-                   box = new Gtkmmext::ClickBox (&adjustment, "ClickButton");
+                   box = new Gtkmm2ext::ClickBox (&adjustment, "ClickButton");
                    label.set_text (str);
                    label.set_name ("GlobalButtonLabel");
                    frame.add (*box);
-                   frame.set_shadow_type (GTK_SHADOW_IN);
+                   frame.set_shadow_type (Gtk::SHADOW_IN);
                    pack_start (label);
                    pack_start (frame);
                    box->set_print_func (printer, this);
@@ -269,8 +271,6 @@ class ARDOUR_UI : public Gtkmmext::UI
        Gtk::Table          transport_table;
        Gtk::Table          option_table;
 
-       static SoundFileSelector* sfdb_window;
-
        int  setup_windows ();
        void setup_session_menu ();
        void setup_transport ();
@@ -323,30 +323,23 @@ class ARDOUR_UI : public Gtkmmext::UI
   private:
        Gtk::VBox     top_packer;
 
-       SigC::Connection clock_signal_connection;
+       sigc::connection clock_signal_connection;
        void         update_clocks ();
        void         start_clocking ();
        void         stop_clocking ();
 
-       class BigClockWindow : public ArdourDialog
-       {
-         public:
-               BigClockWindow () : ArdourDialog ("big clock window") {};
-       };
-
-       AudioClock               big_clock;
-       Gtk::Frame               big_clock_frame;
-       BigClockWindow*          big_clock_window;
-
-       void big_clock_size_event (GtkAllocation *alloc);
-       void big_clock_realize ();
+       void manage_window (Gtk::Window&);
+       
+       AudioClock   big_clock;
+       Gtk::Frame   big_clock_frame;
+       Gtk::Window* big_clock_window;
 
        /* Transport Control */
 
        void detach_tearoff (Gtk::Box* parent, Gtk::Widget* contents);
        void reattach_tearoff (Gtk::Box* parent, Gtk::Widget* contents, int32_t order);
 
-       Gtkmmext::TearOff*       transport_tearoff;
+       Gtkmm2ext::TearOff*       transport_tearoff;
        Gtk::Frame               transport_frame;
        Gtk::HBox                transport_tearoff_hbox;
        Gtk::HBox                transport_hbox;
@@ -383,8 +376,8 @@ class ARDOUR_UI : public Gtkmmext::UI
        Gtk::Label       speed_display_label;
        Gtk::Button      shuttle_units_button;
        Gtk::Button      shuttle_style_button;
-       Gtk::Menu        shuttle_unit_menu;
-       Gtk::Menu        shuttle_style_menu;
+       Gtk::Menu*       shuttle_unit_menu;
+       Gtk::Menu*       shuttle_style_menu;
        ShuttleBehaviour shuttle_behaviour;
        ShuttleUnits     shuttle_units;
 
@@ -450,57 +443,43 @@ class ARDOUR_UI : public Gtkmmext::UI
 
        static void rate_printer (char buf[32], Gtk::Adjustment &, void *);
 
-       Gtk::Menu*   session_popup_menu;
-       Gtk::CTree   session_selector;
-       ArdourDialog* session_selector_window;
-       
-       Gtk::FileSelection* open_session_selector;
+       Gtk::Menu*        session_popup_menu;
+
+       struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
+           RecentSessionModelColumns() { 
+                   add (visible_name);
+                   add (fullpath);
+           }
+           Gtk::TreeModelColumn<Glib::ustring> visible_name;
+           Gtk::TreeModelColumn<Glib::ustring> fullpath;
+       };
+
+       RecentSessionModelColumns    recent_session_columns;
+       Gtk::TreeView                recent_session_display;
+       Glib::RefPtr<Gtk::TreeStore> recent_session_model;
+
+       ArdourDialog*     session_selector_window;
+       Gtk::FileChooserDialog* open_session_selector;
        
        void build_session_selector();
-       void session_selection (Gtk::CTree::Row, gint col);
+       void recent_session_selection_changed ();
+       void redisplay_recent_sessions();
+
        struct RecentSessionsSorter {
-         bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
-           return cmp_nocase(a.first, b.first) == -1;
+           bool operator() (std::pair<string,string> a, std::pair<string,string> b) const {
+                   return cmp_nocase(a.first, b.first) == -1;
            }
        };
-       void redisplay_recent_sessions();
 
        /* menu bar and associated stuff */
 
-       Gtk::MenuBar menu_bar;
-       Gtk::Fixed   menu_bar_base;
-       Gtk::HBox    menu_hbox;
+       Gtk::MenuBar* menu_bar;
+       Gtk::Fixed    menu_bar_base;
+       Gtk::HBox     menu_hbox;
 
        void build_menu_bar ();
        void pack_toplevel_controls();
 
-       /* handles on the menu bar items that need to 
-          be sensitive to whether or not we have
-          a session loaded.
-       */
-
-       Gtk::MenuItem *add_track_item;
-       Gtk::MenuItem *save_item;
-       Gtk::MenuItem *snapshot_item;
-       Gtk::MenuItem *save_as_item;
-       Gtk::MenuItem *save_template_item;
-       Gtk::MenuItem *export_item;
-       Gtk::MenuItem *close_item;
-
-       Gtk::CheckMenuItem *meter_bridge_dialog_check;
-       Gtk::CheckMenuItem *connection_editor_check;
-       Gtk::CheckMenuItem *route_params_check;
-       Gtk::CheckMenuItem *locations_dialog_check;
-       Gtk::CheckMenuItem *big_clock_check;
-       Gtk::CheckMenuItem *tempo_editor_check;
-       Gtk::CheckMenuItem *sfdb_check;
-       Gtk::CheckMenuItem *options_window_check;
-       
-       /* <CMT Additions> */
-       Gtk::MenuItem *image_compositor_item ;
-       /* </CMT Additions> */
-
-
        Gtk::Label   wall_clock_label;
        Gtk::EventBox wall_clock_box;
        gint update_wall_clock ();
@@ -529,9 +508,9 @@ class ARDOUR_UI : public Gtkmmext::UI
        gint every_point_one_seconds ();
        gint every_point_zero_one_seconds ();
 
-       SigC::Connection second_connection;
-       SigC::Connection point_one_second_connection;
-       SigC::Connection point_zero_one_second_connection;
+       sigc::connection second_connection;
+       sigc::connection point_one_second_connection;
+       sigc::connection point_zero_one_second_connection;
 
        void diskstream_added (ARDOUR::DiskStream*);
 
@@ -539,16 +518,9 @@ class ARDOUR_UI : public Gtkmmext::UI
 
        bool _will_create_new_session_automatically;
 
-       NewSessionDialog* new_session_window;
-       string template_name;
-
-       void new_session_ok_clicked ();
-       void new_session_template_choice (Gtkmmext::Selector *, Gtkmmext::SelectionResult*);
-       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 ();
@@ -632,9 +604,6 @@ class ARDOUR_UI : public Gtkmmext::UI
        PublicEditor     *editor;
        int         create_editor ();
 
-       MeterBridge  *meter_bridge;
-       int          create_meter_bridge ();
-
        RouteParams_UI *route_params;
        int             create_route_params ();
 
@@ -644,12 +613,10 @@ class ARDOUR_UI : public Gtkmmext::UI
        LocationUI *location_ui;
        int         create_location_ui ();
 
-       void meter_bridge_hiding ();
        void location_ui_hiding ();
        void big_clock_hiding ();
        void route_params_hiding ();
        void connection_editor_hiding ();
-       void sfdb_hiding ();
        void option_hiding ();
 
        /* Various options */
@@ -664,6 +631,9 @@ class ARDOUR_UI : public Gtkmmext::UI
 
        AddRouteDialog *add_route_dialog;
        void add_route_dialog_done (int status);
+
+       /* SoundFile Browser */
+       void toggle_sound_file_browser ();
        
        /* Keyboard Handling */
        
@@ -672,6 +642,8 @@ class ARDOUR_UI : public Gtkmmext::UI
        /* Keymap handling */
 
        void install_keybindings ();
+       Glib::RefPtr<Gtk::ActionGroup> get_common_actions();
+       void install_actions ();
        void test_binding_action (const char *);
        void start_keyboard_prefix();
 
@@ -723,6 +695,9 @@ class ARDOUR_UI : public Gtkmmext::UI
        Gtk::Menu*     jack_bufsize_menu;
 
        int make_session_clean ();
+       bool filter_ardour_session_dirs (const Gtk::FileFilter::Info&);
+
+       Glib::RefPtr<Gtk::ActionGroup> common_actions;
 };
 
 #endif /* __ardour_gui_h__ */