2010-10-30 16:14:30 -04:00
|
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2009-2010 Red Hat, Inc,
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2012-09-06 07:43:05 -04:00
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2010-10-30 16:14:30 -04:00
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2010-10-30 16:14:30 -04:00
|
|
|
|
*
|
|
|
|
|
* Written by: Matthias Clasen <mclasen@redhat.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
#include "cc-user-panel.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
2013-07-31 13:53:18 +02:00
|
|
|
|
#include <locale.h>
|
2019-02-20 23:42:38 -06:00
|
|
|
|
#include <errno.h>
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
#include <polkit/polkit.h>
|
2012-12-04 12:48:57 -05:00
|
|
|
|
#include <act/act.h>
|
2015-01-13 16:31:10 +01:00
|
|
|
|
#include <cairo-gobject.h>
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
|
|
|
|
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
|
|
|
|
#include <libgnome-desktop/gnome-languages.h>
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
#include <libmalcontent/malcontent.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-11-07 11:56:00 +13:00
|
|
|
|
#include "cc-add-user-dialog.h"
|
2018-11-07 16:36:24 +13:00
|
|
|
|
#include "cc-avatar-chooser.h"
|
2011-08-20 02:17:06 -04:00
|
|
|
|
#include "cc-language-chooser.h"
|
2018-11-07 09:38:10 +13:00
|
|
|
|
#include "cc-login-history-dialog.h"
|
2018-11-07 09:28:46 +13:00
|
|
|
|
#include "cc-password-dialog.h"
|
2018-11-08 10:56:19 +13:00
|
|
|
|
#include "cc-realm-manager.h"
|
2018-11-07 11:56:00 +13:00
|
|
|
|
#include "cc-user-accounts-resources.h"
|
2020-04-10 16:40:27 +02:00
|
|
|
|
#include "cc-fingerprint-manager.h"
|
|
|
|
|
#include "cc-fingerprint-dialog.h"
|
2018-11-08 11:00:37 +13:00
|
|
|
|
#include "user-utils.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2011-01-24 18:15:03 +00:00
|
|
|
|
#include "cc-common-language.h"
|
2019-12-19 15:51:38 +01:00
|
|
|
|
#include "cc-permission-infobar.h"
|
2016-02-12 23:06:59 +00:00
|
|
|
|
#include "cc-util.h"
|
2011-01-24 18:15:03 +00:00
|
|
|
|
|
2012-08-18 18:32:34 +01:00
|
|
|
|
#define USER_ACCOUNTS_PERMISSION "org.gnome.controlcenter.user-accounts.administration"
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
struct _CcUserPanel {
|
|
|
|
|
CcPanel parent_instance;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUserManager *um;
|
2015-02-23 11:47:13 +01:00
|
|
|
|
GSettings *login_screen_settings;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkBox *account_settings_box;
|
|
|
|
|
GtkListBoxRow *account_type_row;
|
|
|
|
|
GtkSwitch *account_type_switch;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GtkWidget *add_user_button;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkListBoxRow *autologin_row;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkSwitch *autologin_switch;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GtkButton *back_button;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkLabel *fingerprint_state_label;
|
|
|
|
|
GtkListBoxRow *fingerprint_row;
|
2020-01-13 12:34:22 +01:00
|
|
|
|
GtkStack *full_name_stack;
|
|
|
|
|
GtkLabel *full_name_label;
|
|
|
|
|
GtkToggleButton *full_name_edit_button;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkEntry *full_name_entry;
|
|
|
|
|
GtkLabel *language_button_label;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkListBoxRow *language_row;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkLabel *last_login_button_label;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkListBoxRow *last_login_row;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GtkWidget *no_users_box;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkRevealer *notification_revealer;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
AdwPreferencesGroup *other_users;
|
|
|
|
|
GtkListBox *other_users_listbox;
|
|
|
|
|
AdwPreferencesRow *other_users_row;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkLabel *password_button_label;
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
GtkLabel *parental_controls_button_label;
|
|
|
|
|
GtkListBoxRow *parental_controls_row;
|
|
|
|
|
#endif
|
2020-01-13 15:35:09 +01:00
|
|
|
|
GtkListBoxRow *password_row;
|
2019-12-19 15:51:38 +01:00
|
|
|
|
CcPermissionInfobar *permission_infobar;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GtkButton *remove_user_button;
|
|
|
|
|
GtkStack *stack;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
AdwAvatar *user_avatar;
|
|
|
|
|
GtkMenuButton *user_avatar_edit_button;
|
2019-11-20 15:14:31 +13:00
|
|
|
|
GtkOverlay *users_overlay;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
ActUser *selected_user;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
GPermission *permission;
|
2018-06-29 16:50:43 +12:00
|
|
|
|
CcLanguageChooser *language_chooser;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GListStore *other_users_model;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-07 16:36:24 +13:00
|
|
|
|
CcAvatarChooser *avatar_chooser;
|
2013-03-21 15:15:16 +01:00
|
|
|
|
|
2020-04-06 22:48:02 +02:00
|
|
|
|
CcFingerprintManager *fingerprint_manager;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
};
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CC_PANEL_REGISTER (CcUserPanel, cc_user_panel)
|
|
|
|
|
|
|
|
|
|
static void show_restart_notification (CcUserPanel *self, const gchar *locale);
|
2014-09-17 14:35:46 +02:00
|
|
|
|
|
2014-09-30 11:08:08 +02:00
|
|
|
|
typedef struct {
|
|
|
|
|
CcUserPanel *self;
|
|
|
|
|
GCancellable *cancellable;
|
|
|
|
|
gchar *login;
|
|
|
|
|
} AsyncDeleteData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
async_delete_data_free (AsyncDeleteData *data)
|
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_clear_object (&data->self);
|
|
|
|
|
g_clear_object (&data->cancellable);
|
|
|
|
|
g_clear_pointer (&data->login, g_free);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
g_slice_free (AsyncDeleteData, data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 11:09:17 +13:00
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AsyncDeleteData, async_delete_data_free)
|
|
|
|
|
|
2014-09-30 08:54:16 +02:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_error_dialog (CcUserPanel *self,
|
2014-09-30 08:54:16 +02:00
|
|
|
|
const gchar *message,
|
|
|
|
|
GError *error)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))),
|
2014-09-30 08:54:16 +02:00
|
|
|
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
|
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
|
"%s", message);
|
|
|
|
|
|
|
|
|
|
if (error != NULL) {
|
|
|
|
|
g_dbus_error_strip_remote_error (error);
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
"%s", error->message);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
|
2014-09-30 08:54:16 +02:00
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
static void show_user (ActUser *user, CcUserPanel *self);
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
static ActUser *
|
2018-05-31 10:42:09 +12:00
|
|
|
|
get_selected_user (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
return self->selected_user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
static void
|
2022-01-26 10:13:58 +01:00
|
|
|
|
set_selected_user (CcUserPanel *self,
|
|
|
|
|
AdwActionRow *row)
|
2011-05-11 17:25:03 +01:00
|
|
|
|
{
|
2016-11-15 14:40:54 +01:00
|
|
|
|
uid_t uid;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
|
|
|
|
|
uid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (row), "uid"));
|
2020-03-26 06:41:33 +01:00
|
|
|
|
g_set_object (&self->selected_user,
|
|
|
|
|
act_user_manager_get_user_by_id (self->um, uid));
|
2022-01-26 10:13:58 +01:00
|
|
|
|
show_user (self->selected_user, self);
|
2011-05-11 17:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
static void
|
|
|
|
|
show_current_user (CcUserPanel *self)
|
2016-11-15 14:40:54 +01:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
ActUser *user;
|
2016-12-18 14:39:04 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
user = act_user_manager_get_user_by_id (self->um, getuid ());
|
|
|
|
|
if (user != NULL)
|
|
|
|
|
show_user (user, self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
2016-07-21 16:10:35 +02:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
static const gchar *
|
|
|
|
|
get_real_or_user_name (ActUser *user)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
const gchar *name;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
name = act_user_get_real_name (user);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
name = act_user_get_user_name (user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
return name;
|
|
|
|
|
}
|
2017-12-05 16:22:29 +01:00
|
|
|
|
|
2022-02-23 11:30:38 +01:00
|
|
|
|
static void
|
|
|
|
|
setup_avatar_for_user (AdwAvatar *avatar, ActUser *user)
|
|
|
|
|
{
|
|
|
|
|
const gchar *avatar_file;
|
|
|
|
|
|
|
|
|
|
adw_avatar_set_custom_image (avatar, NULL);
|
|
|
|
|
adw_avatar_set_text (avatar, get_real_or_user_name (user));
|
|
|
|
|
|
|
|
|
|
avatar_file = act_user_get_icon_file (user);
|
|
|
|
|
if (avatar_file) {
|
|
|
|
|
g_autoptr(GdkPixbuf) pixbuf = NULL;
|
|
|
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file_at_size (avatar_file,
|
|
|
|
|
adw_avatar_get_size (avatar),
|
|
|
|
|
adw_avatar_get_size (avatar),
|
|
|
|
|
NULL);
|
|
|
|
|
if (pixbuf) {
|
|
|
|
|
adw_avatar_set_custom_image (avatar,
|
|
|
|
|
GDK_PAINTABLE (gdk_texture_new_for_pixbuf (pixbuf)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
static GtkWidget *
|
|
|
|
|
create_user_row (gpointer item,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
ActUser *user = ACT_USER (item);
|
|
|
|
|
GtkWidget *row, *user_image;
|
|
|
|
|
|
|
|
|
|
row = adw_action_row_new ();
|
|
|
|
|
g_object_set_data (G_OBJECT (row), "uid", GINT_TO_POINTER (act_user_get_uid (user)));
|
|
|
|
|
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (row), TRUE);
|
|
|
|
|
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row),
|
|
|
|
|
get_real_or_user_name (user));
|
2022-02-23 11:30:38 +01:00
|
|
|
|
user_image = adw_avatar_new (48, NULL, TRUE);
|
|
|
|
|
setup_avatar_for_user (ADW_AVATAR (user_image), user);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
adw_action_row_add_prefix (ADW_ACTION_ROW (row), user_image);
|
|
|
|
|
|
|
|
|
|
return row;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
2022-01-26 10:13:58 +01:00
|
|
|
|
sort_users (gconstpointer a, gconstpointer b, gpointer user_data)
|
2016-11-15 14:40:54 +01:00
|
|
|
|
{
|
|
|
|
|
ActUser *ua, *ub;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
ua = ACT_USER (a);
|
|
|
|
|
ub = ACT_USER (b);
|
|
|
|
|
|
|
|
|
|
/* Make sure the current user is shown first */
|
|
|
|
|
if (act_user_get_uid (ua) == getuid ()) {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return -G_MAXINT32;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
|
|
|
|
else if (act_user_get_uid (ub) == getuid ()) {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return G_MAXINT32;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2016-11-15 14:40:54 +01:00
|
|
|
|
else {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autofree gchar *name1 = NULL;
|
|
|
|
|
g_autofree gchar *name2 = NULL;
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
name1 = g_utf8_collate_key (get_real_or_user_name (ua), -1);
|
|
|
|
|
name2 = g_utf8_collate_key (get_real_or_user_name (ub), -1);
|
2013-03-21 15:15:16 +01:00
|
|
|
|
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return strcmp (name1, name2);
|
2013-03-21 15:15:16 +01:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2022-01-26 10:13:58 +01:00
|
|
|
|
user_changed (CcUserPanel *self, ActUser *user)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GSList *user_list, *l;
|
2022-02-09 11:02:55 +01:00
|
|
|
|
gboolean show;
|
2017-02-13 09:16:59 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
g_list_store_remove_all (self->other_users_model);
|
|
|
|
|
user_list = act_user_manager_list_users (self->um);
|
|
|
|
|
for (l = user_list; l; l = l->next) {
|
|
|
|
|
ActUser *other_user = ACT_USER (l->data);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
if (act_user_is_system_account (other_user)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
if (act_user_get_uid (other_user) == getuid ()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
g_list_store_insert_sorted (self->other_users_model,
|
|
|
|
|
other_user,
|
|
|
|
|
sort_users,
|
|
|
|
|
self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
2017-12-05 16:22:29 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
if (self->selected_user == user)
|
|
|
|
|
show_user (user, self);
|
2022-02-09 11:02:55 +01:00
|
|
|
|
|
|
|
|
|
show = g_list_model_get_n_items (G_LIST_MODEL (self->other_users_model)) > 0;
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->other_users_row), show);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
static void
|
|
|
|
|
on_add_user_dialog_response (CcUserPanel *self,
|
|
|
|
|
gint response,
|
|
|
|
|
CcAddUserDialog *dialog)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2016-11-15 14:40:54 +01:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
user = cc_add_user_dialog_get_user (dialog);
|
|
|
|
|
if (user != NULL) {
|
|
|
|
|
set_default_avatar (user);
|
|
|
|
|
show_user (user, self);
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-11-07 16:05:32 +13:00
|
|
|
|
add_user (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-11-07 11:56:00 +13:00
|
|
|
|
CcAddUserDialog *dialog;
|
2018-11-07 16:05:32 +13:00
|
|
|
|
GtkWindow *toplevel;
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2018-11-07 16:05:32 +13:00
|
|
|
|
dialog = cc_add_user_dialog_new (self->permission);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
toplevel = GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self)));
|
2018-11-07 16:05:32 +13:00
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), toplevel);
|
2012-08-14 17:04:41 +02:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
g_signal_connect_object (dialog, "response", G_CALLBACK (on_add_user_dialog_response),
|
|
|
|
|
self, G_CONNECT_SWAPPED);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
delete_user_done (ActUserManager *manager,
|
|
|
|
|
GAsyncResult *res,
|
|
|
|
|
CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!act_user_manager_delete_user_finish (manager, res, &error)) {
|
2014-09-30 08:54:16 +02:00
|
|
|
|
if (!g_error_matches (error, ACT_USER_MANAGER_ERROR,
|
|
|
|
|
ACT_USER_MANAGER_ERROR_PERMISSION_DENIED))
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_error_dialog (self, _("Failed to delete user"), error);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2022-01-26 10:13:58 +01:00
|
|
|
|
|
|
|
|
|
show_current_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-11-22 13:10:38 +13:00
|
|
|
|
delete_user_response (CcUserPanel *self,
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gint response_id,
|
2019-11-22 13:10:38 +13:00
|
|
|
|
GtkWidget *dialog)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
gboolean remove_files;
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
if (response_id == GTK_RESPONSE_CANCEL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (response_id == GTK_RESPONSE_NO) {
|
|
|
|
|
remove_files = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
remove_files = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2013-04-24 09:23:10 +02:00
|
|
|
|
/* remove autologin */
|
|
|
|
|
if (act_user_get_automatic_login (user)) {
|
|
|
|
|
act_user_set_automatic_login (user, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
act_user_manager_delete_user_async (self->um,
|
2012-12-04 12:48:57 -05:00
|
|
|
|
user,
|
|
|
|
|
remove_files,
|
|
|
|
|
NULL,
|
|
|
|
|
(GAsyncReadyCallback)delete_user_done,
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-09-30 11:08:08 +02:00
|
|
|
|
enterprise_user_revoked (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(AsyncDeleteData) data = user_data;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data->self;
|
2018-11-08 10:56:19 +13:00
|
|
|
|
CcRealmCommon *common = CC_REALM_COMMON (source);
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
cc_realm_common_call_change_login_policy_finish (common, result, &error);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
if (error != NULL) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_error_dialog (self, _("Failed to revoke remotely managed user"), error);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
static CcRealmCommon *
|
|
|
|
|
find_matching_realm (CcRealmManager *realm_manager, const gchar *login)
|
2014-09-30 11:08:08 +02:00
|
|
|
|
{
|
2018-11-08 10:56:19 +13:00
|
|
|
|
CcRealmCommon *common = NULL;
|
2020-11-02 11:09:17 +13:00
|
|
|
|
GList *realms;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
realms = cc_realm_manager_get_realms (realm_manager);
|
2020-11-02 11:09:17 +13:00
|
|
|
|
for (GList *l = realms; l != NULL; l = g_list_next (l)) {
|
2014-09-30 11:08:08 +02:00
|
|
|
|
const gchar * const *permitted_logins;
|
|
|
|
|
gint i;
|
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
common = cc_realm_object_get_common (l->data);
|
2015-02-25 14:31:28 +01:00
|
|
|
|
if (common == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
permitted_logins = cc_realm_common_get_permitted_logins (common);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
for (i = 0; permitted_logins[i] != NULL; i++) {
|
|
|
|
|
if (g_strcmp0 (permitted_logins[i], login) == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (permitted_logins[i] != NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
g_clear_object (&common);
|
|
|
|
|
}
|
|
|
|
|
g_list_free_full (realms, g_object_unref);
|
|
|
|
|
|
|
|
|
|
return common;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
realm_manager_found (GObject *source,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(AsyncDeleteData) data = user_data;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data->self;
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(CcRealmCommon) common = NULL;
|
2018-11-08 10:56:19 +13:00
|
|
|
|
CcRealmManager *realm_manager;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
const gchar *add[1];
|
|
|
|
|
const gchar *remove[2];
|
|
|
|
|
GVariant *options;
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-08 10:56:19 +13:00
|
|
|
|
realm_manager = cc_realm_manager_new_finish (result, &error);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
if (error != NULL) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_error_dialog (self, _("Failed to revoke remotely managed user"), error);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find matching realm */
|
|
|
|
|
common = find_matching_realm (realm_manager, data->login);
|
|
|
|
|
if (common == NULL) {
|
|
|
|
|
/* The realm was probably left */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the user from permitted logins */
|
|
|
|
|
g_debug ("Denying future login for: %s", data->login);
|
|
|
|
|
|
|
|
|
|
add[0] = NULL;
|
|
|
|
|
remove[0] = data->login;
|
|
|
|
|
remove[1] = NULL;
|
|
|
|
|
|
|
|
|
|
options = g_variant_new_array (G_VARIANT_TYPE ("{sv}"), NULL, 0);
|
2018-11-08 10:56:19 +13:00
|
|
|
|
cc_realm_common_call_change_login_policy (common, "",
|
2014-09-30 11:08:08 +02:00
|
|
|
|
add, remove, options,
|
|
|
|
|
data->cancellable,
|
|
|
|
|
enterprise_user_revoked,
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_steal_pointer (&data));
|
2014-09-30 11:08:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
enterprise_user_uncached (GObject *source,
|
|
|
|
|
GAsyncResult *res,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(AsyncDeleteData) data = user_data;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data->self;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
ActUserManager *manager = ACT_USER_MANAGER (source);
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
act_user_manager_uncache_user_finish (manager, res, &error);
|
|
|
|
|
if (error == NULL) {
|
|
|
|
|
/* Find realm manager */
|
2020-11-02 11:09:17 +13:00
|
|
|
|
cc_realm_manager_new (cc_panel_get_cancellable (CC_PANEL (self)), realm_manager_found, g_steal_pointer (&data));
|
2014-09-30 11:08:08 +02:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_error_dialog (self, _("Failed to revoke remotely managed user"), error);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-11-22 13:10:38 +13:00
|
|
|
|
delete_enterprise_user_response (CcUserPanel *self,
|
|
|
|
|
gint response_id,
|
|
|
|
|
GtkWidget *dialog)
|
2014-09-30 11:08:08 +02:00
|
|
|
|
{
|
|
|
|
|
AsyncDeleteData *data;
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_destroy (GTK_WINDOW (dialog));
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
|
|
|
|
if (response_id != GTK_RESPONSE_ACCEPT) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
|
|
|
|
data = g_slice_new (AsyncDeleteData);
|
|
|
|
|
data->self = g_object_ref (self);
|
2020-01-31 10:30:10 +13:00
|
|
|
|
data->cancellable = g_object_ref (cc_panel_get_cancellable (CC_PANEL (self)));
|
2014-09-30 11:08:08 +02:00
|
|
|
|
data->login = g_strdup (act_user_get_user_name (user));
|
|
|
|
|
|
|
|
|
|
/* Uncache the user account from the accountsservice */
|
|
|
|
|
g_debug ("Uncaching remote user: %s", data->login);
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
act_user_manager_uncache_user_async (self->um, data->login,
|
2014-09-30 11:08:08 +02:00
|
|
|
|
data->cancellable,
|
|
|
|
|
enterprise_user_uncached,
|
|
|
|
|
data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
delete_user (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (user == NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-12-04 12:48:57 -05:00
|
|
|
|
else if (act_user_get_uid (user) == getuid ()) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
0,
|
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
|
_("You cannot delete your own account."));
|
|
|
|
|
g_signal_connect (dialog, "response",
|
2022-01-26 10:13:58 +01:00
|
|
|
|
G_CALLBACK (gtk_window_destroy), NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-01-10 12:52:37 -05:00
|
|
|
|
else if (act_user_is_logged_in_anywhere (user)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
0,
|
|
|
|
|
GTK_MESSAGE_INFO,
|
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
|
_("%s is still logged in"),
|
2013-01-05 16:54:17 -05:00
|
|
|
|
get_real_or_user_name (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
_("Deleting a user while they are logged in can leave the system in an inconsistent state."));
|
|
|
|
|
g_signal_connect (dialog, "response",
|
2022-01-26 10:13:58 +01:00
|
|
|
|
G_CALLBACK (gtk_window_destroy), NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-09-30 11:08:08 +02:00
|
|
|
|
else if (act_user_is_local_account (user)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
0,
|
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
|
GTK_BUTTONS_NONE,
|
2016-10-03 14:48:16 +02:00
|
|
|
|
_("Do you want to keep %s’s files?"),
|
2013-01-05 16:54:17 -05:00
|
|
|
|
get_real_or_user_name (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
_("It is possible to keep the home directory, mail spool and temporary files around when deleting a user account."));
|
|
|
|
|
|
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
|
|
|
|
_("_Delete Files"), GTK_RESPONSE_NO,
|
|
|
|
|
_("_Keep Files"), GTK_RESPONSE_YES,
|
|
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
|
|
|
|
|
|
2019-11-22 13:10:38 +13:00
|
|
|
|
g_signal_connect_object (dialog, "response",
|
|
|
|
|
G_CALLBACK (delete_user_response), self, G_CONNECT_SWAPPED);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-09-30 11:08:08 +02:00
|
|
|
|
else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))),
|
2014-09-30 11:08:08 +02:00
|
|
|
|
0,
|
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
|
GTK_BUTTONS_NONE,
|
2016-10-03 14:48:16 +02:00
|
|
|
|
_("Are you sure you want to revoke remotely managed %s’s account?"),
|
2014-09-30 11:08:08 +02:00
|
|
|
|
get_real_or_user_name (user));
|
|
|
|
|
|
|
|
|
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
|
|
|
|
_("_Delete"), GTK_RESPONSE_ACCEPT,
|
|
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");
|
|
|
|
|
|
2019-11-22 13:10:38 +13:00
|
|
|
|
g_signal_connect_object (dialog, "response",
|
|
|
|
|
G_CALLBACK (delete_enterprise_user_response), self, G_CONNECT_SWAPPED);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "close",
|
2022-01-26 10:13:58 +01:00
|
|
|
|
G_CALLBACK (gtk_window_destroy), NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 21:46:37 -05:00
|
|
|
|
static const gchar *
|
|
|
|
|
get_invisible_text (void)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
gunichar invisible_char;
|
|
|
|
|
static gchar invisible_text[40];
|
|
|
|
|
gchar *p;
|
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
|
|
entry = gtk_entry_new ();
|
|
|
|
|
invisible_char = gtk_entry_get_invisible_char (GTK_ENTRY (entry));
|
|
|
|
|
if (invisible_char == 0)
|
|
|
|
|
invisible_char = 0x2022;
|
|
|
|
|
|
|
|
|
|
g_object_ref_sink (entry);
|
|
|
|
|
g_object_unref (entry);
|
|
|
|
|
|
|
|
|
|
/* five bullets */
|
|
|
|
|
p = invisible_text;
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
|
p += g_unichar_to_utf8 (invisible_char, p);
|
|
|
|
|
*p = 0;
|
|
|
|
|
|
|
|
|
|
return invisible_text;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static const gchar *
|
2012-12-04 12:48:57 -05:00
|
|
|
|
get_password_mode_text (ActUser *user)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
|
|
|
|
const gchar *text;
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (act_user_get_locked (user)) {
|
2010-10-30 16:14:30 -04:00
|
|
|
|
text = C_("Password mode", "Account disabled");
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-12-04 12:48:57 -05:00
|
|
|
|
switch (act_user_get_password_mode (user)) {
|
|
|
|
|
case ACT_USER_PASSWORD_MODE_REGULAR:
|
2011-02-23 21:46:37 -05:00
|
|
|
|
text = get_invisible_text ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
break;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN:
|
2010-10-30 16:14:30 -04:00
|
|
|
|
text = C_("Password mode", "To be set at next login");
|
|
|
|
|
break;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
case ACT_USER_PASSWORD_MODE_NONE:
|
2010-10-30 16:14:30 -04:00
|
|
|
|
text = C_("Password mode", "None");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-24 20:23:01 -05:00
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
autologin_changed (CcUserPanel *self)
|
2011-01-24 20:23:01 -05:00
|
|
|
|
{
|
|
|
|
|
gboolean active;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2011-01-24 20:23:01 -05:00
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
active = gtk_switch_get_active (self->autologin_switch);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2011-01-24 20:23:01 -05:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (active != act_user_get_automatic_login (user)) {
|
|
|
|
|
act_user_set_automatic_login (user, active);
|
|
|
|
|
if (act_user_get_automatic_login (user)) {
|
2011-01-24 20:23:01 -05:00
|
|
|
|
GSList *list;
|
|
|
|
|
GSList *l;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
list = act_user_manager_list_users (self->um);
|
2011-01-24 20:23:01 -05:00
|
|
|
|
for (l = list; l != NULL; l = l->next) {
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *u = l->data;
|
|
|
|
|
if (act_user_get_uid (u) != act_user_get_uid (user)) {
|
|
|
|
|
act_user_set_automatic_login (user, FALSE);
|
2011-01-24 20:23:01 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-22 15:14:13 +01:00
|
|
|
|
static gchar *
|
2012-12-04 12:48:57 -05:00
|
|
|
|
get_login_time_text (ActUser *user)
|
2012-11-22 15:14:13 +01:00
|
|
|
|
{
|
|
|
|
|
gint64 time;
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
time = act_user_get_login_time (user);
|
|
|
|
|
if (act_user_is_logged_in (user)) {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return g_strdup (_("Logged in"));
|
2012-11-22 15:14:13 +01:00
|
|
|
|
}
|
|
|
|
|
else if (time > 0) {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GDateTime) date_time = NULL;
|
|
|
|
|
g_autofree gchar *date_str = NULL;
|
|
|
|
|
g_autofree gchar *time_str = NULL;
|
|
|
|
|
|
2012-11-22 15:14:13 +01:00
|
|
|
|
date_time = g_date_time_new_from_unix_local (time);
|
2016-02-12 23:06:59 +00:00
|
|
|
|
date_str = cc_util_get_smart_date (date_time);
|
2020-11-02 11:09:17 +13:00
|
|
|
|
|
2013-08-12 14:49:43 +09:00
|
|
|
|
/* Translators: This is a time format string in the style of "22:58".
|
|
|
|
|
It indicates a login time which follows a date. */
|
|
|
|
|
time_str = g_date_time_format (date_time, C_("login date-time", "%k:%M"));
|
2012-11-22 15:14:13 +01:00
|
|
|
|
|
2013-08-12 14:49:43 +09:00
|
|
|
|
/* Translators: This indicates a login date-time.
|
|
|
|
|
The first %s is a date, and the second %s a time. */
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return g_strdup_printf(C_("login date-time", "%s, %s"), date_str, time_str);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
return g_strdup ("—");
|
2012-11-22 15:14:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-04 14:51:35 +01:00
|
|
|
|
static gboolean
|
|
|
|
|
get_autologin_possible (ActUser *user)
|
|
|
|
|
{
|
|
|
|
|
gboolean locked;
|
|
|
|
|
gboolean set_password_at_login;
|
|
|
|
|
|
|
|
|
|
locked = act_user_get_locked (user);
|
|
|
|
|
set_password_at_login = (act_user_get_password_mode (user) == ACT_USER_PASSWORD_MODE_SET_AT_LOGIN);
|
|
|
|
|
|
|
|
|
|
return !(locked || set_password_at_login);
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
static void on_permission_changed (CcUserPanel *self);
|
2020-01-13 12:34:22 +01:00
|
|
|
|
static void full_name_edit_button_toggled (CcUserPanel *self);
|
2013-08-02 13:31:51 -03:00
|
|
|
|
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
static gboolean
|
|
|
|
|
is_parental_controls_enabled_for_user (ActUser *user)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr(MctManager) manager = NULL;
|
|
|
|
|
g_autoptr(MctAppFilter) app_filter = NULL;
|
|
|
|
|
g_autoptr(GDBusConnection) system_bus = NULL;
|
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
/* FIXME: should become asynchronous */
|
|
|
|
|
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
|
|
|
|
if (system_bus == NULL) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
g_warning ("Error getting system bus while trying to show user details: %s", error->message);
|
|
|
|
|
return FALSE;
|
2020-03-26 14:20:44 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
manager = mct_manager_new (system_bus);
|
|
|
|
|
app_filter = mct_manager_get_app_filter (manager,
|
|
|
|
|
act_user_get_uid (user),
|
|
|
|
|
MCT_GET_APP_FILTER_FLAGS_NONE,
|
|
|
|
|
NULL,
|
|
|
|
|
&error);
|
|
|
|
|
if (error) {
|
|
|
|
|
if (!g_error_matches (error, MCT_MANAGER_ERROR, MCT_MANAGER_ERROR_DISABLED))
|
|
|
|
|
g_warning ("Error retrieving app filter for user %s: %s",
|
|
|
|
|
act_user_get_user_name (user),
|
|
|
|
|
error->message);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mct_app_filter_is_enabled (app_filter);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-04-06 22:48:02 +02:00
|
|
|
|
static void
|
|
|
|
|
update_fingerprint_row_state (CcUserPanel *self, GParamSpec *spec, CcFingerprintManager *fingerprint_manager)
|
|
|
|
|
{
|
|
|
|
|
CcFingerprintState state = cc_fingerprint_manager_get_state (fingerprint_manager);
|
|
|
|
|
|
2020-04-14 00:51:05 +02:00
|
|
|
|
if (state != CC_FINGERPRINT_STATE_UPDATING) {
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row),
|
|
|
|
|
state != CC_FINGERPRINT_STATE_NONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->fingerprint_row),
|
|
|
|
|
state != CC_FINGERPRINT_STATE_UPDATING);
|
2020-04-06 22:48:02 +02:00
|
|
|
|
|
|
|
|
|
if (state == CC_FINGERPRINT_STATE_ENABLED)
|
|
|
|
|
gtk_label_set_text (self->fingerprint_state_label, _("Enabled"));
|
|
|
|
|
else if (state == CC_FINGERPRINT_STATE_DISABLED)
|
|
|
|
|
gtk_label_set_text (self->fingerprint_state_label, _("Disabled"));
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_user (ActUser *user, CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autofree gchar *lang = NULL;
|
|
|
|
|
g_autofree gchar *name = NULL;
|
2012-09-17 12:33:51 +01:00
|
|
|
|
gboolean show, enable;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *current;
|
2022-02-01 13:02:07 +00:00
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
g_autofree gchar *malcontent_control_path = NULL;
|
|
|
|
|
#endif
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->selected_user = user;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2022-02-23 11:30:38 +01:00
|
|
|
|
setup_avatar_for_user (self->user_avatar, user);
|
2018-11-07 16:36:24 +13:00
|
|
|
|
cc_avatar_chooser_set_user (self->avatar_chooser, user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_label_set_label (self->full_name_label, get_real_or_user_name (user));
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (self->full_name_entry), gtk_label_get_label (self->full_name_label));
|
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self->full_name_label), get_real_or_user_name (user));
|
2020-01-13 12:34:22 +01:00
|
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (self->full_name_edit_button, full_name_edit_button_toggled, self);
|
|
|
|
|
gtk_stack_set_visible_child (self->full_name_stack, GTK_WIDGET (self->full_name_label));
|
|
|
|
|
gtk_toggle_button_set_active (self->full_name_edit_button, FALSE);
|
|
|
|
|
g_signal_handlers_unblock_by_func (self->full_name_edit_button, full_name_edit_button_toggled, self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
enable = (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR);
|
|
|
|
|
gtk_switch_set_active (self->account_type_switch, enable);
|
2016-05-31 12:00:47 +02:00
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_label_set_label (self->password_button_label, get_password_mode_text (user));
|
2012-12-04 12:48:57 -05:00
|
|
|
|
enable = act_user_is_local_account (user);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->password_button_label), enable);
|
2011-08-25 12:41:18 -04:00
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
g_signal_handlers_block_by_func (self->autologin_switch, autologin_changed, self);
|
|
|
|
|
gtk_switch_set_active (self->autologin_switch, act_user_get_automatic_login (user));
|
|
|
|
|
g_signal_handlers_unblock_by_func (self->autologin_switch, autologin_changed, self);
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->autologin_switch), get_autologin_possible (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
lang = g_strdup (act_user_get_language (user));
|
2014-10-15 12:41:51 +02:00
|
|
|
|
if (lang && *lang != '\0') {
|
|
|
|
|
name = gnome_get_language_from_locale (lang, NULL);
|
2016-07-20 10:28:06 +02:00
|
|
|
|
} else {
|
|
|
|
|
name = g_strdup ("—");
|
2014-05-30 13:02:00 +02:00
|
|
|
|
}
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_label_set_label (self->language_button_label, name);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2015-02-23 11:47:13 +01:00
|
|
|
|
/* Fingerprint: show when self, local, enabled, and possible */
|
2012-12-04 12:48:57 -05:00
|
|
|
|
show = (act_user_get_uid (user) == getuid() &&
|
|
|
|
|
act_user_is_local_account (user) &&
|
2018-05-31 10:42:09 +12:00
|
|
|
|
(self->login_screen_settings &&
|
2020-03-26 06:41:06 +01:00
|
|
|
|
g_settings_get_boolean (self->login_screen_settings,
|
|
|
|
|
"enable-fingerprint-authentication")));
|
|
|
|
|
|
2020-04-06 22:48:02 +02:00
|
|
|
|
if (show) {
|
|
|
|
|
if (!self->fingerprint_manager) {
|
|
|
|
|
self->fingerprint_manager = cc_fingerprint_manager_new (user);
|
|
|
|
|
g_signal_connect_object (self->fingerprint_manager,
|
|
|
|
|
"notify::state",
|
|
|
|
|
G_CALLBACK (update_fingerprint_row_state),
|
|
|
|
|
self, G_CONNECT_SWAPPED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_fingerprint_row_state (self, NULL, self->fingerprint_manager);
|
2020-04-03 17:36:39 +02:00
|
|
|
|
} else {
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), FALSE);
|
2020-03-26 06:41:06 +01:00
|
|
|
|
}
|
2012-08-14 18:34:22 +02:00
|
|
|
|
|
|
|
|
|
/* Autologin: show when local account */
|
2012-12-04 12:48:57 -05:00
|
|
|
|
show = act_user_is_local_account (user);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->autologin_row), show);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
2022-02-01 13:02:07 +00:00
|
|
|
|
/* Parental Controls: Unavailable if user is admin or if
|
|
|
|
|
* malcontent-control is not available (which can happen if
|
|
|
|
|
* libmalcontent is installed but malcontent-control is not). */
|
|
|
|
|
malcontent_control_path = g_find_program_in_path ("malcontent-control");
|
|
|
|
|
|
|
|
|
|
if (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR ||
|
|
|
|
|
malcontent_control_path == NULL) {
|
2021-08-26 16:49:40 +02:00
|
|
|
|
gtk_widget_hide (GTK_WIDGET (self->parental_controls_row));
|
2020-03-26 14:20:44 +05:30
|
|
|
|
} else {
|
2021-02-11 16:13:25 +13:00
|
|
|
|
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self->parental_controls_button_label));
|
2020-10-19 15:43:52 +01:00
|
|
|
|
|
2020-03-26 14:20:44 +05:30
|
|
|
|
if (is_parental_controls_enabled_for_user (user))
|
|
|
|
|
/* TRANSLATORS: Status of Parental Controls setup */
|
|
|
|
|
gtk_label_set_text (self->parental_controls_button_label, _("Enabled"));
|
|
|
|
|
else
|
|
|
|
|
/* TRANSLATORS: Status of Parental Controls setup */
|
|
|
|
|
gtk_label_set_text (self->parental_controls_button_label, _("Disabled"));
|
|
|
|
|
|
2020-10-19 15:43:52 +01:00
|
|
|
|
gtk_style_context_remove_class (context, "dim-label");
|
2021-08-26 16:49:40 +02:00
|
|
|
|
gtk_widget_show (GTK_WIDGET (self->parental_controls_row));
|
2020-03-26 14:20:44 +05:30
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
/* Current user */
|
|
|
|
|
show = act_user_get_uid (user) == getuid();
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_settings_box), !show);
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->remove_user_button), !show);
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->back_button), !show);
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->other_users), show);
|
2016-06-13 14:27:30 +02:00
|
|
|
|
|
2012-11-22 15:14:13 +01:00
|
|
|
|
/* Last login: show when administrator or current user */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
current = act_user_manager_get_user_by_id (self->um, getuid ());
|
2012-12-04 12:48:57 -05:00
|
|
|
|
show = act_user_get_uid (user) == getuid () ||
|
|
|
|
|
act_user_get_account_type (current) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
|
2012-11-22 15:14:13 +01:00
|
|
|
|
if (show) {
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autofree gchar *text = NULL;
|
|
|
|
|
|
2012-11-22 15:14:13 +01:00
|
|
|
|
text = get_login_time_text (user);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_label_set_label (self->last_login_button_label, text);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
}
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->last_login_row), show);
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
|
|
|
|
enable = act_user_get_login_history (user) != NULL;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->last_login_row), enable);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (self->permission != NULL)
|
2018-10-16 11:23:40 +13:00
|
|
|
|
on_permission_changed (self);
|
2013-08-02 13:31:51 -03:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
static void
|
2020-01-13 12:34:22 +01:00
|
|
|
|
full_name_entry_activate (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
|
|
|
|
const gchar *text;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
text = gtk_editable_get_text (GTK_EDITABLE (self->full_name_entry));
|
2013-05-08 17:05:56 +01:00
|
|
|
|
if (g_strcmp0 (text, act_user_get_real_name (user)) != 0 &&
|
|
|
|
|
is_valid_name (text)) {
|
2012-12-04 12:48:57 -05:00
|
|
|
|
act_user_set_real_name (user, text);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2020-01-13 12:34:22 +01:00
|
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (self->full_name_edit_button, FALSE);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-20 11:26:56 +02:00
|
|
|
|
static void
|
2020-01-13 12:34:22 +01:00
|
|
|
|
full_name_edit_button_toggled (CcUserPanel *self)
|
|
|
|
|
{
|
|
|
|
|
if (gtk_stack_get_visible_child (self->full_name_stack) == GTK_WIDGET (self->full_name_label)) {
|
|
|
|
|
gtk_stack_set_visible_child (self->full_name_stack, GTK_WIDGET (self->full_name_entry));
|
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (GTK_WIDGET (self->full_name_entry));
|
|
|
|
|
} else {
|
|
|
|
|
gtk_stack_set_visible_child (self->full_name_stack, GTK_WIDGET (self->full_name_label));
|
|
|
|
|
|
|
|
|
|
full_name_entry_activate (self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2022-01-26 10:13:58 +01:00
|
|
|
|
full_name_entry_key_press_cb (GtkEventController *controller,
|
|
|
|
|
guint keyval,
|
|
|
|
|
guint keycode,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
CcUserPanel *self)
|
2016-07-20 11:26:56 +02:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
if (keyval == GDK_KEY_Escape) {
|
|
|
|
|
gtk_editable_set_text (GTK_EDITABLE (self->full_name_entry), act_user_get_real_name (self->selected_user));
|
2020-01-13 12:34:22 +01:00
|
|
|
|
|
|
|
|
|
full_name_entry_activate (self);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
2016-07-20 11:26:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
account_type_changed (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2014-09-17 14:35:46 +02:00
|
|
|
|
gboolean self_selected;
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gboolean is_admin;
|
|
|
|
|
ActUserAccountType account_type;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2014-09-17 14:35:46 +02:00
|
|
|
|
self_selected = act_user_get_uid (user) == geteuid ();
|
2020-01-13 15:35:09 +01:00
|
|
|
|
is_admin = gtk_switch_get_active (self->account_type_switch);
|
2011-08-25 23:43:48 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
account_type = is_admin ? ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR : ACT_USER_ACCOUNT_TYPE_STANDARD;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (account_type != act_user_get_account_type (user)) {
|
|
|
|
|
act_user_set_account_type (user, account_type);
|
2014-09-17 14:35:46 +02:00
|
|
|
|
|
|
|
|
|
if (self_selected)
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_restart_notification (self, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-27 16:37:45 +01:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dismiss_notification (CcUserPanel *self)
|
2016-11-27 16:37:45 +01:00
|
|
|
|
{
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, FALSE);
|
2016-11-27 16:37:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 13:53:18 +02:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
restart_now (CcUserPanel *self)
|
2013-07-31 13:53:18 +02:00
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GDBusConnection) bus = NULL;
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, FALSE);
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
|
|
|
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
|
|
|
|
g_dbus_connection_call (bus,
|
|
|
|
|
"org.gnome.SessionManager",
|
|
|
|
|
"/org/gnome/SessionManager",
|
|
|
|
|
"org.gnome.SessionManager",
|
|
|
|
|
"Logout",
|
|
|
|
|
g_variant_new ("(u)", 0),
|
|
|
|
|
NULL, 0, G_MAXINT,
|
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_restart_notification (CcUserPanel *self, const gchar *locale)
|
2013-07-31 13:53:18 +02:00
|
|
|
|
{
|
2019-02-20 23:42:38 -06:00
|
|
|
|
locale_t current_locale;
|
|
|
|
|
locale_t new_locale;
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
|
|
|
|
if (locale) {
|
2019-02-20 23:42:38 -06:00
|
|
|
|
new_locale = newlocale (LC_MESSAGES_MASK, locale, (locale_t) 0);
|
|
|
|
|
if (new_locale == (locale_t) 0)
|
|
|
|
|
g_warning ("Failed to create locale %s: %s", locale, g_strerror (errno));
|
|
|
|
|
else
|
|
|
|
|
current_locale = uselocale (new_locale);
|
2013-07-31 13:53:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_revealer_set_reveal_child (self->notification_revealer, TRUE);
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
2019-02-20 23:42:38 -06:00
|
|
|
|
if (locale && new_locale != (locale_t) 0) {
|
|
|
|
|
uselocale (current_locale);
|
|
|
|
|
freelocale (new_locale);
|
2013-07-31 13:53:18 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2019-11-22 13:10:38 +13:00
|
|
|
|
language_response (CcUserPanel *self,
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gint response_id,
|
2019-11-22 13:10:38 +13:00
|
|
|
|
GtkDialog *dialog)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2015-01-16 09:11:00 +01:00
|
|
|
|
const gchar *lang, *account_language;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2014-10-15 12:41:51 +02:00
|
|
|
|
if (response_id != GTK_RESPONSE_OK) {
|
|
|
|
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2015-01-16 09:11:00 +01:00
|
|
|
|
account_language = act_user_get_language (user);
|
2011-08-25 23:43:48 -04:00
|
|
|
|
|
2018-06-29 16:50:43 +12:00
|
|
|
|
lang = cc_language_chooser_get_language (CC_LANGUAGE_CHOOSER (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (lang) {
|
2018-10-16 11:23:40 +13:00
|
|
|
|
g_autofree gchar *name = NULL;
|
2015-01-16 09:11:00 +01:00
|
|
|
|
if (g_strcmp0 (lang, account_language) != 0) {
|
2012-12-04 12:48:57 -05:00
|
|
|
|
act_user_set_language (user, lang);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-10-15 12:41:51 +02:00
|
|
|
|
|
|
|
|
|
name = gnome_get_language_from_locale (lang, NULL);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_label_set_label (self->language_button_label, name);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-15 12:41:51 +02:00
|
|
|
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
change_language (CcUserPanel *self)
|
2014-10-15 12:41:51 +02:00
|
|
|
|
{
|
|
|
|
|
const gchar *current_language;
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2014-10-15 12:41:51 +02:00
|
|
|
|
current_language = act_user_get_language (user);
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (self->language_chooser) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
cc_language_chooser_clear_filter (self->language_chooser);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
cc_language_chooser_set_language (self->language_chooser, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-10-07 09:03:05 +02:00
|
|
|
|
else {
|
2018-06-29 16:50:43 +12:00
|
|
|
|
self->language_chooser = cc_language_chooser_new ();
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (self->language_chooser),
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self))));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2019-11-22 13:10:38 +13:00
|
|
|
|
g_signal_connect_object (self->language_chooser, "response",
|
|
|
|
|
G_CALLBACK (language_response), self, G_CONNECT_SWAPPED);
|
2014-10-07 09:03:05 +02:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2014-10-07 09:03:05 +02:00
|
|
|
|
if (current_language && *current_language != '\0')
|
2018-05-31 10:42:09 +12:00
|
|
|
|
cc_language_chooser_set_language (self->language_chooser, current_language);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (self->language_chooser));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
change_password (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2018-11-07 09:28:46 +13:00
|
|
|
|
CcPasswordDialog *dialog;
|
2018-11-06 15:42:06 +13:00
|
|
|
|
GtkWindow *parent;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2018-11-07 09:28:46 +13:00
|
|
|
|
dialog = cc_password_dialog_new (user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
parent = (GtkWindow *) gtk_widget_get_native (GTK_WIDGET (self));
|
2018-11-06 15:42:06 +13:00
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
change_fingerprint (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GtkWindow *parent;
|
2020-04-10 16:40:27 +02:00
|
|
|
|
CcFingerprintDialog *dialog;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
parent = (GtkWindow *) gtk_widget_get_native (GTK_WIDGET (self));
|
2011-08-25 23:43:48 -04:00
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
g_assert (g_strcmp0 (g_get_user_name (), act_user_get_user_name (user)) == 0);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-04-10 16:40:27 +02:00
|
|
|
|
dialog = cc_fingerprint_dialog_new (self->fingerprint_manager);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-22 15:18:09 +01:00
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
show_history (CcUserPanel *self)
|
2012-11-22 15:18:09 +01:00
|
|
|
|
{
|
2018-11-07 09:38:10 +13:00
|
|
|
|
CcLoginHistoryDialog *dialog;
|
2012-11-22 15:18:09 +01:00
|
|
|
|
ActUser *user;
|
2018-11-06 14:16:45 +13:00
|
|
|
|
GtkWindow *parent;
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2018-11-07 09:38:10 +13:00
|
|
|
|
dialog = cc_login_history_dialog_new (user);
|
2018-11-06 14:16:45 +13:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
parent = (GtkWindow *) gtk_widget_get_native (GTK_WIDGET (self));
|
2018-11-06 14:16:45 +13:00
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
static void
|
|
|
|
|
spawn_malcontent_control (CcUserPanel *self)
|
|
|
|
|
{
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
|
|
|
|
user = get_selected_user (self);
|
|
|
|
|
|
|
|
|
|
/* no-op if the user is administrator */
|
|
|
|
|
if (act_user_get_account_type (user) != ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR) {
|
2020-10-20 12:50:48 +01:00
|
|
|
|
const gchar *argv[] = {
|
|
|
|
|
"malcontent-control",
|
|
|
|
|
#ifdef HAVE_MALCONTENT_0_10
|
|
|
|
|
"--user",
|
|
|
|
|
act_user_get_user_name (user),
|
|
|
|
|
#endif /* HAVE_MALCONTENT_0_10 */
|
|
|
|
|
NULL
|
|
|
|
|
};
|
2021-08-26 17:20:56 +02:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
|
if (!g_spawn_async (NULL, (char **)argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error))
|
|
|
|
|
g_debug ("Couldn't launch malcontent-control: %s", error->message);
|
|
|
|
|
} else {
|
|
|
|
|
g_debug ("Not launching malcontent because selected user is an admin");
|
2020-03-26 14:20:44 +05:30
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-10-16 11:47:51 +13:00
|
|
|
|
users_loaded (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (act_user_manager_no_service (self->um)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
GtkWidget *toplevel;
|
|
|
|
|
|
|
|
|
|
toplevel = (GtkWidget *)gtk_widget_get_native (GTK_WIDGET (self));
|
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel ),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GTK_DIALOG_MODAL,
|
|
|
|
|
GTK_MESSAGE_OTHER,
|
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
|
_("Failed to contact the accounts service"));
|
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
|
_("Please make sure that the AccountService is installed and enabled."));
|
2019-11-22 13:10:38 +13:00
|
|
|
|
g_signal_connect (dialog, "response",
|
2022-01-26 10:13:58 +01:00
|
|
|
|
G_CALLBACK (gtk_window_destroy),
|
2019-11-22 13:10:38 +13:00
|
|
|
|
NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
gtk_widget_show (dialog);
|
2011-03-23 22:00:58 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_stack_set_visible_child (self->stack, self->no_users_box);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->users_overlay));
|
|
|
|
|
show_current_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-16 11:47:51 +13:00
|
|
|
|
g_signal_connect_object (self->um, "user-changed", G_CALLBACK (user_changed), self, G_CONNECT_SWAPPED);
|
|
|
|
|
g_signal_connect_object (self->um, "user-is-logged-in-changed", G_CALLBACK (user_changed), self, G_CONNECT_SWAPPED);
|
2022-02-16 12:12:34 +01:00
|
|
|
|
g_signal_connect_object (self->um, "user-added", G_CALLBACK (user_changed), self, G_CONNECT_SWAPPED);
|
2018-10-16 11:47:51 +13:00
|
|
|
|
g_signal_connect_object (self->um, "user-removed", G_CALLBACK (user_changed), self, G_CONNECT_SWAPPED);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
add_unlock_tooltip (GtkWidget *widget)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_tooltip_text (widget,
|
|
|
|
|
_("This panel must be unlocked to change this setting"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
remove_unlock_tooltip (GtkWidget *widget)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_tooltip_text (widget, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-09 09:32:00 +13:00
|
|
|
|
static guint
|
|
|
|
|
get_num_active_admin (ActUserManager *um)
|
|
|
|
|
{
|
|
|
|
|
GSList *list;
|
|
|
|
|
GSList *l;
|
|
|
|
|
guint num_admin = 0;
|
|
|
|
|
|
|
|
|
|
list = act_user_manager_list_users (um);
|
|
|
|
|
for (l = list; l != NULL; l = l->next) {
|
|
|
|
|
ActUser *u = l->data;
|
|
|
|
|
if (act_user_get_account_type (u) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR && !act_user_get_locked (u)) {
|
|
|
|
|
num_admin++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_slist_free (list);
|
|
|
|
|
|
|
|
|
|
return num_admin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
would_demote_only_admin (ActUser *user)
|
|
|
|
|
{
|
|
|
|
|
ActUserManager *um = act_user_manager_get_default ();
|
|
|
|
|
|
|
|
|
|
/* Prevent the user from demoting the only admin account.
|
|
|
|
|
* Returns TRUE when user is an administrator and there is only
|
|
|
|
|
* one enabled administrator. */
|
|
|
|
|
|
|
|
|
|
if (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_STANDARD ||
|
|
|
|
|
act_user_get_locked (user))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (get_num_active_admin (um) > 1)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-10-16 11:23:40 +13:00
|
|
|
|
on_permission_changed (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
|
|
|
|
gboolean is_authorized;
|
|
|
|
|
gboolean self_selected;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
is_authorized = g_permission_get_allowed (G_PERMISSION (self->permission));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_sensitive (self->add_user_button, is_authorized);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-05-05 08:52:09 +02:00
|
|
|
|
user = get_selected_user (self);
|
|
|
|
|
if (!user) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self_selected = act_user_get_uid (user) == geteuid ();
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->remove_user_button), is_authorized && !self_selected
|
2013-06-04 16:53:22 +01:00
|
|
|
|
&& !would_demote_only_admin (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (is_authorized) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self->remove_user_button), _("Delete the selected user account"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self->remove_user_button),
|
|
|
|
|
_("To delete the selected user account,\nclick the * icon first"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!act_user_is_local_account (user)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), FALSE);
|
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->autologin_row), FALSE);
|
2012-12-04 12:48:57 -05:00
|
|
|
|
} else if (is_authorized && act_user_is_local_account (user)) {
|
2013-06-04 16:53:22 +01:00
|
|
|
|
if (would_demote_only_admin (user)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), FALSE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
} else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), TRUE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
}
|
2013-06-04 14:51:35 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->autologin_row), get_autologin_possible (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), FALSE);
|
2013-06-04 16:53:22 +01:00
|
|
|
|
if (would_demote_only_admin (user)) {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), FALSE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
} else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->account_type_row), TRUE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
}
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_visible (GTK_WIDGET (self->autologin_row), FALSE);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->autologin_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-08-14 18:34:22 +02:00
|
|
|
|
/* The full name entry: insensitive if remote or not authorized and not self */
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!act_user_is_local_account (user)) {
|
2020-01-13 12:34:22 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->full_name_edit_button), FALSE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->full_name_stack));
|
2012-08-14 18:34:22 +02:00
|
|
|
|
|
|
|
|
|
} else if (is_authorized || self_selected) {
|
2020-01-13 12:34:22 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->full_name_edit_button), TRUE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->full_name_stack));
|
2012-08-14 18:34:22 +02:00
|
|
|
|
|
|
|
|
|
} else {
|
2020-01-13 12:34:22 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->full_name_edit_button), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->full_name_stack));
|
2012-08-14 18:34:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (is_authorized || self_selected) {
|
2020-04-14 00:51:05 +02:00
|
|
|
|
CcFingerprintState fingerprint_state = CC_FINGERPRINT_STATE_NONE;
|
|
|
|
|
|
|
|
|
|
if (self->fingerprint_manager)
|
|
|
|
|
fingerprint_state = cc_fingerprint_manager_get_state (self->fingerprint_manager);
|
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->user_avatar_edit_button), TRUE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->user_avatar_edit_button));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->language_row), TRUE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->language_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->password_row), TRUE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->password_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-04-14 00:51:05 +02:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->fingerprint_row),
|
|
|
|
|
fingerprint_state != CC_FINGERPRINT_STATE_UPDATING);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->fingerprint_row));
|
2016-12-22 11:03:10 +01:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->last_login_row), TRUE);
|
|
|
|
|
remove_unlock_tooltip (GTK_WIDGET (self->last_login_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->user_avatar_edit_button), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->user_avatar_edit_button));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->language_row), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->language_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->password_row), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->password_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->fingerprint_row), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->fingerprint_row));
|
2016-12-22 11:03:10 +01:00
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (self->last_login_row), FALSE);
|
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->last_login_row));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-09-30 11:08:08 +02:00
|
|
|
|
setup_main_window (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GError) error = NULL;
|
2013-01-29 16:40:23 -05:00
|
|
|
|
gboolean loaded;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
self->other_users_model = g_list_store_new (ACT_TYPE_USER);
|
|
|
|
|
gtk_list_box_bind_model (self->other_users_listbox,
|
|
|
|
|
G_LIST_MODEL (self->other_users_model),
|
|
|
|
|
(GtkListBoxCreateWidgetFunc)create_user_row,
|
|
|
|
|
self,
|
|
|
|
|
NULL);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
add_unlock_tooltip (GTK_WIDGET (self->user_avatar));
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->permission = (GPermission *)polkit_permission_new_sync (USER_ACCOUNTS_PERMISSION, NULL, NULL, &error);
|
|
|
|
|
if (self->permission != NULL) {
|
2018-10-16 11:23:40 +13:00
|
|
|
|
g_signal_connect_object (self->permission, "notify",
|
|
|
|
|
G_CALLBACK (on_permission_changed), self, G_CONNECT_SWAPPED);
|
|
|
|
|
on_permission_changed (self);
|
2012-08-18 18:32:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
g_warning ("Cannot create '%s' permission: %s", USER_ACCOUNTS_PERMISSION, error->message);
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2022-01-26 10:13:58 +01:00
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
g_signal_connect_object (self->parental_controls_row, "activated", G_CALLBACK (spawn_malcontent_control), self, G_CONNECT_SWAPPED);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self->remove_user_button),
|
|
|
|
|
_("To delete the selected user account,\nclick the * icon first"));
|
2013-01-29 16:40:23 -05:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_object_get (self->um, "is-loaded", &loaded, NULL);
|
2022-02-09 11:02:55 +01:00
|
|
|
|
if (loaded) {
|
2018-10-16 11:47:51 +13:00
|
|
|
|
users_loaded (self);
|
2022-02-09 11:02:55 +01:00
|
|
|
|
user_changed (self, NULL);
|
|
|
|
|
} else {
|
2018-10-16 11:47:51 +13:00
|
|
|
|
g_signal_connect_object (self->um, "notify::is-loaded", G_CALLBACK (users_loaded), self, G_CONNECT_SWAPPED);
|
2022-02-09 11:02:55 +01:00
|
|
|
|
}
|
2022-03-03 10:59:06 +01:00
|
|
|
|
|
2022-03-03 15:42:23 +01:00
|
|
|
|
self->avatar_chooser = cc_avatar_chooser_new (GTK_WIDGET (self));
|
2022-03-03 10:59:06 +01:00
|
|
|
|
gtk_menu_button_set_popover (self->user_avatar_edit_button,
|
|
|
|
|
GTK_WIDGET (self->avatar_chooser));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 15:38:07 +02:00
|
|
|
|
static GSettings *
|
|
|
|
|
settings_or_null (const gchar *schema)
|
|
|
|
|
{
|
|
|
|
|
GSettingsSchemaSource *source = NULL;
|
|
|
|
|
gchar **non_relocatable = NULL;
|
|
|
|
|
gchar **relocatable = NULL;
|
|
|
|
|
GSettings *settings = NULL;
|
|
|
|
|
|
|
|
|
|
source = g_settings_schema_source_get_default ();
|
|
|
|
|
if (!source)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
g_settings_schema_source_list_schemas (source, TRUE, &non_relocatable, &relocatable);
|
|
|
|
|
|
|
|
|
|
if (g_strv_contains ((const gchar * const *)non_relocatable, schema) ||
|
|
|
|
|
g_strv_contains ((const gchar * const *)relocatable, schema))
|
|
|
|
|
settings = g_settings_new (schema);
|
|
|
|
|
|
|
|
|
|
g_strfreev (non_relocatable);
|
|
|
|
|
g_strfreev (relocatable);
|
|
|
|
|
return settings;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-20 14:20:34 +02:00
|
|
|
|
static void
|
|
|
|
|
cc_user_panel_constructed (GObject *object)
|
|
|
|
|
{
|
2018-11-06 16:00:36 +13:00
|
|
|
|
CcUserPanel *self = CC_USER_PANEL (object);
|
2016-07-20 14:20:34 +02:00
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_user_panel_parent_class)->constructed (object);
|
|
|
|
|
|
2019-12-19 15:51:38 +01:00
|
|
|
|
cc_permission_infobar_set_permission (self->permission_infobar, self->permission);
|
2020-12-08 18:35:09 +00:00
|
|
|
|
cc_permission_infobar_set_title (self->permission_infobar, _("Unlock to Add Users and Change Settings"));
|
2016-07-20 14:20:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2012-12-11 11:46:28 +01:00
|
|
|
|
cc_user_panel_init (CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2011-02-04 15:43:40 -05:00
|
|
|
|
volatile GType type G_GNUC_UNUSED;
|
2020-11-02 11:09:17 +13:00
|
|
|
|
g_autoptr(GtkCssProvider) provider = NULL;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-11-08 10:23:00 +13:00
|
|
|
|
g_resources_register (cc_user_accounts_get_resource ());
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
/* register types that the builder might need */
|
2019-12-19 15:51:38 +01:00
|
|
|
|
type = cc_permission_infobar_get_type ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->um = act_user_manager_get_default ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2017-04-05 13:31:42 +02:00
|
|
|
|
provider = gtk_css_provider_new ();
|
|
|
|
|
gtk_css_provider_load_from_resource (provider, "/org/gnome/control-center/user-accounts/user-accounts-dialog.css");
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
|
|
|
|
GTK_STYLE_PROVIDER (provider),
|
|
|
|
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
2017-04-05 13:31:42 +02:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->login_screen_settings = settings_or_null ("org.gnome.login-screen");
|
2015-02-23 11:47:13 +01:00
|
|
|
|
|
2014-09-30 11:08:08 +02:00
|
|
|
|
setup_main_window (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-12-11 11:46:28 +01:00
|
|
|
|
cc_user_panel_dispose (GObject *object)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-11-06 16:00:36 +13:00
|
|
|
|
CcUserPanel *self = CC_USER_PANEL (object);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2020-03-26 06:41:33 +01:00
|
|
|
|
g_clear_object (&self->selected_user);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_object (&self->login_screen_settings);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
g_clear_pointer ((GtkWindow **)&self->language_chooser, gtk_window_destroy);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_object (&self->permission);
|
2021-01-08 15:08:44 +13:00
|
|
|
|
|
2012-12-11 11:46:28 +01:00
|
|
|
|
G_OBJECT_CLASS (cc_user_panel_parent_class)->dispose (object);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-18 17:08:52 +02:00
|
|
|
|
static const char *
|
2012-12-11 11:46:28 +01:00
|
|
|
|
cc_user_panel_get_help_uri (CcPanel *panel)
|
2012-05-18 17:08:52 +02:00
|
|
|
|
{
|
|
|
|
|
return "help:gnome-help/user-accounts";
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2012-12-11 11:46:28 +01:00
|
|
|
|
cc_user_panel_class_init (CcUserPanelClass *klass)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-10-16 11:23:40 +13:00
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-11 11:46:28 +01:00
|
|
|
|
object_class->dispose = cc_user_panel_dispose;
|
2016-07-20 14:20:34 +02:00
|
|
|
|
object_class->constructed = cc_user_panel_constructed;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2012-12-11 11:46:28 +01:00
|
|
|
|
panel_class->get_help_uri = cc_user_panel_get_help_uri;
|
2018-10-16 11:23:40 +13:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/user-accounts/cc-user-panel.ui");
|
|
|
|
|
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, account_settings_box);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, account_type_row);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, account_type_switch);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, add_user_button);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, autologin_row);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, autologin_switch);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, back_button);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, fingerprint_state_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, fingerprint_row);
|
2020-01-13 12:34:22 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, full_name_stack);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, full_name_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, full_name_edit_button);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, full_name_entry);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, language_button_label);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, language_row);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, last_login_button_label);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, last_login_row);
|
2019-11-20 15:14:31 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, no_users_box);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, notification_revealer);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, other_users);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, other_users_row);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, other_users_listbox);
|
2020-03-26 14:20:44 +05:30
|
|
|
|
#ifdef HAVE_MALCONTENT
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, parental_controls_button_label);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, parental_controls_row);
|
|
|
|
|
#endif
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, password_button_label);
|
2020-01-13 15:35:09 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, password_row);
|
2019-12-19 15:51:38 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, permission_infobar);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, remove_user_button);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, stack);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, user_avatar);
|
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, user_avatar_edit_button);
|
2019-11-20 15:14:31 +13:00
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, CcUserPanel, users_overlay);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, account_type_changed);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, add_user);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, autologin_changed);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, change_fingerprint);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, change_language);
|
2020-01-13 12:34:22 +01:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, full_name_edit_button_toggled);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, full_name_entry_activate);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, full_name_entry_key_press_cb);
|
2018-10-16 11:23:40 +13:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, change_password);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, delete_user);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, dismiss_notification);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, restart_now);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, set_selected_user);
|
2022-01-26 10:13:58 +01:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, show_current_user);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, show_history);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|