66 */
77
88public class Scratch.Dialogs.CloneRepositoryDialog : Granite .MessageDialog {
9- public bool can_clone { get ; private set ; default = false ; }
10-
11-
129 // Git project name rules according to GitLab
1310 // - Must start and end with a letter ( a-zA-Z ) or digit ( 0-9 ).
1411 // - Can contain only letters ( a-zA-Z ), digits ( 0-9 ), underscores ( _ ), dots ( . ), or dashes ( - ).
1512 // - Must not contain consecutive special characters.
1613 // - Cannot end in . git or . atom .
17-
1814 private const string NAME_REGEX = " " " ^[0-9a-zA-Z].([-_.]?[0-9a-zA-Z])*$" " " ; // TODO additional validation required
15+
1916 private Regex name_regex;
2017 private Gtk . Label projects_folder_label;
2118 private Granite . ValidatedEntry remote_repository_uri_entry;
@@ -25,6 +22,7 @@ public class Scratch.Dialogs.CloneRepositoryDialog : Granite.MessageDialog {
2522 private Gtk . Spinner spinner;
2623 private Gtk . Revealer revealer;
2724
25+ public bool can_clone { get ; private set ; default = false ; }
2826 public string suggested_local_folder { get ; construct; }
2927 public string suggested_remote { get ; construct; }
3028
@@ -51,24 +49,27 @@ public class Scratch.Dialogs.CloneRepositoryDialog : Granite.MessageDialog {
5149 construct {
5250 transient_for = ((Gtk . Application )(GLib . Application . get_default ())). get_active_window ();
5351 image_icon = new ThemedIcon (" git" );
52+ badge_icon = new ThemedIcon (" emblem-downloads" );
5453 modal = true ;
5554
55+ // /TRANSLATORS "Git" is a proper name and must not be translated
56+ primary_text = _(" Create a local clone of a Git repository" );
57+ secondary_text = _(" The source repository and local folder must exist and have the required read and write permissions" );
58+
59+ var cancel_button = add_button (_(" Cancel" ), Gtk . ResponseType . CANCEL );
60+ clone_button = (Gtk . Button )add_button (_(" Clone Repository" ), Gtk . ResponseType . APPLY );
61+ set_default (clone_button);
62+
5663 try {
5764 name_regex = new Regex (NAME_REGEX , OPTIMIZE , ANCHORED | NOTEMPTY );
5865 } catch (RegexError e) {
5966 warning (" %s\n " , e. message);
6067 }
6168
62- var cancel_button = add_button (_(" Cancel" ), Gtk . ResponseType . CANCEL );
63-
64- // /TRANSLATORS "Git" is a proper name and must not be translated
65- primary_text = _(" Create a local clone of a Git repository" );
66- secondary_text = _(" The source repository and local folder must exist and have the required read and write permissions" );
67- badge_icon = new ThemedIcon (" emblem-downloads" );
68-
6969 remote_repository_uri_entry = new Granite .ValidatedEntry () {
7070 placeholder_text = _ ("https ://example .com /username /projectname .git "),
71- input_purpose = URL
71+ input_purpose = URL,
72+ activates_default = true
7273 };
7374 remote_repository_uri_entry.changed.connect (on_remote_uri_changed );
7475 remote_repository_uri_entry. text = suggested_remote;
@@ -109,7 +110,9 @@ public class Scratch.Dialogs.CloneRepositoryDialog : Granite.MessageDialog {
109110
110111 });
111112
112- local_project_name_entry = new Granite .ValidatedEntry ();
113+ local_project_name_entry = new Granite .ValidatedEntry () {
114+ activates_default = true
115+ };
113116 local_project_name_entry.changed.connect (validate_local_name );
114117
115118 var content_box = new Gtk .Grid ();
@@ -135,12 +138,9 @@ public class Scratch.Dialogs.CloneRepositoryDialog : Granite.MessageDialog {
135138 custom_bin.add (stack );
136139 custom_bin.show_all ();
137140
138- clone_button = (Gtk . Button )add_button (_ ("Clone Repository "), Gtk.ResponseType.APPLY);
139141 bind_property ("can -clone ", clone_button , "sensitive ", DEFAULT | SYNC_CREATE );
140142 spinner.bind_property ("active ", clone_button , "visible ", INVERT_BOOLEAN );
141143 spinner.bind_property ("active ", cancel_button , "visible ", INVERT_BOOLEAN );
142- // Do not want to connect to "is-valid" property notification as this gets changed to "true" every time the entry
143- // text changed. So call explicitly after we validate the text.
144144 can_clone = false ;
145145
146146 // Focus cancel button so that entry placeholder text shows
0 commit comments