[gnome-control-center] user-accounts: Use sensitivity to denote changes in "Account Type"
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: Use sensitivity to denote changes in "Account Type"
- Date: Mon, 1 Aug 2016 07:39:38 +0000 (UTC)
commit e3148af358bf58382c27c3ddf599e58a45a44615
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Jul 21 16:10:35 2016 +0200
user-accounts: Use sensitivity to denote changes in "Account Type"
Instead of changing from "Account Type" buttons to label, set the
sensitivity of the buttons according to the current users' permission.
Now we hide the "Account Type" for a single user account.
https://bugzilla.gnome.org/show_bug.cgi?id=767065
panels/user-accounts/data/user-accounts-dialog.ui | 53 ++++++---------------
panels/user-accounts/um-user-panel.c | 34 ++++++-------
2 files changed, 30 insertions(+), 57 deletions(-)
---
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui
b/panels/user-accounts/data/user-accounts-dialog.ui
index d808f53..762b236 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -111,53 +111,29 @@
</packing>
</child>
<child>
- <object class="GtkStack" id="account-type-stack">
+ <object class="GtkBox" id="account-type-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="sensitive">False</property>
+ <style>
+ <class name="linked"/>
+ </style>
<child>
- <object class="GtkBox" id="account-type-box">
+ <object class="GtkRadioButton" id="account-type-standard">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <style>
- <class name="linked"/>
- </style>
- <child>
- <object class="GtkRadioButton" id="account-type-standard">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Standard</property>
- <property name="draw_indicator">False</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkRadioButton" id="account-type-admin">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Administrator</property>
- <property name="draw_indicator">False</property>
- <property name="group">account-type-standard</property>
- <property name="hexpand">True</property>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Standard</property>
+ <property name="draw_indicator">False</property>
</object>
- <packing>
- <property name="name">buttons</property>
- </packing>
</child>
<child>
- <object class="GtkLabel" id="account-type-static">
+ <object class="GtkRadioButton" id="account-type-admin">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Standard</property>
- <property name="use_underline">True</property>
- <property name="halign">start</property>
- <property name="margin_start">17</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Administrator</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">account-type-standard</property>
</object>
- <packing>
- <property name="name">static</property>
- </packing>
</child>
</object>
<packing>
@@ -513,7 +489,6 @@
<widget name="account-language-button"/>
<widget name="account-password-button"/>
<widget name="account-type-box"/>
- <widget name="account-type-static"/>
<widget name="autologin-box"/>
<widget name="last-login-button"/>
</widgets>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 0408820..bbe848f 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -186,6 +186,8 @@ get_name_col_str (ActUser *user)
act_user_get_user_name (user));
}
+static void show_user (ActUser *user, CcUserPanelPrivate *d);
+
static void
user_added (ActUserManager *um, ActUser *user, CcUserPanelPrivate *d)
{
@@ -332,8 +334,6 @@ user_removed (ActUserManager *um, ActUser *user, CcUserPanelPrivate *d)
}
}
-static void show_user (ActUser *user, CcUserPanelPrivate *d);
-
static void
user_changed (ActUserManager *um, ActUser *user, CcUserPanelPrivate *d)
{
@@ -876,7 +876,7 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
{
GtkWidget *image;
GtkWidget *label;
- gchar *lang, *text, *name, *account_type_label;
+ gchar *lang, *text, *name;
GtkWidget *widget;
gboolean show, enable;
ActUser *current;
@@ -895,13 +895,10 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
widget = get_widget (d, act_user_get_account_type (user) ? "account-type-admin" :
"account-type-standard");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- widget = get_widget (d, "account-type-static");
- if (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR)
- account_type_label = g_strdup (_("Administrator"));
- else
- account_type_label = g_strdup (_("Standard"));
- gtk_label_set_text (GTK_LABEL (widget), account_type_label);
- g_free (account_type_label);
+ /* Do not show the "Account Type" option when there's a single user account. */
+ show = (d->other_accounts != 0);
+ gtk_widget_set_visible (get_widget (d, "account-type-label"), show);
+ gtk_widget_set_visible (get_widget (d, "account-type-box"), show);
widget = get_widget (d, "account-password-button-label");
gtk_label_set_label (GTK_LABEL (widget), get_password_mode_text (user));
@@ -1314,6 +1311,7 @@ users_loaded (ActUserManager *manager,
g_debug ("adding user %s\n", get_real_or_user_name (user));
user_added (d->um, user, d);
}
+ show_user (list->data, d);
g_slist_free (list);
g_signal_connect (d->um, "user-added", G_CALLBACK (user_added), d);
@@ -1415,28 +1413,28 @@ on_permission_changed (GPermission *permission,
}
if (!act_user_is_local_account (user)) {
- gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")),
"static");
- remove_unlock_tooltip (get_widget (d, "account-type-stack"));
+ gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
+ remove_unlock_tooltip (get_widget (d, "account-type-box"));
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE);
remove_unlock_tooltip (get_widget (d, "autologin-switch"));
} else if (is_authorized && act_user_is_local_account (user)) {
if (would_demote_only_admin (user)) {
- gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")),
"static");
+ gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
} else {
- gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")),
"buttons");
+ gtk_widget_set_sensitive (get_widget (d, "account-type-box"), TRUE);
}
- remove_unlock_tooltip (get_widget (d, "account-type-stack"));
+ remove_unlock_tooltip (get_widget (d, "account-type-box"));
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")),
get_autologin_possible (user));
remove_unlock_tooltip (get_widget (d, "autologin-switch"));
}
else {
- gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")),
"static");
+ gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
if (would_demote_only_admin (user)) {
- remove_unlock_tooltip (get_widget (d, "account-type-stack"));
+ remove_unlock_tooltip (get_widget (d, "account-type-box"));
} else {
- add_unlock_tooltip (get_widget (d, "account-type-stack"));
+ add_unlock_tooltip (get_widget (d, "account-type-box"));
}
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE);
add_unlock_tooltip (get_widget (d, "autologin-switch"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]