Commit 01be7132 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Do not check account availability at each character being typed by the user...

Do not check account availability at each character being typed by the user but only when it's been 500ms since he has not typed anything in.
parent 067bbef1
...@@ -283,6 +283,16 @@ void* check_username_availability(void* w) { ...@@ -283,6 +283,16 @@ void* check_username_availability(void* w) {
return NULL; return NULL;
} }
static gboolean start_check_username_availability_thread(GtkWidget *w) {
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_create(check_username_availability, (void*)w, FALSE, NULL);
#else
g_thread_new(NULL, check_username_availability, w);
#endif
g_object_set_data(G_OBJECT(w), "usernameAvailabilityTimerID", GUINT_TO_POINTER(0));
return FALSE;
}
static void account_username_changed(GtkEntry *entry, GtkWidget *w) { static void account_username_changed(GtkEntry *entry, GtkWidget *w) {
// Verifying if username choosed is available, and if form is correctly filled, let the user go next page // Verifying if username choosed is available, and if form is correctly filled, let the user go next page
GtkWidget *assistant = gtk_widget_get_toplevel(GTK_WIDGET(w)); GtkWidget *assistant = gtk_widget_get_toplevel(GTK_WIDGET(w));
...@@ -295,11 +305,12 @@ static void account_username_changed(GtkEntry *entry, GtkWidget *w) { ...@@ -295,11 +305,12 @@ static void account_username_changed(GtkEntry *entry, GtkWidget *w) {
linphone_account_creator_set_domain(creator, "sip.linphone.org"); linphone_account_creator_set_domain(creator, "sip.linphone.org");
if (g_regex_match_simple("^[a-zA-Z]+[a-zA-Z0-9.\\-_]{3,}$", gtk_entry_get_text(username), 0, 0)) { if (g_regex_match_simple("^[a-zA-Z]+[a-zA-Z0-9.\\-_]{3,}$", gtk_entry_get_text(username), 0, 0)) {
#if !GLIB_CHECK_VERSION(2, 31, 0) guint timerID = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(w), "usernameAvailabilityTimerID"));
g_thread_create(check_username_availability, (void*)w, FALSE, NULL); if (timerID > 0) {
#else g_source_remove(timerID);
g_thread_new(NULL, check_username_availability, w); }
#endif timerID = g_timeout_add(500, start_check_username_availability_thread, w);
g_object_set_data(G_OBJECT(w), "usernameAvailabilityTimerID", GUINT_TO_POINTER(timerID));
} }
else { else {
GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok")); GdkPixbuf *notok = GDK_PIXBUF(g_object_get_data(G_OBJECT(the_assistant), "notok"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment