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"
|
|
|
|
|
|
|
|
|
|
#include "um-user-panel.h"
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/types.h>
|
2013-07-31 13:53:18 +02:00
|
|
|
|
#include <locale.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
|
|
|
|
|
2015-01-14 09:14:19 +01:00
|
|
|
|
#include "um-user-image.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
#include "um-account-dialog.h"
|
2011-08-20 02:17:06 -04:00
|
|
|
|
#include "cc-language-chooser.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
#include "um-password-dialog.h"
|
2016-11-15 14:40:54 +01:00
|
|
|
|
#include "um-carousel.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
#include "um-photo-dialog.h"
|
|
|
|
|
#include "um-fingerprint-dialog.h"
|
|
|
|
|
#include "um-utils.h"
|
2013-01-04 18:04:03 +01:00
|
|
|
|
#include "um-resources.h"
|
2012-11-22 15:18:09 +01:00
|
|
|
|
#include "um-history-dialog.h"
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2011-01-24 18:15:03 +00:00
|
|
|
|
#include "cc-common-language.h"
|
2016-02-12 23:06:59 +00:00
|
|
|
|
#include "cc-util.h"
|
2011-01-24 18:15:03 +00:00
|
|
|
|
|
2014-09-30 11:08:08 +02:00
|
|
|
|
#include "um-realm-manager.h"
|
|
|
|
|
|
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;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
GCancellable *cancellable;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GtkBuilder *builder;
|
2013-07-31 13:53:18 +02:00
|
|
|
|
GtkWidget *notification;
|
2015-02-23 11:47:13 +01:00
|
|
|
|
GSettings *login_screen_settings;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-07-20 14:20:34 +02:00
|
|
|
|
GtkWidget *headerbar_buttons;
|
2017-02-22 12:18:24 +01:00
|
|
|
|
GtkWidget *stack;
|
2011-01-24 19:34:02 -05:00
|
|
|
|
GtkWidget *main_box;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
UmCarousel *carousel;
|
|
|
|
|
ActUser *selected_user;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
GPermission *permission;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GtkWidget *language_chooser;
|
|
|
|
|
|
|
|
|
|
UmPasswordDialog *password_dialog;
|
|
|
|
|
UmPhotoDialog *photo_dialog;
|
2012-11-22 15:18:09 +01:00
|
|
|
|
UmHistoryDialog *history_dialog;
|
2013-03-21 15:15:16 +01:00
|
|
|
|
|
|
|
|
|
gint other_accounts;
|
2013-04-18 17:49:03 +02:00
|
|
|
|
|
|
|
|
|
UmAccountDialog *account_dialog;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
};
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CC_PANEL_REGISTER (CcUserPanel, cc_user_panel)
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static GtkWidget *
|
2018-05-31 10:42:09 +12:00
|
|
|
|
get_widget (CcUserPanel *self, const char *name)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
return (GtkWidget *)gtk_builder_get_object (self->builder, name);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-22 12:18:24 +01:00
|
|
|
|
/* Headerbar button states. */
|
2016-07-20 14:20:34 +02:00
|
|
|
|
#define PAGE_LOCK "_lock"
|
|
|
|
|
#define PAGE_ADDUSER "_adduser"
|
|
|
|
|
|
2017-02-22 12:18:24 +01:00
|
|
|
|
/* Panel states */
|
|
|
|
|
#define PAGE_NO_USERS "_empty_state"
|
|
|
|
|
#define PAGE_USERS "_users"
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
static void show_restart_notification (CcUserPanel *self, const gchar *locale);
|
2017-02-13 09:16:59 +01:00
|
|
|
|
static gint user_compare (gconstpointer i, gconstpointer u);
|
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)
|
|
|
|
|
{
|
|
|
|
|
g_object_unref (data->self);
|
|
|
|
|
g_object_unref (data->cancellable);
|
|
|
|
|
g_free (data->login);
|
|
|
|
|
g_slice_free (AsyncDeleteData, data);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2013-01-05 16:54:17 -05:00
|
|
|
|
static const gchar *
|
|
|
|
|
get_real_or_user_name (ActUser *user)
|
|
|
|
|
{
|
|
|
|
|
const gchar *name;
|
|
|
|
|
|
|
|
|
|
name = act_user_get_real_name (user);
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
name = act_user_get_user_name (user);
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
static void show_user (ActUser *user, CcUserPanel *self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
set_selected_user (UmCarousel *carousel, UmCarouselItem *item, CcUserPanel *self)
|
2011-05-11 17:25:03 +01:00
|
|
|
|
{
|
2016-11-15 14:40:54 +01:00
|
|
|
|
uid_t uid;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_object (&self->selected_user);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
|
|
|
|
uid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "uid"));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->selected_user = act_user_manager_get_user_by_id (self->um, uid);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (self->selected_user != NULL) {
|
|
|
|
|
show_user (self->selected_user, self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
2011-05-11 17:25:03 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
static GtkWidget *
|
2018-05-31 10:42:09 +12:00
|
|
|
|
create_carousel_entry (CcUserPanel *self, ActUser *user)
|
2016-11-15 14:40:54 +01:00
|
|
|
|
{
|
|
|
|
|
GtkWidget *box, *widget;
|
2016-12-18 14:33:32 +01:00
|
|
|
|
gchar *label;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2016-12-18 14:39:04 +01:00
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
|
|
|
|
widget = um_user_image_new ();
|
|
|
|
|
um_user_image_set_user (UM_USER_IMAGE (widget), user);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
|
|
|
|
|
|
2016-12-18 14:33:32 +01:00
|
|
|
|
label = g_strdup_printf ("<b>%s</b>",
|
|
|
|
|
get_real_or_user_name (user));
|
|
|
|
|
widget = gtk_label_new (label);
|
|
|
|
|
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
|
2016-12-18 14:39:04 +01:00
|
|
|
|
gtk_widget_set_margin_top (widget, 5);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
|
2016-12-18 14:33:32 +01:00
|
|
|
|
g_free (label);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2016-12-18 14:39:04 +01:00
|
|
|
|
if (act_user_get_uid (user) == getuid ())
|
2017-02-24 17:12:10 +01:00
|
|
|
|
label = g_strdup_printf ("<small>%s</small>", _("Your account"));
|
2016-12-18 14:39:04 +01:00
|
|
|
|
else
|
|
|
|
|
label = g_strdup (" ");
|
|
|
|
|
|
|
|
|
|
widget = gtk_label_new (label);
|
|
|
|
|
gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
|
|
|
|
|
g_free (label);
|
|
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (box), widget, FALSE, TRUE, 0);
|
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (widget),
|
|
|
|
|
"dim-label");
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
return box;
|
|
|
|
|
}
|
2016-07-21 16:10:35 +02:00
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user_added (ActUserManager *um, ActUser *user, CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2016-11-15 14:40:54 +01:00
|
|
|
|
GtkWidget *item, *widget;
|
|
|
|
|
gboolean show_carousel;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2013-06-25 16:07:51 +02:00
|
|
|
|
if (act_user_is_system_account (user)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-05 16:54:17 -05:00
|
|
|
|
g_debug ("user added: %d %s\n", act_user_get_uid (user), get_real_or_user_name (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = create_carousel_entry (self, user);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
item = um_carousel_item_new ();
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (item), widget);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
g_object_set_data (G_OBJECT (item), "uid", GINT_TO_POINTER (act_user_get_uid (user)));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (self->carousel), item);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
|
|
|
|
if (act_user_get_uid (user) != getuid ()) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->other_accounts++;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
/* Show heading for other accounts if new one have been added. */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_carousel = (self->other_accounts > 0);
|
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->carousel), show_carousel);
|
2017-12-05 16:22:29 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (self->stack), PAGE_USERS);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
sort_users (gconstpointer a, gconstpointer b)
|
|
|
|
|
{
|
|
|
|
|
ActUser *ua, *ub;
|
|
|
|
|
gchar *name1, *name2;
|
|
|
|
|
gint result;
|
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 ()) {
|
|
|
|
|
result = -G_MAXINT32;
|
|
|
|
|
}
|
|
|
|
|
else if (act_user_get_uid (ub) == getuid ()) {
|
|
|
|
|
result = G_MAXINT32;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2016-11-15 14:40:54 +01:00
|
|
|
|
else {
|
|
|
|
|
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
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
result = strcmp (name1, name2);
|
|
|
|
|
|
|
|
|
|
g_free (name1);
|
|
|
|
|
g_free (name2);
|
2013-03-21 15:15:16 +01:00
|
|
|
|
}
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
|
|
|
|
return result;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
reload_users (CcUserPanel *self, ActUser *selected_user)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
GSList *list, *l;
|
2017-12-05 16:22:29 +01:00
|
|
|
|
UmCarouselItem *item = NULL;
|
2017-02-13 09:16:59 +01:00
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
gboolean animations;
|
|
|
|
|
|
|
|
|
|
settings = gtk_settings_get_default ();
|
|
|
|
|
|
|
|
|
|
g_object_get (settings, "gtk-enable-animations", &animations, NULL);
|
|
|
|
|
g_object_set (settings, "gtk-enable-animations", FALSE, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_carousel_purge_items (self->carousel);
|
|
|
|
|
self->other_accounts = 0;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
list = act_user_manager_list_users (self->um);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
g_debug ("Got %d users\n", g_slist_length (list));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
list = g_slist_sort (list, (GCompareFunc) sort_users);
|
|
|
|
|
for (l = list; l; l = l->next) {
|
|
|
|
|
user = l->data;
|
|
|
|
|
g_debug ("adding user %s\n", get_real_or_user_name (user));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user_added (self->um, user, self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
}
|
|
|
|
|
g_slist_free (list);
|
2017-02-13 09:16:59 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (um_carousel_get_item_count (self->carousel) == 0)
|
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (self->stack), PAGE_NO_USERS);
|
|
|
|
|
if (self->other_accounts == 0)
|
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->carousel), FALSE);
|
2017-12-05 16:22:29 +01:00
|
|
|
|
|
|
|
|
|
if (selected_user)
|
2018-05-31 10:42:09 +12:00
|
|
|
|
item = um_carousel_find_item (self->carousel, selected_user, user_compare);
|
|
|
|
|
um_carousel_select_item (self->carousel, item);
|
2017-02-13 09:16:59 +01:00
|
|
|
|
|
|
|
|
|
g_object_set (settings, "gtk-enable-animations", animations, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
static gint
|
|
|
|
|
user_compare (gconstpointer i,
|
|
|
|
|
gconstpointer u)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2016-11-15 14:40:54 +01:00
|
|
|
|
UmCarouselItem *item;
|
|
|
|
|
ActUser *user;
|
|
|
|
|
gint uid_a, uid_b;
|
|
|
|
|
gint result;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
item = (UmCarouselItem *) i;
|
|
|
|
|
user = ACT_USER (u);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
uid_a = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "uid"));
|
|
|
|
|
uid_b = act_user_get_uid (user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
result = uid_a - uid_b;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-11-15 14:40:54 +01:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user_changed (ActUserManager *um, ActUser *user, CcUserPanel *self)
|
2016-11-15 14:40:54 +01:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
reload_users (self, self->selected_user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2012-06-06 22:51:19 +02:00
|
|
|
|
select_created_user (GObject *object,
|
|
|
|
|
GAsyncResult *result,
|
|
|
|
|
gpointer user_data)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = user_data;
|
2012-08-14 17:04:41 +02:00
|
|
|
|
UmAccountDialog *dialog;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2012-06-06 22:51:19 +02:00
|
|
|
|
|
2012-08-14 17:04:41 +02:00
|
|
|
|
dialog = UM_ACCOUNT_DIALOG (object);
|
|
|
|
|
user = um_account_dialog_finish (dialog, result);
|
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->account_dialog = NULL;
|
2012-08-14 17:04:41 +02:00
|
|
|
|
|
2012-06-06 22:51:19 +02:00
|
|
|
|
if (user == NULL)
|
|
|
|
|
return;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
reload_users (self, user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
add_user (GtkButton *button, CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->account_dialog = um_account_dialog_new ();
|
|
|
|
|
um_account_dialog_show (self->account_dialog, GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
|
|
|
|
self->permission, select_created_user, self);
|
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
|
|
|
|
{
|
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
|
|
error = NULL;
|
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
|
|
|
|
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
delete_user_response (GtkWidget *dialog,
|
|
|
|
|
gint response_id,
|
|
|
|
|
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
|
|
|
|
gboolean remove_files;
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
AsyncDeleteData *data = user_data;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data->self;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
UmRealmCommon *common = UM_REALM_COMMON (source);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
um_realm_common_call_change_login_policy_finish (common, result, &error);
|
|
|
|
|
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
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static UmRealmCommon *
|
|
|
|
|
find_matching_realm (UmRealmManager *realm_manager, const gchar *login)
|
|
|
|
|
{
|
|
|
|
|
UmRealmCommon *common = NULL;
|
|
|
|
|
GList *realms, *l;
|
|
|
|
|
|
|
|
|
|
realms = um_realm_manager_get_realms (realm_manager);
|
|
|
|
|
for (l = realms; l != NULL; l = g_list_next (l)) {
|
|
|
|
|
const gchar * const *permitted_logins;
|
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
|
|
common = um_realm_object_get_common (l->data);
|
2015-02-25 14:31:28 +01:00
|
|
|
|
if (common == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
2014-09-30 11:08:08 +02:00
|
|
|
|
permitted_logins = um_realm_common_get_permitted_logins (common);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
AsyncDeleteData *data = user_data;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data->self;
|
2014-09-30 11:08:08 +02:00
|
|
|
|
UmRealmCommon *common;
|
|
|
|
|
UmRealmManager *realm_manager;
|
|
|
|
|
const gchar *add[1];
|
|
|
|
|
const gchar *remove[2];
|
|
|
|
|
GVariant *options;
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
realm_manager = um_realm_manager_new_finish (result, &error);
|
|
|
|
|
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
|
|
|
|
g_error_free (error);
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find matching realm */
|
|
|
|
|
common = find_matching_realm (realm_manager, data->login);
|
|
|
|
|
if (common == NULL) {
|
|
|
|
|
/* The realm was probably left */
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
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);
|
|
|
|
|
um_realm_common_call_change_login_policy (common, "",
|
|
|
|
|
add, remove, options,
|
|
|
|
|
data->cancellable,
|
|
|
|
|
enterprise_user_revoked,
|
|
|
|
|
data);
|
|
|
|
|
|
|
|
|
|
g_object_unref (common);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
enterprise_user_uncached (GObject *source,
|
|
|
|
|
GAsyncResult *res,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
|
|
if (g_cancellable_is_cancelled (data->cancellable)) {
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
act_user_manager_uncache_user_finish (manager, res, &error);
|
|
|
|
|
if (error == NULL) {
|
|
|
|
|
/* Find realm manager */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_realm_manager_new (self->cancellable, realm_manager_found, 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
|
|
|
|
g_error_free (error);
|
|
|
|
|
async_delete_data_free (data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
delete_enterprise_user_response (GtkWidget *dialog,
|
|
|
|
|
gint response_id,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
CcUserPanel *self = UM_USER_PANEL (user_data);
|
|
|
|
|
AsyncDeleteData *data;
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
|
|
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);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
data->cancellable = g_object_ref (self->cancellable);
|
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
|
|
|
|
|
delete_user (GtkButton *button, 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 ()) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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",
|
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
|
}
|
2014-01-10 12:52:37 -05:00
|
|
|
|
else if (act_user_is_logged_in_anywhere (user)) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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",
|
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
|
}
|
2014-09-30 11:08:08 +02:00
|
|
|
|
else if (act_user_is_local_account (user)) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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");
|
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response",
|
2018-05-31 10:42:09 +12:00
|
|
|
|
G_CALLBACK (delete_user_response), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2014-09-30 11:08:08 +02:00
|
|
|
|
else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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");
|
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
|
G_CALLBACK (delete_enterprise_user_response), self);
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
g_signal_connect (dialog, "close",
|
|
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
|
|
|
|
|
|
|
|
|
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-05-31 10:42:09 +12:00
|
|
|
|
autologin_changed (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
active = gtk_switch_get_active (GTK_SWITCH (object));
|
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
|
|
|
|
{
|
|
|
|
|
gchar *text, *date_str, *time_str;
|
|
|
|
|
GDateTime *date_time;
|
|
|
|
|
gint64 time;
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
time = act_user_get_login_time (user);
|
|
|
|
|
if (act_user_is_logged_in (user)) {
|
2012-11-22 15:14:13 +01:00
|
|
|
|
text = g_strdup (_("Logged in"));
|
|
|
|
|
}
|
|
|
|
|
else if (time > 0) {
|
|
|
|
|
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);
|
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. */
|
|
|
|
|
text = g_strdup_printf(C_("login date-time", "%s, %s"), date_str, time_str);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
|
|
|
|
|
g_date_time_unref (date_time);
|
|
|
|
|
g_free (date_str);
|
|
|
|
|
g_free (time_str);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
text = g_strdup ("—");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-02 13:31:51 -03:00
|
|
|
|
static void on_permission_changed (GPermission *permission, GParamSpec *pspec, gpointer data);
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
GtkWidget *image;
|
|
|
|
|
GtkWidget *label;
|
2016-07-21 16:10:35 +02:00
|
|
|
|
gchar *lang, *text, *name;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GtkWidget *widget;
|
2012-09-17 12:33:51 +01:00
|
|
|
|
gboolean show, enable;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *current;
|
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
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
image = get_widget (self, "user-icon-image");
|
2015-01-14 09:14:19 +01:00
|
|
|
|
um_user_image_set_user (UM_USER_IMAGE (image), user);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
image = get_widget (self, "user-icon-image2");
|
2015-01-14 09:14:19 +01:00
|
|
|
|
um_user_image_set_user (UM_USER_IMAGE (image), user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_photo_dialog_set_user (self->photo_dialog, user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "full-name-entry");
|
2016-07-20 11:26:56 +02:00
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (widget), act_user_get_real_name (user));
|
2012-12-04 12:48:57 -05:00
|
|
|
|
gtk_widget_set_tooltip_text (widget, act_user_get_user_name (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, act_user_get_account_type (user) ? "account-type-admin" : "account-type-standard");
|
2016-05-31 12:00:47 +02:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
|
|
|
|
|
2016-07-21 16:10:35 +02:00
|
|
|
|
/* Do not show the "Account Type" option when there's a single user account. */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show = (self->other_accounts != 0);
|
|
|
|
|
gtk_widget_set_visible (get_widget (self, "account-type-label"), show);
|
|
|
|
|
gtk_widget_set_visible (get_widget (self, "account-type-box"), show);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "account-password-button-label");
|
2016-07-20 10:28:06 +02:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (widget), get_password_mode_text (user));
|
2012-12-04 12:48:57 -05:00
|
|
|
|
enable = act_user_is_local_account (user);
|
2012-09-17 12:33:51 +01:00
|
|
|
|
gtk_widget_set_sensitive (widget, enable);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "autologin-switch");
|
|
|
|
|
g_signal_handlers_block_by_func (widget, autologin_changed, self);
|
2012-12-04 12:48:57 -05:00
|
|
|
|
gtk_switch_set_active (GTK_SWITCH (widget), act_user_get_automatic_login (user));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_signal_handlers_unblock_by_func (widget, autologin_changed, self);
|
2013-06-04 14:51:35 +01:00
|
|
|
|
gtk_widget_set_sensitive (widget, get_autologin_possible (user));
|
2011-08-25 12:41:18 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "account-language-button-label");
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2014-10-15 12:41:51 +02:00
|
|
|
|
name = NULL;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
lang = g_strdup (act_user_get_language (user));
|
2014-09-24 12:07:48 +02:00
|
|
|
|
if ((!lang || *lang == '\0') && act_user_get_uid (user) == getuid ()) {
|
2011-01-24 18:26:00 +00:00
|
|
|
|
lang = cc_common_language_get_current_language ();
|
2014-09-24 12:07:48 +02:00
|
|
|
|
act_user_set_language (user, lang);
|
|
|
|
|
}
|
2014-05-30 13:02:00 +02:00
|
|
|
|
|
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
|
|
|
|
}
|
2016-07-20 10:28:06 +02:00
|
|
|
|
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (widget), name);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
g_free (lang);
|
2014-10-15 12:41:51 +02:00
|
|
|
|
g_free (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 */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "account-fingerprint-button");
|
|
|
|
|
label = get_widget (self, "account-fingerprint-label");
|
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 &&
|
|
|
|
|
g_settings_get_boolean (self->login_screen_settings, "enable-fingerprint-authentication")) &&
|
2014-08-28 09:47:41 +02:00
|
|
|
|
set_fingerprint_label (widget));
|
2012-08-14 18:34:22 +02:00
|
|
|
|
gtk_widget_set_visible (label, show);
|
|
|
|
|
gtk_widget_set_visible (widget, show);
|
|
|
|
|
|
|
|
|
|
/* Autologin: show when local account */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "autologin-box");
|
|
|
|
|
label = get_widget (self, "autologin-label");
|
2012-12-04 12:48:57 -05:00
|
|
|
|
show = act_user_is_local_account (user);
|
2012-08-14 18:34:22 +02:00
|
|
|
|
gtk_widget_set_visible (widget, show);
|
|
|
|
|
gtk_widget_set_visible (label, show);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
|
2016-06-13 14:27:30 +02:00
|
|
|
|
/* Language: do not show for current user */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "account-language-button");
|
|
|
|
|
label = get_widget (self, "language-label");
|
2016-06-13 14:27:30 +02:00
|
|
|
|
show = act_user_get_uid (user) != getuid();
|
|
|
|
|
gtk_widget_set_visible (widget, show);
|
|
|
|
|
gtk_widget_set_visible (label, show);
|
|
|
|
|
|
2012-11-22 15:14:13 +01:00
|
|
|
|
/* Last login: show when administrator or current user */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "last-login-button");
|
|
|
|
|
label = get_widget (self, "last-login-button-label");
|
2012-11-22 15:14:13 +01:00
|
|
|
|
|
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) {
|
|
|
|
|
text = get_login_time_text (user);
|
2016-07-15 13:04:51 +02:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (label), text);
|
2012-11-22 15:14:13 +01:00
|
|
|
|
g_free (text);
|
|
|
|
|
}
|
2018-05-31 10:42:09 +12:00
|
|
|
|
label = get_widget (self, "last-login-label");
|
2012-11-22 15:14:13 +01:00
|
|
|
|
gtk_widget_set_visible (widget, show);
|
|
|
|
|
gtk_widget_set_visible (label, show);
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
|
|
|
|
enable = act_user_get_login_history (user) != NULL;
|
|
|
|
|
gtk_widget_set_sensitive (widget, enable);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (self->permission != NULL)
|
|
|
|
|
on_permission_changed (self->permission, NULL, self);
|
2013-08-02 13:31:51 -03:00
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
change_name_done (GtkWidget *entry,
|
|
|
|
|
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);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2016-07-20 11:26:56 +02:00
|
|
|
|
text = gtk_entry_get_text (GTK_ENTRY (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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-20 11:26:56 +02:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
change_name_focus_out (GtkWidget *entry,
|
|
|
|
|
GdkEvent *event,
|
|
|
|
|
CcUserPanel *self)
|
2016-07-20 11:26:56 +02:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
change_name_done (entry, self);
|
2016-07-20 11:26:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2016-05-31 12:00:47 +02:00
|
|
|
|
account_type_changed (GtkToggleButton *button,
|
2018-05-31 10:42:09 +12:00
|
|
|
|
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
|
|
|
|
gint account_type;
|
2014-09-17 14:35:46 +02:00
|
|
|
|
gboolean self_selected;
|
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 ();
|
2011-08-25 23:43:48 -04:00
|
|
|
|
|
2016-05-31 12:00:47 +02:00
|
|
|
|
account_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
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-05-31 10:42:09 +12:00
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification), 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
|
|
|
|
{
|
|
|
|
|
GDBusConnection *bus;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification), 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);
|
|
|
|
|
g_object_unref (bus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
|
gchar *current_locale;
|
|
|
|
|
|
|
|
|
|
if (locale) {
|
|
|
|
|
current_locale = g_strdup (setlocale (LC_MESSAGES, NULL));
|
|
|
|
|
setlocale (LC_MESSAGES, locale);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification), TRUE);
|
2013-07-31 13:53:18 +02:00
|
|
|
|
|
|
|
|
|
if (locale) {
|
|
|
|
|
setlocale (LC_MESSAGES, current_locale);
|
|
|
|
|
g_free (current_locale);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
language_response (GtkDialog *dialog,
|
|
|
|
|
gint response_id,
|
|
|
|
|
CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2014-10-15 12:41:51 +02:00
|
|
|
|
GtkWidget *button;
|
2012-12-04 12:48:57 -05:00
|
|
|
|
ActUser *user;
|
2015-01-16 09:11:00 +01:00
|
|
|
|
const gchar *lang, *account_language;
|
2014-10-15 12:41:51 +02:00
|
|
|
|
gchar *name = NULL;
|
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
|
|
|
|
|
2014-10-15 12:41:51 +02:00
|
|
|
|
lang = cc_language_chooser_get_language (GTK_WIDGET (dialog));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (lang) {
|
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
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "account-language-button-label");
|
2014-10-15 12:41:51 +02:00
|
|
|
|
name = gnome_get_language_from_locale (lang, NULL);
|
2016-07-20 10:28:06 +02:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (button), name);
|
2014-10-15 12:41:51 +02:00
|
|
|
|
g_free (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-05-31 10:42:09 +12:00
|
|
|
|
change_language (GtkButton *button,
|
|
|
|
|
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) {
|
|
|
|
|
cc_language_chooser_clear_filter (self->language_chooser);
|
|
|
|
|
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-05-31 10:42:09 +12:00
|
|
|
|
self->language_chooser = cc_language_chooser_new (gtk_widget_get_toplevel (self->main_box));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_signal_connect (self->language_chooser, "response",
|
|
|
|
|
G_CALLBACK (language_response), self);
|
|
|
|
|
g_signal_connect (self->language_chooser, "delete-event",
|
2014-10-07 09:03:05 +02:00
|
|
|
|
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
|
2011-08-20 02:17:06 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (gtk_widget_get_toplevel (self->main_box)), NULL);
|
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-05-31 10:42:09 +12:00
|
|
|
|
change_password (GtkButton *button, 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
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_password_dialog_set_user (self->password_dialog, user);
|
|
|
|
|
um_password_dialog_show (self->password_dialog,
|
|
|
|
|
GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
change_fingerprint (GtkButton *button, CcUserPanel *self)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2014-08-28 09:47:41 +02:00
|
|
|
|
GtkWidget *widget;
|
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);
|
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
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "account-fingerprint-button");
|
|
|
|
|
fingerprint_button_clicked (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)), widget, user);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-22 15:18:09 +01:00
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
show_history (GtkButton *button, CcUserPanel *self)
|
2012-11-22 15:18:09 +01:00
|
|
|
|
{
|
|
|
|
|
ActUser *user;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2012-11-22 15:18:09 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_history_dialog_set_user (self->history_dialog, user);
|
|
|
|
|
um_history_dialog_show (self->history_dialog, GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-05-31 10:42:09 +12:00
|
|
|
|
users_loaded (ActUserManager *manager,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
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)) {
|
|
|
|
|
dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (self->main_box)),
|
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."));
|
2011-03-23 22:00:58 -04:00
|
|
|
|
g_signal_connect_swapped (dialog, "response",
|
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
|
dialog);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
gtk_widget_show (dialog);
|
2011-03-23 22:00:58 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (self->main_box, FALSE);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_signal_connect (self->um, "user-changed", G_CALLBACK (user_changed), self);
|
|
|
|
|
g_signal_connect (self->um, "user-is-logged-in-changed", G_CALLBACK (user_changed), self);
|
|
|
|
|
g_signal_connect (self->um, "user-added", G_CALLBACK (user_added), self);
|
|
|
|
|
g_signal_connect (self->um, "user-removed", G_CALLBACK (user_changed), self);
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
reload_users (self, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_unlock_tooltip (GtkWidget *button)
|
|
|
|
|
{
|
2010-11-15 14:02:27 -05:00
|
|
|
|
gchar *names[3];
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GIcon *icon;
|
|
|
|
|
|
2011-10-25 17:56:03 +01:00
|
|
|
|
names[0] = "changes-allow-symbolic";
|
|
|
|
|
names[1] = "changes-allow";
|
2010-10-30 16:14:30 -04:00
|
|
|
|
names[2] = NULL;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
setup_tooltip_with_embedded_icon (button,
|
2017-01-27 23:02:44 +01:00
|
|
|
|
/* Translator comments:
|
|
|
|
|
* We split the line in 2 here to "make it look good", as there's
|
|
|
|
|
* no good way to do this in GTK+ for tooltips. See:
|
|
|
|
|
* https://bugzilla.gnome.org/show_bug.cgi?id=657168 */
|
2010-10-30 16:14:30 -04:00
|
|
|
|
_("To make changes,\nclick the * icon first"),
|
|
|
|
|
"*",
|
|
|
|
|
icon);
|
|
|
|
|
g_object_unref (icon);
|
|
|
|
|
g_signal_connect (button, "button-release-event",
|
|
|
|
|
G_CALLBACK (show_tooltip_now), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
remove_unlock_tooltip (GtkWidget *button)
|
|
|
|
|
{
|
|
|
|
|
setup_tooltip_with_embedded_icon (button, NULL, NULL, NULL);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (button,
|
|
|
|
|
G_CALLBACK (show_tooltip_now), NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-11-15 14:02:27 -05:00
|
|
|
|
on_permission_changed (GPermission *permission,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer data)
|
2010-10-30 16:14:30 -04:00
|
|
|
|
{
|
2018-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = data;
|
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
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
user = get_selected_user (self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (!user) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
is_authorized = g_permission_get_allowed (G_PERMISSION (self->permission));
|
2012-12-04 12:48:57 -05:00
|
|
|
|
self_selected = act_user_get_uid (user) == geteuid ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_stack_set_visible_child_name (GTK_STACK (self->headerbar_buttons), is_authorized ? PAGE_ADDUSER : PAGE_LOCK);
|
2016-07-20 14:20:34 +02:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "add-user-toolbutton");
|
2010-10-30 16:14:30 -04:00
|
|
|
|
gtk_widget_set_sensitive (widget, is_authorized);
|
|
|
|
|
if (is_authorized) {
|
2011-10-25 17:56:44 +01:00
|
|
|
|
setup_tooltip_with_embedded_icon (widget, _("Create a user account"), NULL, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2010-11-15 14:02:27 -05:00
|
|
|
|
gchar *names[3];
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GIcon *icon;
|
|
|
|
|
|
2011-10-25 17:56:03 +01:00
|
|
|
|
names[0] = "changes-allow-symbolic";
|
|
|
|
|
names[1] = "changes-allow";
|
2010-10-30 16:14:30 -04:00
|
|
|
|
names[2] = NULL;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
setup_tooltip_with_embedded_icon (widget,
|
2011-10-25 17:56:44 +01:00
|
|
|
|
_("To create a user account,\nclick the * icon first"),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
"*",
|
|
|
|
|
icon);
|
|
|
|
|
g_object_unref (icon);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "remove-user-toolbutton");
|
2013-06-04 16:53:22 +01:00
|
|
|
|
gtk_widget_set_sensitive (widget, is_authorized && !self_selected
|
|
|
|
|
&& !would_demote_only_admin (user));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (is_authorized) {
|
2011-10-25 17:56:44 +01:00
|
|
|
|
setup_tooltip_with_embedded_icon (widget, _("Delete the selected user account"), NULL, NULL);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2010-11-15 14:02:27 -05:00
|
|
|
|
gchar *names[3];
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GIcon *icon;
|
|
|
|
|
|
2011-10-25 17:56:03 +01:00
|
|
|
|
names[0] = "changes-allow-symbolic";
|
|
|
|
|
names[1] = "changes-allow";
|
2010-10-30 16:14:30 -04:00
|
|
|
|
names[2] = NULL;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
setup_tooltip_with_embedded_icon (widget,
|
2011-10-25 17:56:44 +01:00
|
|
|
|
_("To delete the selected user account,\nclick the * icon first"),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
"*",
|
|
|
|
|
icon);
|
|
|
|
|
g_object_unref (icon);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!act_user_is_local_account (user)) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-type-box"), FALSE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-type-box"));
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (self, "autologin-switch")), FALSE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "autologin-switch"));
|
2012-08-14 18:34:22 +02:00
|
|
|
|
|
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)) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-type-box"), FALSE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
} else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-type-box"), TRUE);
|
2013-05-29 17:16:47 -07:00
|
|
|
|
}
|
2018-05-31 10:42:09 +12:00
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-type-box"));
|
2013-06-04 14:51:35 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (self, "autologin-switch")), get_autologin_possible (user));
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "autologin-switch"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-type-box"), FALSE);
|
2013-06-04 16:53:22 +01:00
|
|
|
|
if (would_demote_only_admin (user)) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-type-box"));
|
2013-05-29 17:16:47 -07:00
|
|
|
|
} else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
add_unlock_tooltip (get_widget (self, "account-type-box"));
|
2013-05-29 17:16:47 -07:00
|
|
|
|
}
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (self, "autologin-switch")), FALSE);
|
|
|
|
|
add_unlock_tooltip (get_widget (self, "autologin-switch"));
|
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 */
|
2018-05-31 10:42:09 +12:00
|
|
|
|
widget = get_widget (self, "full-name-entry");
|
2012-12-04 12:48:57 -05:00
|
|
|
|
if (!act_user_is_local_account (user)) {
|
2016-07-20 11:26:56 +02:00
|
|
|
|
gtk_widget_set_sensitive (widget, FALSE);
|
2012-08-14 18:34:22 +02:00
|
|
|
|
remove_unlock_tooltip (widget);
|
|
|
|
|
|
|
|
|
|
} else if (is_authorized || self_selected) {
|
2016-07-20 11:26:56 +02:00
|
|
|
|
gtk_widget_set_sensitive (widget, TRUE);
|
2012-08-14 18:34:22 +02:00
|
|
|
|
remove_unlock_tooltip (widget);
|
|
|
|
|
|
|
|
|
|
} else {
|
2016-07-20 11:26:56 +02:00
|
|
|
|
gtk_widget_set_sensitive (widget, FALSE);
|
2012-08-14 18:34:22 +02:00
|
|
|
|
add_unlock_tooltip (widget);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 16:14:30 -04:00
|
|
|
|
if (is_authorized || self_selected) {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_stack_set_visible_child (GTK_STACK (get_widget (self, "user-icon")),
|
|
|
|
|
get_widget (self, "user-icon-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-language-button"), TRUE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-language-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-password-button"), TRUE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-password-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-fingerprint-button"), TRUE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "account-fingerprint-button"));
|
2016-12-22 11:03:10 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "last-login-button"), TRUE);
|
|
|
|
|
remove_unlock_tooltip (get_widget (self, "last-login-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_stack_set_visible_child (GTK_STACK (get_widget (self, "user-icon")),
|
|
|
|
|
get_widget (self, "user-icon-image"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-language-button"), FALSE);
|
|
|
|
|
add_unlock_tooltip (get_widget (self, "account-language-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-password-button"), FALSE);
|
|
|
|
|
add_unlock_tooltip (get_widget (self, "account-password-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "account-fingerprint-button"), FALSE);
|
|
|
|
|
add_unlock_tooltip (get_widget (self, "account-fingerprint-button"));
|
2016-12-22 11:03:10 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
gtk_widget_set_sensitive (get_widget (self, "last-login-button"), FALSE);
|
|
|
|
|
add_unlock_tooltip (get_widget (self, "last-login-button"));
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
um_password_dialog_set_user (self->password_dialog, user);
|
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
|
|
|
|
{
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
GIcon *icon;
|
2012-08-18 18:32:34 +01:00
|
|
|
|
GError *error = NULL;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
gchar *names[3];
|
2013-01-29 16:40:23 -05:00
|
|
|
|
gboolean loaded;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->notification = get_widget (self, "notification");
|
2016-11-27 16:37:45 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "restart-button");
|
|
|
|
|
g_signal_connect_swapped (button, "clicked", G_CALLBACK (restart_now), self);
|
2016-11-27 16:37:45 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "dismiss-button");
|
|
|
|
|
g_signal_connect_swapped (button, "clicked", G_CALLBACK (dismiss_notification), self);
|
2016-11-27 16:37:45 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->other_accounts = 0;
|
2016-11-15 14:40:54 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->carousel = UM_CAROUSEL (get_widget (self, "carousel"));
|
|
|
|
|
g_signal_connect (self->carousel, "item-activated", G_CALLBACK (set_selected_user), self);
|
2012-03-08 17:13:50 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "add-user-toolbutton");
|
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (add_user), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "remove-user-toolbutton");
|
2014-09-30 11:08:08 +02:00
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (delete_user), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "user-icon-image");
|
2010-10-30 16:14:30 -04:00
|
|
|
|
add_unlock_tooltip (button);
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "full-name-entry");
|
|
|
|
|
g_signal_connect (button, "activate", G_CALLBACK (change_name_done), self);
|
|
|
|
|
g_signal_connect (button, "focus-out-event", G_CALLBACK (change_name_focus_out), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "account-type-standard");
|
|
|
|
|
g_signal_connect (button, "toggled", G_CALLBACK (account_type_changed), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "account-password-button");
|
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (change_password), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "account-language-button");
|
|
|
|
|
g_signal_connect (button, "clicked", G_CALLBACK (change_language), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "autologin-switch");
|
|
|
|
|
g_signal_connect (button, "notify::active", G_CALLBACK (autologin_changed), self);
|
2011-01-24 20:23:01 -05:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "account-fingerprint-button");
|
2016-07-20 10:28:06 +02:00
|
|
|
|
g_signal_connect (button, "clicked",
|
2018-05-31 10:42:09 +12:00
|
|
|
|
G_CALLBACK (change_fingerprint), self);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "last-login-button");
|
2012-11-22 15:18:09 +01:00
|
|
|
|
g_signal_connect (button, "clicked",
|
2018-05-31 10:42:09 +12:00
|
|
|
|
G_CALLBACK (show_history), self);
|
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) {
|
|
|
|
|
g_signal_connect (self->permission, "notify",
|
|
|
|
|
G_CALLBACK (on_permission_changed), self);
|
|
|
|
|
on_permission_changed (self->permission, NULL, self);
|
2012-08-18 18:32:34 +01:00
|
|
|
|
} else {
|
|
|
|
|
g_warning ("Cannot create '%s' permission: %s", USER_ACCOUNTS_PERMISSION, error->message);
|
|
|
|
|
g_error_free (error);
|
|
|
|
|
}
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "add-user-toolbutton");
|
2011-10-25 17:56:03 +01:00
|
|
|
|
names[0] = "changes-allow-symbolic";
|
|
|
|
|
names[1] = "changes-allow";
|
2010-10-30 16:14:30 -04:00
|
|
|
|
names[2] = NULL;
|
2010-11-15 14:02:27 -05:00
|
|
|
|
icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
setup_tooltip_with_embedded_icon (button,
|
2011-10-25 17:56:44 +01:00
|
|
|
|
_("To create a user account,\nclick the * icon first"),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
"*",
|
|
|
|
|
icon);
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "remove-user-toolbutton");
|
2010-10-30 16:14:30 -04:00
|
|
|
|
setup_tooltip_with_embedded_icon (button,
|
2011-10-25 17:56:44 +01:00
|
|
|
|
_("To delete the selected user account,\nclick the * icon first"),
|
2010-10-30 16:14:30 -04:00
|
|
|
|
"*",
|
|
|
|
|
icon);
|
|
|
|
|
g_object_unref (icon);
|
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);
|
2013-01-29 16:40:23 -05:00
|
|
|
|
if (loaded)
|
2018-05-31 10:42:09 +12:00
|
|
|
|
users_loaded (self->um, NULL, self);
|
2013-01-29 16:40:23 -05:00
|
|
|
|
else
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_signal_connect (self->um, "notify::is-loaded", G_CALLBACK (users_loaded), self);
|
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)
|
|
|
|
|
{
|
|
|
|
|
CcUserPanel *self = UM_USER_PANEL (object);
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
CcShell *shell;
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_user_panel_parent_class)->constructed (object);
|
|
|
|
|
|
|
|
|
|
shell = cc_panel_get_shell (CC_PANEL (self));
|
2018-05-31 10:42:09 +12:00
|
|
|
|
cc_shell_embed_widget_in_header (shell, self->headerbar_buttons);
|
2016-07-20 14:20:34 +02:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
button = get_widget (self, "lock-button");
|
|
|
|
|
gtk_lock_button_set_permission (GTK_LOCK_BUTTON (button), self->permission);
|
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
|
|
|
|
{
|
|
|
|
|
GError *error;
|
2011-02-04 15:43:40 -05:00
|
|
|
|
volatile GType type G_GNUC_UNUSED;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
GtkWidget *button;
|
2017-04-05 13:31:42 +02:00
|
|
|
|
GtkCssProvider *provider;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2013-01-04 18:04:03 +01:00
|
|
|
|
g_resources_register (um_get_resource ());
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
/* register types that the builder might need */
|
2015-01-14 09:14:19 +01:00
|
|
|
|
type = um_user_image_get_type ();
|
2016-11-15 14:40:54 +01:00
|
|
|
|
type = um_carousel_get_type ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->builder = gtk_builder_new ();
|
|
|
|
|
self->um = act_user_manager_get_default ();
|
|
|
|
|
self->cancellable = g_cancellable_new ();
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
|
|
|
|
error = NULL;
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (!gtk_builder_add_from_resource (self->builder,
|
2013-01-04 18:04:03 +01:00
|
|
|
|
"/org/gnome/control-center/user-accounts/user-accounts-dialog.ui",
|
|
|
|
|
&error)) {
|
2010-10-30 16:14:30 -04:00
|
|
|
|
g_error ("%s", error->message);
|
|
|
|
|
g_error_free (error);
|
2011-01-21 13:59:30 +00:00
|
|
|
|
return;
|
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");
|
|
|
|
|
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
|
|
|
|
|
GTK_STYLE_PROVIDER (provider),
|
|
|
|
|
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
|
|
|
|
g_object_unref (provider);
|
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->headerbar_buttons = get_widget (self, "headerbar-buttons");
|
|
|
|
|
self->stack = get_widget (self, "stack");
|
|
|
|
|
self->login_screen_settings = settings_or_null ("org.gnome.login-screen");
|
2015-02-23 11:47:13 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
self->password_dialog = um_password_dialog_new ();
|
|
|
|
|
button = get_widget (self, "user-icon-button");
|
|
|
|
|
self->photo_dialog = um_photo_dialog_new (button);
|
|
|
|
|
self->main_box = get_widget (self, "accounts-vbox");
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (self), self->stack);
|
|
|
|
|
self->history_dialog = um_history_dialog_new ();
|
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-05-31 10:42:09 +12:00
|
|
|
|
CcUserPanel *self = UM_USER_PANEL (object);
|
2010-10-30 16:14:30 -04:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_cancellable_cancel (self->cancellable);
|
|
|
|
|
g_clear_object (&self->cancellable);
|
2014-09-30 11:08:08 +02:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_object (&self->login_screen_settings);
|
2015-02-23 11:47:13 +01:00
|
|
|
|
|
2018-05-31 10:42:09 +12:00
|
|
|
|
if (self->um) {
|
|
|
|
|
g_signal_handlers_disconnect_by_data (self->um, self);
|
|
|
|
|
self->um = NULL;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_object (&self->builder);
|
|
|
|
|
g_clear_pointer (&self->password_dialog, um_password_dialog_free);
|
|
|
|
|
g_clear_pointer (&self->history_dialog, um_history_dialog_free);
|
|
|
|
|
if (self->account_dialog) {
|
|
|
|
|
gtk_dialog_response (GTK_DIALOG (self->account_dialog), GTK_RESPONSE_DELETE_EVENT);
|
|
|
|
|
self->account_dialog = NULL;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|
2018-05-31 10:42:09 +12:00
|
|
|
|
g_clear_pointer (&self->language_chooser, gtk_widget_destroy);
|
|
|
|
|
g_clear_object (&self->permission);
|
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
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2011-05-20 21:29:33 -04:00
|
|
|
|
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;
|
2010-10-30 16:14:30 -04:00
|
|
|
|
}
|