user-accounts: use radio buttons for account type

According to the mockups at
https://wiki.gnome.org/Design/SystemSettings/UserAccounts

https://bugzilla.gnome.org/show_bug.cgi?id=767065
This commit is contained in:
Felipe Borges 2016-05-31 12:00:47 +02:00
parent 5b3a2cc649
commit 1a6d716774
2 changed files with 73 additions and 25 deletions

View file

@ -141,11 +141,54 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="UmEditableCombo" id="account-type-combo"> <object class="GtkStack" id="account-type-stack">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">account-type-model</property> <property name="can_focus">False</property>
<property name="text-column">0</property> <child>
<property name="hexpand">True</property> <object class="GtkBox" id="account-type-box">
<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="hexpand">True</property>
<property name="label" translatable="yes">Standard</property>
<property name="draw_indicator">False</property>
</object>
</child>
<child>
<object class="GtkRadioButton" id="account-type-admin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Administrator</property>
<property name="draw_indicator">False</property>
<property name="group">account-type-standard</property>
</object>
</child>
</object>
<packing>
<property name="name">buttons</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="account-type-static">
<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>
</object>
<packing>
<property name="name">static</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -160,7 +203,7 @@
<property name="xalign">1</property> <property name="xalign">1</property>
<property name="label" translatable="yes">Account _Type</property> <property name="label" translatable="yes">Account _Type</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">account-type-combo</property> <property name="mnemonic_widget">account-type-box</property>
<style> <style>
<class name="dim-label"/> <class name="dim-label"/>
</style> </style>
@ -487,7 +530,8 @@
<widget name="account-fingerprint-button"/> <widget name="account-fingerprint-button"/>
<widget name="account-language-button"/> <widget name="account-language-button"/>
<widget name="account-password-button"/> <widget name="account-password-button"/>
<widget name="account-type-combo"/> <widget name="account-type-box"/>
<widget name="account-type-static"/>
<widget name="autologin-box"/> <widget name="autologin-box"/>
<widget name="last-login-grid"/> <widget name="last-login-grid"/>
</widgets> </widgets>

View file

@ -874,7 +874,7 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
{ {
GtkWidget *image; GtkWidget *image;
GtkWidget *label; GtkWidget *label;
gchar *lang, *text, *name; gchar *lang, *text, *name, *account_type_label;
GtkWidget *widget; GtkWidget *widget;
gboolean show, enable; gboolean show, enable;
ActUser *current; ActUser *current;
@ -890,8 +890,16 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), act_user_get_real_name (user)); cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), act_user_get_real_name (user));
gtk_widget_set_tooltip_text (widget, act_user_get_user_name (user)); gtk_widget_set_tooltip_text (widget, act_user_get_user_name (user));
widget = get_widget (d, "account-type-combo"); widget = get_widget (d, act_user_get_account_type (user) ? "account-type-admin" : "account-type-standard");
um_editable_combo_set_active (UM_EDITABLE_COMBO (widget), act_user_get_account_type (user)); 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);
widget = get_widget (d, "account-password-button"); widget = get_widget (d, "account-password-button");
um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user)); um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user));
@ -998,21 +1006,17 @@ change_name_done (GtkWidget *entry,
} }
static void static void
account_type_changed (UmEditableCombo *combo, account_type_changed (GtkToggleButton *button,
CcUserPanelPrivate *d) CcUserPanelPrivate *d)
{ {
ActUser *user; ActUser *user;
GtkTreeModel *model;
GtkTreeIter iter;
gint account_type; gint account_type;
gboolean self_selected; gboolean self_selected;
user = get_selected_user (d); user = get_selected_user (d);
self_selected = act_user_get_uid (user) == geteuid (); self_selected = act_user_get_uid (user) == geteuid ();
model = um_editable_combo_get_model (combo); account_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
um_editable_combo_get_active_iter (combo, &iter);
gtk_tree_model_get (model, &iter, 1, &account_type, -1);
if (account_type != act_user_get_account_type (user)) { if (account_type != act_user_get_account_type (user)) {
act_user_set_account_type (user, account_type); act_user_set_account_type (user, account_type);
@ -1390,28 +1394,28 @@ on_permission_changed (GPermission *permission,
} }
if (!act_user_is_local_account (user)) { if (!act_user_is_local_account (user)) {
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE); gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), "static");
remove_unlock_tooltip (get_widget (d, "account-type-combo")); remove_unlock_tooltip (get_widget (d, "account-type-stack"));
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE);
remove_unlock_tooltip (get_widget (d, "autologin-switch")); remove_unlock_tooltip (get_widget (d, "autologin-switch"));
} else if (is_authorized && act_user_is_local_account (user)) { } else if (is_authorized && act_user_is_local_account (user)) {
if (would_demote_only_admin (user)) { if (would_demote_only_admin (user)) {
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE); gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), "static");
} else { } else {
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), TRUE); gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), "buttons");
} }
remove_unlock_tooltip (get_widget (d, "account-type-combo")); remove_unlock_tooltip (get_widget (d, "account-type-stack"));
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), get_autologin_possible (user)); gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), get_autologin_possible (user));
remove_unlock_tooltip (get_widget (d, "autologin-switch")); remove_unlock_tooltip (get_widget (d, "autologin-switch"));
} }
else { else {
um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), FALSE); gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), "static");
if (would_demote_only_admin (user)) { if (would_demote_only_admin (user)) {
remove_unlock_tooltip (get_widget (d, "account-type-combo")); remove_unlock_tooltip (get_widget (d, "account-type-stack"));
} else { } else {
add_unlock_tooltip (get_widget (d, "account-type-combo")); add_unlock_tooltip (get_widget (d, "account-type-stack"));
} }
gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (get_widget (d, "autologin-switch")), FALSE);
add_unlock_tooltip (get_widget (d, "autologin-switch")); add_unlock_tooltip (get_widget (d, "autologin-switch"));
@ -1636,8 +1640,8 @@ setup_main_window (CcUserPanel *self)
button = get_widget (d, "full-name-entry"); button = get_widget (d, "full-name-entry");
g_signal_connect (button, "editing-done", G_CALLBACK (change_name_done), d); g_signal_connect (button, "editing-done", G_CALLBACK (change_name_done), d);
button = get_widget (d, "account-type-combo"); button = get_widget (d, "account-type-standard");
g_signal_connect (button, "editing-done", G_CALLBACK (account_type_changed), d); g_signal_connect (button, "toggled", G_CALLBACK (account_type_changed), d);
button = get_widget (d, "account-password-button"); button = get_widget (d, "account-password-button");
g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d); g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d);