[accounts-dialog] Don't allow changing usernames



commit a2b1505061036e959262a6a2c501470559fc6b81
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Mar 25 17:16:05 2010 -0400

    Don't allow changing usernames
    
    This is not really expected functionality, security guys hate it,
    and removing it allows us to get rid of the popup dialog.

 data/Makefile.am             |    1 -
 data/names-dialog.ui         |  234 ------------------------------------------
 data/user-accounts-dialog.ui |    9 ++
 src/Makefile.am              |    2 -
 src/main.c                   |  100 ++++++++++++++++--
 src/um-names-dialog.c        |  231 -----------------------------------------
 src/um-names-dialog.h        |   41 --------
 7 files changed, 99 insertions(+), 519 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 3b686b5..411ba30 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,7 +4,6 @@ uidir   = $(pkgdatadir)
 ui_DATA = \
 	account-dialog.ui	\
 	language-chooser.ui	\
-	names-dialog.ui		\
 	password-dialog.ui	\
 	photo-dialog.ui		\
 	user-accounts-dialog.ui \
diff --git a/data/user-accounts-dialog.ui b/data/user-accounts-dialog.ui
index 8120c1f..606e238 100644
--- a/data/user-accounts-dialog.ui
+++ b/data/user-accounts-dialog.ui
@@ -407,6 +407,15 @@
                                         <property name="position">1</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkEntry" id="full-name-entry">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                   <packing>
                                     <property name="position">1</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index b39be61..18c1e58 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,8 +31,6 @@ accounts_dialog_SOURCES = \
 	um-language-dialog.c		\
 	um-login-options.h		\
 	um-login-options.c		\
-	um-names-dialog.h		\
-	um-names-dialog.c		\
 	um-password-dialog.h		\
 	um-password-dialog.c		\
 	um-photo-dialog.h		\
diff --git a/src/main.c b/src/main.c
index ccd6072..d78d0f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -47,7 +47,6 @@
 #include "um-user-manager.h"
 
 #include "um-account-dialog.h"
-#include "um-names-dialog.h"
 #include "um-language-dialog.h"
 #include "um-login-options.h"
 #include "um-password-dialog.h"
@@ -67,7 +66,6 @@ typedef struct {
         GtkWidget *language_chooser;
 
         UmAccountDialog *account_dialog;
-        UmNamesDialog *names_dialog;
         UmPasswordDialog *password_dialog;
         UmPhotoDialog *photo_dialog;
         UmLoginOptions *login_options;
@@ -484,6 +482,8 @@ show_user (UmUser *user, UserAccountDialog *d)
         gtk_label_set_text (GTK_LABEL (label), um_user_get_real_name (user));
         widget = get_widget (d, "full-name-button");
         gtk_widget_set_tooltip_text (label, um_user_get_user_name (user));
+        widget = get_widget (d, "full-name-entry");
+        gtk_entry_set_text (GTK_ENTRY (widget), um_user_get_real_name (user));
 
         label = get_widget (d, "account-type-value-label");
         gtk_label_set_text (GTK_LABEL (label), um_account_type_get_name (um_user_get_account_type (user)));
@@ -605,17 +605,93 @@ selected_user_changed (GtkTreeSelection *selection, UserAccountDialog *d)
 }
 
 static void
