Skip to content

Commit 31cad16

Browse files
danirabbitalainm23
andauthored
Form: set spacing on boxes, use header label features (#17)
* Form: set spacing on boxes, use header label features * remove another colon --------- Co-authored-by: Alain <[email protected]>
1 parent 4f5f79a commit 31cad16

File tree

3 files changed

+52
-80
lines changed

3 files changed

+52
-80
lines changed

src/Views/Developer.vala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,35 @@ public class Views.Developer : Adw.Bin {
2525
}
2626

2727
name_entry = new Granite.ValidatedEntry () {
28-
margin_top = 6,
2928
text = GLib.Environment.get_real_name ()
3029
};
3130

3231
var name_invalid = new Widgets.InvalidLabel () {
3332
text = _("This field is required")
3433
};
3534

35+
var name_box = new Gtk.Box (VERTICAL, 6);
36+
name_box.append (new Granite.HeaderLabel (_("Name")) {
37+
mnemonic_widget = name_entry
38+
});
39+
name_box.append (name_entry);
40+
name_box.append (name_invalid);
41+
3642
email_entry = new Granite.ValidatedEntry () {
3743
regex = email_regex,
38-
margin_top = 6
3944
};
4045

4146
var email_invalid = new Widgets.InvalidLabel () {
4247
text = _("The email is invalid")
4348
};
4449

50+
var email_box = new Gtk.Box (VERTICAL, 6);
51+
email_box.append (new Granite.HeaderLabel (_("Email")) {
52+
mnemonic_widget = email_entry
53+
});
54+
email_box.append (email_entry);
55+
email_box.append (email_invalid);
56+
4557
next_button = new Gtk.Button.with_label (_("Next")) {
4658
margin_bottom = 32,
4759
sensitive = false,
@@ -50,17 +62,13 @@ public class Views.Developer : Adw.Bin {
5062
};
5163
next_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);
5264

53-
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
65+
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24);
5466
form_box.append (new Gtk.Label (_("Developer")) {
5567
halign = START,
5668
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
5769
});
58-
form_box.append (new Granite.HeaderLabel (_("Name:")));
59-
form_box.append (name_entry);
60-
form_box.append (name_invalid);
61-
form_box.append (new Granite.HeaderLabel (_("Email:")));
62-
form_box.append (email_entry);
63-
form_box.append (email_invalid);
70+
form_box.append (name_box);
71+
form_box.append (email_box);
6472
form_box.append (next_button);
6573

6674
var content_box = new Adw.Bin () {

src/Views/Form.vala

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -32,75 +32,64 @@ public class Views.Form : Adw.Bin {
3232
critical (e.message);
3333
}
3434

35-
var project_name_header = new Granite.HeaderLabel (_("Project Name:")) {
36-
valign = CENTER
37-
};
38-
39-
var project_name_info = new Gtk.MenuButton () {
40-
can_focus = false,
41-
hexpand = true,
42-
halign = END,
43-
icon_name = "dialog-information-symbolic",
44-
popover = build_info_popover (_("A unique name that is used for the project folder and other resources. The name should be in lower case without spaces and should not start with a number"))
45-
};
46-
project_name_info.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);
47-
project_name_info.add_css_class (Granite.STYLE_CLASS_FLAT);
48-
49-
var project_name_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
50-
margin_top = 12
51-
};
52-
project_name_box.append (project_name_header);
53-
project_name_box.append (project_name_info);
54-
5535
project_name_entry = new Granite.ValidatedEntry () {
5636
regex = project_name_regex,
57-
margin_top = 6
5837
};
5938

