@@ -16,6 +16,12 @@ public class Views.Form : Adw.Bin {
1616 public string developer_name { get ; set ; }
1717 public string developer_email { get ; set ; }
1818
19+ public bool is_valid {
20+ get {
21+ return project_name_entry. is_valid && identifier_entry. is_valid && location_entry. text. length > 0 ;
22+ }
23+ }
24+
1925 construct {
2026 Regex ? project_name_regex = null ;
2127 Regex ? identifier_regex = null ;
@@ -26,31 +32,63 @@ public class Views.Form : Adw.Bin {
2632 critical (e. message);
2733 }
2834
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+
2955 project_name_entry = new Granite .ValidatedEntry () {
3056 regex = project_name_regex,
3157 margin_top = 6
3258 };
3359
34- var project_name_description = new Gtk .Label (_(" 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." )) {
35- wrap = true ,
36- xalign = 0 ,
37- margin_top = 3
60+ var project_name_invalid = new Widgets .InvalidLabel () {
61+ text = _ ("Project name must start with a lowercase letter and contain only letters and numbers ")
3862 };
39- project_name_description. add_css_class (Granite . STYLE_CLASS_DIM_LABEL );
40- project_name_description. add_css_class (Granite . STYLE_CLASS_SMALL_LABEL );
63+
64+ var identifier_header = new Granite .HeaderLabel (_(" Organization Identifier:" )) {
65+ valign = CENTER
66+ };
67+
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 );
77+
78+ var identifier_box = new Gtk .Box (Gtk . Orientation . HORIZONTAL , 0 ) {
79+ margin_top = 12
80+ };
81+ identifier_box.append (identifier_header );
82+ identifier_box.append (identifier_info );
4183
4284 identifier_entry = new Granite .ValidatedEntry () {
4385 regex = identifier_regex,
4486 margin_top = 6
4587 };
4688
47- var identifier_description = new Gtk .Label (_(" A reverse domain-name identifier used to identify the application, such as 'io.github.username'. It may not contain dashes." )) {
48- wrap = true ,
49- xalign = 0 ,
50- margin_top = 3
89+ var identifier_invalid = new Widgets .InvalidLabel () {
90+ text = _ ("App ID must start with a lowercase letter , use dots to separate parts , contain only letters and numbers , and replace hyphens (-) with underscores (_ )")
5191 };
52- identifier_description. add_css_class (Granite . STYLE_CLASS_DIM_LABEL );
53- identifier_description. add_css_class (Granite . STYLE_CLASS_SMALL_LABEL );
5492
5593 application_id_entry = new Gtk .Entry () {
5694 margin_top = 6 ,
@@ -92,6 +130,7 @@ public class Views.Form : Adw.Bin {
92130 vexpand = true ,
93131 valign = END ,
94132 margin_bottom = 32 ,
133+ margin_top = 12
95134 };
96135 buttons_box.append (back_button );
97136 buttons_box.append (create_button );
@@ -101,12 +140,12 @@ public class Views.Form : Adw.Bin {
101140 halign = START ,
102141 css_classes = { Granite . STYLE_CLASS_H1_LABEL }
103142 });
104- form_box.append (new Granite . HeaderLabel ( _ (" Project Name :")) );
143+ form_box.append (project_name_box );
105144 form_box.append (project_name_entry );
106- // form_box.append (project_name_description );
107- form_box.append (new Granite . HeaderLabel ( _ (" Organization Identifier :")) );
145+ form_box.append (project_name_invalid );
146+ form_box.append (identifier_box );
108147 form_box.append (identifier_entry );
109- // form_box.append (identifier_description );
148+ form_box.append (identifier_invalid );
110149 form_box.append (new Granite .HeaderLabel (_ ("Application ID :")));
111150 form_box.append (application_id_entry );
112151 form_box.append (new Granite .HeaderLabel (_ ("Location :")));
@@ -133,16 +172,18 @@ public class Views.Form : Adw.Bin {
133172
134173 project_name_entry.changed.connect (() => {
135174 application_id_entry. text = identifier_entry. text + " ." + project_name_entry. text;
136- create_button. sensitive = project_name_entry. is_valid && identifier_entry. is_valid && location_entry. text. length > 0 ;
175+ create_button. sensitive = is_valid;
176+ project_name_invalid. reveal_child = ! project_name_entry. is_valid;
137177 });
138178
139179 identifier_entry.changed.connect (() => {
140180 application_id_entry. text = identifier_entry. text + " ." + project_name_entry. text;
141- create_button. sensitive = project_name_entry. is_valid && identifier_entry. is_valid && location_entry. text. length > 0 ;
181+ create_button. sensitive = is_valid;
182+ identifier_invalid. reveal_child = ! identifier_entry. is_valid;
142183 });
143184
144185 location_entry.changed.connect (() => {
145- create_button. sensitive = project_name_entry . is_valid && identifier_entry . is_valid && location_entry . text . length > 0 ;
186+ create_button. sensitive = is_valid;
146187 });
147188
148189 location_entry.icon_release.connect ((icon_pos ) => {
@@ -285,7 +326,7 @@ public class Views.Form : Adw.Bin {
285326 }
286327 }
287328
288- void rename_file (string old_name, string new_name) {
329+ private void rename_file (string old_name , string new_name ) {
289330 try {
290331 GLib . File old_file = GLib . File . new_for_path (old_name);
291332 GLib . File new_file = GLib . File . new_for_path (new_name);
@@ -294,4 +335,26 @@ public class Views.Form : Adw.Bin {
294335 debug (e. message);
295336 }
296337 }
338+
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+
357+ public void focus_name () {
358+ project_name_entry. grab_focus ();
359+ }
297360}
0 commit comments