update main window title appropriately
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 9 Jul 2015 17:56:12 +0000 (13:56 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 22 Feb 2016 20:31:22 +0000 (15:31 -0500)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui2.cc
gtk2_ardour/ardour_ui_dialogs.cc

index 9e17d52e5e7eb93459669cb2315de04d93cb8f78..997b790c1a5fe4a1e84e90ec6232c70df09a6063 100644 (file)
@@ -801,10 +801,15 @@ ARDOUR_UI::autosave_session ()
 }
 
 void
-ARDOUR_UI::update_autosave ()
+ARDOUR_UI::session_dirty_changed ()
 {
-       ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_autosave)
+       update_autosave ();
+       update_title ();
+}
 
+void
+ARDOUR_UI::update_autosave ()
+{
        if (_session && _session->dirty()) {
                if (_autosave_connection.connected()) {
                        _autosave_connection.disconnect();
index cbc75e83a9ff2775000dabbb9c0c1ef7a17bcde5..7b6c6f9e2146922eea8042bbe13ac8138ebe667c 100644 (file)
@@ -396,6 +396,9 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        void update_autosave();
        sigc::connection _autosave_connection;
 
+       void session_dirty_changed ();
+       void update_title ();
+       
        void map_transport_state ();
        int32_t do_engine_start ();
 
index bf965c7d34d8412c832e94d61c79953a8fcfd6ce..6205272c4bca77f8fea1f3725040928fb7434a01 100644 (file)
 #include "pbd/error.h"
 #include "pbd/basename.h"
 #include "pbd/fastlog.h"
-#include <gtkmm2ext/cairocell.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/click_box.h>
-#include <gtkmm2ext/tearoff.h>
+
+#include "gtkmm2ext/cairocell.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/click_box.h"
+#include "gtkmm2ext/tearoff.h"
+#include "gtkmm2ext/window_title.h"
 
 #include "ardour/profile.h"
 #include "ardour/session.h"
@@ -795,4 +797,29 @@ ARDOUR_UI::toggle_follow_edits ()
        UIConfiguration::instance().set_follow_edits (tact->get_active ());
 }
 
+void
+ARDOUR_UI::update_title ()
+{
+       if (_session) {
+               bool dirty = _session->dirty();
 
+               string session_name;
+
+               if (_session->snap_name() != _session->name()) {
+                       session_name = _session->snap_name();
+               } else {
+                       session_name = _session->name();
+               }
+
+               if (dirty) {
+                       session_name = "*" + session_name;
+               }
+
+               WindowTitle title (session_name);
+               title += Glib::get_application_name();
+               _main_window.set_title (title.get_string());
+       } else {
+               WindowTitle title (Glib::get_application_name());
+               _main_window.set_title (title.get_string());
+       }
+}
index 3bfe6d4a45f9e361dca350761ed8522518395508..2b24b8535ad2ad1b3135926ea281b0e7801fe2d7 100644 (file)
@@ -153,7 +153,7 @@ ARDOUR_UI::set_session (Session *s)
        _session->RecordStateChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::record_state_changed, this), gui_context());
        _session->StepEditStatusChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::step_edit_status_change, this, _1), gui_context());
        _session->TransportStateChange.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::map_transport_state, this), gui_context());
-       _session->DirtyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_autosave, this), gui_context());
+       _session->DirtyChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_dirty_changed, this), gui_context());
 
        _session->Xrun.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::xrun_handler, this, _1), gui_context());
        _session->SoloActive.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::soloing_changed, this, _1), gui_context());
@@ -237,6 +237,8 @@ ARDOUR_UI::set_session (Session *s)
                        editor_meter_peak_display.show();
                }
        }
+
+       update_title ();
 }
 
 int
@@ -315,7 +317,8 @@ ARDOUR_UI::unload_session (bool hide_stuff)
        session_loaded = false;
 
        update_buffer_load ();
-
+       update_title ();
+       
        return 0;
 }