-change_name (GtkButton *button, UserAccountDialog *d)
+name_style_set (GtkWidget *widget, GtkStyle *previous_style, UserAccountDialog *d)
 {
+        PangoFontDescription *desc;
+        gint size;
+
+        desc = pango_font_description_copy (widget->style->font_desc);
+        size = pango_font_description_get_size (desc);
+        pango_font_description_set_size (desc, 1.2 * size);
+        pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
+
+        g_signal_handlers_block_by_func (widget, name_style_set, d);
+        gtk_widget_modify_font (widget, desc);
+        g_signal_handlers_unblock_by_func (widget, name_style_set, d);
+
+        pango_font_description_free (desc);
+}
+
+static void
+change_name_start (GtkButton *button, UserAccountDialog *d)
+{
+        gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "full-name-notebook")), 2);
+}
+
+static void
+change_name_done (GtkWidget         *entry,
+                  UserAccountDialog *d)
+{
+        const gchar *text;
         UmUser *user;
 
         user = get_selected_user (d);
 
-        um_names_dialog_set_user (d->names_dialog, user);
-        um_names_dialog_show (d->names_dialog,
-                              GTK_WINDOW (get_widget (d, "user-account-window")));
+        text = gtk_entry_get_text (GTK_ENTRY (entry));
+        if (g_strcmp0 (text, um_user_get_location (user)) != 0) {
+                um_user_set_real_name (user, text);
+        }
 
-        g_object_unref (user);
+        gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "full-name-notebook")), 1);
+}
+
+static void
+change_name_canceled (UserAccountDialog *d)
+{
+        UmUser *user;
+        const gchar *text;
+        GtkWidget *widget;
+
+        user = get_selected_user (d);
+        text = um_user_get_real_name (user);
+
+        widget = get_widget (d, "full-name-value-label");
+        gtk_label_set_text (GTK_LABEL (widget), nonempty (text));
+        widget = get_widget (d, "full-name-button-label");
+        gtk_label_set_text (GTK_LABEL (widget), nonempty (text));
+        widget = get_widget (d, "full-name-entry");
+        gtk_entry_set_text (GTK_ENTRY (widget), text);
+
+        gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "full-name-notebook")), 1);
+}
+
+static void
+change_name_activate (GtkWidget         *widget,
+                      UserAccountDialog *d)
+{
+        change_name_done (widget, d);
+}
+
+static gboolean
+change_name_focus_out (GtkWidget         *widget,
+                       GdkEventFocus     *event,
+                       UserAccountDialog *d)
+{
+        change_name_done (widget, d);
+
+        return FALSE;
+}
+
+static gboolean
+change_name_key_press (GtkWidget         *widget,
+                       GdkEventKey       *event,
+                       UserAccountDialog *d)
+{
+        if (event->keyval == GDK_Escape) {
+                change_name_canceled (d);
+        }
+
+        return FALSE;
 }
 
 static void
@@ -795,7 +871,7 @@ language_changed (GtkComboBox       *combo,
                                cursor);
         gdk_cursor_unref (cursor);
 
-        g_idle_add (finish_language_chooser, d);
+        g_idle_add ((GSourceFunc)finish_language_chooser, d);
 }
 
 static gboolean
@@ -1406,7 +1482,12 @@ setup_main_window (UserAccountDialog *d)
                            G_CALLBACK (show_tooltip_now), NULL);
 
         button = get_widget (d, "full-name-button");
-        g_signal_connect (button, "clicked", G_CALLBACK (change_name), d);
+        g_signal_connect (button, "clicked", G_CALLBACK (change_name_start), d);
+        button = get_widget (d, "full-name-entry");
+        g_signal_connect (button, "style-set", G_CALLBACK (name_style_set), d);
+        g_signal_connect (button, "activate", G_CALLBACK (change_name_activate), d);
+        g_signal_connect (button, "focus-out-event", G_CALLBACK (change_name_focus_out), d);
+        g_signal_connect (button, "key-press-event", G_CALLBACK (change_name_key_press), d);
 
         button = get_widget (d, "account-type-value-label");
         setup_tooltip_with_embedded_icon (button,
@@ -1612,7 +1693,6 @@ main (int argc, char *argv[])
         setup_main_window (d);
         d->login_options = um_login_options_new (d->builder);
         d->account_dialog = um_account_dialog_new ();
-        d->names_dialog = um_names_dialog_new ();
         d->password_dialog = um_password_dialog_new ();
         button = get_widget (d, "user-icon-button");
         d->photo_dialog = um_photo_dialog_new (button, d->main_window);



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