cpw.nader.asynclogging-3: 66845be3: Fixed history.c to work with webkit
morshed.nader at gmail.com
morshed.nader at gmail.com
Tue Dec 20 21:25:53 EST 2011
----------------------------------------------------------------------
Revision: 66845be3ca64d98e414fd7165f670b00c1f36d2c
Parent: 071c2dfd3ee996f70e19680dfc8384d95ecd7c70
Author: morshed.nader at gmail.com
Date: 12/15/11 18:04:13
Branch: im.pidgin.cpw.nader.asynclogging-3
URL: http://d.pidgin.im/viewmtn/revision/info/66845be3ca64d98e414fd7165f670b00c1f36d2c
Changelog:
Fixed history.c to work with webkit
Changes against parent 071c2dfd3ee996f70e19680dfc8384d95ecd7c70
patched pidgin/plugins/history.c
-------------- next part --------------
============================================================
--- pidgin/plugins/history.c 3518e130e6b517c3a240b2a72848368c7a7a8dc3
+++ pidgin/plugins/history.c a1a6671127bfbb2c52504455d21e9b5c149660db
@@ -14,7 +14,6 @@
#include "version.h"
#include "gtkconv.h"
-#include "gtkimhtml.h"
#include "gtkplugin.h"
#include "gtkwebview.h"
@@ -115,7 +114,7 @@ historize(PurpleConversation *c)
callback_data->count++;
- purple_logs_get_logs_async(PURPLE_LOG_IM, purple_buddy_get_name(buddy),
+ purple_logs_list_logs_async(PURPLE_LOG_IM, purple_buddy_get_name(buddy),
purple_buddy_get_account(buddy), G_PRIORITY_DEFAULT,
callback_data->cancel, historize_log_collector_cb, callback_data);
}
@@ -137,7 +136,7 @@ historize(PurpleConversation *c)
callback_data->count = 1;
- purple_logs_get_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
+ purple_logs_list_logs_async(PURPLE_LOG_CHAT, name, account, G_PRIORITY_DEFAULT,
callback_data->cancel, historize_log_list_cb, callback_data);
}
@@ -146,12 +145,12 @@ static gboolean
}
static gboolean
-_scroll_imhtml_to_end(gpointer userdata)
+_scroll_webview_to_end(gpointer userdata)
{
- GtkIMHtml *imhtml = GTK_IMHTML(userdata);
+ GtkWebView *wv = GTK_WEBVIEW(userdata);
- gtk_imhtml_scroll_to_end(imhtml, FALSE);
- g_object_unref(imhtml);
+ gtk_webview_scroll_to_end(wv, FALSE);
+ g_object_unref(wv);
return FALSE;
}
@@ -186,13 +185,11 @@ historize_log_read_cb(GObject *object, G
PurpleLog *log = PURPLE_LOG(object);
PurpleLogReadFlags flags;
PidginConversation *gtkconv = PIDGIN_CONVERSATION(callback_data->conv);
- GtkIMHtmlOptions options;
- GtkIMHtml *imhtml = GTK_IMHTML(gtkconv->imhtml);
+ GtkWebView *wv = GTK_WEBVIEW(gtkconv->webview);
GError *err = NULL;
const gchar *header_date;
- gchar *text, *escaped_alias, *header, *full_header, *text_backup, *protocol, *imhtml_text;
+ gchar *text, *escaped_alias, *header, *full_header;
const struct tm *log_tm;
- time_t log_time;
if (res == NULL) {
callback_data->count--;
@@ -203,75 +200,70 @@ historize_log_read_cb(GObject *object, G
return;
}
- options = GTK_IMHTML_NO_COLOURS;
- imhtml_text = gtk_imhtml_get_markup(imhtml);
#if 0
/* FIXME: WebView has no options */
+ GtkIMHtmlOptions options;
+ options = GTK_IMHTML_NO_COLOURS;
#endif
- if (imhtml_text != NULL && *imhtml_text) {
- text_backup = strdup(imhtml_text);
- gtk_imhtml_clear(imhtml);
- } else
- text_backup = NULL;
-#endif
-
+#if 0
+ /* FIXME: WebView has no protocol setting */
+ gchar *protocol;
protocol = g_strdup(gtk_imhtml_get_protocol_name(imhtml));
gtk_imhtml_set_protocol_name(imhtml,
purple_account_get_protocol_name(purple_log_get_account(log)));
+#endif
- if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(imhtml))))
- gtk_imhtml_append_text(imhtml, "<br>", options);
+ /* Write the header */
+ if (!gtk_webview_is_empty(wv))
+ gtk_webview_append_html(wv, "<br>");
log_tm = purple_log_get_tm(log);
- log_time = purple_log_get_time(log);
if (log_tm != NULL)
header_date = purple_date_format_full(log_tm);
- else
+ else {
+ time_t log_time = purple_log_get_time(log);
header_date = purple_date_format_full(localtime(&log_time));
+ }
escaped_alias = g_markup_escape_text(callback_data->alias, -1);
full_header = g_strdup_printf(_("Conversation with %s on %s"), escaped_alias, header_date);
header = g_strdup_printf("<b>%s:</b><br>", full_header);
- gtk_imhtml_append_text(imhtml, header, options);
+ gtk_webview_append_html(wv, header);
- gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), header);
g_free(header);
g_free(escaped_alias);
g_free(full_header);
+ /* Then add in the old conversation */
text = purple_log_read_finish(log, res, &flags, &err);
- gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), history);
if (text == NULL)
text = err->message;
else
g_strchomp(text);
+#if 0
+ /* FIXME: WebView has no options */
if (flags & PURPLE_LOG_READ_NO_NEWLINE)
options |= GTK_IMHTML_NO_NEWLINE;
+#endif
//purple_conversation_write?
- gtk_imhtml_append_text(imhtml, text, options);
- gtk_imhtml_append_text(imhtml, "<hr>", options);
- gtk_imhtml_set_protocol_name(imhtml, protocol);
+ gtk_webview_append_html(wv, text);
+ gtk_webview_append_html(wv, "<hr>");
- if (text_backup != NULL) {
- gtk_imhtml_append_text(imhtml, text_backup, GTK_IMHTML_NO_NEWLINE);
- g_free(text_backup);
- }
+ g_idle_add(_scroll_webview_to_end, g_object_ref(wv));
- g_idle_add(_scroll_imhtml_to_end, g_object_ref(imhtml));
-
#if 0
/* FIXME: WebView has no protocol setting */
gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol);
g_free(protocol);
- g_clear_error(&err);
#endif
+ g_clear_error(&err);
callback_data->count--;
if (callback_data->count < 1)
@@ -294,7 +286,7 @@ historize_log_list_cb(GObject *object, G
return;
}
- list = purple_log_get_logs_finish(PURPLE_LOG(object), res, &err);
+ list = purple_log_list_logs_finish(PURPLE_LOG(object), res, &err);
if (list != NULL)
callback_data->log = get_last_log(list, callback_data->log);
@@ -329,7 +321,7 @@ historize_log_collector_cb(GObject *obje
GList *list;
GError *err = NULL;
- list = purple_log_get_logs_finish(PURPLE_LOG(object), res, &err);
+ list = purple_log_list_logs_finish(PURPLE_LOG(object), res, &err);
if (list != NULL)
callback_data->log = get_last_log(list, callback_data->log);
@@ -350,7 +342,7 @@ historize_log_collector_cb_done(_histori
callback_data->count++;
if (callback_data->log == NULL)
- purple_logs_get_logs_async(PURPLE_LOG_IM, callback_data->name,
+ purple_logs_list_logs_async(PURPLE_LOG_IM, callback_data->name,
callback_data->account, G_PRIORITY_DEFAULT, callback_data->cancel,
historize_log_list_cb, callback_data);
else
More information about the Commits
mailing list