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