60-
var project_name_invalid = new Widgets.InvalidLabel () {
61-
text = _("Project name must start with a lowercase letter and contain only letters and numbers")
39+
var project_name_header = new Granite.HeaderLabel (_("Project Name")) {
40+
mnemonic_widget = project_name_entry,
41+
secondary_text = _("A unique name that is used for the project folder and other resources. The name should be in lower case without spaces and should not start with a number")
6242
};
6343

64-
var identifier_header = new Granite.HeaderLabel (_("Organization Identifier:")) {
65-
valign = CENTER
44+
var project_name_invalid = new Widgets.InvalidLabel () {
45+
text = _("Project name must start with a lowercase letter and contain only letters and numbers")
6646
};
6747

68-
var identifier_info = new Gtk.MenuButton () {
69-
can_focus = false,
70-
hexpand = true,
71-
halign = END,
72-
icon_name = "dialog-information-symbolic",
73-
popover = build_info_popover (_("A reverse domain-name identifier used to identify the application, such as 'io.github.username'. It may not contain dashes"))
74-
};
75-
identifier_info.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);
76-
identifier_info.add_css_class (Granite.STYLE_CLASS_FLAT);
48+
var project_name_box = new Gtk.Box (VERTICAL, 6);
49+
project_name_box.append (project_name_header);
50+
project_name_box.append (project_name_entry);
51+
project_name_box.append (project_name_invalid);
7752

78-
var identifier_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
79-
margin_top = 12
53+
identifier_entry = new Granite.ValidatedEntry () {
54+
placeholder_text = "io.github.username",
55+
regex = identifier_regex
8056
};
81-
identifier_box.append (identifier_header);
82-
identifier_box.append (identifier_info);
8357

84-
identifier_entry = new Granite.ValidatedEntry () {
85-
regex = identifier_regex,
86-
margin_top = 6
58+
var identifier_header = new Granite.HeaderLabel (_("Organization Identifier")) {
59+
secondary_text = _("A reverse domain-name identifier used to identify the application. It may not contain dashes"),
60+
mnemonic_widget = identifier_entry,
8761
};
8862

8963
var identifier_invalid = new Widgets.InvalidLabel () {
9064
text = _("App ID must start with a lowercase letter, use dots to separate parts, contain only letters and numbers, and replace hyphens (-) with underscores (_)")
9165
};
9266

67+
var identifier_box = new Gtk.Box (VERTICAL, 6);
68+
identifier_box.append (identifier_header);
69+
identifier_box.append (identifier_entry);
70+
identifier_box.append (identifier_invalid);
71+
9372
application_id_entry = new Gtk.Entry () {
94-
margin_top = 6,
9573
editable = false
9674
};
9775

76+
var app_id_box = new Gtk.Box (VERTICAL, 6);
77+
app_id_box.append (new Granite.HeaderLabel (_("Application ID")) {
78+
mnemonic_widget = application_id_entry
79+
});
80+
app_id_box.append (application_id_entry);
81+
9882
location_entry = new Gtk.Entry () {
99-
margin_top = 6,
10083
secondary_icon_name = "folder-symbolic",
10184
text = GLib.Environment.get_user_special_dir (GLib.UserDirectory.TEMPLATES)
10285
};
10386

87+
var location_box = new Gtk.Box (VERTICAL, 6);
88+
location_box.append (new Granite.HeaderLabel (_("Location")) {
89+
mnemonic_widget = location_entry
90+
});
91+
location_box.append (location_entry);
92+
10493
var spinner = new Gtk.Spinner () {
10594
valign = Gtk.Align.CENTER,
10695
halign = Gtk.Align.CENTER,
@@ -135,21 +124,15 @@ public class Views.Form : Adw.Bin {
135124
buttons_box.append (back_button);
136125
buttons_box.append (create_button);
137126

138-
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
127+
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24);
139128
form_box.append (new Gtk.Label (_("Application")) {
140129
halign = START,
141130
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
142131
});
143132
form_box.append (project_name_box);
144-
form_box.append (project_name_entry);
145-
form_box.append (project_name_invalid);
146133
form_box.append (identifier_box);
147-
form_box.append (identifier_entry);
148-
form_box.append (identifier_invalid);
149-
form_box.append (new Granite.HeaderLabel (_("Application ID:")));
150-
form_box.append (application_id_entry);
151-
form_box.append (new Granite.HeaderLabel (_("Location:")));
152-
form_box.append (location_entry);
134+
form_box.append (app_id_box);
135+
form_box.append (location_box);
153136
form_box.append (buttons_box);
154137

155138
var content_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
@@ -336,24 +319,6 @@ public class Views.Form : Adw.Bin {
336319
}
337320
}
338321

339-
private Gtk.Popover build_info_popover (string text) {
340-
var label = new Gtk.Label (text) {
341-
wrap = true,
342-
margin_top = 6,
343-
margin_bottom = 6,
344-
margin_start = 6,
345-
margin_end = 6,
346-
max_width_chars = 24,
347-
justify = CENTER
348-
};
349-
350-
var popover = new Gtk.Popover () {
351-
child = label
352-
};
353-
354-
return popover;
355-
}
356-
357322
public void focus_name () {
358323
project_name_entry.grab_focus ();
359324
}

src/Widgets/InvalidLabel.vala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class Widgets.InvalidLabel : Gtk.Grid {
3030
construct {
3131
text_label = new Gtk.Label (null) {
3232
xalign = 0,
33-
margin_top = 6,
3433
wrap = true
3534
};
3635
text_label.add_css_class ("error");

0 commit comments

Comments
 (0)