diff pidgin/gtkconv.c @ 22802:958f9379eb1a

Add a "minimum lines" pref for the im entry box thing; up to 8 lines. * This uses a spinbutton for the prefs; who wants to make this a slider? * The string is clumsy. Sorry. * The example imhtml in the prefs dialog doesn't change size to match the pref; I think Sadrul wanted this to happen?
author Will Thompson <will.thompson@collabora.co.uk>
date Sat, 03 May 2008 17:36:17 +0000
parents 9cbb7c2aba23
children 7b21c5b208fb
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Sat May 03 07:27:25 2008 +0000
+++ b/pidgin/gtkconv.c	Sat May 03 17:36:17 2008 +0000
@@ -4460,6 +4460,7 @@
 	int pad_top, pad_inside, pad_bottom;
 	int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height);
 	int max_height = total_height / 2;
+	int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines");
 	int min_height;
 
 	pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry));
@@ -4481,10 +4482,10 @@
 	} while (gtk_text_iter_forward_line(&iter));
 	height += lines * (oneline.height + pad_top + pad_bottom);
 
-	/* Make sure there's enough room for at least two lines. Allocate enough space to
+	/* Make sure there's enough room for at least min_lines. Allocate enough space to
 	 * prevent scrolling when the second line is a continuation of the first line, or
 	 * is the beginning of a new paragraph. */
-	min_height = 2 * (oneline.height + MAX(pad_inside, pad_top + pad_bottom));
+	min_height = min_lines * (oneline.height + MAX(pad_inside, pad_top + pad_bottom));
 	height = CLAMP(height, min_height, max_height);
 
 	diff = height - gtkconv->entry->allocation.height;
@@ -4498,6 +4499,25 @@
 }
 
 static void
+minimum_entry_lines_pref_cb(const char *name,
+                            PurplePrefType type,
+                            gconstpointer value,
+                            gpointer data)
+{
+	GList *l = purple_get_conversations();
+	PurpleConversation *conv;
+	while (l != NULL)
+	{
+		conv = (PurpleConversation *)l->data;
+
+		if (PIDGIN_IS_PIDGIN_CONVERSATION(conv))
+			resize_imhtml_cb(PIDGIN_CONVERSATION(conv));
+
+		l = l->next;
+	}
+}
+
+static void
 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox)
 {
 	PurpleConversation *conv = gtkconv->active_conv;
@@ -7745,6 +7765,7 @@
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE);
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE);
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE);
+	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", 2);
 
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps", TRUE);
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE);
@@ -7809,6 +7830,9 @@
 								conv_placement_pref_cb, NULL);
 	purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement");
 
+	purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines",
+		minimum_entry_lines_pref_cb, NULL);
+
 	/* IM callbacks */
 	purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons",
 								animate_buddy_icons_pref_cb, NULL);