static void user_removed (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d) { GtkTreeView *tv; GtkTreeModel *model; GtkTreeSelection *selection; GtkListStore *store; GtkTreeIter iter, next; UmUser *u; g_debug ("user removed: %s\n", um_user_get_user_name (user)); tv = (GtkTreeView *)get_widget (d, "list-treeview"); selection = gtk_tree_view_get_selection (tv); model = gtk_tree_view_get_model (tv); store = GTK_LIST_STORE (model); if (gtk_tree_model_get_iter_first (model, &iter)) { do { gtk_tree_model_get (model, &iter, USER_COL, &u, -1); if (u != NULL) { if (um_user_get_uid (user) == um_user_get_uid (u)) { if (!get_next_user_row (model, &iter, &next)) get_previous_user_row (model, &iter, &next); gtk_list_store_remove (store, &iter); gtk_tree_selection_select_iter (selection, &next); g_object_unref (u); break; } g_object_unref (u); } } while (gtk_tree_model_iter_next (model, &iter)); } }
static void user_added_handler (UmUserManager *manager, const char *object_path) { UmUser *user; if (g_hash_table_lookup (manager->user_by_object_path, object_path)) return; user = um_user_new_from_object_path (object_path); if (!user) return; if (um_user_is_system_account (user)) { g_object_unref (user); return; } add_user_to_dupe_ring (manager, user); g_signal_connect (user, "changed", G_CALLBACK (user_changed_handler), manager); g_hash_table_insert (manager->user_by_object_path, g_strdup (um_user_get_object_path (user)), g_object_ref (user)); g_hash_table_insert (manager->user_by_name, g_strdup (um_user_get_user_name (user)), g_object_ref (user)); g_signal_emit (manager, signals[USER_ADDED], 0, user); g_object_unref (user); }
static char * get_name_col_str (UmUser *user) { return g_markup_printf_escaped ("<b>%s</b>\n<small>%s</small>", um_user_get_display_name (user), um_user_get_user_name (user)); }
static void on_register_user (GObject *source, GAsyncResult *result, gpointer user_data) { UmAccountDialog *self = UM_ACCOUNT_DIALOG (user_data); GError *error = NULL; UmUser *user = NULL; um_user_manager_cache_user_finish (UM_USER_MANAGER (source), result, &user, &error); /* This is where we're finally done */ if (error == NULL) { g_debug ("Successfully cached remote user: %s", um_user_get_user_name (user)); finish_action (self); complete_dialog (self, user); } else { show_error_dialog (self, _("Failed to register account"), error); g_message ("Couldn't cache user account: %s", error->message); finish_action (self); g_error_free (error); } }
void um_password_dialog_set_user (UmPasswordDialog *um, UmUser *user) { GdkPixbuf *pixbuf; GtkTreeModel *model; if (um->user) { g_object_unref (um->user); um->user = NULL; } if (user) { um->user = g_object_ref (user); um->using_ecryptfs = is_using_ecryptfs (um_user_get_user_name (user)); pixbuf = um_user_render_icon (user, FALSE, 48); gtk_image_set_from_pixbuf (GTK_IMAGE (um->user_icon), pixbuf); g_object_unref (pixbuf); gtk_label_set_label (GTK_LABEL (um->user_name), um_user_get_real_name (user)); gtk_entry_set_text (GTK_ENTRY (um->password_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->verify_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->normal_hint_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), ""); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->show_password_button), FALSE); if (um_user_get_uid (um->user) == getuid () && um_user_get_password_mode (um->user) == UM_PASSWORD_MODE_REGULAR) { gtk_widget_show (um->old_password_label); gtk_widget_show (um->old_password_entry); um->old_password_ok = FALSE; } else { gtk_widget_hide (um->old_password_label); gtk_widget_hide (um->old_password_entry); um->old_password_ok = TRUE; } if (um_user_get_uid (um->user) == getuid()) { if (um->passwd_handler != NULL) passwd_destroy (um->passwd_handler); um->passwd_handler = passwd_init (); } } model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); if (!GTK_IS_TREE_MODEL_FILTER (model)) { model = gtk_tree_model_filter_new (model, NULL); gtk_combo_box_set_model (GTK_COMBO_BOX (um->action_combo), model); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model), (GtkTreeModelFilterVisibleFunc) visible_func, um, NULL); } gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model)); gtk_combo_box_set_active (GTK_COMBO_BOX (um->action_combo), 0); }
static void show_user (UmUser *user, UmUserPanelPrivate *d) { GtkWidget *image; GtkWidget *label; GtkWidget *label2; GtkWidget *label3; GdkPixbuf *pixbuf; gchar *lang; GtkWidget *widget; GtkTreeModel *model; GtkTreeIter iter; gboolean show, enable; pixbuf = um_user_render_icon (user, FALSE, 48); image = get_widget (d, "user-icon-image"); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); image = get_widget (d, "user-icon-image2"); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); g_object_unref (pixbuf); um_photo_dialog_set_user (d->photo_dialog, user); widget = get_widget (d, "full-name-entry"); cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), um_user_get_real_name (user)); gtk_widget_set_tooltip_text (widget, um_user_get_user_name (user)); widget = get_widget (d, "account-type-combo"); um_editable_combo_set_active (UM_EDITABLE_COMBO (widget), um_user_get_account_type (user)); widget = get_widget (d, "account-password-button"); um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user)); enable = um_user_is_local_account (user); gtk_widget_set_sensitive (widget, enable); widget = get_widget (d, "account-language-combo"); model = um_editable_combo_get_model (UM_EDITABLE_COMBO (widget)); cc_add_user_languages (model); lang = g_strdup (um_user_get_language (user)); if (!lang) lang = cc_common_language_get_current_language (); cc_common_language_get_iter_for_language (model, lang, &iter); um_editable_combo_set_active_iter (UM_EDITABLE_COMBO (widget), &iter); g_free (lang); /* Fingerprint: show when self, possible, and local account */ widget = get_widget (d, "account-fingerprint-notebook"); label = get_widget (d, "account-fingerprint-label"); label2 = get_widget (d, "account-fingerprint-value-label"); label3 = get_widget (d, "account-fingerprint-button-label"); show = (um_user_get_uid (user) == getuid() && um_user_is_local_account (user) && set_fingerprint_label (label2, label3)); gtk_widget_set_visible (label, show); gtk_widget_set_visible (widget, show); }
static void change_fingerprint (GtkButton *button, UmUserPanelPrivate *d) { GtkWidget *label, *label2; UmUser *user; user = get_selected_user (d); g_assert (g_strcmp0 (g_get_user_name (), um_user_get_user_name (user)) == 0); label = get_widget (d, "account-fingerprint-value-label"); label2 = get_widget (d, "account-fingerprint-button-label"); fingerprint_button_clicked (GTK_WINDOW (gtk_widget_get_toplevel (d->main_box)), label, label2, user); g_object_unref (user); }
static void user_deleted_handler (UmUserManager *manager, const char *object_path) { UmUser *user; user = g_hash_table_lookup (manager->user_by_object_path, object_path); if (!user) return; g_object_ref (user); g_signal_handlers_disconnect_by_func (user, user_changed_handler, manager); remove_user_from_dupe_ring (manager, user); g_hash_table_remove (manager->user_by_object_path, um_user_get_object_path (user)); g_hash_table_remove (manager->user_by_name, um_user_get_user_name (user)); g_signal_emit (manager, signals[USER_REMOVED], 0, user); g_object_unref (user); }
static void user_added (UmUserManager *um, UmUser *user, UmLoginOptions *d) { GtkComboBox *combo; GtkListStore *store; GtkTreeIter iter; g_debug ("adding user '%s', %d", um_user_get_user_name (user), um_user_get_automatic_login (user)); combo = GTK_COMBO_BOX (d->autologin_combo); store = (GtkListStore*)gtk_combo_box_get_model (combo); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, AUTOLOGIN_NAME_COL, um_user_get_display_name (user), AUTOLOGIN_USER_COL, user, -1); if (um_user_get_automatic_login (user)) { gtk_combo_box_set_active_iter (combo, &iter); } }
static void update_password_strength (UmPasswordDialog *um) { const gchar *password; const gchar *old_password; const gchar *username; gint strength_level; const gchar *hint; const gchar *long_hint; password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); old_password = gtk_entry_get_text (GTK_ENTRY (um->old_password_entry)); username = um_user_get_user_name (um->user); pw_strength (password, old_password, username, &hint, &long_hint, &strength_level); gtk_level_bar_set_value (GTK_LEVEL_BAR (um->strength_indicator), strength_level); gtk_label_set_label (GTK_LABEL (um->strength_indicator_label), hint); gtk_widget_set_tooltip_text (um->strength_indicator, long_hint); gtk_widget_set_tooltip_text (um->strength_indicator_label, long_hint); }
static void create_user_done (UmUserManager *manager, GAsyncResult *res, UmAccountDialog *self) { UmUser *user; GError *error; finish_action (self); /* Note that user is returned without an extra reference */ error = NULL; if (!um_user_manager_create_user_finish (manager, res, &user, &error)) { g_debug ("Failed to create user: %s", error->message); if (!g_error_matches (error, UM_USER_MANAGER_ERROR, UM_USER_MANAGER_ERROR_PERMISSION_DENIED)) show_error_dialog (self, _("Failed to add account"), error); g_error_free (error); gtk_widget_grab_focus (self->local_name); } else { g_debug ("Created user: %s", um_user_get_user_name (user)); complete_dialog (self, user); } }
static gboolean match_user (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) { UmUser *user; const gchar *name; gchar *normalized_key = NULL; gchar *normalized_name = NULL; gchar *case_normalized_key = NULL; gchar *case_normalized_name = NULL; gchar *p; gboolean result = TRUE; gint i; gtk_tree_model_get (model, iter, USER_COL, &user, -1); if (!user) { goto out; } normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); if (!normalized_key) { goto out; } case_normalized_key = g_utf8_casefold (normalized_key, -1); for (i = 0; i < 2; i++) { if (i == 0) { name = um_user_get_real_name (user); } else { name = um_user_get_user_name (user); } g_free (normalized_name); normalized_name = g_utf8_normalize (name, -1, G_NORMALIZE_ALL); if (normalized_name) { g_free (case_normalized_name); case_normalized_name = g_utf8_casefold (normalized_name, -1); p = strstr (case_normalized_name, case_normalized_key); /* poor man's \b */ if (p == case_normalized_name || (p && p[-1] == ' ')) { result = FALSE; break; } } } out: if (user) { g_object_unref (user); } g_free (normalized_key); g_free (case_normalized_key); g_free (normalized_name); g_free (case_normalized_name); return result; }
static void show_user (UmUser *user, UmUserPanelPrivate *d) { GtkWidget *image; GtkWidget *label; GtkWidget *label2; GtkWidget *label3; GdkPixbuf *pixbuf; gchar *lang; GtkWidget *widget; GtkTreeModel *model; GtkTreeIter iter; pixbuf = um_user_render_icon (user, FALSE, 48); image = get_widget (d, "user-icon-image"); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); image = get_widget (d, "user-icon-image2"); gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); g_object_unref (pixbuf); um_photo_dialog_set_user (d->photo_dialog, user); widget = get_widget (d, "full-name-entry"); cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), um_user_get_real_name (user)); gtk_widget_set_tooltip_text (widget, um_user_get_user_name (user)); widget = get_widget (d, "account-type-combo"); um_editable_combo_set_active (UM_EDITABLE_COMBO (widget), um_user_get_account_type (user)); widget = get_widget (d, "account-password-button"); um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user)); widget = get_widget (d, "autologin-switch"); g_signal_handlers_block_by_func (widget, autologin_changed, d); gtk_switch_set_active (GTK_SWITCH (widget), um_user_get_automatic_login (user)); g_signal_handlers_unblock_by_func (widget, autologin_changed, d); gtk_widget_set_sensitive (widget, !um_user_get_locked (user)); widget = get_widget (d, "account-language-combo"); model = um_editable_combo_get_model (UM_EDITABLE_COMBO (widget)); cc_add_user_languages (model); lang = g_strdup (um_user_get_language (user)); if (!lang) lang = cc_common_language_get_current_language (); cc_common_language_get_iter_for_language (model, lang, &iter); um_editable_combo_set_active_iter (UM_EDITABLE_COMBO (widget), &iter); g_free (lang); widget = get_widget (d, "account-fingerprint-notebook"); label = get_widget (d, "account-fingerprint-label"); label2 = get_widget (d, "account-fingerprint-value-label"); label3 = get_widget (d, "account-fingerprint-button-label"); if (um_user_get_uid (user) != getuid() || !set_fingerprint_label (label2, label3)) { gtk_widget_hide (label); gtk_widget_hide (widget); } else { gtk_widget_show (label); gtk_widget_show (widget); } }