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



commit 6622f0a97b1115cac28d77cf6de817e6886077c3
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.

 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 2744952..8d91aec 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -277,6 +277,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>
@@ -292,7 +311,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>
@@ -316,7 +335,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>
@@ -336,7 +355,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 c4777ab..09fd8c7 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))
 
@@ -607,6 +609,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);
@@ -762,6 +779,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;
@@ -1199,6 +1232,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]