summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorinfirit <[email protected]>2015-09-11 12:25:29 +0200
committerinfirit <[email protected]>2015-09-13 12:48:59 +0200
commit7aca21485bcd8601e989f141573c3bcc3c3fe609 (patch)
tree98280ed8b08675bf0902e66c6b07a65b589493d8
parentdf8f274527c9006303c2a9902dc1ec238a6dc2e6 (diff)
downloadmate-polkit-7aca21485bcd8601e989f141573c3bcc3c3fe609.tar.bz2
mate-polkit-7aca21485bcd8601e989f141573c3bcc3c3fe609.tar.xz
Select the current user to authenticate by default
Patch from Robert Ancell taken from gnome bug https://bugzilla.gnome.org/show_bug.cgi?id=596188
-rw-r--r--src/polkitmateauthenticationdialog.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/polkitmateauthenticationdialog.c b/src/polkitmateauthenticationdialog.c
index 806df27..446d92b 100644
--- a/src/polkitmateauthenticationdialog.c
+++ b/src/polkitmateauthenticationdialog.c
@@ -254,7 +254,7 @@ get_user_icon (char *username)
static void
create_user_combobox (PolkitMateAuthenticationDialog *dialog)
{
- int n;
+ int n, i, selected_index = 0;
GtkComboBox *combo;
GtkTreeIter iter;
GtkCellRenderer *renderer;
@@ -278,8 +278,8 @@ create_user_combobox (PolkitMateAuthenticationDialog *dialog)
/* For each user */
- for (n = 0; dialog->priv->users[n] != NULL; n++)
- {
+ for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+ {
gchar *gecos;
gchar *real_name;
GdkPixbuf *pixbuf = NULL;
@@ -332,6 +332,14 @@ create_user_combobox (PolkitMateAuthenticationDialog *dialog)
USERNAME_COL, dialog->priv->users[n],
-1);
+ i++;
+ if (passwd->pw_uid == getuid ())
+ {
+ selected_index = i;
+ g_free (dialog->priv->selected_user);
+ dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+ }
+
g_free (real_name);
g_object_unref (pixbuf);
}
@@ -360,8 +368,8 @@ create_user_combobox (PolkitMateAuthenticationDialog *dialog)
user_combobox_set_sensitive,
NULL, NULL);
- /* Initially select the "Select user..." ... */
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+ /* Select the default user */
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
/* Listen when a new user is selected */
g_signal_connect (GTK_WIDGET (combo),
@@ -825,16 +833,13 @@ polkit_mate_authentication_dialog_constructed (GObject *object)
gtk_widget_set_tooltip_markup (label, s);
g_free (s);
- if (have_user_combobox)
+ /* Disable password entry and authenticate until have a user selected */
+ if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
{
- /* ... and make the password entry and "Authenticate" button insensitive */
gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
}
- else
- {
- }
gtk_widget_realize (GTK_WIDGET (dialog));