Mercurial > pidgin
comparison pidgin/plugins/history.c @ 32672:3828a61c44da
A boring and large patch so I can merge heads.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 23 Dec 2011 08:21:58 +0000 |
parents | ea325948453c |
children |
comparison
equal
deleted
inserted
replaced
32671:0e69949b3e61 | 32672:3828a61c44da |
---|---|
14 #include "version.h" | 14 #include "version.h" |
15 | 15 |
16 #include "gtkconv.h" | 16 #include "gtkconv.h" |
17 #include "gtkimhtml.h" | 17 #include "gtkimhtml.h" |
18 #include "gtkplugin.h" | 18 #include "gtkplugin.h" |
19 #include "gtkwebview.h" | |
19 | 20 |
20 #define HISTORY_PLUGIN_ID "gtk-history" | 21 #define HISTORY_PLUGIN_ID "gtk-history" |
21 | 22 |
22 #define HISTORY_SIZE (4 * 1024) | 23 #define HISTORY_SIZE (4 * 1024) |
23 | 24 |
24 static gboolean _scroll_imhtml_to_end(gpointer data) | 25 static gboolean _scroll_webview_to_end(gpointer data) |
25 { | 26 { |
26 GtkIMHtml *imhtml = data; | 27 GtkWebView *webview = data; |
27 gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml), FALSE); | 28 gtk_webview_scroll_to_end(GTK_WEBVIEW(webview), FALSE); |
28 g_object_unref(G_OBJECT(imhtml)); | 29 g_object_unref(G_OBJECT(webview)); |
29 return FALSE; | 30 return FALSE; |
30 } | 31 } |
31 | 32 |
32 static void historize(PurpleConversation *c) | 33 static void historize(PurpleConversation *c) |
33 { | 34 { |
37 GList *logs = NULL; | 38 GList *logs = NULL; |
38 const char *alias = name; | 39 const char *alias = name; |
39 guint flags; | 40 guint flags; |
40 char *history; | 41 char *history; |
41 PidginConversation *gtkconv; | 42 PidginConversation *gtkconv; |
43 #if 0 | |
44 /* FIXME: WebView has no options */ | |
42 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; | 45 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
46 #endif | |
43 char *header; | 47 char *header; |
48 #if 0 | |
49 /* FIXME: WebView has no protocol setting */ | |
44 char *protocol; | 50 char *protocol; |
51 #endif | |
45 char *escaped_alias; | 52 char *escaped_alias; |
46 const char *header_date; | 53 const char *header_date; |
47 | 54 |
48 convtype = purple_conversation_get_type(c); | 55 convtype = purple_conversation_get_type(c); |
49 gtkconv = PIDGIN_CONVERSATION(c); | 56 gtkconv = PIDGIN_CONVERSATION(c); |
114 if (logs == NULL) | 121 if (logs == NULL) |
115 return; | 122 return; |
116 | 123 |
117 history = purple_log_read((PurpleLog*)logs->data, &flags); | 124 history = purple_log_read((PurpleLog*)logs->data, &flags); |
118 gtkconv = PIDGIN_CONVERSATION(c); | 125 gtkconv = PIDGIN_CONVERSATION(c); |
126 #if 0 | |
127 /* FIXME: WebView has no options */ | |
119 if (flags & PURPLE_LOG_READ_NO_NEWLINE) | 128 if (flags & PURPLE_LOG_READ_NO_NEWLINE) |
120 options |= GTK_IMHTML_NO_NEWLINE; | 129 options |= GTK_IMHTML_NO_NEWLINE; |
121 | 130 #endif |
131 | |
132 #if 0 | |
133 /* FIXME: WebView has no protocol setting */ | |
122 protocol = g_strdup(gtk_imhtml_get_protocol_name(GTK_IMHTML(gtkconv->imhtml))); | 134 protocol = g_strdup(gtk_imhtml_get_protocol_name(GTK_IMHTML(gtkconv->imhtml))); |
123 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), | 135 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
124 purple_account_get_protocol_name(((PurpleLog*)logs->data)->account)); | 136 purple_account_get_protocol_name(((PurpleLog*)logs->data)->account)); |
125 | 137 #endif |
126 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) | 138 |
127 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", options); | 139 if (!gtk_webview_is_empty(GTK_WEBVIEW(gtkconv->webview))) |
140 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR>"); | |
128 | 141 |
129 escaped_alias = g_markup_escape_text(alias, -1); | 142 escaped_alias = g_markup_escape_text(alias, -1); |
130 | 143 |
131 if (((PurpleLog *)logs->data)->tm) | 144 if (((PurpleLog *)logs->data)->tm) |
132 header_date = purple_date_format_full(((PurpleLog *)logs->data)->tm); | 145 header_date = purple_date_format_full(((PurpleLog *)logs->data)->tm); |
133 else | 146 else |
134 header_date = purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)); | 147 header_date = purple_date_format_full(localtime(&((PurpleLog *)logs->data)->time)); |
135 | 148 |
136 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), escaped_alias, header_date); | 149 header = g_strdup_printf(_("<b>Conversation with %s on %s:</b><br>"), escaped_alias, header_date); |
137 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), header, options); | 150 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), header); |
138 g_free(header); | 151 g_free(header); |
139 g_free(escaped_alias); | 152 g_free(escaped_alias); |
140 | 153 |
141 g_strchomp(history); | 154 g_strchomp(history); |
142 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); | 155 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), history); |
143 g_free(history); | 156 g_free(history); |
144 | 157 |
145 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); | 158 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<hr>"); |
146 | 159 |
160 #if 0 | |
161 /* FIXME: WebView has no protocol setting */ | |
147 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol); | 162 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol); |
148 g_free(protocol); | 163 g_free(protocol); |
149 | 164 #endif |
150 g_object_ref(G_OBJECT(gtkconv->imhtml)); | 165 |
151 g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml); | 166 g_object_ref(G_OBJECT(gtkconv->webview)); |
167 g_idle_add(_scroll_webview_to_end, gtkconv->webview); | |
152 | 168 |
153 g_list_foreach(logs, (GFunc)purple_log_free, NULL); | 169 g_list_foreach(logs, (GFunc)purple_log_free, NULL); |
154 g_list_free(logs); | 170 g_list_free(logs); |
155 } | 171 } |
156 | 172 |