[gnome-control-center/wip/identity: 2/11] user-accounts: add "Other Passwords" button



commit f87057b4c452048b9c6fdc0259dd5ba172da04d8
Author: Ray Strode <rstrode redhat com>
Date:   Tue Feb 28 23:00:58 2012 -0500

    user-accounts: add "Other Passwords" button
    
    Since the user can change the login password from
    the user panel, it stands to reason the user may want
    to be able to adjust other passwords from there as well.
    
    This commit adds an "Other Passwords" button which runs
    seahorse when clicked.
    
    See:
    
    https://live.gnome.org/Design/Proposals/UserIdentities
    
    for more information.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671156

 panels/user-accounts/data/user-accounts-dialog.ui |   25 +++++++++++++--
 panels/user-accounts/um-user-panel.c              |   36 +++++++++++++++++++++
 2 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/panels/user-accounts/data/user-accounts-dialog.ui b/panels/user-accounts/data/user-accounts-dialog.ui
index 620d2f9..0c37fd6 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -279,6 +279,25 @@
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkButton" id="other-passwords-button">
+                            <property name="visible">True</property>
+                            <property name="halign">GTK_ALIGN_START</property>
+                            <property name="hexpand">TRUE</property>
+                            <child>
+                              <object class="GtkLabel" id="other-passwords-label">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">Other Passwordsâ</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">2</property>
+                            <property name="width">1</property>
+                            <property name="top_attach">6</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkLabel" id="autologin-label">
                             <property name="visible">True</property>
                             <property name="xalign">1</property>
@@ -294,7 +313,7 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="width">1</property>
-                            <property name="top_attach">6</property>
+                            <property name="top_attach">7</property>
                             <property name="height">1</property>
                           </packing>
                         </child>
@@ -318,7 +337,7 @@
                           <packing>
                             <property name="left_attach">2</property>
                             <property name="width">1</property>
-                            <property name="top_attach">6</property>
+                            <property name="top_attach">7</property>
                             <property name="height">1</property>
                           </packing>
                         </child>
@@ -338,7 +357,7 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="width">1</property>
-                            <property name="top_attach">7</property>
+                            <property name="top_attach">8</property>
                             <property name="height">1</property>
                           </packing>
                         </child>
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 3612608..0dd709a 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -57,6 +57,8 @@
 
 G_DEFINE_DYNAMIC_TYPE (UmUserPanel, um_user_panel, CC_TYPE_PANEL)
 
+#define OTHER_PASSWORDS_PROGRAM "seahorse"
+
 #define UM_USER_PANEL_PRIVATE(o) \
   (G_TYPE_INSTANCE_GET_PRIVATE ((o), UM_TYPE_USER_PANEL, UmUserPanelPrivate))
 
@@ -617,6 +619,21 @@ show_user (UmUser *user, UmUserPanelPrivate *d)
                 gtk_widget_show (label);
                 gtk_widget_show (widget);
         }
+
+        widget = get_widget (d, "other-passwords-button");
+        if (um_user_get_uid (user) != getuid()) {
+                gtk_widget_hide (widget);
+        } else {
+                char *other_passwords;
+
+                other_passwords = g_find_program_in_path (OTHER_PASSWORDS_PROGRAM);
+                if (other_passwords != NULL) {
+                        gtk_widget_show (widget);
+                        g_free (other_passwords);
+                } else {
+                        gtk_widget_hide (widget);
+                }
+        }
 }
 
 static void on_permission_changed (GPermission *permission, GParamSpec *pspec, gpointer data);
@@ -775,6 +792,22 @@ change_password (GtkButton *button, UmUserPanelPrivate *d)
 }
 
 static void
+edit_other_passwords (GtkButton *button, UmUserPanelPrivate *d)
+{
+      GError *error;
+
+      error = NULL;
+
+      g_spawn_command_line_async (OTHER_PASSWORDS_PROGRAM, &error);
+
+      if (error != NULL) {
+              g_warning ("unable to launch " OTHER_PASSWORDS_PROGRAM ": %s",
+                         error->message);
+              g_error_free (error);
+      }
+}
+
+static void
 change_fingerprint (GtkButton *button, UmUserPanelPrivate *d)
 {
         GtkWidget *label, *label2;
@@ -1213,6 +1246,9 @@ setup_main_window (UmUserPanelPrivate *d)
         button = get_widget (d, "account-password-button");
         g_signal_connect (button, "start-editing", G_CALLBACK (change_password), d);
 
+        button = get_widget (d, "other-passwords-button");
+        g_signal_connect (button, "clicked", G_CALLBACK (edit_other_passwords), d);
+
         button = get_widget (d, "account-language-combo");
         g_signal_connect (button, "editing-done", G_CALLBACK (language_changed), d);
 



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