[gnome-control-center/wip/feborges/new-users-panel] user-accounts: use a label for Account Type when user isn't admin



commit 8c599bd3151c588d2fec7a0225d7ec482932ddb1
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue May 31 14:56:30 2016 +0200

    user-accounts: use a label for Account Type when user isn't admin

 panels/user-accounts/data/user-accounts-dialog.ui |   54 +++++++++++++++------
 panels/user-accounts/um-user-panel.c              |   26 +++++++----
 2 files changed, 56 insertions(+), 24 deletions(-)
---
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui 
b/panels/user-accounts/data/user-accounts-dialog.ui
index 335e5c0..c9f3621 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -141,30 +141,53 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkBox" id="account-type-box">
+                          <object class="GtkStack" id="account-type-stack">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <style>
-                              <class name="linked"/>
-                            </style>
                             <child>
-                              <object class="GtkRadioButton" id="account-type-standard">
+                              <object class="GtkBox" id="account-type-box">
                                 <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>
+                                <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="GtkRadioButton" id="account-type-admin">
+                              <object class="GtkLabel" id="account-type-static">
                                 <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>
+                                <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>
@@ -508,6 +531,7 @@
       <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-grid"/>
     </widgets>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 8d4f58f..6d3675f 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;
@@ -893,6 +893,14 @@ 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) == 1)
+          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));
         enable = act_user_is_local_account (user);
@@ -1386,28 +1394,28 @@ on_permission_changed (GPermission *permission,
         }
 
         if (!act_user_is_local_account (user)) {
-                gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
-                remove_unlock_tooltip (get_widget (d, "account-type-box"));
+                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)) {
-                        gtk_widget_set_sensitive (get_widget (d, "account-type-box"), FALSE);
+                        gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), 
"static");
                 } else {
-                        gtk_widget_set_sensitive (get_widget (d, "account-type-box"), TRUE);
+                        gtk_stack_set_visible_child_name (GTK_STACK (get_widget (d, "account-type-stack")), 
"buttons");
                 }
-                remove_unlock_tooltip (get_widget (d, "account-type-box"));
+                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 {
-                gtk_widget_set_sensitive (get_widget (d, "account-type-box"), 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-box"));
+                        remove_unlock_tooltip (get_widget (d, "account-type-stack"));
                 } else {
-                        add_unlock_tooltip (get_widget (d, "account-type-box"));
+                        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"));


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