[gnome-control-center] user-accounts: Fix bug when name is changed to contain markup



commit f66e7bb4dd7124cebeff7531fa7d4e28aa0c782d
Author: Bastien Nocera <hadess hadess net>
Date:   Wed May 11 17:25:03 2011 +0100

    user-accounts: Fix bug when name is changed to contain markup
    
    When changing to a "display name" that contains markup, such
    as "Foo & Bar", the code to update the user list on the left
    wasn't escaping the text correctly.

 panels/user-accounts/um-user-panel.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index f3d18d1..d431ec8 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -116,6 +116,14 @@ get_selected_user (UmUserPanelPrivate *d)
         return NULL;
 }
 
+static char *
+get_name_col_str (UmUser *user)
+{
+        return g_markup_printf_escaped ("<b>%s</b>\n<i>%s</i>",
+                                        um_user_get_display_name (user),
+                                        um_account_type_get_name (um_user_get_account_type (user)));
+}
+
 static void
 user_added (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d)
 {
@@ -128,7 +136,6 @@ user_added (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d)
         gchar *text;
         GtkTreeSelection *selection;
         gint sort_key;
-        gchar *escaped_name;
         gboolean is_autologin;
 
         g_debug ("user added: %d %s\n", um_user_get_uid (user), um_user_get_real_name (user));
@@ -138,11 +145,7 @@ user_added (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d)
         selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
 
         pixbuf = um_user_render_icon (user, TRUE, 48);
-        escaped_name = g_markup_escape_text (um_user_get_display_name (user), -1);
-        text = g_strdup_printf ("<b>%s</b>\n<i>%s</i>",
-                                escaped_name,
-                                um_account_type_get_name (um_user_get_account_type (user)));
-        g_free (escaped_name);
+        text = get_name_col_str (user);
 
         is_autologin = um_user_get_automatic_login (user);
 
@@ -269,9 +272,7 @@ user_changed (UmUserManager *um, UmUser *user, UmUserPanelPrivate *d)
                 gtk_tree_model_get (model, &iter, USER_COL, &current, -1);
                 if (current == user) {
                         pixbuf = um_user_render_icon (user, TRUE, 48);
-                        text = g_strdup_printf ("<b>%s</b>\n<i>%s</i>",
-                                                um_user_get_display_name (user),
-                                                um_account_type_get_name (um_user_get_account_type (user)));
+                        text = get_name_col_str (user);
                         is_autologin = um_user_get_automatic_login (user);
 
                         gtk_list_store_set (GTK_LIST_STORE (model), &iter,



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