[gnome-control-center] user-accounts: use radio buttons for account type



commit 1a6d7167743399e9274bd9ea398557a6ba08029d
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue May 31 12:00:47 2016 +0200

    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

 panels/user-accounts/data/user-accounts-dialog.ui |   56 ++++++++++++++++++--
 panels/user-accounts/um-user-panel.c              |   42 +++++++++-------
 2 files changed, 73 insertions(+), 25 deletions(-)
---
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui 
b/panels/user-accounts/data/user-accounts-dialog.ui
index 740f4df..c9f3621 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -141,11 +141,54 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="UmEditableCombo" id="account-type-combo">
+                          <object class="GtkStack" id="account-type-stack">
                             <property name="visible">True</property>
-                            <property name="model">account-type-model</property>
-                            <property name="text-column">0</property>
-                            <property name="hexpand">True</property>
+                            <property name="can_focus">False</property>
+                            <child>
+                              <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>
                           <packing>
                             <property name="left_attach">1</property>
@@ -160,7 +203,7 @@
                             <property name="xalign">1</property>
                             <property name="label" translatable="yes">Account _Type</property>
                             <property name="use_underline">True</property>
-                            <property name="mnemonic_widget">account-type-combo</property>
+                            <property name="mnemonic_widget">account-type-box</property>
                             <style>
                               <class name="dim-label"/>
                             </style>
@@ -487,7 +530,8 @@
       <widget name="account-fingerprint-button"/>
       <widget name="account-language-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="last-login-grid"/>
     </widgets>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 196add7..b3a40bf 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -874,7 +874,7 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
 {
         GtkWidget *image;
         GtkWidget *label;
-        gchar *lang, *text, *name;
+        gchar *lang, *text, *name, *account_type_label;
         GtkWidget *widget;
         gboolean show, enable;
         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));
         gtk_widget_set_tooltip_text (widget, act_user_get_user_name (user));
 
-        widget = get_widget (d, "account-type-combo");
-        um_editable_combo_set_active (UM_EDITABLE_COMBO (widget), act_user_get_account_type (user));
+        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);
 
         widget = get_widget (d, "account-password-button");
         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
-account_type_changed (UmEditableCombo    *combo,
+account_type_changed (GtkToggleButton    *button,
                       CcUserPanelPrivate *d)
 {
         ActUser *user;
-        GtkTreeModel *model;
-        GtkTreeIter iter;
         gint account_type;
         gboolean self_selected;
 
         user = get_selected_user (d);
         self_selected = act_user_get_uid (user) == geteuid ();
 
-        model = um_editable_combo_get_model (combo);
-        um_editable_combo_get_active_iter (combo, &iter);
-        gtk_tree_model_get (model, &iter, 1, &account_type, -1);
+        account_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ?  
ACT_USER_ACCOUNT_TYPE_STANDARD : ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR;
 
         if (account_type != act_user_get_account_type (user)) {
                 act_user_set_account_type (user, account_type);
@@ -1390,28 +1394,28 @@ on_permission_changed (GPermission *permission,
         }
 
         if (!act_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"));
+                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 (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)) {
-                        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 {
-                        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));
                 remove_unlock_tooltip (get_widget (d, "autologin-switch"));
         }
         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)) {
-                        remove_unlock_tooltip (get_widget (d, "account-type-combo"));
+                        remove_unlock_tooltip (get_widget (d, "account-type-stack"));
                 } 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);
                 add_unlock_tooltip (get_widget (d, "autologin-switch"));
@@ -1636,8 +1640,8 @@ setup_main_window (CcUserPanel *self)
         button = get_widget (d, "full-name-entry");
         g_signal_connect (button, "editing-done", G_CALLBACK (change_name_done), d);
 
-        button = get_widget (d, "account-type-combo");
-        g_signal_connect (button, "editing-done", G_CALLBACK (account_type_changed), d);
+        button = get_widget (d, "account-type-standard");
+        g_signal_connect (button, "toggled", G_CALLBACK (account_type_changed), d);
 
         button = get_widget (d, "account-password-button");
         g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]