[gnome-control-center/wip/feborges/new-users-panel] user-accounts: use radio buttons for account type



commit b0633c4b3bf95030f5410206ab76c7e7339d219c
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

 panels/user-accounts/data/user-accounts-dialog.ui |   32 +++++++++++++++++----
 panels/user-accounts/um-user-panel.c              |   32 +++++++++-----------
 2 files changed, 40 insertions(+), 24 deletions(-)
---
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui 
b/panels/user-accounts/data/user-accounts-dialog.ui
index 8328972..16d4e3f 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -141,11 +141,31 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="UmEditableCombo" id="account-type-combo">
+                          <object class="GtkBox" id="account-type-box">
                             <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>
+                            <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="left_attach">1</property>
@@ -160,7 +180,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>
@@ -506,7 +526,7 @@
       <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="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..8d4f58f 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -890,8 +890,8 @@ 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-password-button");
         um_editable_button_set_text (UM_EDITABLE_BUTTON (widget), get_password_mode_text (user));
@@ -998,21 +998,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)) ? 0 : 1;
 
         if (account_type != act_user_get_account_type (user)) {
                 act_user_set_account_type (user, account_type);
@@ -1390,28 +1386,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_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)) {
-                        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, 
"account-type-combo")), FALSE);
+                        gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
                 } else {
-                        um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, 
"account-type-combo")), TRUE);
+                        gtk_widget_set_sensitive (get_widget (d, "account-type-box"), TRUE);
                 }
-                remove_unlock_tooltip (get_widget (d, "account-type-combo"));
+                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 {
-                um_editable_combo_set_editable (UM_EDITABLE_COMBO (get_widget (d, "account-type-combo")), 
FALSE);
+                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-combo"));
+                        remove_unlock_tooltip (get_widget (d, "account-type-box"));
                 } else {
-                        add_unlock_tooltip (get_widget (d, "account-type-combo"));
+                        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"));
@@ -1636,8 +1632,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]