Skip to content
Open
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
35 changes: 11 additions & 24 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 @@ -143,23 +138,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) => {
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 @@ -220,16 +198,25 @@ public class Code.ChooseProjectButton : Gtk.MenuButton {
);
}

private Gtk.GestureMultiPress button_controller;

class construct {
set_css_name (Gtk.STYLE_CLASS_MENUITEM);
}

construct {
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));
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