Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form: set spacing on boxes, use header label features #17

Merged
merged 3 commits into from
Oct 17, 2024
Merged
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
26 changes: 17 additions & 9 deletions src/Views/Developer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,35 @@ public class Views.Developer : Adw.Bin {
}

name_entry = new Granite.ValidatedEntry () {
margin_top = 6,
text = GLib.Environment.get_real_name ()
};

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

var name_box = new Gtk.Box (VERTICAL, 6);
name_box.append (new Granite.HeaderLabel (_("Name")) {
mnemonic_widget = name_entry
});
name_box.append (name_entry);
name_box.append (name_invalid);

email_entry = new Granite.ValidatedEntry () {
regex = email_regex,
margin_top = 6
};

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

var email_box = new Gtk.Box (VERTICAL, 6);
email_box.append (new Granite.HeaderLabel (_("Email")) {
mnemonic_widget = email_entry
});
email_box.append (email_entry);
email_box.append (email_invalid);

next_button = new Gtk.Button.with_label (_("Next")) {
margin_bottom = 32,
sensitive = false,
Expand All @@ -50,17 +62,13 @@ public class Views.Developer : Adw.Bin {
};
next_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION);

var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24);
form_box.append (new Gtk.Label (_("Developer")) {
halign = START,
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
});
form_box.append (new Granite.HeaderLabel (_("Name:")));
form_box.append (name_entry);
form_box.append (name_invalid);
form_box.append (new Granite.HeaderLabel (_("Email:")));
form_box.append (email_entry);
form_box.append (email_invalid);
form_box.append (name_box);
form_box.append (email_box);
form_box.append (next_button);

var content_box = new Adw.Bin () {
Expand Down
105 changes: 35 additions & 70 deletions src/Views/Form.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,75 +32,64 @@ public class Views.Form : Adw.Bin {
critical (e.message);
}

var project_name_header = new Granite.HeaderLabel (_("Project Name:")) {
valign = CENTER
};

var project_name_info = new Gtk.MenuButton () {
can_focus = false,
hexpand = true,
halign = END,
icon_name = "dialog-information-symbolic",
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"))
};
project_name_info.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);
project_name_info.add_css_class (Granite.STYLE_CLASS_FLAT);

var project_name_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
margin_top = 12
};
project_name_box.append (project_name_header);
project_name_box.append (project_name_info);

project_name_entry = new Granite.ValidatedEntry () {
regex = project_name_regex,
margin_top = 6
};

var project_name_invalid = new Widgets.InvalidLabel () {
text = _("Project name must start with a lowercase letter and contain only letters and numbers")
var project_name_header = new Granite.HeaderLabel (_("Project Name")) {
mnemonic_widget = project_name_entry,
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")
};

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

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

var identifier_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
margin_top = 12
identifier_entry = new Granite.ValidatedEntry () {
placeholder_text = "io.github.username",
regex = identifier_regex
};
identifier_box.append (identifier_header);
identifier_box.append (identifier_info);

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

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

var identifier_box = new Gtk.Box (VERTICAL, 6);
identifier_box.append (identifier_header);
identifier_box.append (identifier_entry);
identifier_box.append (identifier_invalid);

application_id_entry = new Gtk.Entry () {
margin_top = 6,
editable = false
};

var app_id_box = new Gtk.Box (VERTICAL, 6);
app_id_box.append (new Granite.HeaderLabel (_("Application ID")) {
mnemonic_widget = application_id_entry
});
app_id_box.append (application_id_entry);

location_entry = new Gtk.Entry () {
margin_top = 6,
secondary_icon_name = "folder-symbolic",
text = GLib.Environment.get_user_special_dir (GLib.UserDirectory.TEMPLATES)
};

var location_box = new Gtk.Box (VERTICAL, 6);
location_box.append (new Granite.HeaderLabel (_("Location")) {
mnemonic_widget = location_entry
});
location_box.append (location_entry);

var spinner = new Gtk.Spinner () {
valign = Gtk.Align.CENTER,
halign = Gtk.Align.CENTER,
Expand Down Expand Up @@ -135,21 +124,15 @@ public class Views.Form : Adw.Bin {
buttons_box.append (back_button);
buttons_box.append (create_button);

var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
var form_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 24);
form_box.append (new Gtk.Label (_("Application")) {
halign = START,
css_classes = { Granite.STYLE_CLASS_H1_LABEL }
});
form_box.append (project_name_box);
form_box.append (project_name_entry);
form_box.append (project_name_invalid);
form_box.append (identifier_box);
form_box.append (identifier_entry);
form_box.append (identifier_invalid);
form_box.append (new Granite.HeaderLabel (_("Application ID:")));
form_box.append (application_id_entry);
form_box.append (new Granite.HeaderLabel (_("Location:")));
form_box.append (location_entry);
form_box.append (app_id_box);
form_box.append (location_box);
form_box.append (buttons_box);

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

private Gtk.Popover build_info_popover (string text) {
var label = new Gtk.Label (text) {
wrap = true,
margin_top = 6,
margin_bottom = 6,
margin_start = 6,
margin_end = 6,
max_width_chars = 24,
justify = CENTER
};

var popover = new Gtk.Popover () {
child = label
};

return popover;
}

public void focus_name () {
project_name_entry.grab_focus ();
}
Expand Down
1 change: 0 additions & 1 deletion src/Widgets/InvalidLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class Widgets.InvalidLabel : Gtk.Grid {
construct {
text_label = new Gtk.Label (null) {
xalign = 0,
margin_top = 6,
wrap = true
};
text_label.add_css_class ("error");
Expand Down