restrict-applications-dialog: Drop accountsservice dependency

Instead of taking an `ActUser` as a property of the
`MctRestrictApplicationsDialog`, take the display name which we would
have queried from it.

This will allow the restrict applications dialog to be used in
situations where an `ActUser` isn’t available, such as when setting the
parental controls for a yet-to-be-created user.

This breaks the `MctRestrictApplicationsDialog` API, but the previous
API hadn’t yet been released.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2020-02-06 11:54:44 +00:00
parent acf402dcc5
commit 6b45ad9f76
3 changed files with 79 additions and 67 deletions

View file

@ -155,6 +155,25 @@ get_content_rating_system (ActUser *user)
return gs_utils_content_rating_system_from_locale (user_language);
}
static const gchar *
get_user_display_name (ActUser *user)
{
const gchar *display_name;
g_return_val_if_fail (ACT_IS_USER (user), _("unknown"));
display_name = act_user_get_real_name (user);
if (display_name != NULL)
return display_name;
display_name = act_user_get_user_name (user);
if (display_name != NULL)
return display_name;
/* Translators: this is the full name for an unknown user account. */
return _("unknown");
}
static void
schedule_update_blacklisted_apps (MctUserControls *self)
{
@ -549,7 +568,7 @@ on_restrict_applications_button_clicked_cb (GtkButton *button,
gtk_window_set_transient_for (GTK_WINDOW (self->restrict_applications_dialog),
GTK_WINDOW (toplevel));
mct_restrict_applications_dialog_set_user (self->restrict_applications_dialog, self->user);
mct_restrict_applications_dialog_set_user_display_name (self->restrict_applications_dialog, get_user_display_name (self->user));
mct_restrict_applications_dialog_set_app_filter (self->restrict_applications_dialog, self->filter);
gtk_widget_show (GTK_WIDGET (self->restrict_applications_dialog));