Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 15 additions & 25 deletions src/Widgets/ChooseProjectButton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
private Gtk.Label label_widget;
private Gtk.ListBox project_listbox;

public ActionGroup toplevel_action_group { get; construct; }
public signal void project_chosen ();

construct {
realize.connect (() => {
toplevel_action_group = get_action_group (Scratch.MainWindow.ACTION_GROUP);
assert_nonnull (toplevel_action_group);
});

var img = new Gtk.Image () {
gicon = new ThemedIcon ("git-symbolic"),
Expand Down Expand Up @@ -144,23 +139,6 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
}
});

project_listbox.remove.connect ((row) => {
var project_row = row as ProjectRow;
var current_project = Scratch.Services.GitManager.get_instance ().active_project_path;
if (project_row.project_path == current_project) {
Scratch.Services.GitManager.get_instance ().active_project_path = "";
// Label and active_path will be updated automatically
}
});

project_listbox.row_activated.connect ((row) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rows can be activated in other ways than just button presses, such as with the keyboard. So we really need to keep this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? The rows are bound to an action now so it doesn't matter how they are activated, the action will fire.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think itts possible for the checkboxes to get focus and change without activating the row but I'll check.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it is possible (though not obvious how) so I'll make the checkbuttons non-focusable.

var project_entry = ((ProjectRow) row);
toplevel_action_group.activate_action (
Scratch.MainWindow.ACTION_SET_ACTIVE_PROJECT,
new Variant.string (project_entry.project_path)
);
});

toggled.connect (() => {
if (active) {
unowned var active_path = Scratch.Services.GitManager.get_instance ().active_project_path;
Expand Down Expand Up @@ -221,16 +199,28 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
);
}

private Gtk.GestureMultiPress button_controller;

class construct {
set_css_name (Gtk.STYLE_CLASS_MENUITEM);
}

construct {
check_button = new Gtk.CheckButton.with_label (Path.get_basename (project_path));
can_focus = true;
action_name = Scratch.MainWindow.ACTION_PREFIX + Scratch.MainWindow.ACTION_SET_ACTIVE_PROJECT;
action_target = new Variant.string (project_path);

check_button = new Gtk.CheckButton.with_label (Path.get_basename (project_path)) {
can_focus = false
};
add (check_button);
check_button.button_release_event.connect (() => {

button_controller = new Gtk.GestureMultiPress (check_button) {
propagation_phase = CAPTURE,
button = 0
};
button_controller.released.connect (() => {
activate ();
return Gdk.EVENT_PROPAGATE;
});

show_all ();
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/Sidebar.vala
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*-
* Copyright 2017-2026 elementary, Inc. (https://elementary.io)
*
* 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 3 of the License, or
* This program is free software: you can redistribute it and/or * it under the terms of the GNU General Public License as published by

modify * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
Expand Down