Comment button hilighted when comments exist. Thanks Brian!
[ardour.git] / gtk2_ardour / mixer_strip.cc
index b089883c80a2d5a98f650af89ea1abaf0f589c32..c84bdad4e5d51f0f9f3174b8a07ca22d26086e37 100644 (file)
@@ -232,6 +232,8 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt
                                                        _route->comment());
 
        comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
+       comment_button.signal_enter().connect (mem_fun(*this, &MixerStrip::comment_button_refresh));
+       comment_button.signal_leave().connect (mem_fun(*this, &MixerStrip::comment_button_refresh));
        
        global_vpacker.set_border_width (0);
        global_vpacker.set_spacing (0);
@@ -759,6 +761,49 @@ MixerStrip::output_changed (IOChange change, void *src)
        Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
 }
 
+void
+MixerStrip::comment_button_refresh() {
+       if (! _route->comment().empty()) {
+               comment_button.set_state (Gtk::STATE_ACTIVE);
+       }
+}
+
+void 
+MixerStrip::comment_editor_done_editing() {
+       string str =  comment_area->get_buffer()->get_text();
+       if (_route->comment() != str) {
+               _route->set_comment (str, this);
+
+               switch (_width) {
+                  
+               case Wide:
+                       if (! str.empty()) {
+                               comment_button.set_label (_("*Comments*"));
+                       } else {
+                               comment_button.set_label (_("Comments"));
+                       }
+                       break;
+                  
+               case Narrow:
+                       if (! str.empty()) {
+                               comment_button.set_label (_("*Cmt*"));
+                       } else {
+                               comment_button.set_label (_("Cmt"));
+                       } 
+                       break;
+               }
+                
+               ARDOUR_UI::instance()->tooltips().set_tip (comment_button, 
+                               str.empty() ? _("Click to Add/Edit Comments") : str);
+       }
+
+       if (! _route->comment().empty()) {
+               comment_button.set_state (Gtk::STATE_ACTIVE);
+       } else {
+               comment_button.set_state (Gtk::STATE_NORMAL);
+       }
+}
+
 void
 MixerStrip::comment_button_clicked ()
 {
@@ -766,38 +811,13 @@ MixerStrip::comment_button_clicked ()
                setup_comment_editor ();
        }
 
-        int x, y, cw_width, cw_height;
+    int x, y, cw_width, cw_height;
 
        if (comment_window->is_visible()) {
-              string str =  comment_area->get_buffer()->get_text();
-              if (_route->comment() != str) {
-                _route->set_comment (str, this);
+               comment_window->hide ();
+               return;
+       }
 
-                switch (_width) {
-                  
-                case Wide:
-                  if (! str.empty()) {
-                    comment_button.set_label (_("*Comments*"));
-                  } else {
-                    comment_button.set_label (_("Comments"));
-                     }
-                  break;
-                  
-                case Narrow:
-                  if (! str.empty()) {
-                    comment_button.set_label (_("*Cmt*"));
-                  } else {
-                    comment_button.set_label (_("Cmt"));
-                  } 
-                  break;
-                }
-                
-                ARDOUR_UI::instance()->tooltips().set_tip (comment_button, 
-                                                           str.empty() ? _("Click to Add/Edit Comments") : str);
-              }
-              comment_window->hide ();
-              return;
-       } 
        comment_window->get_size (cw_width, cw_height);
        comment_window->get_position(x, y);
        comment_window->move(x, y - (cw_height / 2) - 45);
@@ -808,7 +828,6 @@ MixerStrip::comment_button_clicked ()
 
        comment_window->show();
        comment_window->present();
-
 }
 
 void
@@ -821,6 +840,7 @@ MixerStrip::setup_comment_editor ()
        comment_window = new ArdourDialog (title, false);
        comment_window->set_position (Gtk::WIN_POS_MOUSE);
        comment_window->set_skip_taskbar_hint (true);
+       comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
 
        comment_area = manage (new TextView());
        comment_area->set_name ("MixerTrackCommentArea");