changeset 15354:db11d9e416ac

[gaim-migrate @ 18147] when auto-growing a conversation entry to fit text without scrollbars, reset to the default size once the message is sent committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 17 Jan 2007 09:47:55 +0000
parents 445b2bee14b9
children 00d0d4524377
files gtk/gtkconv.c gtk/gtkconv.h
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/gtkconv.c	Wed Jan 17 09:22:04 2007 +0000
+++ b/gtk/gtkconv.c	Wed Jan 17 09:47:55 2007 +0000
@@ -451,6 +451,18 @@
 	gtkconv->send_history = g_list_prepend(first, NULL);
 }
 
+static void
+reset_default_size(GaimGtkConversation *gtkconv)
+{
+	GaimConversation *conv = gtkconv->active_conv;
+	if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT)
+		gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
+					    gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height"));
+	else
+		gtk_widget_set_size_request(gtkconv->lower_hbox, -1,
+					    gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height"));
+}
+
 static gboolean
 check_for_and_do_command(GaimConversation *conv)
 {
@@ -537,6 +549,10 @@
 		return;
 
 	if (check_for_and_do_command(conv)) {
+		if (gtkconv->entry_growing) {
+			reset_default_size(gtkconv);
+			gtkconv->entry_growing = FALSE;
+		}
 		gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
 		return;
 	}
@@ -586,6 +602,10 @@
 	g_free(buf);
 
 	gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry));
+	if (gtkconv->entry_growing) {
+		reset_default_size(gtkconv);
+		gtkconv->entry_growing = FALSE;
+	}
 	gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE);
 }
 
@@ -3992,6 +4012,7 @@
 	gtk_widget_size_request(gtkconv->lower_hbox, &sr);
 	if (sr.height < height + GAIM_HIG_BOX_SPACE) {
 		gtkconv->auto_resize = TRUE;
+		gtkconv->entry_growing = TRUE;
 	        gtk_widget_set_size_request(gtkconv->lower_hbox, -1, height + GAIM_HIG_BOX_SPACE);
 	        g_idle_add(reset_auto_resize_cb, gtkconv);
 	}
--- a/gtk/gtkconv.h	Wed Jan 17 09:22:04 2007 +0000
+++ b/gtk/gtkconv.h	Wed Jan 17 09:47:55 2007 +0000
@@ -131,6 +131,9 @@
 		 	 	 * is being resized by a non-user-initiated
 		 		 * event, such as the buddy icon appearing
 				 */
+	gboolean entry_growing; /* True if the size of the entry was set
+				 * automatically by typing too much to fit
+				 * in one line */
 	
 	GtkWidget *close; /* "x" on the tab */
 	GtkWidget *icon;