Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame^] | 1 | From: Utopia Maintenance Team |
| 2 | <pkg-utopia-maintainers@lists.alioth.debian.org> |
| 3 | Date: Mon, 30 Apr 2018 17:56:52 +0000 |
| 4 | Subject: Select the current user to authenticate with by default |
| 5 | |
| 6 | Bug: http://bugzilla.gnome.org/show_bug.cgi?id=596188 |
| 7 | Bug-Ubuntu: https://launchpad.net/bugs/435227 |
| 8 | Upstream-Status: Pending |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | src/polkitgnomeauthenticationdialog.c | 23 ++++++++++++++--------- |
| 12 | 1 file changed, 14 insertions(+), 9 deletions(-) |
| 13 | |
| 14 | diff --git a/src/polkitgnomeauthenticationdialog.c b/src/polkitgnomeauthenticationdialog.c |
| 15 | index 743cc96..d307516 100644 |
| 16 | --- a/src/polkitgnomeauthenticationdialog.c |
| 17 | +++ b/src/polkitgnomeauthenticationdialog.c |
| 18 | @@ -138,7 +138,7 @@ user_combobox_changed (GtkComboBox *widget, |
| 19 | static void |
| 20 | create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) |
| 21 | { |
| 22 | - int n; |
| 23 | + int n, i, selected_index = 0; |
| 24 | GtkComboBox *combo; |
| 25 | GtkTreeIter iter; |
| 26 | GtkCellRenderer *renderer; |
| 27 | @@ -162,7 +162,7 @@ create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) |
| 28 | |
| 29 | |
| 30 | /* For each user */ |
| 31 | - for (n = 0; dialog->priv->users[n] != NULL; n++) |
| 32 | + for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++) |
| 33 | { |
| 34 | gchar *gecos; |
| 35 | gchar *real_name; |
| 36 | @@ -224,6 +224,14 @@ create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) |
| 37 | USERNAME_COL, dialog->priv->users[n], |
| 38 | -1); |
| 39 | |
| 40 | + i++; |
| 41 | + if (passwd->pw_uid == getuid ()) |
| 42 | + { |
| 43 | + selected_index = i; |
| 44 | + g_free (dialog->priv->selected_user); |
| 45 | + dialog->priv->selected_user = g_strdup (dialog->priv->users[n]); |
| 46 | + } |
| 47 | + |
| 48 | g_free (real_name); |
| 49 | g_object_unref (pixbuf); |
| 50 | } |
| 51 | @@ -252,8 +260,8 @@ create_user_combobox (PolkitGnomeAuthenticationDialog *dialog) |
| 52 | user_combobox_set_sensitive, |
| 53 | NULL, NULL); |
| 54 | |
| 55 | - /* Initially select the "Select user..." ... */ |
| 56 | - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); |
| 57 | + /* Select the default user */ |
| 58 | + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index); |
| 59 | |
| 60 | /* Listen when a new user is selected */ |
| 61 | g_signal_connect (GTK_WIDGET (combo), |
| 62 | @@ -719,16 +727,13 @@ polkit_gnome_authentication_dialog_constructed (GObject *object) |
| 63 | gtk_widget_set_tooltip_markup (label, s); |
| 64 | g_free (s); |
| 65 | |
| 66 | - if (have_user_combobox) |
| 67 | + /* Disable password entry and authenticate until have a user selected */ |
| 68 | + if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0) |
| 69 | { |
| 70 | - /* ... and make the password entry and "Authenticate" button insensitive */ |
| 71 | gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE); |
| 72 | gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE); |
| 73 | gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE); |
| 74 | } |
| 75 | - else |
| 76 | - { |
| 77 | - } |
| 78 | |
| 79 | gtk_widget_realize (GTK_WIDGET (dialog)); |
| 80 | |