[gnome-system-tools/users-ui-redesign] Set width of user account type label to the max needed size



commit 2e1545532b346e4b6f19b8d4ff65acd9cd757c0b
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon Nov 30 21:44:57 2009 +0100

    Set width of user account type label to the max needed size
    
    Iterate over all user profiles to find the longest name, so that the label won't be resized, making widgets move, and dialog possibly resize itself when selecting users.

 src/users/users-tool.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/users/users-tool.c b/src/users/users-tool.c
index 468b02c..1734ae4 100644
--- a/src/users/users-tool.c
+++ b/src/users/users-tool.c
@@ -173,8 +173,10 @@ update_groups (GstUsersTool *tool)
 static void
 update_profiles (GstUsersTool *tool)
 {
-	GList *list;
+	GList *list, *l;
 	GtkWidget *label1, *label2, *button;
+	GstUserProfile *profile;
+	int max_len, len;
 
 	list = gst_user_profiles_get_list (tool->profiles);
 	table_populate_profiles (tool, list);
@@ -196,7 +198,20 @@ update_profiles (GstUsersTool *tool)
 		gtk_widget_hide (label1);
 		gtk_widget_hide (label2);
 		gtk_widget_hide (button);
+		return;
 	}
+
+	/* use the length of the longest profile name to avoid resizing
+	 * the label and moving widgets around */
+	max_len = 0;
+	for (l = list; l; l = l->next) {
+		profile = l->data;
+		len = g_utf8_strlen (profile->name, -1);
+		if (len > max_len)
+			max_len = len;
+	}
+
+	gtk_label_set_width_chars (GTK_LABEL (label1), max_len);
 }
 
 void



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