changeset 14424:c374f45f4c94

[gaim-migrate @ 17132] Do the same for the texts in buttons, and minor adjustments. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 02 Sep 2006 23:23:30 +0000
parents cfd5bcc06a7e
children 3a91ef295cbb
files console/libgnt/gntbutton.c console/libgnt/gntutils.c
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gntbutton.c	Sat Sep 02 23:06:25 2006 +0000
+++ b/console/libgnt/gntbutton.c	Sat Sep 02 23:23:30 2006 +0000
@@ -128,7 +128,7 @@
 	GntWidget *widget = g_object_new(GNT_TYPE_BUTTON, NULL);
 	GntButton *button = GNT_BUTTON(widget);
 
-	button->priv->text = g_strdup(text);
+	button->priv->text = gnt_util_onscreen_fit_string(text, -1);
 	gnt_widget_set_take_focus(widget, TRUE);
 
 	return widget;
--- a/console/libgnt/gntutils.c	Sat Sep 02 23:06:25 2006 +0000
+++ b/console/libgnt/gntutils.c	Sat Sep 02 23:23:30 2006 +0000
@@ -82,17 +82,18 @@
 	while (*start) {
 		if ((end = strchr(start, '\n')) != NULL ||
 			(end = strchr(start, '\r')) != NULL) {
-			if (gnt_util_onscreen_width(start, end) <= maxw) {
-				++end;
-			} else
+			if (gnt_util_onscreen_width(start, end) > maxw)
 				end = NULL;
 		}
 		if (end == NULL)
 			end = gnt_util_onscreen_width_to_pointer(start, maxw, NULL);
 		str = g_string_append_len(str, start, end - start);
+		if (*end) {
+			str = g_string_append_c(str, '\n');
+			if (*end == '\n' || *end == '\r')
+				end++;
+		}
 		start = end;
-		if (*end && *end != '\n' && *end != '\r')
-			str = g_string_append_c(str, '\n');
 	}
 	return g_string_free(str, FALSE);
 }