Mercurial > pidgin.yaz
changeset 12553:9d7fb0b21d9f
[gaim-migrate @ 14871]
one reactionary pref down, eleventy billion to go
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Mon, 19 Dec 2005 05:55:30 +0000 |
parents | 5e6c3f539eb6 |
children | 9d9030dfd689 |
files | src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkprefs.c |
diffstat | 4 files changed, 48 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkconv.c Mon Dec 19 01:19:56 2005 +0000 +++ b/src/gtkconv.c Mon Dec 19 05:55:30 2005 +0000 @@ -4290,6 +4290,7 @@ GaimAccount *account; GaimPluginProtocolInfo *prpl_info; int gtk_font_options = 0; + int gtk_font_options_all = 0; int max_scrollback_lines = gaim_prefs_get_int( "/gaim/gtk/conversations/scrollback_lines"); int line_count; @@ -4303,6 +4304,9 @@ gtkconv = GAIM_GTK_CONVERSATION(conv); + if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) + gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; + /* Set the active conversation to the one that just messaged us. */ /* TODO: consider not doing this if the account is offline or something */ gaim_gtkconv_set_active_conversation(conv); @@ -4331,7 +4335,7 @@ } if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); @@ -4354,29 +4358,30 @@ gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; } + /* TODO: These colors should not be hardcoded so log.c can use them */ if (flags & GAIM_MESSAGE_SYSTEM) { g_snprintf(buf2, sizeof(buf2), "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", sml_attrib ? sml_attrib : "", mdate, message); - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); } else if (flags & GAIM_MESSAGE_ERROR) { g_snprintf(buf2, sizeof(buf2), "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", sml_attrib ? sml_attrib : "", mdate, message); - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); } else if (flags & GAIM_MESSAGE_NO_LOG) { g_snprintf(buf2, BUF_LONG, "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", sml_attrib ? sml_attrib : "", message); - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); } else if (flags & GAIM_MESSAGE_RAW) { - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); } else { char *new_message = g_memdup(message, length); char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); @@ -4479,7 +4484,7 @@ color, sml_attrib ? sml_attrib : "", mdate, str); } - gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); + gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && !(flags & GAIM_MESSAGE_SEND)) { @@ -4525,7 +4530,7 @@ with_font_tag = g_memdup(new_message, length); gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), - with_font_tag, gtk_font_options); + with_font_tag, gtk_font_options | gtk_font_options_all); g_free(with_font_tag); g_free(new_message); @@ -5876,6 +5881,7 @@ /* Conversations */ gaim_prefs_add_none("/gaim/gtk/conversations"); + gaim_prefs_add_bool("/gaim/gtk/conversations/use_smooth_scrolling", TRUE); gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE);
--- a/src/gtkimhtml.c Mon Dec 19 01:19:56 2005 +0000 +++ b/src/gtkimhtml.c Mon Dec 19 05:55:30 2005 +0000 @@ -2313,7 +2313,7 @@ } if (!(options & GTK_IMHTML_NO_SCROLL)) { - gtk_imhtml_scroll_to_end(imhtml); + gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); } } @@ -2346,21 +2346,37 @@ return TRUE; } -static gboolean scroll_idle_cb(gpointer data) +static gboolean smooth_scroll_idle_cb(gpointer data) { GtkIMHtml *imhtml = data; imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); return FALSE; } -void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml) +static gboolean scroll_idle_cb(gpointer data) +{ + GtkIMHtml *imhtml = data; + GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; + if(adj) { + gtk_adjustment_set_value(adj, adj->upper - adj->page_size); + } + imhtml->scroll_src = 0; + return FALSE; +} + +void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) { if (imhtml->scroll_time) g_timer_destroy(imhtml->scroll_time); - imhtml->scroll_time = g_timer_new(); if (imhtml->scroll_src) g_source_remove(imhtml->scroll_src); - imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); + if(smooth) { + imhtml->scroll_time = g_timer_new(); + imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, smooth_scroll_idle_cb, imhtml, NULL); + } else { + imhtml->scroll_time = NULL; + imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); + } } void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml,
--- a/src/gtkimhtml.h Mon Dec 19 01:19:56 2005 +0000 +++ b/src/gtkimhtml.h Mon Dec 19 05:55:30 2005 +0000 @@ -188,16 +188,17 @@ }; typedef enum { - GTK_IMHTML_NO_COLOURS = 1 << 0, - GTK_IMHTML_NO_FONTS = 1 << 1, - GTK_IMHTML_NO_COMMENTS = 1 << 2, /* Remove */ - GTK_IMHTML_NO_TITLE = 1 << 3, - GTK_IMHTML_NO_NEWLINE = 1 << 4, - GTK_IMHTML_NO_SIZES = 1 << 5, - GTK_IMHTML_NO_SCROLL = 1 << 6, - GTK_IMHTML_RETURN_LOG = 1 << 7, - GTK_IMHTML_USE_POINTSIZE = 1 << 8, - GTK_IMHTML_NO_FORMATTING = 1 << 9 + GTK_IMHTML_NO_COLOURS = 1 << 0, + GTK_IMHTML_NO_FONTS = 1 << 1, + GTK_IMHTML_NO_COMMENTS = 1 << 2, /* Remove */ + GTK_IMHTML_NO_TITLE = 1 << 3, + GTK_IMHTML_NO_NEWLINE = 1 << 4, + GTK_IMHTML_NO_SIZES = 1 << 5, + GTK_IMHTML_NO_SCROLL = 1 << 6, + GTK_IMHTML_RETURN_LOG = 1 << 7, + GTK_IMHTML_USE_POINTSIZE = 1 << 8, + GTK_IMHTML_NO_FORMATTING = 1 << 9, + GTK_IMHTML_USE_SMOOTHSCROLLING = 1 << 10 } GtkIMHtmlOptions; enum { @@ -359,7 +360,7 @@ * * @param imhtml The GTK+ IM/HTML. */ -void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml); +void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth); /** * Delete the contents of a GTK+ IM/HTML between start and end.
--- a/src/gtkprefs.c Mon Dec 19 01:19:56 2005 +0000 +++ b/src/gtkprefs.c Mon Dec 19 05:55:30 2005 +0000 @@ -839,6 +839,8 @@ "/gaim/gtk/conversations/spellcheck", vbox); #endif + gaim_gtk_prefs_checkbox(_("Use smooth-scrolling"), "/gaim/gtk/conversations/use_smooth_scrolling", vbox); + frame = gaim_gtk_create_imhtml(TRUE, &imhtml, &toolbar); gtk_widget_set_name(imhtml, "gaim_gtkprefs_font_imhtml"); gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(imhtml), TRUE);