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_name_done (GtkWidget          *entry,
                  UmUserPanelPrivate *d)
{
    const gchar *text;
    UmUser *user;

    user = get_selected_user (d);

    text = cc_editable_entry_get_text (CC_EDITABLE_ENTRY (entry));
    if (g_strcmp0 (text, um_user_get_real_name (user)) != 0) {
        um_user_set_real_name (user, text);
    }

    g_object_unref (user);
}
static void
on_permission_changed (GPermission *permission,
                       GParamSpec  *pspec,
                       gpointer     data)
{
    UmUserPanelPrivate *d = data;
    gboolean is_authorized;
    gboolean self_selected;
    UmUser *user;
    GtkWidget *widget;

    user = get_selected_user (d);
    if (!user) {
        return;
    }

    is_authorized = g_permission_get_allowed (G_PERMISSION (d->permission));
    self_selected = um_user_get_uid (user) == geteuid ();

    widget = get_widget (d, "add-user-toolbutton");
    gtk_widget_set_sensitive (widget, is_authorized);
    if (is_authorized) {
        setup_tooltip_with_embedded_icon (widget, _("Create a user account"), NULL, NULL);
    }
    else {
        gchar *names[3];
        GIcon *icon;

        names[0] = "changes-allow-symbolic";
        names[1] = "changes-allow";
        names[2] = NULL;
        icon = (GIcon *)g_themed_icon_new_from_names (names, -1);
        setup_tooltip_with_embedded_icon (widget,
                                          _("To create a user account,\nclick the * icon first"),
                                          "*",
                                          icon);
        g_object_unref (icon);
    }

    widget = get_widget (d, "remove-user-toolbutton");
    gtk_widget_set_sensitive (widget, is_authorized && !self_selected);
    if (is_authorized) {
        setup_tooltip_with_embedded_icon (widget, _("Delete the selected user account"), NULL, NULL);
    }
    else {
        gchar *names[3];
        GIcon *icon;

        names[0] = "changes-allow-symbolic";
        names[1] = "changes-allow";
        names[2] = NULL;
        icon = (GIcon *)g_themed_icon_new_from_names (names, -1);

        setup_tooltip_with_embedded_icon (widget,
                                          _("To delete the selected user account,\nclick the * icon first"),
                                          "*",
                                          icon);
        g_object_unref (icon);
    }

    if (!um_user_is_local_account (user)) {
        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE);
        remove_unlock_tooltip (get_widget (d, "account-type-combo"));

    } else if (is_authorized && um_user_is_local_account (user)) {
        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), TRUE);
        remove_unlock_tooltip (get_widget (d, "account-type-combo"));
    }
    else {
        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE);
        add_unlock_tooltip (get_widget (d, "account-type-combo"));
    }

    /* The full name entry: insensitive if remote or not authorized and not self */
    widget = get_widget (d, "full-name-entry");
    if (!um_user_is_local_account (user)) {
        cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), FALSE);
        remove_unlock_tooltip (widget);

    } else if (is_authorized || self_selected) {
        cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), TRUE);
        remove_unlock_tooltip (widget);

    } else {
        cc_editable_entry_set_editable (CC_EDITABLE_ENTRY (widget), FALSE);
        add_unlock_tooltip (widget);
    }

    if (is_authorized || self_selected) {
        gtk_widget_show (get_widget (d, "user-icon-button"));
        gtk_widget_hide (get_widget (d, "user-icon-nonbutton"));

        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), TRUE);
        remove_unlock_tooltip (get_widget (d, "account-language-combo"));

        um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), TRUE);
        remove_unlock_tooltip (get_widget (d, "account-password-button"));

        gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 1);
    }
    else {
        gtk_widget_hide (get_widget (d, "user-icon-button"));
        gtk_widget_show (get_widget (d, "user-icon-nonbutton"));

        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-language-combo")), FALSE);
        add_unlock_tooltip (get_widget (d, "account-language-combo"));

        um_editable_button_set_editable (UM_EDITABLE_BUTTON (get_widget (d, "account-password-button")), FALSE);
        add_unlock_tooltip (get_widget (d, "account-password-button"));

        gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 0);
    }

    um_password_dialog_set_privileged (d->password_dialog, is_authorized);

    g_object_unref (user);
}
Exemple #4
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;

        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);
        }
}