02-select-default-user.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Description: Select the current user to authenticate with by default
  2. # Ubuntu: https://launchpad.net/bugs/435227
  3. # Upstream: http://bugzilla.gnome.org/show_bug.cgi?id=596188
  4. Index: policykit-1-gnome/src/polkitgnomeauthenticationdialog.c
  5. ===================================================================
  6. --- policykit-1-gnome.orig/src/polkitgnomeauthenticationdialog.c 2011-03-04 00:06:46.599981036 +0100
  7. +++ policykit-1-gnome/src/polkitgnomeauthenticationdialog.c 2011-03-04 00:07:11.211981036 +0100
  8. @@ -138,7 +138,7 @@
  9. static void
  10. create_user_combobox (PolkitGnomeAuthenticationDialog *dialog)
  11. {
  12. - int n;
  13. + int n, i, selected_index = 0;
  14. GtkComboBox *combo;
  15. GtkTreeIter iter;
  16. GtkCellRenderer *renderer;
  17. @@ -162,7 +162,7 @@
  18. /* For each user */
  19. - for (n = 0; dialog->priv->users[n] != NULL; n++)
  20. + for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
  21. {
  22. gchar *gecos;
  23. gchar *real_name;
  24. @@ -224,6 +224,14 @@
  25. USERNAME_COL, dialog->priv->users[n],
  26. -1);
  27. + i++;
  28. + if (passwd->pw_uid == getuid ())
  29. + {
  30. + selected_index = i;
  31. + g_free (dialog->priv->selected_user);
  32. + dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
  33. + }
  34. +
  35. g_free (real_name);
  36. g_object_unref (pixbuf);
  37. }
  38. @@ -252,8 +260,8 @@
  39. user_combobox_set_sensitive,
  40. NULL, NULL);
  41. - /* Initially select the "Select user..." ... */
  42. - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
  43. + /* Select the default user */
  44. + gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
  45. /* Listen when a new user is selected */
  46. g_signal_connect (GTK_WIDGET (combo),
  47. @@ -719,16 +727,13 @@
  48. gtk_widget_set_tooltip_markup (label, s);
  49. g_free (s);
  50. - if (have_user_combobox)
  51. + /* Disable password entry and authenticate until have a user selected */
  52. + if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
  53. {
  54. - /* ... and make the password entry and "Authenticate" button insensitive */
  55. gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
  56. gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
  57. gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
  58. }
  59. - else
  60. - {
  61. - }
  62. gtk_widget_realize (GTK_WIDGET (dialog));