Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
22801:6fe3a32c5ee9 | 22802:958f9379eb1a |
---|---|
4458 GdkRectangle oneline; | 4458 GdkRectangle oneline; |
4459 int height, diff; | 4459 int height, diff; |
4460 int pad_top, pad_inside, pad_bottom; | 4460 int pad_top, pad_inside, pad_bottom; |
4461 int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height); | 4461 int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height); |
4462 int max_height = total_height / 2; | 4462 int max_height = total_height / 2; |
4463 int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines"); | |
4463 int min_height; | 4464 int min_height; |
4464 | 4465 |
4465 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry)); | 4466 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
4466 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry)); | 4467 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
4467 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry)); | 4468 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry)); |
4479 height += lineheight; | 4480 height += lineheight; |
4480 lines--; | 4481 lines--; |
4481 } while (gtk_text_iter_forward_line(&iter)); | 4482 } while (gtk_text_iter_forward_line(&iter)); |
4482 height += lines * (oneline.height + pad_top + pad_bottom); | 4483 height += lines * (oneline.height + pad_top + pad_bottom); |
4483 | 4484 |
4484 /* Make sure there's enough room for at least two lines. Allocate enough space to | 4485 /* Make sure there's enough room for at least min_lines. Allocate enough space to |
4485 * prevent scrolling when the second line is a continuation of the first line, or | 4486 * prevent scrolling when the second line is a continuation of the first line, or |
4486 * is the beginning of a new paragraph. */ | 4487 * is the beginning of a new paragraph. */ |
4487 min_height = 2 * (oneline.height + MAX(pad_inside, pad_top + pad_bottom)); | 4488 min_height = min_lines * (oneline.height + MAX(pad_inside, pad_top + pad_bottom)); |
4488 height = CLAMP(height, min_height, max_height); | 4489 height = CLAMP(height, min_height, max_height); |
4489 | 4490 |
4490 diff = height - gtkconv->entry->allocation.height; | 4491 diff = height - gtkconv->entry->allocation.height; |
4491 if (ABS(diff) < oneline.height / 2) | 4492 if (ABS(diff) < oneline.height / 2) |
4492 return FALSE; | 4493 return FALSE; |
4493 | 4494 |
4494 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | 4495 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, |
4495 diff + gtkconv->lower_hbox->allocation.height); | 4496 diff + gtkconv->lower_hbox->allocation.height); |
4496 | 4497 |
4497 return FALSE; | 4498 return FALSE; |
4499 } | |
4500 | |
4501 static void | |
4502 minimum_entry_lines_pref_cb(const char *name, | |
4503 PurplePrefType type, | |
4504 gconstpointer value, | |
4505 gpointer data) | |
4506 { | |
4507 GList *l = purple_get_conversations(); | |
4508 PurpleConversation *conv; | |
4509 while (l != NULL) | |
4510 { | |
4511 conv = (PurpleConversation *)l->data; | |
4512 | |
4513 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
4514 resize_imhtml_cb(PIDGIN_CONVERSATION(conv)); | |
4515 | |
4516 l = l->next; | |
4517 } | |
4498 } | 4518 } |
4499 | 4519 |
4500 static void | 4520 static void |
4501 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) | 4521 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) |
4502 { | 4522 { |
7743 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); | 7763 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
7744 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); | 7764 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
7745 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); | 7765 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
7746 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); | 7766 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck", TRUE); |
7747 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); | 7767 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE); |
7768 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", 2); | |
7748 | 7769 |
7749 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps", TRUE); | 7770 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps", TRUE); |
7750 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE); | 7771 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE); |
7751 | 7772 |
7752 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/placement", "last"); | 7773 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/placement", "last"); |
7806 conv_placement_usetabs_cb, NULL); | 7827 conv_placement_usetabs_cb, NULL); |
7807 | 7828 |
7808 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/placement", | 7829 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/placement", |
7809 conv_placement_pref_cb, NULL); | 7830 conv_placement_pref_cb, NULL); |
7810 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); | 7831 purple_prefs_trigger_callback(PIDGIN_PREFS_ROOT "/conversations/placement"); |
7832 | |
7833 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", | |
7834 minimum_entry_lines_pref_cb, NULL); | |
7811 | 7835 |
7812 /* IM callbacks */ | 7836 /* IM callbacks */ |
7813 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons", | 7837 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/animate_buddy_icons", |
7814 animate_buddy_icons_pref_cb, NULL); | 7838 animate_buddy_icons_pref_cb, NULL); |
7815 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", | 7839 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", |