@@ -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 = END
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 = END
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 ,
@@ -101,12 +139,12 @@ public class Views.Form : Adw.Bin {
101139 halign = START ,
102140 css_classes = { Granite . STYLE_CLASS_H1_LABEL }
103141 });
104- form_box.append (new Granite . HeaderLabel ( _ (" Project Name :")) );
142+ form_box.append (project_name_box );
105143 form_box.append (project_name_entry );
106- // form_box.append (project_name_description );
107- form_box.append (new Granite . HeaderLabel ( _ (" Organization Identifier :")) );
144+ form_box.append (project_name_invalid );
145+ form_box.append (identifier_box );
108146 form_box.append (identifier_entry );
109- // form_box.append (identifier_description );
147+ form_box.append (identifier_invalid );
110148 form_box.append (new Granite .HeaderLabel (_ ("Application ID :")));
111149 form_box.append (application_id_entry );
112150 form_box.append (new Granite .HeaderLabel (_ ("Location :")));
@@ -133,16 +171,18 @@ public class Views.Form : Adw.Bin {
133171
134172 project_name_entry.changed.connect (() => {
135173 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 ;
174+ create_button. sensitive = is_valid;
175+ project_name_invalid. reveal_child = ! project_name_entry. is_valid;
137176 });
138177
139178 identifier_entry.changed.connect (() => {
140179 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 ;
180+ create_button. sensitive = is_valid;
181+ identifier_invalid. reveal_child = ! identifier_entry. is_valid;
142182 });
143183
144184 location_entry.changed.connect (() => {
145- create_button. sensitive = project_name_entry . is_valid && identifier_entry . is_valid && location_entry . text . length > 0 ;
185+ create_button. sensitive = is_valid;
146186 });
147187
148188 location_entry.icon_release.connect ((icon_pos ) => {
@@ -281,7 +321,7 @@ public class Views.Form : Adw.Bin {
281321 }
282322 }
283323
284- void rename_file (string old_name, string new_name) {
324+ private void rename_file (string old_name , string new_name ) {
285325 try {
286326 GLib . File old_file = GLib . File . new_for_path (old_name);
287327 GLib . File new_file = GLib . File . new_for_path (new_name);
@@ -290,4 +330,26 @@ public class Views.Form : Adw.Bin {
290330 debug (e. message);
291331 }
292332 }
333+
334+ private Gtk .Popover build_info_popover (string text ) {
335+ var label = new Gtk .Label (text) {
336+ wrap = true ,
337+ margin_top = 6 ,
338+ margin_bottom = 6 ,
339+ margin_start = 6 ,
340+ margin_end = 6 ,
341+ max_width_chars = 24 ,
342+ justify = CENTER
343+ };
344+
345+ var popover = new Gtk .Popover () {
346+ child = label
347+ };
348+
349+ return popover;
350+ }
351+
352+ public void focus_name () {
353+ project_name_entry. grab_focus ();
354+ }
293355}
0 commit comments