pidgin/android/android

Add autoscrolling for the debug window.

2012-08-11, Elliott Sales de Andrade
d8d6e87ce594
Parents b9a5b8ddf92c
Children 565884eb4354
Add autoscrolling for the debug window.
--- a/pidgin/gtkdebug.c Sat Aug 11 20:27:30 2012 -0400
+++ b/pidgin/gtkdebug.c Sat Aug 11 20:55:27 2012 -0400
@@ -812,6 +812,7 @@
frame = pidgin_create_webview(FALSE, &win->text, NULL, NULL);
gtk_webview_set_format_functions(GTK_WEBVIEW(win->text),
GTK_WEBVIEW_ALL ^ GTK_WEBVIEW_SMILEY ^ GTK_WEBVIEW_IMAGE);
+ gtk_webview_set_autoscroll(GTK_WEBVIEW(win->text), TRUE);
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
gtk_widget_show(frame);
--- a/pidgin/gtkwebview.c Sat Aug 11 20:27:30 2012 -0400
+++ b/pidgin/gtkwebview.c Sat Aug 11 20:55:27 2012 -0400
@@ -78,6 +78,7 @@
/* Scroll adjustments */
GtkAdjustment *vadj;
+ gboolean autoscroll;
guint scroll_src;
GTimer *scroll_time;
@@ -150,6 +151,7 @@
WebKitDOMHTMLElement *body;
WebKitDOMNode *start, *end;
WebKitDOMRange *range;
+ gboolean require_scroll = FALSE;
if (priv->is_loading) {
priv->loader = 0;
@@ -169,6 +171,12 @@
body = webkit_dom_document_get_body(doc);
start = webkit_dom_node_get_last_child(WEBKIT_DOM_NODE(body));
+ if (priv->autoscroll) {
+ require_scroll = (gtk_adjustment_get_value(priv->vadj)
+ >= (gtk_adjustment_get_upper(priv->vadj) -
+ gtk_adjustment_get_page_size(priv->vadj)));
+ }
+
webkit_dom_html_element_insert_adjacent_html(body, "beforeend",
str, NULL);
@@ -187,6 +195,15 @@
NULL);
}
+ if (require_scroll) {
+ if (start)
+ webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(start),
+ TRUE);
+ else
+ webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(body),
+ TRUE);
+ }
+
g_signal_emit(webview, signals[HTML_APPENDED], 0, range);
break;
@@ -855,6 +872,28 @@
}
void
+gtk_webview_set_autoscroll(GtkWebView *webview, gboolean scroll)
+{
+ GtkWebViewPriv *priv;
+
+ g_return_if_fail(webview != NULL);
+
+ priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+ priv->autoscroll = scroll;
+}
+
+gboolean
+gtk_webview_get_autoscroll(GtkWebView *webview)
+{
+ GtkWebViewPriv *priv;
+
+ g_return_val_if_fail(webview != NULL, FALSE);
+
+ priv = GTK_WEBVIEW_GET_PRIVATE(webview);
+ return priv->autoscroll;
+}
+
+void
gtk_webview_page_up(GtkWebView *webview)
{
GtkWebViewPriv *priv;
--- a/pidgin/gtkwebview.h Sat Aug 11 20:27:30 2012 -0400
+++ b/pidgin/gtkwebview.h Sat Aug 11 20:55:27 2012 -0400
@@ -163,6 +163,25 @@
void gtk_webview_scroll_to_end(GtkWebView *webview, gboolean smooth);
/**
+ * Set whether the GtkWebView stays at its end when HTML content is appended. If
+ * not already at the end before appending, then scrolling will not occur.
+ *
+ * @param webview The GtkWebView object
+ * @param scroll Whether to automatically scroll
+ */
+void gtk_webview_set_autoscroll(GtkWebView *webview, gboolean scroll);
+
+/**
+ * Set whether the GtkWebView stays at its end when HTML content is appended. If
+ * not already at the end before appending, then scrolling will not occur.
+ *
+ * @param webview The GtkWebView object
+ *
+ * @return Whether to automatically scroll
+ */
+gboolean gtk_webview_get_autoscroll(GtkWebView *webview);
+
+/**
* Scrolls a GtkWebView up by one page.
*
* @param webview The GtkWebView.