-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathBranchCreatePage.vala
More file actions
71 lines (59 loc) · 1.88 KB
/
BranchCreatePage.vala
File metadata and controls
71 lines (59 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright 2025 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Authored by: Jeremy Wootten <jeremywootten@gmail.com>
*/
public class Scratch.Dialogs.BranchCreatePage : Gtk.Box, BranchActionPage {
public BranchAction action {
get {
return BranchAction.CREATE;
}
}
public Ggit.Ref? branch_ref {
get {
return null;
}
}
public string new_branch_name {
get {
return new_branch_name_entry.text;
}
}
public BranchActionDialog dialog { get; construct; }
private Granite.ValidatedEntry new_branch_name_entry;
public BranchCreatePage (BranchActionDialog dialog) {
Object (
dialog: dialog
);
}
construct {
orientation = VERTICAL;
vexpand = false;
hexpand = true;
margin_start = 24;
spacing = 12;
valign = CENTER;
var label = new Granite.HeaderLabel (_("Name of branch to create"));
new_branch_name_entry = new Granite.ValidatedEntry () {
activates_default = true,
placeholder_text = _("Enter new branch name")
};
add (label);
add (new_branch_name_entry);
new_branch_name_entry.bind_property ("is-valid", dialog, "can-apply");
new_branch_name_entry.changed.connect (() => {
unowned var new_name = new_branch_name_entry.text;
if (!dialog.project.is_valid_new_branch_name (new_name)) {
new_branch_name_entry.is_valid = false;
return;
}
if (dialog.project.has_local_branch_name (new_name)) {
new_branch_name_entry.is_valid = false;
return;
}
//Do we need to check remote branches as well?
new_branch_name_entry.is_valid = true;
});
}
}