@@ -118,23 +118,24 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
118118 project_chosen ();
119119 });
120120
121- realize.connect (() => {
122- set_active_path (git_manager. active_project_path);
123- git_manager. notify[" active-project-path" ]. connect (() = > {
124- // Sync menubutton states
125- set_active_path (git_manager. active_project_path);
126- });
121+ toggled.connect (() => {
122+ if (active) {
123+ unowned var active_path = Scratch . Services . GitManager . get_instance (). active_project_path;
124+ foreach (var child in project_listbox. get_children ()) {
125+ var project_row = ((ProjectRow ) child);
126+ // All paths must not end in directory separator so can be compared directly
127+ project_row. active = active_path == project_row. project_path;
128+ }
129+ }
127130 });
131+
132+ git_manager.notify["active-project-path"].connect (update_button );
133+ update_button ();
128134 }
129135
130136 // Set appearance (only) of project chooser button and list according to active path
131- private void set_active_path (string active_path) {
132- foreach (var child in project_listbox. get_children ()) {
133- var project_row = ((ProjectRow ) child);
134- // All paths must not end in directory separator so can be compared directly
135- project_row. active = active_path == project_row. project_path;
136- }
137-
137+ private void update_button () {
138+ unowned var active_path = Scratch . Services . GitManager . get_instance (). active_project_path;
138139 if (active_path != " " ) {
139140 label_widget. label = Path . get_basename (active_path);
140141 tooltip_text = _(PROJECT_TOOLTIP ). printf (Scratch . Utils . replace_home_with_tilde (active_path));
0 commit comments