hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From bb4ff4b134383bfdadf7cb5353d3553a8a72d47e Mon Sep 17 00:00:00 2001
From: Kai Kang <kai.kang@windriver.com>
Date: Wed, 13 Jan 2021 10:45:48 +0800
Subject: [PATCH 8/8] greeter.c: show information on gtk label 'info'
 
Show information on a gtk label 'info' which is added under label
'prompt' in the .glade or .ui files.
 
Upstream-Status: Submitted [https://sourceforge.net/p/lxdm/code/merge-requests/1/]
 
Signed-off-by: Kai Kang <kai.kang@windriver.com>
---
 src/greeter.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
 
diff --git a/src/greeter.c b/src/greeter.c
index 804fca0..a4a2336 100644
--- a/src/greeter.c
+++ b/src/greeter.c
@@ -64,6 +64,7 @@ static GtkWidget* win;
 static GtkWidget* alignment2;
 static GtkWidget* prompt;
 static GtkWidget* login_entry;
+static GtkWidget* info;
 static GtkWidget* user_list_scrolled;
 static GtkWidget* user_list;
 
@@ -241,10 +242,12 @@ static void on_entry_activate(GtkEntry* entry)
                     new_pass = NULL;
                     // if new passwords not match, retry for 3 times at most
                     if (++count < 3) {
+                        gtk_label_set_text((GtkLabel *)info, _("Passwords do not match, please retry."));
                         switch_to_input_passwd();
                     } else {
                         count = 0;
                         pass_expired = FALSE;
+                        gtk_label_set_text((GtkLabel *)info, _("Maximum number of failed update password attempts exceeded."));
                         switch_to_input_user();
                     }
                 } else if (!strcmp(pass, g_base64_encode((guchar*)new_pass, strlen(new_pass) + 1))) {
@@ -252,6 +255,7 @@ static void on_entry_activate(GtkEntry* entry)
                     g_free(new_pass);
                     new_pass = NULL;
                     if (++count < 3) {
+                        gtk_label_set_text((GtkLabel *)info, _("New password is same as old one, password unchanged."));
                         switch_to_input_passwd();
                     } else {
                         count = 0;
@@ -1146,6 +1150,9 @@ static void on_screen_size_changed(GdkScreen *screen,GtkWidget *win)
 
 static gint login_entry_on_key_press (GtkWidget *widget,GdkEventKey *event)
 {
+
+    gtk_label_set_text(GTK_LABEL(info), "");
+
     if(event->keyval == GDK_Escape) {
         g_free(new_pass);
         new_pass = NULL;
@@ -1211,11 +1218,14 @@ static void create_win()
     login_entry = (GtkWidget*)gtk_builder_get_object(builder, "login_entry");
     if(login_entry!=NULL)
     {
-        g_signal_connect_after(login_entry,"key-press-event",G_CALLBACK(login_entry_on_key_press),NULL);
+        g_signal_connect(login_entry,"key-press-event",G_CALLBACK(login_entry_on_key_press),NULL);
     }
 
     g_signal_connect(login_entry, "activate", G_CALLBACK(on_entry_activate), NULL);
 
+    info = (GtkWidget *)gtk_builder_get_object(builder, "info");
+    gtk_label_set_text(GTK_LABEL(info), "");
+
     if( g_key_file_get_integer(config, "display", "bottom_pane", 0)==1)
     {
         /* hacks to let GtkEventBox paintable with gtk pixmap engine. */
@@ -1359,11 +1369,13 @@ static gboolean on_lxdm_command(GIOChannel *source, GIOCondition condition, gpoi
     gtk_main_quit();
     else if( !strncmp(str, "reset", 5) )
     {
+        gtk_label_set_text(GTK_LABEL(info), _("Authentication failed."));
         switch_to_input_user();
     }
     else if (!strncmp(str, "password-expire", 15))
     {
         pass_expired = TRUE;
+        gtk_label_set_text(GTK_LABEL(info), _("You are required to change your password immediately."));
         switch_to_input_passwd();
     }
     else if( !strncmp(str, "password", 8))
@@ -1376,6 +1388,7 @@ static gboolean on_lxdm_command(GIOChannel *source, GIOCondition condition, gpoi
         new_pass = NULL;
 
         if (count++ < 3) {
+            gtk_label_set_text(GTK_LABEL(info), _("Invalid new password. Please input new password again."));
             switch_to_input_passwd();
         } else {
             count = 0;
-- 
2.25.1